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