1 #if !defined(__CINT__) || defined(__MAKECINT__)
7 #include <TClassTable.h>
18 #include "AliRunLoader.h"
20 #include "STEER/AliESDEvent.h"
21 #include "STEER/AliESDZDC.h"
24 void CheckAlienZDCESD(Int_t year=2010, const char* period="10f",
25 Int_t nRun=0, Int_t recoPass=1, Int_t nMaxFiles=1,
26 Bool_t plot=kTRUE, Bool_t esdWordCut=kFALSE)
30 printf("\n\n YOU MUST PROVIDE A RUN NUMBER!!! \n\n");
34 // Histogram definition
35 // ----------------------------------------------------------------
36 /* TH2F *centroidZNsideC = new TH2F("centroidZNsideC","Impact point over ZNC",100,-5.,5.,100,-5.,5.);
37 centroidZNsideC->SetXTitle("X_{ZNC} (cm)");
38 centroidZNsideC->SetYTitle("Y_{ZNC} (cm)");
39 TH2F * centroidZNsideA = new TH2F("centroidZNsideA","Impact point over ZNA",100,-5.,5.,100,-5.,5.);
40 centroidZNsideA->SetXTitle("X_{ZNA} (cm)");
41 centroidZNsideA->SetYTitle("Y_{ZNA} (cm)");
43 TH1F * enZNC = new TH1F("enZNC", "ZNC signal",100,0.,2000.);
44 enZNC->SetXTitle("E (GeV)");
45 TH1F * enZPC = new TH1F("enZPC", "ZPC signal",100,0.,2000.);
46 enZPC->SetXTitle("E (GeV)");
47 TH1F * enZNA = new TH1F("enZNA", "ZNA signal",100,0.,2000.);
48 enZNA->SetXTitle("E (GeV)");
49 TH1F * enZPA = new TH1F("enZPA", "ZPA signal",100,0.,2000.);
50 enZPA->SetXTitle("E (GeV)");
51 TH1D * enZEM1 = new TH1D("enZEM1", "Energy in ZEM1",100,0.,2000.);
52 enZEM1->SetXTitle("E (GeV)");
53 TH1D * enZEM2 = new TH1D("enZEM2", "Energy in ZEM2",100,0.,2000.);
54 enZEM2->SetXTitle("E (GeV)");
55 // ----------------------------------------------------------------
56 TH1D * hZNCTow[5]; TH1D * hZPCTow[5];
57 TH1D * hZNATow[5]; TH1D * hZPATow[5];
58 char nomehistznc[30], nomehistzpc[30], nomehistzna[30], nomehistzpa[30];
59 for(Int_t i=0; i<5; i++){
60 sprintf(nomehistznc,"ZNC-pm%d",i);
61 hZNCTow[i] = new TH1D(nomehistznc, nomehistznc, 100, 0.,1000.);
62 sprintf(nomehistzpc,"ZPC-pm%d",i);
63 hZPCTow[i] = new TH1D(nomehistzpc, nomehistzpc, 100, 0.,1000.);
64 sprintf(nomehistzna,"ZNA-pm%d",i);
65 hZNATow[i] = new TH1D(nomehistzna, nomehistzna, 100, 0.,1000.);
66 sprintf(nomehistzpa,"ZPA-pm%d",i);
67 hZPATow[i] = new TH1D(nomehistzpa, nomehistzpa, 100, 0.,1000.);
70 /* TH1D *hSumQZNC = new TH1D("hSumQZNC", "hSumQZNC", 100, 0., 1000.);
71 TH1D *hSumQZPC = new TH1D("hSumQZPC", "hSumQZPC", 100, 0., 1000.);
72 TH1D *hSumQZNA = new TH1D("hSumQZNA", "hSumQZNA", 100, 0., 1000.);
73 TH1D *hSumQZPA = new TH1D("hSumQZPA", "hSumQZPA", 100, 0., 1000.);
76 TH1F *hESDword = new TH1F("hESDword","hESDword",6,0.5,6.5);
77 hESDword->SetXTitle("ZDC trigger pattern");
81 for(Int_t itdc=0; itdc<32; itdc++){
82 sprintf(ntdchist,"TDC-ch.%d",itdc);
83 hTDC[itdc] = new TH1F(ntdchist, ntdchist, 160, -350., -310.);
84 hTDC[itdc]->SetXTitle("TDC (ns)");
87 TGrid::Connect("alien:",0,0,"t");
88 gSystem->Exec(Form("gbbox find \"/alice/data/%d/LHC%s/000%d/ESDs/pass%d\" \"AliESDs.root\" > ESDFiles.txt",
89 year, period, nRun, recoPass));
90 FILE* listruns=fopen("ESDFiles.txt","r");
92 char esdFileName[200], filnamalien[200];
95 Int_t nAnalyzedFiles=0;
96 Int_t nevPhys=0, nevZNC=0, nevZPC=0, nevZNA=0, nevZPA=0, nevZEM1=0, nevZEM2=0;
98 while(!feof(listruns)){
100 if(nAnalyzedFiles!=nMaxFiles){
102 int st = fscanf(listruns,"%s\n",esdFileName);
103 Char_t directory[100];
104 sprintf(directory,"/alice/data/%d",year);
105 if(!strstr(esdFileName,directory)) continue;
106 sscanf(esdFileName,"/alice/data/%d/LHC%s/000%d/ESDs/pass%d/%s/AliESDs.root",&year,&yperiod,&nRun,&recoPass,&dirESD);
107 sprintf(filnamalien,"alien://%s",esdFileName);
108 printf("\n Opening file: %s\n",filnamalien);
111 TFile* esdFile = TFile::Open(filnamalien);
113 Error("CheckZDCESD", "opening ESD file %s failed",filnamalien);
117 AliESDEvent* esd = new AliESDEvent();
118 TTree* tree = (TTree*) esdFile->Get("esdTree");
120 Error("CheckZDCESD", "No ESD tree found");
124 tree->SetBranchStatus("*", 0);
125 tree->SetBranchStatus("AliESDHeader*", 1);
126 tree->SetBranchStatus("AliESDRun*", 1);
127 tree->SetBranchStatus("AliESDZDC*", 1);
128 tree->SetBranchStatus("PrimaryVertex*", 1);
129 tree->SetBranchStatus("SPDVertex*", 1);
130 tree->SetBranchStatus("AliESDVZERO*", 1);
132 esd->ReadFromTree(tree);
134 Int_t nevents = (Int_t)tree->GetEntries();
135 printf("\n No. of events in ESD tree = %d\n", nevents);
136 for(Int_t iEvent=0; iEvent<nevents; iEvent++){
137 // get the event summary data
138 tree->GetEvent(iEvent);
140 //printf(" ev. type %d\n",esd->GetEventType());
142 if(esd->GetEventType() == 7){
145 Error("CheckESD", "no ESD object found for event %d", iEvent);
149 Double_t sumQznc=0., sumQzpc=0., sumQzna=0., sumQzpa=0.;
151 AliESDZDC *esdZDC = esd->GetESDZDC();
152 //Double_t centrZNC={-999.,-999.}, centrZNA={-999.,-999.};
153 //esdZDC->GetZNCentroidInpp(centrZNC, centrZNA);
154 //Short_t npart = esdZDC->GetZDCParticipants();
155 Double_t energyZNC = esdZDC->GetZDCN1Energy();
156 Double_t energyZPC = esdZDC->GetZDCP1Energy();
157 Double_t energyZNA = esdZDC->GetZDCN2Energy();
158 Double_t energyZPA = esdZDC->GetZDCP2Energy();
159 Double_t energyZEM1 = esdZDC->GetZDCEMEnergy(0);
160 Double_t energyZEM2 = esdZDC->GetZDCEMEnergy(1);
161 const Double_t * towZNC = esdZDC->GetZN1TowerEnergy();
162 const Double_t * towZPC = esdZDC->GetZP1TowerEnergy();
163 const Double_t * towZNA = esdZDC->GetZN2TowerEnergy();
164 const Double_t * towZPA = esdZDC->GetZP2TowerEnergy();
165 UInt_t iWord = esdZDC->GetESDQuality();
167 if((iWord & 0x00000001) == 0x00000001){
171 if((iWord & 0x00000002) == 0x00000002){
175 if((iWord & 0x00000004) == 0x00000004){
179 if((iWord & 0x00000008) == 0x00000008){
183 if((iWord & 0x00000010) == 0x00000010){
187 if((iWord & 0x00000020) == 0x00000020){
191 //if(centrZNC[0]!=-999. && centrZNC[1]!=-999) centroidZNsideC->Fill(centrZNC[0], centrZNC[1]);
192 //if(centrZNA[0]!=-999. && centrZNA[1]!=-999) centroidZNsideA->Fill(centrZNA[0], centrZNA[1]);
193 enZNC->Fill(energyZNC);
194 enZPC->Fill(energyZPC);
195 enZNA->Fill(energyZNA);
196 enZPA->Fill(energyZPA);
197 enZEM1->Fill(energyZEM1);
198 enZEM2->Fill(energyZEM2);
200 for(Int_t jj=0; jj<5; jj++){
202 if((iWord & 0x00000010) == 0x00000010) hZNCTow[jj]->Fill(towZNC[jj]);
203 if((iWord & 0x00000020) == 0x00000020) hZPCTow[jj]->Fill(towZPC[jj]);
204 if((iWord & 0x00000001) == 0x00000001) hZNATow[jj]->Fill(towZNA[jj]);
205 if((iWord & 0x00000002) == 0x00000002) hZPATow[jj]->Fill(towZPA[jj]);
208 hZNCTow[jj]->Fill(towZNC[jj]);
209 hZPCTow[jj]->Fill(towZPC[jj]);
210 hZNATow[jj]->Fill(towZNA[jj]);
211 hZPATow[jj]->Fill(towZPA[jj]);
216 if((iWord & 0x00000010) == 0x00000010) sumQznc += towZNC[jj];
217 if((iWord & 0x00000020) == 0x00000020) sumQzpc += towZPC[jj];
218 if((iWord & 0x00000001) == 0x00000001) sumQzna += towZNA[jj];
219 if((iWord & 0x00000002) == 0x00000002) sumQzpa += towZPA[jj];
222 sumQznc += towZNC[jj];
223 sumQzpc += towZPC[jj];
224 sumQzna += towZNA[jj];
225 sumQzpa += towZPA[jj];
231 if((iWord & 0x00000010) == 0x00000010) {
232 hSumQZNC->Fill(sumQznc);
234 //if(centrZNA[0]!=-999. && centrZNA[1]!=-999) centroidZNsideC->Fill(centrZNA[0], centrZNA[1]);
237 if((iWord & 0x00000020) == 0x00000020) {
238 hSumQZPC->Fill(sumQzpc);
243 hSumQZNC->Fill(sumQznc);
245 hSumQZPC->Fill(sumQzpc);
248 hSumQZNA->Fill(sumQzna);
249 hSumQZPA->Fill(sumQzpa);
251 Float_t tdcData[32][4];
252 for(Int_t isc=0; isc<32; isc++){
253 for(Int_t i=0; i<4; i++) tdcData[isc][i] = esdZDC->GetZDCTDCData(isc, i);
255 for(Int_t itdc=0; itdc<32; itdc++){
256 for(Int_t j=0; j<4; j++){
257 if((itdc>=0 || itdc<=9) && (tdcData[itdc][j]!=0)){
258 hTDC[itdc]->Fill(tdcData[itdc][j]-tdcData[15][j]);
269 }//if(nAnalyzedFiles<=nMaxFiles)
271 printf("\t %d files analyzed\n\n",nMaxFiles);
276 printf(" No. of events over threshold: ZNA: %d ZPA: %d ZEM1: %d "
277 " ZEM2: %d ZNC: %d ZPC: %d\n\n",
278 nevZNA, nevZPA, nevZEM1, nevZEM2, nevZNC, nevZPC);
281 //***********************************************************
282 // #### ROOT initialization
284 gStyle->SetCanvasColor(10);
285 gStyle->SetFrameFillColor(10);
286 gStyle->SetOptTitle(1);
287 if(esdWordCut) gStyle->SetOptStat(1111111);
288 else gStyle->SetOptStat(1111);
289 gStyle->SetOptFit(0);
290 gStyle->SetTitleTextColor(4);
291 gStyle->SetStatTextColor(4);
292 gStyle->SetStatX(0.92);
293 gStyle->SetStatY(0.92);
294 gStyle->SetLineColor(1);
295 gStyle->SetPalette(1);
296 gStyle->SetPadTopMargin(0.04);
297 gStyle->SetPadRightMargin(0.04);
298 gStyle->SetPadBottomMargin(0.14);
299 gStyle->SetPadLeftMargin(0.16);
302 //-------------------------------------------------
303 TCanvas *c1 = new TCanvas("c1","ZDCs + ZEMs signals",400,0,500,800);
308 enZNC->SetLineColor(kBlue);
309 enZNC->SetFillColor(kBlue);
313 enZPC->SetLineColor(kBlue+3);
314 enZPC->SetFillColor(kBlue+3);
317 enZEM1->SetLineColor(kRed);
318 enZEM1->SetFillColor(kRed);
322 enZEM2->SetLineColor(kRed);
323 enZEM2->SetFillColor(kRed);
328 enZNA->SetLineColor(kRed);
329 enZNA->SetFillColor(kRed);
333 enZPA->SetLineColor(kRed+1);
334 enZPA->SetFillColor(kRed+1);
336 //-------------------------------------------------
337 TCanvas *c3 = new TCanvas("c3","Side C ZDCs",0,0,800,400);
341 hZNCTow[0]->SetLineColor(kBlue);
342 hZNCTow[0]->SetFillColor(kBlue);
343 hZNCTow[0]->Draw("");
346 hZNCTow[1]->SetLineColor(kBlue);
347 hZNCTow[1]->SetFillColor(kBlue);
348 hZNCTow[1]->Draw("");
351 hZNCTow[2]->SetLineColor(kBlue);
352 hZNCTow[2]->SetFillColor(kBlue);
353 hZNCTow[2]->Draw("");
356 hZNCTow[3]->SetLineColor(kBlue);
357 hZNCTow[3]->SetFillColor(kBlue);
358 hZNCTow[3]->Draw("");
361 hZNCTow[4]->SetLineColor(kBlue);
362 hZNCTow[4]->SetFillColor(kBlue);
363 hZNCTow[4]->Draw("");
367 hZPCTow[0]->SetLineColor(kBlue+3);
368 hZPCTow[0]->SetFillColor(kBlue+3);
369 hZPCTow[0]->Draw("");
372 hZPCTow[1]->SetLineColor(kBlue+3);
373 hZPCTow[1]->SetFillColor(kBlue+3);
374 hZPCTow[1]->Draw("");
377 hZPCTow[2]->SetLineColor(kBlue+3);
378 hZPCTow[2]->SetFillColor(kBlue+3);
379 hZPCTow[2]->Draw("");
382 hZPCTow[3]->SetLineColor(kBlue+3);
383 hZPCTow[3]->SetFillColor(kBlue+3);
384 hZPCTow[3]->Draw("");
387 hZPCTow[4]->SetLineColor(kBlue+3);
388 hZPCTow[4]->SetFillColor(kBlue+3);
389 hZPCTow[4]->Draw("");
392 //-------------------------------------------------
393 TCanvas *c32 = new TCanvas("c32","side A ZDCs",700,0,800,400);
397 hZNATow[0]->SetLineColor(kRed);
398 hZNATow[0]->SetFillColor(kRed);
399 hZNATow[0]->Draw("");
402 hZNATow[1]->SetLineColor(kRed);
403 hZNATow[1]->SetFillColor(kRed);
404 hZNATow[1]->Draw("");
407 hZNATow[2]->SetLineColor(kRed);
408 hZNATow[2]->SetFillColor(kRed);
409 hZNATow[2]->Draw("");
412 hZNATow[3]->SetLineColor(kRed);
413 hZNATow[3]->SetFillColor(kRed);
414 hZNATow[3]->Draw("");
417 hZNATow[4]->SetLineColor(kRed);
418 hZNATow[4]->SetFillColor(kRed);
419 hZNATow[4]->Draw("");
423 hZPATow[0]->SetLineColor(kRed+1);
424 hZPATow[0]->SetFillColor(kRed+1);
425 hZPATow[0]->Draw("");
428 hZPATow[1]->SetLineColor(kRed+1);
429 hZPATow[1]->SetFillColor(kRed+1);
430 hZPATow[1]->Draw("");
433 hZPATow[2]->SetLineColor(kRed+1);
434 hZPATow[2]->SetFillColor(kRed+1);
435 hZPATow[2]->Draw("");
438 hZPATow[3]->SetLineColor(kRed+1);
439 hZPATow[3]->SetFillColor(kRed+1);
440 hZPATow[3]->Draw("");
443 hZPATow[4]->SetLineColor(kRed+1);
444 hZPATow[4]->SetFillColor(kRed+1);
445 hZPATow[4]->Draw("");
447 //-------------------------------------------------
448 TCanvas *c4 = new TCanvas("c4","TDCs",400,0,700,500);
451 hTDC[1]->SetFillColor(kPink); hTDC[1]->SetLineColor(kPink);
454 hTDC[3]->SetFillColor(kPink+4); hTDC[3]->SetLineColor(kPink+4);
457 hTDC[5]->SetFillColor(kGreen); hTDC[5]->SetLineColor(kGreen);
460 hTDC[7]->SetFillColor(kGreen+2); hTDC[7]->SetLineColor(kGreen+2);
463 hTDC[8]->SetFillColor(kAzure); hTDC[8]->SetLineColor(kAzure);
466 hTDC[9]->SetFillColor(kAzure+5); hTDC[9]->SetLineColor(kAzure+5);
470 TFile * fileout = new TFile("ESDhistos.root","recreate");
472 //centroidZNsideC->Write();
473 //centroidZNsideA->Write();
480 for(Int_t jj=0; jj<5; jj++){
481 hZNCTow[jj]->Write();
482 hZPCTow[jj]->Write();
483 hZNATow[jj]->Write();
484 hZPATow[jj]->Write();
492 for(Int_t jj=0; jj<9; jj++) hTDC[jj]->Write();