00001 {gROOT->Reset();
00002
00003 gSystem->Load("/home1/chefdevi/micromegasFrameWork/trunk/libMicro.so");
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 bool display = 0;
00014
00015
00016 TString path = "/lapp_data/LC/Detecteurs/MicroMegas/data/TB2009/May/Rootfiles/dev/";
00017
00018 TString fileName= "beam_profile_alice_pm.root";
00019
00020 TString fileName2= "histo_beam_profile_alice_pm.root";
00021
00022 TFile *f = new TFile(path+fileName);
00023 cout<<"reading File : "<<path<<fileName<<endl;
00024 TTree *tree;
00025 tree = (TTree*) f.Get("t1");cout<<"tree built\n";
00026 int nEvent = tree.GetEntries();
00027 MTEvent *evt = new MTEvent();
00028 TBranch *branch= tree->GetBranch("MTEvent");
00029 branch->SetAddress(&evt);
00030 cout <<"nEvent="<<nEvent<<endl;
00031 int NC = 672;
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044 TH1F * hnhit1 = new TH1F("hnhit1","",96,0,96);
00045 TH1F * hnhit2 = new TH1F("hnhit2","",96,0,96);
00046 TH1F * hnhit3 = new TH1F("hnhit3","",96,0,96);
00047 TH1F * hnhit4 = new TH1F("hnhit4","",96*4,0,96*4);
00048
00049 TH1F * hnhit1_clean = new TH1F("hnhit1_clean","",96*4,0,96*4);
00050 TH1F * hnhit2_clean = new TH1F("hnhit2_clean","",96*4,0,96*4);
00051 TH1F * hnhit3_clean = new TH1F("hnhit3_clean","",96*4,0,96*4);
00052 TH1F * hnhit4_clean = new TH1F("hnhit4_clean","",96*4,0,96*4);
00053
00054
00055
00056
00057 TH1F * hadc1 = new TH1F("hadc1","",100,0,1024*5);
00058 TH1F * hadc2 = new TH1F("hadc2","",100,0,1024*5);
00059 TH1F * hadc3 = new TH1F("hadc3","",100,0,1024*5);
00060 TH1F * hadc4 = new TH1F("hadc4","",100,0,1024*10);
00061
00062 TH1F * hadc1_clean = new TH1F("hadc1_clean","",100,0,1024*5);
00063 TH1F * hadc2_clean = new TH1F("hadc2_clean","",100,0,1024*5);
00064 TH1F * hadc3_clean = new TH1F("hadc3_clean","",100,0,1024*5);
00065 TH1F * hadc4_clean = new TH1F("hadc4_clean","",100,0,1024*10);
00066
00067
00068
00069
00070 TH1F * hxpos1 = new TH1F("hxpos1","",40,0,40);
00071 TH1F * hxpos2 = new TH1F("hxpos2","",40,0,40);
00072 TH1F * hxpos3 = new TH1F("hxpos3","",40,0,40);
00073 TH1F * hxpos4 = new TH1F("hxpos4","",40,0,40);
00074
00075 TH1F * hxpos1_clean = new TH1F("hxpos1_clean","",40,0,40);
00076 TH1F * hxpos2_clean = new TH1F("hxpos2_clean","",40,0,40);
00077 TH1F * hxpos3_clean = new TH1F("hxpos3_clean","",40,0,40);
00078 TH1F * hxpos4_clean = new TH1F("hxpos4_clean","",40,0,40);
00079
00080 TH1F * hypos1 = new TH1F("hypos1","",40,0,40);
00081 TH1F * hypos2 = new TH1F("hypos2","",40,0,40);
00082 TH1F * hypos3 = new TH1F("hypos3","",40,0,40);
00083 TH1F * hypos4 = new TH1F("hxpos4","",40,0,40);
00084
00085 TH1F * hypos1_clean = new TH1F("hypos1_clean","",40,0,40);
00086 TH1F * hypos2_clean = new TH1F("hypos2_clean","",40,0,40);
00087 TH1F * hypos3_clean = new TH1F("hypos3_clean","",40,0,40);
00088 TH1F * hypos4_clean = new TH1F("hypos4_clean","",40,0,40);
00089
00090
00091
00092
00093 TH2I * hxy1 = new TH2I("hxy1","",32,0,32,32,0,32);
00094 TH2I * hxy2 = new TH2I("hxy2","",32,0,32,32,0,32);
00095 TH2I * hxy3 = new TH2I("hxy3","",32,0,32,32,0,32);
00096 TH2I * hxy4 = new TH2I("hxy4","",32,0,32,32,0,32);
00097
00098 TH2I * hxy1_all = new TH2I("hxy1_all","",32,0,32,32,0,32);
00099 TH2I * hxy2_all = new TH2I("hxy2_all","",32,0,32,32,0,32);
00100 TH2I * hxy3_all = new TH2I("hxy3_all","",32,0,32,32,0,32);
00101 TH2I * hxy4_all = new TH2I("hxy4_all","",32,0,32,32,0,32);
00102
00103
00104
00105
00106 hnhit1->SetLineWidth(2);
00107 hnhit2->SetLineWidth(2);
00108 hnhit3->SetLineWidth(2);
00109 hnhit4->SetLineWidth(2);
00110
00111 hnhit1_clean->SetLineWidth(2);
00112 hnhit2_clean->SetLineWidth(2);
00113 hnhit3_clean->SetLineWidth(2);
00114 hnhit4_clean->SetLineWidth(2);
00115
00116 hadc1->SetLineWidth(2);
00117 hadc2->SetLineWidth(2);
00118 hadc3->SetLineWidth(2);
00119 hadc4->SetLineWidth(2);
00120
00121 hadc1_clean->SetLineWidth(2);
00122 hadc2_clean->SetLineWidth(2);
00123 hadc3_clean->SetLineWidth(2);
00124 hadc4_clean->SetLineWidth(2);
00125
00126 hxpos1->SetLineWidth(2);
00127 hypos1->SetLineWidth(2);
00128 hxpos2->SetLineWidth(2);
00129 hypos2->SetLineWidth(2);
00130 hxpos3->SetLineWidth(2);
00131 hypos3->SetLineWidth(2);
00132 hxpos4->SetLineWidth(2);
00133 hypos4->SetLineWidth(2);
00134
00135 hxpos1_clean->SetLineWidth(2);
00136 hypos1_clean->SetLineWidth(2);
00137 hxpos2_clean->SetLineWidth(2);
00138 hypos2_clean->SetLineWidth(2);
00139 hxpos3_clean->SetLineWidth(2);
00140 hypos3_clean->SetLineWidth(2);
00141 hxpos4_clean->SetLineWidth(2);
00142 hypos4_clean->SetLineWidth(2);
00143
00144
00145
00146 hnhit2->SetLineColor(2);
00147 hnhit3->SetLineColor(4);
00148 hnhit4->SetLineColor(8);
00149
00150 hnhit2_clean->SetLineColor(2);
00151 hnhit3_clean->SetLineColor(4);
00152 hnhit4_clean->SetLineColor(8);
00153
00154 hadc2->SetLineColor(2);
00155 hadc3->SetLineColor(4);
00156 hadc4->SetLineColor(8);
00157
00158 hadc2_clean->SetLineColor(2);
00159 hadc3_clean->SetLineColor(4);
00160 hadc4_clean->SetLineColor(8);
00161
00162 hxpos2->SetLineColor(2);
00163 hypos2->SetLineColor(2);
00164 hxpos3->SetLineColor(4);
00165 hypos3->SetLineColor(4);
00166 hxpos4->SetLineColor(8);
00167 hypos4->SetLineColor(8);
00168
00169 hxpos2_clean->SetLineColor(2);
00170 hypos2_clean->SetLineColor(2);
00171 hxpos3_clean->SetLineColor(4);
00172 hypos3_clean->SetLineColor(4);
00173 hxpos4_clean->SetLineColor(8);
00174 hypos4_clean->SetLineColor(8);
00175
00176
00177
00178 hxpos1_clean->SetLineStyle(2);
00179 hypos1_clean->SetLineStyle(2);
00180 hxpos2_clean->SetLineStyle(2);
00181 hypos2_clean->SetLineStyle(2);
00182
00183 hxpos3_clean->SetLineStyle(2);
00184 hypos3_clean->SetLineStyle(2);
00185 hxpos4_clean->SetLineStyle(2);
00186 hypos4_clean->SetLineStyle(2);
00187
00188 hnhit1_clean->SetLineStyle(2);
00189 hnhit2_clean->SetLineStyle(2);
00190 hnhit3_clean->SetLineStyle(2);
00191 hnhit4_clean->SetLineStyle(2);
00192
00193 hadc1_clean->SetLineStyle(2);
00194 hadc2_clean->SetLineStyle(2);
00195 hadc3_clean->SetLineStyle(2);
00196 hadc4_clean->SetLineStyle(2);
00197
00198
00199
00200
00201
00202
00203 int xpos1,ypos1,adc1,sum_adc1;
00204 int xpos2,ypos2,adc2,sum_adc2;
00205 int xpos3,ypos3,adc3,sum_adc3;
00206 int xpos4,ypos4,adc4,sum_adc4;
00207
00208 vector <int> vxpos1,vypos1,vadc1;
00209 vector <int> vxpos2,vypos2,vadc2;
00210 vector <int> vxpos3,vypos3,vadc3;
00211 vector <int> vxpos4,vypos4,vadc4;
00212
00213 float avgx[3],avgy[3];
00214 float posz1 = 6;
00215 float posz2 = 13;
00216 float posz3 = 19;
00217 float posz4 = 98;
00218 float avgz[3] = {posz1,posz2,posz3};
00219 float avgx1=0,avgx2=0,avgx3=0,avgx4=0;
00220 float avgy1=0,avgy2=0,avgy3=0,avgy4=0;
00221
00222 int threshold = 35;
00223 float nhit1=0,nhit2=0,nhit3=0,nhit4=0;
00224 int nclean = 0;
00225 bool clean = 0;
00226
00227 int event = 2;
00228 int crap_event = 0;
00229
00230
00231
00232
00233
00234
00235
00236 for( int i=0;i<1000;i++){
00237
00238
00239 if (display){cout<<"Event # "<<i<<endl;}
00240
00241 tree.GetEntry(i);
00242 NC = evt->GetNchannel();
00243
00244 if (NC != 672){crap_event++;}
00245 else{
00246
00247 clean=0;
00248 nhit1=0,nhit2=0,nhit3=0,nhit4=0;
00249 sum_adc1=0;sum_adc2=0;sum_adc3=0;sum_adc4=0;
00250
00251 vxpos1.clear();vypos1.clear();vadc1.clear();
00252 vxpos2.clear();vypos2.clear();vadc2.clear();
00253 vxpos3.clear();vypos3.clear();vadc3.clear();
00254 vxpos4.clear();vypos4.clear();vadc4.clear();
00255
00256 hxy1->Reset();
00257 hxy2->Reset();
00258 hxy3->Reset();
00259 hxy4->Reset();
00260
00261
00262
00263
00264 for(int j=0;j<96;j++){
00265
00266 MTChannel* channel = (MTChannel*)evt->GetChannels()->UncheckedAt(j);
00267 xpos1 = channel.GetX();
00268 ypos1 = channel.GetY();
00269 adc1 = channel.GetValue();
00270
00271 if (adc1>=threshold){
00272
00273 vxpos1.push_back(xpos1);
00274 vypos1.push_back(ypos1);
00275 vadc1.push_back(adc1);
00276 sum_adc1+=adc1;
00277
00278 if (display){cout<<" x1="<<xpos1<<" y1="<<ypos1<<" adc1="<<adc1<<endl;}
00279
00280 nhit1++;
00281 hxpos1->Fill(xpos1);
00282 hypos1->Fill(ypos1);
00283 hxy1->SetBinContent(xpos1+1,ypos1+1,hxy1->GetBinContent(xpos1+1,ypos1+1)+1);
00284 hxy1_all->SetBinContent(xpos1+1,ypos1+1,hxy1_all->GetBinContent(xpos1+1,ypos1+1)+1);}}
00285
00286
00287
00288
00289 for(int j=0+96;j<96+96;j++){
00290
00291 MTChannel* channel = (MTChannel*)evt->GetChannels()->UncheckedAt(j);
00292 xpos2 = channel.GetX();
00293 ypos2 = channel.GetY();
00294 adc2 = channel.GetValue();
00295
00296 if (adc2>=threshold){
00297
00298 vxpos2.push_back(xpos2);
00299 vypos2.push_back(ypos2);
00300 vadc2.push_back(adc2);
00301 sum_adc2+=adc2;
00302
00303 if (display){cout<<" x2="<<xpos2<<" y2="<<ypos2<<" adc2="<<adc2<<endl;}
00304
00305 nhit2++;
00306 hxpos2->Fill(xpos2);
00307 hypos2->Fill(ypos2);
00308 hxy2->SetBinContent(xpos2+1,ypos2+1,hxy2->GetBinContent(xpos2+1,ypos2+1)+1);
00309 hxy2_all->SetBinContent(xpos2+1,ypos2+1,hxy2_all->GetBinContent(xpos2+1,ypos2+1)+1);}}
00310
00311
00312
00313
00314
00315 for(int j=0+96+96;j<96+96+96;j++){
00316
00317 MTChannel* channel = (MTChannel*)evt->GetChannels()->UncheckedAt(j);
00318 xpos3 = channel.GetX();
00319 ypos3 = channel.GetY();
00320 adc3 = channel.GetValue();
00321
00322 if (adc3>=threshold){
00323
00324 vxpos3.push_back(xpos3);
00325 vypos3.push_back(ypos3);
00326 vadc3.push_back(adc3);
00327 sum_adc3+=adc3;
00328
00329 if (display){cout<<" x3="<<xpos3<<" y3="<<ypos3<<" adc3="<<adc3<<endl;}
00330
00331 nhit3++;
00332 hxpos3->Fill(xpos3);
00333 hypos3->Fill(ypos3);
00334 hxy3->SetBinContent(xpos3+1,ypos3+1,hxy3->GetBinContent(xpos3+1,ypos3+1)+1);
00335 hxy3_all->SetBinContent(xpos3+1,ypos3+1,hxy3_all->GetBinContent(xpos3+1,ypos3+1)+1);}}
00336
00337
00338
00339
00340
00341
00342
00343 for(int j=287;j<672;j++){
00344
00345 MTChannel* channel = (MTChannel*)evt->GetChannels()->UncheckedAt(j);
00346 xpos4 = channel.GetX();
00347 ypos4 = channel.GetY();
00348 adc4 = channel.GetValue();
00349
00350
00351
00352 if (adc4>=threshold){
00353
00354 vxpos4.push_back(xpos4);
00355 vypos4.push_back(ypos4);
00356 vadc4.push_back(adc4);
00357 sum_adc4+=adc4;
00358
00359 if (display){cout<<" x4="<<xpos4<<" y4="<<ypos4<<" adc4="<<adc4<<endl;}
00360
00361 nhit4++;
00362 hxpos4->Fill(xpos4);
00363 hypos4->Fill(ypos4);
00364 hxy4->SetBinContent(xpos4+1,ypos4+1,hxy4->GetBinContent(xpos4+1,ypos4+1)+1);
00365 hxy4_all->SetBinContent(xpos4+1,ypos4+1,hxy4_all->GetBinContent(xpos4+1,ypos4+1)+1);}}
00366
00367
00368 hnhit1->Fill(nhit1);
00369 hnhit2->Fill(nhit2);
00370 hnhit3->Fill(nhit3);
00371 hnhit4->Fill(nhit4);
00372
00373 hadc1->Fill(sum_adc1);
00374 hadc2->Fill(sum_adc2);
00375 hadc3->Fill(sum_adc3);
00376 hadc4->Fill(sum_adc4);
00377
00378
00379
00380
00381
00382 clean = (nhit1==1) && (nhit2==1) && (nhit3==1) && (nhit4==1);
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393 if (clean){
00394
00395 if (display){cout<<"clean event!"<<endl;}
00396
00397 nclean++;
00398
00399 avgx1=0;avgx2=0;avgx3=0;avgx4=0;
00400 avgy1=0;avgy2=0;avgy3=0;avgy4=0;
00401
00402 hnhit1_clean->Fill(nhit1);
00403 hnhit2_clean->Fill(nhit2);
00404 hnhit3_clean->Fill(nhit3);
00405 hnhit4_clean->Fill(nhit4);
00406
00407 hadc1_clean->Fill(sum_adc1);
00408 hadc2_clean->Fill(sum_adc2);
00409 hadc3_clean->Fill(sum_adc3);
00410 hadc4_clean->Fill(sum_adc4);
00411
00412 for (int k=0;k<nhit1;k++){
00413 hxpos1_clean->Fill(vxpos1[k]);
00414 hypos1_clean->Fill(vypos1[k]);}
00415
00416 for (int k=0;k<nhit2;k++){
00417 hxpos2_clean->Fill(vxpos2[k]);
00418 hypos2_clean->Fill(vypos2[k]);}
00419
00420 for (int k=0;k<nhit3;k++){
00421 hxpos3_clean->Fill(vxpos3[k]);
00422 hypos3_clean->Fill(vypos3[k]);}
00423
00424 for (int k=0;k<nhit4;k++){
00425 hxpos4_clean->Fill(vxpos4[k]);
00426 hypos4_clean->Fill(vypos4[k]);}}
00427
00428
00429 if (display){cout<<nhit1<<" "<<nhit2<<" "<<nhit3<<" "<<nhit4<<endl;}}}
00430
00431
00432
00433
00434
00435
00436 cout<<"ntotal = "<<nEvent<<" nclean = "<<nclean<<endl;
00437
00438 hxy4_all->Draw("zcol");
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451 bool nhit_distribution = 0;
00452 bool adc_distribution = 0;
00453 bool chamber_xy_display = 0;
00454 bool xyz_plot = 0;
00455
00456 bool number_hit_distrib_4_chamber = 0;
00457 bool number_hit_distrib_beta24 = 0;
00458
00459 bool x_y_hit_distrib_beta21 = 0;
00460 bool x_y_hit_distrib_beta22 = 0;
00461 bool x_y_hit_distrib_beta23 = 0;
00462 bool x_y_hit_distrib_beta24 = 0;
00463
00464
00465 if (nhit_distribution){
00466
00467 TCanvas * myc = new TCanvas("myc");
00468 myc->Divide(2,2);
00469 myc->cd(1);
00470 hnhit1->Draw();
00471 hnhit1_clean->Draw("same");
00472 myc->cd(2);
00473 hnhit2->Draw();
00474 hnhit2_clean->Draw("same");
00475 myc->cd(3);
00476 hnhit3->Draw();
00477 hnhit3_clean->Draw("same");
00478 myc->cd(4);
00479 hnhit4->Draw();
00480 hnhit4_clean->Draw("same");}
00481
00482 if (adc_distribution){
00483
00484 TCanvas * myc = new TCanvas("myc");
00485 myc->Divide(2,2);
00486 myc->cd(1);
00487 hadc1->Draw();
00488 hadc1_clean->Draw("same");
00489 myc->cd(2);
00490 hadc2->Draw();
00491 hadc2_clean->Draw("same");
00492 myc->cd(3);
00493 hadc3->Draw();
00494 hadc3_clean->Draw("same");
00495 myc->cd(4);
00496 hadc4->Draw();
00497 hadc4_clean->Draw("same");}
00498
00499
00500 if (chamber_xy_display){
00501
00502 TCanvas * myc3 = new TCanvas("myc3");
00503 myc3->Divide(2,2);
00504 myc3->cd(1);
00505 hxy1->Draw("zcol");
00506 myc3->cd(2);
00507 hxy2->Draw("zcol");
00508 myc3->cd(3);
00509 hxy3->Draw("zcol");
00510 myc3->cd(4);
00511 hxy4->Draw("zcol");}
00512
00513
00514 if (xyz_plot){
00515
00516 TCanvas * myc4 = new TCanvas("myc4");
00517
00518 tgxy->SetMarkerStyle(21);
00519 tgzx->SetMarkerStyle(21);
00520 tgzy->SetMarkerStyle(21);
00521
00522 myc4->Divide(2,2);
00523 myc4->cd(1);
00524 tgxy->Draw("ap");
00525 myc4->cd(2);
00526 tgzx->Draw("ap");
00527 myc4->cd(3);
00528 tgzy->Draw("ap");}
00529
00530
00531 if (number_hit_distrib_4_chamber){
00532
00533 hnhit1->DrawNormalized();
00534 hnhit2->DrawNormalized("same");
00535 hnhit3->DrawNormalized("same");
00536 hnhit4->DrawNormalized("same");}
00537
00538 if (number_hit_distrib_beta24){
00539
00540 hnhit4->DrawNormalized();
00541 hnhit4_clean->DrawNormalized("same");}
00542
00543 if (x_y_hit_distrib_beta21){
00544
00545 hxpos1->DrawNormalized();
00546 hxpos1_clean->DrawNormalized("same");
00547 hypos1->DrawNormalized("same");
00548 hypos1_clean->DrawNormalized("same");}
00549
00550 if (x_y_hit_distrib_beta22){
00551
00552 hxpos2->DrawNormalized();
00553 hxpos2_clean->DrawNormalized("same");
00554 hypos2->DrawNormalized("same");
00555 hypos2_clean->DrawNormalized("same");}
00556
00557 if (x_y_hit_distrib_beta23){
00558
00559 hxpos3->DrawNormalized();
00560 hxpos3_clean->DrawNormalized("same");
00561 hypos3->DrawNormalized("same");
00562 hypos3_clean->DrawNormalized("same");}
00563
00564 if (x_y_hit_distrib_beta24){
00565
00566 hxpos4_clean->DrawNormalized();
00567 hxpos4->DrawNormalized("same");
00568 hypos4_clean->DrawNormalized("same");
00569 hypos4->DrawNormalized("same");}
00570
00571
00572 }