]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ZDC/CheckAlienZDCESD.C
Allow to pass trigger mask value as parameter to AddTaskQAsym
[u/mrichter/AliRoot.git] / ZDC / CheckAlienZDCESD.C
CommitLineData
9577d217 1#if !defined(__CINT__) || defined(__MAKECINT__)
2
3#include <stdio.h>
4#include <stdlib.h>
5#include <TROOT.h>
6#include <Riostream.h>
7#include <TClassTable.h>
8#include <TStyle.h>
9#include <TMath.h>
10#include <TGrid.h>
11#include <TFile.h>
12#include <TCanvas.h>
13#include <TH1.h>
14#include <TH2.h>
15#include <TProfile.h>
16#include <TLine.h>
17#include "AliRun.h"
18#include "AliRunLoader.h"
19#include "AliPDG.h"
20#include "STEER/AliESDEvent.h"
21#include "STEER/AliESDZDC.h"
22
23#endif
fb8c9f86 24void CheckAlienZDCESD(Int_t year=2010, const char* period="10f",
9577d217 25 Int_t nRun=0, Int_t recoPass=1, Int_t nMaxFiles=1,
26 Bool_t plot=kTRUE, Bool_t esdWordCut=kFALSE)
27{
28
29 if(nRun==0){
30 printf("\n\n YOU MUST PROVIDE A RUN NUMBER!!! \n\n");
31 return;
32 }
33
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)");
42*/
13727fd4 43 TH1F * enZNC = new TH1F("enZNC", "ZNC signal",100,0.,2000.);
9577d217 44 enZNC->SetXTitle("E (GeV)");
13727fd4 45 TH1F * enZPC = new TH1F("enZPC", "ZPC signal",100,0.,2000.);
9577d217 46 enZPC->SetXTitle("E (GeV)");
13727fd4 47 TH1F * enZNA = new TH1F("enZNA", "ZNA signal",100,0.,2000.);
9577d217 48 enZNA->SetXTitle("E (GeV)");
13727fd4 49 TH1F * enZPA = new TH1F("enZPA", "ZPA signal",100,0.,2000.);
9577d217 50 enZPA->SetXTitle("E (GeV)");
13727fd4 51 TH1D * enZEM1 = new TH1D("enZEM1", "Energy in ZEM1",100,0.,2000.);
9577d217 52 enZEM1->SetXTitle("E (GeV)");
13727fd4 53 TH1D * enZEM2 = new TH1D("enZEM2", "Energy in ZEM2",100,0.,2000.);
9577d217 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);
13727fd4 61 hZNCTow[i] = new TH1D(nomehistznc, nomehistznc, 100, 0.,1000.);
9577d217 62 sprintf(nomehistzpc,"ZPC-pm%d",i);
13727fd4 63 hZPCTow[i] = new TH1D(nomehistzpc, nomehistzpc, 100, 0.,1000.);
9577d217 64 sprintf(nomehistzna,"ZNA-pm%d",i);
13727fd4 65 hZNATow[i] = new TH1D(nomehistzna, nomehistzna, 100, 0.,1000.);
9577d217 66 sprintf(nomehistzpa,"ZPA-pm%d",i);
13727fd4 67 hZPATow[i] = new TH1D(nomehistzpa, nomehistzpa, 100, 0.,1000.);
9577d217 68 }
13727fd4 69 //
70/* TH1D *hSumQZNC = new TH1D("hSumQZNC", "hSumQZNC", 100, 0., 1000.);
9577d217 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.);
13727fd4 74*/
9577d217 75 //
76 TH1F *hESDword = new TH1F("hESDword","hESDword",6,0.5,6.5);
77 hESDword->SetXTitle("ZDC trigger pattern");
fb8c9f86 78 //
79 TH1F * hTDC[32];
80 char ntdchist[20];
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)");
85 }
9577d217 86
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");
91
92 char esdFileName[200], filnamalien[200];
93 char yperiod, dirESD;
94 //
95 Int_t nAnalyzedFiles=0;
96 Int_t nevPhys=0, nevZNC=0, nevZPC=0, nevZNA=0, nevZPA=0, nevZEM1=0, nevZEM2=0;
97
98 while(!feof(listruns)){
99
100 if(nAnalyzedFiles!=nMaxFiles){
101
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);
109
110 // open the ESD file
111 TFile* esdFile = TFile::Open(filnamalien);
112 if(!esdFile) {
113 Error("CheckZDCESD", "opening ESD file %s failed",filnamalien);
114 return;
115 }
116
117 AliESDEvent* esd = new AliESDEvent();
118 TTree* tree = (TTree*) esdFile->Get("esdTree");
119 if(!tree) {
120 Error("CheckZDCESD", "No ESD tree found");
121 return;
122 }
123
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);
131
132 esd->ReadFromTree(tree);
133
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);
139
140 //printf(" ev. type %d\n",esd->GetEventType());
141 //
142 if(esd->GetEventType() == 7){
143 nevPhys++;
144 if(!esd) {
145 Error("CheckESD", "no ESD object found for event %d", iEvent);
146 return;
147 }
148
149 Double_t sumQznc=0., sumQzpc=0., sumQzna=0., sumQzpa=0.;
150
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();
166 //
167 if((iWord & 0x00000001) == 0x00000001){
168 nevZNA++;
169 hESDword->Fill(1.);
170 }
171 if((iWord & 0x00000002) == 0x00000002){
172 nevZPA++;
173 hESDword->Fill(2.);
174 }
175 if((iWord & 0x00000004) == 0x00000004){
176 nevZEM1++;
177 hESDword->Fill(3.);
178 }
179 if((iWord & 0x00000008) == 0x00000008){
180 nevZEM2++;
181 hESDword->Fill(4.);
182 }
183 if((iWord & 0x00000010) == 0x00000010){
184 nevZNC++;
185 hESDword->Fill(5.);
186 }
187 if((iWord & 0x00000020) == 0x00000020){
188 nevZPC++;
189 hESDword->Fill(6.);
190 }
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);
199 //
200 for(Int_t jj=0; jj<5; jj++){
201 if(esdWordCut){
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]);
206 }
207 else{
208 hZNCTow[jj]->Fill(towZNC[jj]);
209 hZPCTow[jj]->Fill(towZPC[jj]);
210 hZNATow[jj]->Fill(towZNA[jj]);
211 hZPATow[jj]->Fill(towZPA[jj]);
212 }
213 //
214 if(jj!=0){
215 if(esdWordCut){
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];
9577d217 220 }
221 else{
222 sumQznc += towZNC[jj];
223 sumQzpc += towZPC[jj];
224 sumQzna += towZNA[jj];
225 sumQzpa += towZPA[jj];
226 }
227 }
228 }
229 //
13727fd4 230/* if(esdWordCut){
9577d217 231 if((iWord & 0x00000010) == 0x00000010) {
232 hSumQZNC->Fill(sumQznc);
233 //
234 //if(centrZNA[0]!=-999. && centrZNA[1]!=-999) centroidZNsideC->Fill(centrZNA[0], centrZNA[1]);
235 }
236 //
237 if((iWord & 0x00000020) == 0x00000020) {
238 hSumQZPC->Fill(sumQzpc);
239 }
13727fd4 240
9577d217 241 }
242 else{
243 hSumQZNC->Fill(sumQznc);
244 //
245 hSumQZPC->Fill(sumQzpc);
246 }
247 //
248 hSumQZNA->Fill(sumQzna);
249 hSumQZPA->Fill(sumQzpa);
13727fd4 250*/
fb8c9f86 251 Float_t tdcData[32][4];
252 for(Int_t isc=0; isc<32; isc++){
9e05925b 253 for(Int_t i=0; i<4; i++) tdcData[isc][i] = esdZDC->GetZDCTDCData(isc, i);
fb8c9f86 254 }
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]);
259 }
260 }
261 }
262
9577d217 263 }
264
265 }
266
267 nAnalyzedFiles++;
268 esdFile->Close();
269 }//if(nAnalyzedFiles<=nMaxFiles)
270 else{
271 printf("\t %d files analyzed\n\n",nMaxFiles);
272 break;
273 }
274 } // while closing
275
13727fd4 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);
279
9577d217 280 if(plot){
281 //***********************************************************
282 // #### ROOT initialization
283 gROOT->Reset();
284 gStyle->SetCanvasColor(10);
285 gStyle->SetFrameFillColor(10);
286 gStyle->SetOptTitle(1);
287 if(esdWordCut) gStyle->SetOptStat(1111111);
13727fd4 288 else gStyle->SetOptStat(1111);
9577d217 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);
300
301
302 //-------------------------------------------------
13727fd4 303 TCanvas *c1 = new TCanvas("c1","ZDCs + ZEMs signals",400,0,500,800);
9577d217 304 c1->Divide(2,3);
305 c1->cd(1);
13727fd4 306 gPad->SetLogy(1);
307 enZNC->Draw("");
308 enZNC->SetLineColor(kBlue);
309 enZNC->SetFillColor(kBlue);
9577d217 310 c1->cd(2);
13727fd4 311 gPad->SetLogy(1);
312 enZPC->Draw("");
313 enZPC->SetLineColor(kBlue+3);
314 enZPC->SetFillColor(kBlue+3);
9577d217 315 c1->cd(3);
13727fd4 316 gPad->SetLogy(1);
9577d217 317 enZEM1->SetLineColor(kRed);
318 enZEM1->SetFillColor(kRed);
319 enZEM1->Draw("");
320 c1->cd(4);
13727fd4 321 gPad->SetLogy(1);
9577d217 322 enZEM2->SetLineColor(kRed);
323 enZEM2->SetFillColor(kRed);
324 enZEM2->Draw("");
325 c1->cd(5);
13727fd4 326 gPad->SetLogy(1);
9577d217 327 enZNA->Draw("");
328 enZNA->SetLineColor(kRed);
329 enZNA->SetFillColor(kRed);
13727fd4 330 c1->cd(6);
331 gPad->SetLogy(1);
9577d217 332 enZPA->Draw("");
333 enZPA->SetLineColor(kRed+1);
13727fd4 334 enZPA->SetFillColor(kRed+1);
9577d217 335
336 //-------------------------------------------------
337 TCanvas *c3 = new TCanvas("c3","Side C ZDCs",0,0,800,400);
338 c3->Divide(5,2);
339 c3->cd(1);
13727fd4 340 gPad->SetLogy(1);
9577d217 341 hZNCTow[0]->SetLineColor(kBlue);
342 hZNCTow[0]->SetFillColor(kBlue);
343 hZNCTow[0]->Draw("");
344 c3->cd(2);
345 gPad->SetLogy(1);
346 hZNCTow[1]->SetLineColor(kBlue);
347 hZNCTow[1]->SetFillColor(kBlue);
348 hZNCTow[1]->Draw("");
349 c3->cd(3);
13727fd4 350 gPad->SetLogy(1);
9577d217 351 hZNCTow[2]->SetLineColor(kBlue);
352 hZNCTow[2]->SetFillColor(kBlue);
353 hZNCTow[2]->Draw("");
354 c3->cd(4);
13727fd4 355 gPad->SetLogy(1);
9577d217 356 hZNCTow[3]->SetLineColor(kBlue);
357 hZNCTow[3]->SetFillColor(kBlue);
358 hZNCTow[3]->Draw("");
359 c3->cd(5);
13727fd4 360 gPad->SetLogy(1);
9577d217 361 hZNCTow[4]->SetLineColor(kBlue);
362 hZNCTow[4]->SetFillColor(kBlue);
363 hZNCTow[4]->Draw("");
364 //
365 c3->cd(6);
13727fd4 366 gPad->SetLogy(1);
9577d217 367 hZPCTow[0]->SetLineColor(kBlue+3);
368 hZPCTow[0]->SetFillColor(kBlue+3);
369 hZPCTow[0]->Draw("");
370 c3->cd(7);
13727fd4 371 gPad->SetLogy(1);
9577d217 372 hZPCTow[1]->SetLineColor(kBlue+3);
373 hZPCTow[1]->SetFillColor(kBlue+3);
374 hZPCTow[1]->Draw("");
375 c3->cd(8);
13727fd4 376 gPad->SetLogy(1);
9577d217 377 hZPCTow[2]->SetLineColor(kBlue+3);
378 hZPCTow[2]->SetFillColor(kBlue+3);
379 hZPCTow[2]->Draw("");
380 c3->cd(9);
13727fd4 381 gPad->SetLogy(1);
9577d217 382 hZPCTow[3]->SetLineColor(kBlue+3);
383 hZPCTow[3]->SetFillColor(kBlue+3);
384 hZPCTow[3]->Draw("");
385 c3->cd(10);
13727fd4 386 gPad->SetLogy(1);
9577d217 387 hZPCTow[4]->SetLineColor(kBlue+3);
388 hZPCTow[4]->SetFillColor(kBlue+3);
389 hZPCTow[4]->Draw("");
390
391
392 //-------------------------------------------------
393 TCanvas *c32 = new TCanvas("c32","side A ZDCs",700,0,800,400);
394 c32->Divide(5,2);
395 c32->cd(1);
13727fd4 396 gPad->SetLogy(1);
9577d217 397 hZNATow[0]->SetLineColor(kRed);
398 hZNATow[0]->SetFillColor(kRed);
399 hZNATow[0]->Draw("");
400 c32->cd(2);
401 gPad->SetLogy(1);
402 hZNATow[1]->SetLineColor(kRed);
403 hZNATow[1]->SetFillColor(kRed);
404 hZNATow[1]->Draw("");
405 c32->cd(3);
13727fd4 406 gPad->SetLogy(1);
9577d217 407 hZNATow[2]->SetLineColor(kRed);
408 hZNATow[2]->SetFillColor(kRed);
409 hZNATow[2]->Draw("");
410 c32->cd(4);
13727fd4 411 gPad->SetLogy(1);
9577d217 412 hZNATow[3]->SetLineColor(kRed);
413 hZNATow[3]->SetFillColor(kRed);
414 hZNATow[3]->Draw("");
415 c32->cd(5);
13727fd4 416 gPad->SetLogy(1);
9577d217 417 hZNATow[4]->SetLineColor(kRed);
418 hZNATow[4]->SetFillColor(kRed);
419 hZNATow[4]->Draw("");
420 //
421 c32->cd(6);
13727fd4 422 gPad->SetLogy(1);
9577d217 423 hZPATow[0]->SetLineColor(kRed+1);
424 hZPATow[0]->SetFillColor(kRed+1);
425 hZPATow[0]->Draw("");
426 c32->cd(7);
13727fd4 427 gPad->SetLogy(1);
9577d217 428 hZPATow[1]->SetLineColor(kRed+1);
429 hZPATow[1]->SetFillColor(kRed+1);
430 hZPATow[1]->Draw("");
431 c32->cd(8);
13727fd4 432 gPad->SetLogy(1);
9577d217 433 hZPATow[2]->SetLineColor(kRed+1);
434 hZPATow[2]->SetFillColor(kRed+1);
435 hZPATow[2]->Draw("");
436 c32->cd(9);
13727fd4 437 gPad->SetLogy(1);
9577d217 438 hZPATow[3]->SetLineColor(kRed+1);
439 hZPATow[3]->SetFillColor(kRed+1);
440 hZPATow[3]->Draw("");
441 c32->cd(10);
13727fd4 442 gPad->SetLogy(1);
9577d217 443 hZPATow[4]->SetLineColor(kRed+1);
444 hZPATow[4]->SetFillColor(kRed+1);
445 hZPATow[4]->Draw("");
fb8c9f86 446
447 //-------------------------------------------------
448 TCanvas *c4 = new TCanvas("c4","TDCs",400,0,700,500);
449 c4->Divide(3,2);
450 c4->cd(1);
451 hTDC[1]->SetFillColor(kPink); hTDC[1]->SetLineColor(kPink);
452 hTDC[1]->Draw("");
453 c4->cd(2);
454 hTDC[3]->SetFillColor(kPink+4); hTDC[3]->SetLineColor(kPink+4);
455 hTDC[3]->Draw("");
456 c4->cd(3);
457 hTDC[5]->SetFillColor(kGreen); hTDC[5]->SetLineColor(kGreen);
458 hTDC[5]->Draw("");
459 c4->cd(4);
460 hTDC[7]->SetFillColor(kGreen+2); hTDC[7]->SetLineColor(kGreen+2);
461 hTDC[7]->Draw("");
462 c4->cd(5);
463 hTDC[8]->SetFillColor(kAzure); hTDC[8]->SetLineColor(kAzure);
464 hTDC[8]->Draw("");
465 c4->cd(6);
466 hTDC[9]->SetFillColor(kAzure+5); hTDC[9]->SetLineColor(kAzure+5);
467 hTDC[9]->Draw("");
9577d217 468 }
469
470 TFile * fileout = new TFile("ESDhistos.root","recreate");
471 fileout->cd();
472 //centroidZNsideC->Write();
473 //centroidZNsideA->Write();
474 enZNC->Write();
475 enZNA->Write();
476 enZPC->Write();
477 enZPA->Write();
478 enZEM1->Write();
479 enZEM2->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();
485 }
13727fd4 486 /*hSumQZNC->Write();
9577d217 487 hSumQZPC->Write();
488 hSumQZNA->Write();
13727fd4 489 hSumQZPA->Write();*/
9577d217 490 //
491 hESDword->Write();
fb8c9f86 492 for(Int_t jj=0; jj<9; jj++) hTDC[jj]->Write();
9577d217 493 //
494 fileout->Close();
495
496}