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