]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ZDC/CheckAlienZDCESD.C
First version of a class to compute the number of collisions corresponding to a data...
[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
24void CheckAlienZDCESD(Int_t year=2010, const char* period="10a",
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");
78
79 TGrid::Connect("alien:",0,0,"t");
80 gSystem->Exec(Form("gbbox find \"/alice/data/%d/LHC%s/000%d/ESDs/pass%d\" \"AliESDs.root\" > ESDFiles.txt",
81 year, period, nRun, recoPass));
82 FILE* listruns=fopen("ESDFiles.txt","r");
83
84 char esdFileName[200], filnamalien[200];
85 char yperiod, dirESD;
86 //
87 Int_t nAnalyzedFiles=0;
88 Int_t nevPhys=0, nevZNC=0, nevZPC=0, nevZNA=0, nevZPA=0, nevZEM1=0, nevZEM2=0;
89
90 while(!feof(listruns)){
91
92 if(nAnalyzedFiles!=nMaxFiles){
93
94 int st = fscanf(listruns,"%s\n",esdFileName);
95 Char_t directory[100];
96 sprintf(directory,"/alice/data/%d",year);
97 if(!strstr(esdFileName,directory)) continue;
98 sscanf(esdFileName,"/alice/data/%d/LHC%s/000%d/ESDs/pass%d/%s/AliESDs.root",&year,&yperiod,&nRun,&recoPass,&dirESD);
99 sprintf(filnamalien,"alien://%s",esdFileName);
100 printf("\n Opening file: %s\n",filnamalien);
101
102 // open the ESD file
103 TFile* esdFile = TFile::Open(filnamalien);
104 if(!esdFile) {
105 Error("CheckZDCESD", "opening ESD file %s failed",filnamalien);
106 return;
107 }
108
109 AliESDEvent* esd = new AliESDEvent();
110 TTree* tree = (TTree*) esdFile->Get("esdTree");
111 if(!tree) {
112 Error("CheckZDCESD", "No ESD tree found");
113 return;
114 }
115
116 tree->SetBranchStatus("*", 0);
117 tree->SetBranchStatus("AliESDHeader*", 1);
118 tree->SetBranchStatus("AliESDRun*", 1);
119 tree->SetBranchStatus("AliESDZDC*", 1);
120 tree->SetBranchStatus("PrimaryVertex*", 1);
121 tree->SetBranchStatus("SPDVertex*", 1);
122 tree->SetBranchStatus("AliESDVZERO*", 1);
123
124 esd->ReadFromTree(tree);
125
126 Int_t nevents = (Int_t)tree->GetEntries();
127 printf("\n No. of events in ESD tree = %d\n", nevents);
128 for(Int_t iEvent=0; iEvent<nevents; iEvent++){
129 // get the event summary data
130 tree->GetEvent(iEvent);
131
132 //printf(" ev. type %d\n",esd->GetEventType());
133 //
134 if(esd->GetEventType() == 7){
135 nevPhys++;
136 if(!esd) {
137 Error("CheckESD", "no ESD object found for event %d", iEvent);
138 return;
139 }
140
141 Double_t sumQznc=0., sumQzpc=0., sumQzna=0., sumQzpa=0.;
142
143 AliESDZDC *esdZDC = esd->GetESDZDC();
144 //Double_t centrZNC={-999.,-999.}, centrZNA={-999.,-999.};
145 //esdZDC->GetZNCentroidInpp(centrZNC, centrZNA);
146 //Short_t npart = esdZDC->GetZDCParticipants();
147 Double_t energyZNC = esdZDC->GetZDCN1Energy();
148 Double_t energyZPC = esdZDC->GetZDCP1Energy();
149 Double_t energyZNA = esdZDC->GetZDCN2Energy();
150 Double_t energyZPA = esdZDC->GetZDCP2Energy();
151 Double_t energyZEM1 = esdZDC->GetZDCEMEnergy(0);
152 Double_t energyZEM2 = esdZDC->GetZDCEMEnergy(1);
153 const Double_t * towZNC = esdZDC->GetZN1TowerEnergy();
154 const Double_t * towZPC = esdZDC->GetZP1TowerEnergy();
155 const Double_t * towZNA = esdZDC->GetZN2TowerEnergy();
156 const Double_t * towZPA = esdZDC->GetZP2TowerEnergy();
157 UInt_t iWord = esdZDC->GetESDQuality();
158 //
159 if((iWord & 0x00000001) == 0x00000001){
160 nevZNA++;
161 hESDword->Fill(1.);
162 }
163 if((iWord & 0x00000002) == 0x00000002){
164 nevZPA++;
165 hESDword->Fill(2.);
166 }
167 if((iWord & 0x00000004) == 0x00000004){
168 nevZEM1++;
169 hESDword->Fill(3.);
170 }
171 if((iWord & 0x00000008) == 0x00000008){
172 nevZEM2++;
173 hESDword->Fill(4.);
174 }
175 if((iWord & 0x00000010) == 0x00000010){
176 nevZNC++;
177 hESDword->Fill(5.);
178 }
179 if((iWord & 0x00000020) == 0x00000020){
180 nevZPC++;
181 hESDword->Fill(6.);
182 }
183 //if(centrZNC[0]!=-999. && centrZNC[1]!=-999) centroidZNsideC->Fill(centrZNC[0], centrZNC[1]);
184 //if(centrZNA[0]!=-999. && centrZNA[1]!=-999) centroidZNsideA->Fill(centrZNA[0], centrZNA[1]);
185 enZNC->Fill(energyZNC);
186 enZPC->Fill(energyZPC);
187 enZNA->Fill(energyZNA);
188 enZPA->Fill(energyZPA);
189 enZEM1->Fill(energyZEM1);
190 enZEM2->Fill(energyZEM2);
191 //
192 for(Int_t jj=0; jj<5; jj++){
193 if(esdWordCut){
194 if((iWord & 0x00000010) == 0x00000010) hZNCTow[jj]->Fill(towZNC[jj]);
195 if((iWord & 0x00000020) == 0x00000020) hZPCTow[jj]->Fill(towZPC[jj]);
196 if((iWord & 0x00000001) == 0x00000001) hZNATow[jj]->Fill(towZNA[jj]);
197 if((iWord & 0x00000002) == 0x00000002) hZPATow[jj]->Fill(towZPA[jj]);
198 }
199 else{
200 hZNCTow[jj]->Fill(towZNC[jj]);
201 hZPCTow[jj]->Fill(towZPC[jj]);
202 hZNATow[jj]->Fill(towZNA[jj]);
203 hZPATow[jj]->Fill(towZPA[jj]);
204 }
205 //
206 if(jj!=0){
207 if(esdWordCut){
208 if((iWord & 0x00000010) == 0x00000010) sumQznc += towZNC[jj];
209 if((iWord & 0x00000020) == 0x00000020) sumQzpc += towZPC[jj];
210 if((iWord & 0x00000001) == 0x00000001) sumQzna += towZNA[jj];
211 if((iWord & 0x00000002) == 0x00000002) sumQzpa += towZPA[jj];
9577d217 212 }
213 else{
214 sumQznc += towZNC[jj];
215 sumQzpc += towZPC[jj];
216 sumQzna += towZNA[jj];
217 sumQzpa += towZPA[jj];
218 }
219 }
220 }
221 //
13727fd4 222/* if(esdWordCut){
9577d217 223 if((iWord & 0x00000010) == 0x00000010) {
224 hSumQZNC->Fill(sumQznc);
225 //
226 //if(centrZNA[0]!=-999. && centrZNA[1]!=-999) centroidZNsideC->Fill(centrZNA[0], centrZNA[1]);
227 }
228 //
229 if((iWord & 0x00000020) == 0x00000020) {
230 hSumQZPC->Fill(sumQzpc);
231 }
13727fd4 232
9577d217 233 }
234 else{
235 hSumQZNC->Fill(sumQznc);
236 //
237 hSumQZPC->Fill(sumQzpc);
238 }
239 //
240 hSumQZNA->Fill(sumQzna);
241 hSumQZPA->Fill(sumQzpa);
13727fd4 242*/
9577d217 243 }
244
245 }
246
247 nAnalyzedFiles++;
248 esdFile->Close();
249 }//if(nAnalyzedFiles<=nMaxFiles)
250 else{
251 printf("\t %d files analyzed\n\n",nMaxFiles);
252 break;
253 }
254 } // while closing
255
13727fd4 256 printf(" No. of events over threshold: ZNA: %d ZPA: %d ZEM1: %d "
257 " ZEM2: %d ZNC: %d ZPC: %d\n\n",
258 nevZNA, nevZPA, nevZEM1, nevZEM2, nevZNC, nevZPC);
259
9577d217 260 if(plot){
261 //***********************************************************
262 // #### ROOT initialization
263 gROOT->Reset();
264 gStyle->SetCanvasColor(10);
265 gStyle->SetFrameFillColor(10);
266 gStyle->SetOptTitle(1);
267 if(esdWordCut) gStyle->SetOptStat(1111111);
13727fd4 268 else gStyle->SetOptStat(1111);
9577d217 269 gStyle->SetOptFit(0);
270 gStyle->SetTitleTextColor(4);
271 gStyle->SetStatTextColor(4);
272 gStyle->SetStatX(0.92);
273 gStyle->SetStatY(0.92);
274 gStyle->SetLineColor(1);
275 gStyle->SetPalette(1);
276 gStyle->SetPadTopMargin(0.04);
277 gStyle->SetPadRightMargin(0.04);
278 gStyle->SetPadBottomMargin(0.14);
279 gStyle->SetPadLeftMargin(0.16);
280
281
282 //-------------------------------------------------
13727fd4 283 TCanvas *c1 = new TCanvas("c1","ZDCs + ZEMs signals",400,0,500,800);
9577d217 284 c1->Divide(2,3);
285 c1->cd(1);
13727fd4 286 gPad->SetLogy(1);
287 enZNC->Draw("");
288 enZNC->SetLineColor(kBlue);
289 enZNC->SetFillColor(kBlue);
9577d217 290 c1->cd(2);
13727fd4 291 gPad->SetLogy(1);
292 enZPC->Draw("");
293 enZPC->SetLineColor(kBlue+3);
294 enZPC->SetFillColor(kBlue+3);
9577d217 295 c1->cd(3);
13727fd4 296 gPad->SetLogy(1);
9577d217 297 enZEM1->SetLineColor(kRed);
298 enZEM1->SetFillColor(kRed);
299 enZEM1->Draw("");
300 c1->cd(4);
13727fd4 301 gPad->SetLogy(1);
9577d217 302 enZEM2->SetLineColor(kRed);
303 enZEM2->SetFillColor(kRed);
304 enZEM2->Draw("");
305 c1->cd(5);
13727fd4 306 gPad->SetLogy(1);
9577d217 307 enZNA->Draw("");
308 enZNA->SetLineColor(kRed);
309 enZNA->SetFillColor(kRed);
13727fd4 310 c1->cd(6);
311 gPad->SetLogy(1);
9577d217 312 enZPA->Draw("");
313 enZPA->SetLineColor(kRed+1);
13727fd4 314 enZPA->SetFillColor(kRed+1);
9577d217 315
316 //-------------------------------------------------
317 TCanvas *c3 = new TCanvas("c3","Side C ZDCs",0,0,800,400);
318 c3->Divide(5,2);
319 c3->cd(1);
13727fd4 320 gPad->SetLogy(1);
9577d217 321 hZNCTow[0]->SetLineColor(kBlue);
322 hZNCTow[0]->SetFillColor(kBlue);
323 hZNCTow[0]->Draw("");
324 c3->cd(2);
325 gPad->SetLogy(1);
326 hZNCTow[1]->SetLineColor(kBlue);
327 hZNCTow[1]->SetFillColor(kBlue);
328 hZNCTow[1]->Draw("");
329 c3->cd(3);
13727fd4 330 gPad->SetLogy(1);
9577d217 331 hZNCTow[2]->SetLineColor(kBlue);
332 hZNCTow[2]->SetFillColor(kBlue);
333 hZNCTow[2]->Draw("");
334 c3->cd(4);
13727fd4 335 gPad->SetLogy(1);
9577d217 336 hZNCTow[3]->SetLineColor(kBlue);
337 hZNCTow[3]->SetFillColor(kBlue);
338 hZNCTow[3]->Draw("");
339 c3->cd(5);
13727fd4 340 gPad->SetLogy(1);
9577d217 341 hZNCTow[4]->SetLineColor(kBlue);
342 hZNCTow[4]->SetFillColor(kBlue);
343 hZNCTow[4]->Draw("");
344 //
345 c3->cd(6);
13727fd4 346 gPad->SetLogy(1);
9577d217 347 hZPCTow[0]->SetLineColor(kBlue+3);
348 hZPCTow[0]->SetFillColor(kBlue+3);
349 hZPCTow[0]->Draw("");
350 c3->cd(7);
13727fd4 351 gPad->SetLogy(1);
9577d217 352 hZPCTow[1]->SetLineColor(kBlue+3);
353 hZPCTow[1]->SetFillColor(kBlue+3);
354 hZPCTow[1]->Draw("");
355 c3->cd(8);
13727fd4 356 gPad->SetLogy(1);
9577d217 357 hZPCTow[2]->SetLineColor(kBlue+3);
358 hZPCTow[2]->SetFillColor(kBlue+3);
359 hZPCTow[2]->Draw("");
360 c3->cd(9);
13727fd4 361 gPad->SetLogy(1);
9577d217 362 hZPCTow[3]->SetLineColor(kBlue+3);
363 hZPCTow[3]->SetFillColor(kBlue+3);
364 hZPCTow[3]->Draw("");
365 c3->cd(10);
13727fd4 366 gPad->SetLogy(1);
9577d217 367 hZPCTow[4]->SetLineColor(kBlue+3);
368 hZPCTow[4]->SetFillColor(kBlue+3);
369 hZPCTow[4]->Draw("");
370
371
372 //-------------------------------------------------
373 TCanvas *c32 = new TCanvas("c32","side A ZDCs",700,0,800,400);
374 c32->Divide(5,2);
375 c32->cd(1);
13727fd4 376 gPad->SetLogy(1);
9577d217 377 hZNATow[0]->SetLineColor(kRed);
378 hZNATow[0]->SetFillColor(kRed);
379 hZNATow[0]->Draw("");
380 c32->cd(2);
381 gPad->SetLogy(1);
382 hZNATow[1]->SetLineColor(kRed);
383 hZNATow[1]->SetFillColor(kRed);
384 hZNATow[1]->Draw("");
385 c32->cd(3);
13727fd4 386 gPad->SetLogy(1);
9577d217 387 hZNATow[2]->SetLineColor(kRed);
388 hZNATow[2]->SetFillColor(kRed);
389 hZNATow[2]->Draw("");
390 c32->cd(4);
13727fd4 391 gPad->SetLogy(1);
9577d217 392 hZNATow[3]->SetLineColor(kRed);
393 hZNATow[3]->SetFillColor(kRed);
394 hZNATow[3]->Draw("");
395 c32->cd(5);
13727fd4 396 gPad->SetLogy(1);
9577d217 397 hZNATow[4]->SetLineColor(kRed);
398 hZNATow[4]->SetFillColor(kRed);
399 hZNATow[4]->Draw("");
400 //
401 c32->cd(6);
13727fd4 402 gPad->SetLogy(1);
9577d217 403 hZPATow[0]->SetLineColor(kRed+1);
404 hZPATow[0]->SetFillColor(kRed+1);
405 hZPATow[0]->Draw("");
406 c32->cd(7);
13727fd4 407 gPad->SetLogy(1);
9577d217 408 hZPATow[1]->SetLineColor(kRed+1);
409 hZPATow[1]->SetFillColor(kRed+1);
410 hZPATow[1]->Draw("");
411 c32->cd(8);
13727fd4 412 gPad->SetLogy(1);
9577d217 413 hZPATow[2]->SetLineColor(kRed+1);
414 hZPATow[2]->SetFillColor(kRed+1);
415 hZPATow[2]->Draw("");
416 c32->cd(9);
13727fd4 417 gPad->SetLogy(1);
9577d217 418 hZPATow[3]->SetLineColor(kRed+1);
419 hZPATow[3]->SetFillColor(kRed+1);
420 hZPATow[3]->Draw("");
421 c32->cd(10);
13727fd4 422 gPad->SetLogy(1);
9577d217 423 hZPATow[4]->SetLineColor(kRed+1);
424 hZPATow[4]->SetFillColor(kRed+1);
425 hZPATow[4]->Draw("");
426 }
427
428 TFile * fileout = new TFile("ESDhistos.root","recreate");
429 fileout->cd();
430 //centroidZNsideC->Write();
431 //centroidZNsideA->Write();
432 enZNC->Write();
433 enZNA->Write();
434 enZPC->Write();
435 enZPA->Write();
436 enZEM1->Write();
437 enZEM2->Write();
438 for(Int_t jj=0; jj<5; jj++){
439 hZNCTow[jj]->Write();
440 hZPCTow[jj]->Write();
441 hZNATow[jj]->Write();
442 hZPATow[jj]->Write();
443 }
13727fd4 444 /*hSumQZNC->Write();
9577d217 445 hSumQZPC->Write();
446 hSumQZNA->Write();
13727fd4 447 hSumQZPA->Write();*/
9577d217 448 //
449 hESDword->Write();
450 //
451 fileout->Close();
452
453}