00001 {gROOT->Reset();
00002
00003 gSystem->Load("/home1/chefdevi/micromegasFrameWork/trunk/libMicro.so");
00004
00005
00006 bool display = 0;
00007 bool write_root_file = 1;
00008
00009
00010
00011 TString particle[2] = {"electron","hadron"};
00012 TString nabsorber[6] = {"2","4","6","8","10","12"};
00013
00014
00015
00016 for (int p=0;p<2;p++){
00017
00018 for (int a=0;a<6;a++){
00019
00020
00021 TString filename= particle[p] + "_2gev_" + nabsorber[a] + "absorber.root";
00022
00023 TString path = "/lapp_data/LC/Detecteurs/MicroMegas/data/TB2009/May/Rootfiles/dev/";
00024
00025
00026 TFile *f = new TFile(path+filename);
00027 cout<<"reading File : "<<path<<filename<<endl;
00028 TTree *tree;
00029 tree = (TTree*) f.Get("t1");cout<<"tree built\n";
00030 int nEvent = tree.GetEntries();
00031 MTEvent *evt = new MTEvent();
00032 TBranch *branch= tree->GetBranch("MTEvent");
00033 branch->SetAddress(&evt);
00034 cout <<"nEvent="<<nEvent<<endl;
00035 int NC = 672;
00036
00037
00038
00039
00040
00041 if (write_root_file){
00042 TString filename2= "Root_histo_files/adc_" + filename;
00043 TFile * tf = new TFile(filename2,"recreate");}
00044
00045
00046
00047
00048
00049 TH1F * hadc1 = new TH1F("hadc1","",400,0,1024*5);
00050 TH1F * hadc2 = new TH1F("hadc2","",400,0,1024*5);
00051 TH1F * hadc3 = new TH1F("hadc3","",400,0,1024*5);
00052 TH1F * hadc4 = new TH1F("hadc4","",400,0,1024*10);
00053
00054 TH1F * hadc1_clean = new TH1F("hadc1_clean","",400,0,1024*5);
00055 TH1F * hadc2_clean = new TH1F("hadc2_clean","",400,0,1024*5);
00056 TH1F * hadc3_clean = new TH1F("hadc3_clean","",400,0,1024*5);
00057 TH1F * hadc4_clean = new TH1F("hadc4_clean","",400,0,1024*10);
00058
00059 TH1F * hadc1_no_sat = new TH1F("hadc1_no_sat","",400,0,1024*5);
00060 TH1F * hadc2_no_sat = new TH1F("hadc2_no_sat","",400,0,1024*5);
00061 TH1F * hadc3_no_sat = new TH1F("hadc3_no_sat","",400,0,1024*5);
00062 TH1F * hadc4_no_sat = new TH1F("hadc4_no_sat","",400,0,1024*10);
00063
00064 TH1F * hpedestal = new TH1F("hpedestal","",2048,-1024,1024);
00065 TH1F * hmean_pedestal = new TH1F("hmean_pedestal","",2048,-1024,1024);
00066
00067
00068
00069
00070
00071
00072 hadc1->SetLineWidth(2);
00073 hadc2->SetLineWidth(2);
00074 hadc3->SetLineWidth(2);
00075 hadc4->SetLineWidth(2);
00076
00077 hadc1_clean->SetLineWidth(2);
00078 hadc2_clean->SetLineWidth(2);
00079 hadc3_clean->SetLineWidth(2);
00080 hadc4_clean->SetLineWidth(2);
00081
00082 hadc1_no_sat->SetLineWidth(2);
00083 hadc2_no_sat->SetLineWidth(2);
00084 hadc3_no_sat->SetLineWidth(2);
00085 hadc4_no_sat->SetLineWidth(2);
00086
00087
00088
00089 hadc2->SetLineColor(2);
00090 hadc3->SetLineColor(4);
00091 hadc4->SetLineColor(8);
00092
00093 hadc2_clean->SetLineColor(2);
00094 hadc3_clean->SetLineColor(4);
00095 hadc4_clean->SetLineColor(8);
00096
00097 hadc2_no_sat->SetLineColor(2);
00098 hadc3_no_sat->SetLineColor(4);
00099 hadc4_no_sat->SetLineColor(8);
00100
00101
00102
00103
00104 hadc1_clean->SetLineStyle(2);
00105 hadc2_clean->SetLineStyle(2);
00106 hadc3_clean->SetLineStyle(2);
00107 hadc4_clean->SetLineStyle(2);
00108
00109 hadc1_no_sat->SetLineStyle(2);
00110 hadc2_no_sat->SetLineStyle(2);
00111 hadc3_no_sat->SetLineStyle(2);
00112 hadc4_no_sat->SetLineStyle(2);
00113
00114
00115
00116
00117
00118 int xpos1,ypos1,adc1,sum_adc1;
00119 int xpos2,ypos2,adc2,sum_adc2;
00120 int xpos3,ypos3,adc3,sum_adc3;
00121 int xpos4,ypos4,adc4,sum_adc4;
00122
00123 int threshold = 35;
00124 float nhit1=0,nhit2=0,nhit3=0,nhit4=0;
00125 int nclean = 0;
00126 bool clean = 0;
00127 int adc_sat = 900;
00128 int pedestal = 0;
00129 int correction = 0;
00130 int nunsaturated = 0;
00131 bool no_sat1 = 1,no_sat2 = 1;
00132 bool no_sat3 = 1,no_sat4 = 1;
00133
00134 int event = 0;
00135 int crap_event = 0;
00136
00137
00138
00139
00140
00141
00142
00143 for(int i=0;i<nEvent;i++){
00144
00145
00146
00147 if (display){cout<<"Event # "<<i<<endl;}
00148
00149 tree.GetEntry(i);
00150 NC = evt->GetNchannel();
00151
00152 if (NC == 672){
00153
00154
00155 clean=0;
00156 no_sat1 = 1;no_sat2 = 1;no_sat3 = 1;no_sat4 = 1;
00157 nhit1=0,nhit2=0,nhit3=0,nhit4=0;
00158 sum_adc1=0;sum_adc2=0;sum_adc3=0;sum_adc4=0;
00159 hpedestal->Reset();
00160
00161
00162
00163
00164 for(int j=0;j<96;j++){
00165
00166 MTChannel* channel = (MTChannel*)evt->GetChannels()->UncheckedAt(j);
00167 xpos1 = channel.GetX();
00168 ypos1 = channel.GetY();
00169 adc1 = channel.GetValue();
00170
00171 if (adc1>=threshold){
00172
00173 sum_adc1+=adc1;
00174
00175 if (adc1>adc_sat){no_sat1 = 0;}
00176 if (display){cout<<" x1="<<xpos1<<" y1="<<ypos1<<" adc1="<<adc1<<endl;}
00177 nhit1++;}}
00178
00179
00180
00181
00182
00183 for(int j=0+96;j<96+96;j++){
00184
00185 MTChannel* channel = (MTChannel*)evt->GetChannels()->UncheckedAt(j);
00186 xpos2 = channel.GetX();
00187 ypos2 = channel.GetY();
00188 adc2 = channel.GetValue();
00189
00190 if (adc2>=threshold){
00191
00192 sum_adc2+=adc2;
00193
00194 if (adc2>adc_sat){no_sat2 = 0;}
00195 if (display){cout<<" x2="<<xpos2<<" y2="<<ypos2<<" adc2="<<adc2<<endl;}
00196 nhit2++;}}
00197
00198
00199
00200
00201
00202 for(int j=0+96+96;j<96+96+96;j++){
00203
00204 MTChannel* channel = (MTChannel*)evt->GetChannels()->UncheckedAt(j);
00205 xpos3 = channel.GetX();
00206 ypos3 = channel.GetY();
00207 adc3 = channel.GetValue();
00208
00209 if (adc3>=threshold){
00210
00211 sum_adc3+=adc3;
00212
00213 if (adc3>adc_sat){no_sat3 = 0;}
00214 if (display){cout<<" x3="<<xpos3<<" y3="<<ypos3<<" adc3="<<adc3<<endl;}
00215 nhit3++;}}
00216
00217
00218
00219
00220
00221 clean = (nhit1==1) && (nhit2==1) && (nhit3==1);
00222
00223
00224
00225
00226
00227
00228 for(int j=287;j<672;j++){
00229
00230 MTChannel* channel = (MTChannel*)evt->GetChannels()->UncheckedAt(j);
00231 xpos4 = channel.GetX();
00232 ypos4 = channel.GetY();
00233 adc4 = channel.GetValue();
00234
00235 if (adc4>=threshold){
00236
00237 sum_adc4+=adc4;
00238
00239 if (adc4>adc_sat){no_sat4 = 0;}
00240 if (display){cout<<" x4="<<xpos4<<" y4="<<ypos4<<" adc4="<<adc4<<endl;}
00241 nhit4++;}
00242
00243 else{hpedestal->Fill(adc4);}}
00244
00245
00246 pedestal = hpedestal->GetMean();
00247 hmean_pedestal->Fill(pedestal);
00248 correction = nhit4 * pedestal;
00249
00250
00251
00252 if (sum_adc1>0){hadc1->Fill(sum_adc1-correction);}
00253 if (sum_adc2>0){hadc2->Fill(sum_adc2-correction);}
00254 if (sum_adc3>0){hadc3->Fill(sum_adc3-correction);}
00255 if (sum_adc4>0){hadc4->Fill(sum_adc4-correction);nunsaturated++;}
00256
00257
00258 if (clean){
00259
00260 if (sum_adc1>0){hadc1_clean->Fill(sum_adc1-correction);}
00261 if (sum_adc2>0){hadc2_clean->Fill(sum_adc2-correction);}
00262 if (sum_adc3>0){hadc3_clean->Fill(sum_adc3-correction);}
00263 if (sum_adc4>0){hadc4_clean->Fill(sum_adc4-correction);}
00264
00265 if (no_sat1 && (sum_adc1>0)){hadc1_no_sat->Fill(sum_adc1-correction);}
00266 if (no_sat2 && (sum_adc2>0)){hadc2_no_sat->Fill(sum_adc2-correction);}
00267 if (no_sat3 && (sum_adc3>0)){hadc3_no_sat->Fill(sum_adc3-correction);}
00268 if (no_sat4 && (sum_adc4>0)){hadc4_no_sat->Fill(sum_adc4-correction);}
00269
00270 if (display){cout<<"clean event!"<<endl;}
00271
00272 nclean++;}
00273
00274
00275 if (display){cout<<nhit1<<" "<<nhit2<<" "<<nhit3<<" "<<nhit4<<endl;}}
00276
00277
00278 else{crap_event++;}}
00279
00280
00281
00282
00283
00284 cout<<"Run "<<filename<<endl;
00285 cout<<"ntotal = "<<nEvent<<" nclean = "<<nclean<<" ncrap = "<<crap_event<<" nunsaturated-4 = "<<nunsaturated<<endl;
00286 cout<<endl;
00287
00288
00289
00290
00291 if (write_root_file){
00292 tf->Write();
00293 tf->Close();}}}
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303 }