00001 {
00002 gROOT->Reset();
00003 gROOT->SetStyle("Bold");
00004 gStyle->SetPalette(1);
00005 gSystem->Load("/LC/Detecteurs/MicroMegas/Offline/micromegasFrameWork/trunk/lib/libMicro.so");
00006
00007
00008
00009 int offset_y = 29;
00010 int offset_x = 33;
00011
00012
00013 int search = 5;
00014
00015
00016 int dt_min = 5;
00017 int dt_max = 8;
00018
00019
00020 int adc_cut = 30;
00021
00022
00023
00024
00025 std::ifstream xml;
00026 xml.open("complete_detector.xml",ifstream::in);
00027 std::string line = "";
00028 std::string lineb = "";
00029 while(line.find("path=")==string::npos || lineb.find("<output")==string::npos)
00030 {
00031 lineb=line;
00032 xml>>line;
00033 }
00034 int start = line.find("\"")+1;
00035 int end = line.rfind("\"")-6;
00036 TString file = line.substr(start,end);
00037
00038 for (int i=0;i<5;i++){file.Chop();}
00039 file += "_MGT.root";
00040
00041
00042
00043
00044 bool noisy[9][32][32];
00045 for (int i=0;i<32;i++){
00046 for (int j=0;j<32;j++){
00047 for (int k=0;k<9;k++){
00048 noisy[k][i][j] = 0;}}}
00049
00050
00051 noisy[6][5][5] = 1;
00052 noisy[7][5][5] = 1;
00053 noisy[8][5][5] = 1;
00054
00055
00056 noisy[6][17][5] = 1;
00057 noisy[8][15][9] = 1;
00058
00059
00060
00061
00062
00063 int nhot_m2 = 0;
00064 int nhot_tel = 0;
00065 int nsuper_hot_tel = 0;
00066 int nhit[10];
00067 bool hot[10];
00068 bool super_hot[10];
00069 for (int i=0;i<10;i++){nhit[i] = 0;hot[i] = 0;}
00070
00071 int nchannel = 0;
00072 int hardid = 0;
00073 int chipid = 0;
00074 int xpos = 0;
00075 int ypos = 0;
00076 int zpos = 0;
00077 int adc = 0;
00078 int chbid = 0;
00079 int ntree = 0;
00080 int mult = 0;
00081 int ntrack = 0;
00082 int neff = 0;
00083 int track_x = 0;
00084 int track_y = 0;
00085 int target_x = 0;
00086 int target_y = 0;
00087 int dt_tp_max = 0;
00088
00089 Long64_t t,t0,t1,t2,t3,dt;
00090
00091 TH2I * hxy_m2 = new TH2I("hxy_m2","Hit position distribution;y (cm);x (cm)",96,0,96,96,0,96);
00092 TH2I * hxy_m2_target = new TH2I("hxy_m2_target","Extrapolated hit position distribution;y (cm);x (cm)",96,0,96,96,0,96);
00093 TH2I * hxy_m2_cut = new TH2I("hxy_m2_cut","Hit position distribution - time cut;y (cm);x (cm)",96,0,96,96,0,96);
00094 TH2I * hxy_m2_cut_track = new TH2I("hxy_m2_cut_track","Hit position distribution when track in telescope- time cut;y (cm);x (cm)",96,0,96,96,0,96);
00095 TH2I * hxy_m2_cut_temp = new TH2I("hxy_m2_cut_temp","Hit position distribution - time cut;y (cm);x (cm)",96,0,96,96,0,96);
00096 TH1I * hnhit = new TH1I("hnhit","Number of hit distribution;Nhits",10000,0,10000);
00097 TH1I * hmult_m2 = new TH1I("hmult_m2","Number of hit in target area in m2;Nhit",10,0,10);
00098 TH1I * hnhot_tel = new TH1I("hnhot_tel","Number of hot telescope chambers (Nhit>0);Nhot",9,0,9);
00099 TH1I * hnsuper_hot_tel = new TH1I("hnsuper_hot_tel","Number of super hot telescope chambers (Nhit=1);Nhot",9,0,9);
00100 TH1I * hnhit_cut = new TH1I("hnhit_cut","Number of hit distribution - time cut;Nhits",10000,0,10000);
00101 TH1I * hdt = new TH1I("hdt","Time to readout disitribution;time (200 ns clock cycle)",200,0,200);
00102 TH1I * hdt_first = new TH1I("hdt_first","Time to readout of first hit;time (200 ns clock cycle)",20,0,20);
00103 TH1I * hdt_width = new TH1I("hdt_width","Time to first hit disitribution;time (200 ns clock cycle)",20,0,20);
00104 TH1I * hdt_tp = new TH1I("hdt_tp","Time to readout disitribution;time (200 ns clock cycle)",20,0,20);
00105 TH1I * hx_res = new TH1I("hx_res","Vertical residuals Prototype - telescope;Xm2 - Xtarget (cm)",51,-25,25);
00106 TH1I * hy_res = new TH1I("hy_res","Horizontal residuals Prototype - telescope;Ym2 - Ytarget (cm)",51,-25,25);
00107 TH1F * hr_res = new TH1F("hr_res","Residuals Prototype - telescope;d(m2 - target) (cm)",100,0,25);
00108 TH2I * hx_cor = new TH2I("hx_cor","Correlation Prototype - telescope;Xtarget (cm);Xm2 (cm)",100,0,100,100,0,100);
00109 TH2I * hy_cor = new TH2I("hy_cor","Correlation Prototype - telescope;Ytarget (cm);Ym2 (cm)",100,0,100,100,0,100);
00110 TH2I * hxy_tel_pad_temp = new TH2I("hxy_tel_pad_temp","Hit position distribution in telescope pad chamber for super hot events (Nhit=1);y (cm);x (cm)",32,0,32,32,0,32);
00111
00112 TH1I * hnhit_tel[9];
00113 TH2I * hxy_tel[9];
00114 TH2I * hxy_tel_temp[9];
00115 TString title,name;
00116
00117 for (int i=0;i<9;i++)
00118 {
00119 name = Form("hxy_tel_chamber_%i",i+1);
00120 title = Form("Hit pattern (adc>%i) chamber %i;y (cm);x (cm)",adc_cut,i+1);
00121 hxy_tel[i] = new TH2I(name,title,32,0,32,32,0,32);
00122
00123 name = Form("hxy_tel_temp_chamber_%i",i+1);
00124 title = Form("Hit pattern (adc>%i) chamber %i;y (cm);x (cm)",adc_cut,i+1);
00125 hxy_tel_temp[i] = new TH2I(name,title,32,0,32,32,0,32);
00126
00127 name = Form("hnhit_tel_chamber_%i",i+1);
00128 title = Form("Number of hits (adc>%i) in chamber %i;Nhit",adc_cut,i+1);
00129 hnhit_tel[i] = new TH1I(name,title,96,0,96);
00130 }
00131
00132
00133
00134
00135 TFile *f = new TFile(file);
00136 cout<<endl;
00137 cout<<"Reading file : "<<file<<endl;
00138 cout<<endl;
00139
00140 TIter nextkey(f.GetListOfKeys());
00141 TKey *key;
00142
00143
00144
00145
00146 while (key = (TKey*)nextkey())
00147 {
00148
00149 TTree *tree = (TTree*)key->ReadObj();
00150 MTRun* run = (MTRun*)tree->GetUserInfo()->FindObject("MTRun");
00151
00152 int nEvent = tree.GetEntries();
00153 ntree++;
00154 cout<<" Tree "<<ntree<<" contains "<<nEvent<<" events"<<endl;
00155
00156 MTEvent *evt = new MTEvent();
00157
00158 TBranch *branch= tree->GetBranch("MTEvent");
00159 branch->SetAddress(&evt);
00160
00161 for (int i=0;i<nEvent-1;i++)
00162 {
00163
00164 if (i%100==0){cout<<"Progress: "<<i/1./nEvent*100<<" \r"<<flush;}
00165
00166 tree.GetEntry(i);
00167 nchannel = evt->GetNchannel();
00168
00169 nhot_m2 = 0;
00170 nhot_tel = 0;
00171 nsuper_hot_tel = 0;
00172 for (int k=0;k<10;k++){nhit[k] = 0;super_hot[k] = 0;}
00173
00174
00175 for (int j=0;j<nchannel;j++)
00176 {
00177
00178 MTChannel* channel = (MTChannel*)evt->GetChannels()->UncheckedAt(j);
00179 chbid = channel->GetChamberId();
00180 xpos = channel->GetX()*1e-4;
00181 ypos = channel->GetY()*1e-4;
00182
00183 if (chbid < 10)
00184 {
00185 if (!noisy[chbid-1][ypos][xpos])
00186 {
00187 adc = channel->GetAnalogValue();
00188
00189 if (adc>=adc_cut)
00190 {
00191 nhit[chbid-1]++;
00192
00193 hxy_tel[chbid-1]->Fill(ypos,xpos);
00194 hxy_tel_temp[chbid-1]->Fill(ypos,xpos);
00195
00196 if (chbid == 7 || chbid == 8 || chbid == 9)
00197 {
00198
00199 hxy_tel_pad_temp->Fill(ypos,xpos);
00200
00201 }
00202
00203 if (chbid == 8)
00204 {
00205
00206 track_x = xpos;
00207 track_y = ypos;
00208
00209 }
00210
00211 }
00212 }
00213 }
00214 }
00215
00216
00217
00218 for (int k=6;k<9;k++)
00219 {
00220
00221 if (nhit[k] != 0)
00222 {
00223 hot[k] = 1;
00224
00225 if (nhit[k] == 1)
00226 {
00227 super_hot[k] = 1;
00228 }
00229 }
00230
00231 hnhit_tel[k]->Fill(nhit[k]);
00232
00233 if (hot[k])
00234 {
00235 nhot_tel++;
00236 }
00237
00238 if (super_hot[k])
00239 {
00240 nsuper_hot_tel++;
00241 }
00242 }
00243
00244 hnhot_tel->Fill(nhot_tel);
00245 hnsuper_hot_tel->Fill(nsuper_hot_tel);
00246
00247
00248
00249 if (nsuper_hot_tel == 3)
00250 {
00251
00252 if (hxy_tel_pad_temp->GetRMS(1) == 0 && hxy_tel_pad_temp->GetRMS(2) == 0){
00253
00254 ntrack++;
00255
00256
00257 target_x = track_x + offset_x;
00258 target_y = track_y + offset_y;
00259 hxy_m2_target->Fill(target_y,target_x);
00260
00261 for (int j=0;j<nchannel;j++)
00262 {
00263
00264 MTChannel* channel = (MTChannel*)evt->GetChannels()->UncheckedAt(j);
00265 chbid = channel->GetChamberId();
00266
00267 if (chbid == 10)
00268 {
00269
00270 t2 = channel->GetBcId_Dif();
00271 t3 = channel->GetBcId_Hit();
00272 dt = t2 - t3;
00273 hdt->Fill(dt);
00274 hdt_tp->Fill(dt);
00275
00276 xpos = channel->GetX()*1e-4;
00277 ypos = channel->GetY()*1e-4;
00278 hxy_m2->Fill(ypos,xpos);
00279
00280 if (dt>=dt_min && dt<dt_max)
00281 {
00282 nhit[chbid-1]++;
00283 hxy_m2_cut->Fill(ypos,xpos);
00284 hxy_m2_cut_temp->Fill(ypos,xpos);
00285
00286 hx_cor->Fill(target_x,xpos);
00287 hy_cor->Fill(target_y,ypos);
00288
00289 hr_res->Fill(sqrt(pow(xpos-target_x,2) + pow(ypos-target_y,2)));
00290 hx_res->Fill(xpos - target_x);
00291 hy_res->Fill(ypos - target_y);
00292
00293
00294 if (fabs(xpos - target_x)<=search && fabs(ypos - target_y)<=search)
00295 {
00296
00297 mult++;
00298 hxy_m2_cut_track->Fill(ypos,xpos);
00299
00300 }
00301 }
00302 }
00303 }
00304
00305 for (k=10;k>0;k--){if (hdt_tp->GetBinContent(k+1)!=0){dt_tp_max = k;k = 0;}}
00306 hdt_first->Fill(dt_tp_max);
00307 for (k=10;k>0;k--){if (hdt_tp->GetBinContent(k+1)!=0){hdt_width->Fill(dt_tp_max-k);}}
00308 hdt_tp->Reset();
00309
00310 if (mult != 0)
00311 {
00312 neff++;
00313 hmult_m2->Fill(mult);
00314 mult = 0;
00315 }
00316
00317 hxy_m2_cut_temp->Reset();
00318
00319 }
00320 }
00321
00322 hxy_tel_pad_temp->Reset();
00323
00324 }
00325 }
00326
00327
00328
00329
00330 cout<<endl;
00331 cout<<endl;
00332 cout<<"Number of tracks in telescope = "<<ntrack<<endl;
00333 cout<<"Number of time the m2 prototype was efficienct (search area of "<<search*2+1<<"*"<<search*2+1<<") = "<<neff<<endl;
00334 cout<<endl;
00335 cout<<"Global efficiency = "<<neff<<" / "<<ntrack<<" = "<<neff*1./ntrack*100.<<" %"<<endl;
00336 cout<<endl;
00337 cout<<"Hit multiplicity = "<<hmult_m2->GetMean()<<endl;
00338 cout<<endl;
00339 cout<<endl;
00340
00341
00342
00343
00344
00345 }
00346
00347