- replaced CreateStdContent() with GetStdContent()
[u/mrichter/AliRoot.git] / PWG1 / AliAnaVZEROQA.cxx
CommitLineData
ecb38463 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16//------------------------------
17// Analysis task for quality-assurance
18// of VZERO ESD
19//
20// 05/12/2009 cvetan.cheshkov@cern.ch
21//------------------------------
22
23#include "TChain.h"
24#include "TROOT.h"
25#include "TFile.h"
26#include "TH1F.h"
27#include "TH2F.h"
28#include "TF1.h"
29#include "TCanvas.h"
30#include "AliLog.h"
31#include "AliESDEvent.h"
32#include "AliESDVZERO.h"
33
34#include "AliAnaVZEROQA.h"
35
36ClassImp(AliAnaVZEROQA)
37
38AliAnaVZEROQA::AliAnaVZEROQA():
39AliAnalysisTaskSE("AliAnaVZEROQA"),
40 fListOfHistos(0),
41
42 fhAdcNoTimeA(0),
43 fhAdcWithTimeA(0),
44 fhAdcNoTimeC(0),
45 fhAdcWithTimeC(0),
46
47 fhAdcPMTNoTime(0),
48 fhAdcPMTWithTime(0),
49
50 fhTimeA(0),
51 fhTimeC(0),
52
53 fhWidthA(0),
54 fhWidthC(0),
55
56 fhTimePMT(0),
57 fhWidthPMT(0),
58
59 fhAdcWidthA(0),
60 fhAdcWidthC(0),
61
62 fhTimeCorr(0),
63
64 fhAdcTimeA(0),
65 fhAdcTimeC(0),
66
67 fV0a(0),
68 fV0c(0),
69 fV0multA(0),
70 fV0multC(0),
71 fV0ampl(0)
72{
73 // Default constructor
74 // Define input and output slots here
75 // Input slot #0 works with a TChain
76 DefineInput(0, TChain::Class());
77 // Output slot #1 TList
78 DefineOutput(1, TList::Class());
79}
80
81AliAnaVZEROQA::AliAnaVZEROQA(const char* name):
82AliAnalysisTaskSE(name),
83 fListOfHistos(0),
84 fhAdcNoTimeA(0),
85 fhAdcWithTimeA(0),
86 fhAdcNoTimeC(0),
87 fhAdcWithTimeC(0),
88
89 fhAdcPMTNoTime(0),
90 fhAdcPMTWithTime(0),
91
92 fhTimeA(0),
93 fhTimeC(0),
94
95 fhWidthA(0),
96 fhWidthC(0),
97
98 fhTimePMT(0),
99 fhWidthPMT(0),
100
101 fhAdcWidthA(0),
102 fhAdcWidthC(0),
103
104 fhTimeCorr(0),
105
106 fhAdcTimeA(0),
107 fhAdcTimeC(0),
108
109 fV0a(0),
110 fV0c(0),
111 fV0multA(0),
112 fV0multC(0),
113 fV0ampl(0)
114{
115 // Constructor
116 AliInfo("Constructor AliAnaVZEROQA");
117 // Define input and output slots here
118 // Input slot #0 works with a TChain
119 DefineInput(0, TChain::Class());
120 // Output slot #1 TList
121 DefineOutput(1, TList::Class());
122}
123
124TH1F * AliAnaVZEROQA::CreateHisto1D(const char* name, const char* title,Int_t nBins,
125 Double_t xMin, Double_t xMax,
126 const char* xLabel, const char* yLabel)
127{
128 // create a histogram
129 TH1F* result = new TH1F(name, title, nBins, xMin, xMax);
130 result->SetOption("E");
131 if (xLabel) result->GetXaxis()->SetTitle(xLabel);
132 if (yLabel) result->GetYaxis()->SetTitle(yLabel);
133 result->SetMarkerStyle(kFullCircle);
134 return result;
135}
136
137TH2F * AliAnaVZEROQA::CreateHisto2D(const char* name, const char* title,Int_t nBinsX,
138 Double_t xMin, Double_t xMax,
139 Int_t nBinsY,
140 Double_t yMin, Double_t yMax,
141 const char* xLabel, const char* yLabel)
142{
143 // create a histogram
144 TH2F* result = new TH2F(name, title, nBinsX, xMin, xMax, nBinsY, yMin, yMax);
145 if (xLabel) result->GetXaxis()->SetTitle(xLabel);
146 if (yLabel) result->GetYaxis()->SetTitle(yLabel);
147 return result;
148}
149
150void AliAnaVZEROQA::UserCreateOutputObjects()
151{
152 // Create histograms
153 AliInfo("AliAnaVZEROQA::UserCreateOutputObjects");
154 // Create output container
155 fListOfHistos = new TList();
156
157 fhAdcNoTimeA = CreateHisto1D("hAdcNoTimeA","ADC (no Leading Time) V0A",200,0,200,"ADC charge","Entries");
158 fhAdcWithTimeA = CreateHisto1D("hAdcWithTimeA","ADC ( with Leading Time) V0A",200,0,200,"ADC charge","Entries");
159 fhAdcNoTimeC = CreateHisto1D("hAdcNoTimeC","ADC (no Leading Time) V0C",200,0,200,"ADC charge","Entries");
160 fhAdcWithTimeC = CreateHisto1D("hAdcWithTimeC","ADC ( with Leading Time) V0C",200,0,200,"ADC charge","Entries");
161
162 fhAdcPMTNoTime = CreateHisto2D("hadcpmtnotime","ADC vs PMT index (no leading time)",64,-0.5,63.5,200,0,200,"PMT index","ADC charge");
163 fhAdcPMTWithTime = CreateHisto2D("hadcpmtwithtime","ADC vs PMT index (with leading time)",64,-0.5,63.5,200,0,200,"PMT index","ADC charge");
164
165 fhTimeA = CreateHisto1D("htimepmtA","Time measured by TDC V0A",400,-100,100,"Leading time (ns)","Entries");
166 fhTimeC = CreateHisto1D("htimepmtC","Time measured by TDC V0C",400,-100,100,"Leading time (ns)","Entries");
167
168 fhWidthA = CreateHisto1D("hwidthA","Signal width measured by TDC V0A",200,0,100,"Signal width (ns)","Entries");
169 fhWidthC = CreateHisto1D("hwidthC","Signal width measured by TDC V0C",200,0,100,"Signal width (ns)","Entries");
170
171 fhTimePMT = CreateHisto2D("htimepmt","Time measured by TDC vs PMT index",64,-0.5,63.5,200,0,100,"PMT Index","Leading time (ns)");
172 fhWidthPMT = CreateHisto2D("hwidthpmt","Time width vs PMT index",64,-0.5,63.5,200,0,100,"PMT Index","Signal width (ns)");
173
174 fhAdcWidthA = CreateHisto2D("hadcwidthA","Time width vs ADC V0A",200,0,200,200,0,100,"ADC charge","Width (ns)");
175 fhAdcWidthC = CreateHisto2D("hadcwidthC","Time width vs ADC V0C",200,0,200,200,0,100,"ADC charge","Width (ns)");
176
177 fhTimeCorr = CreateHisto2D("htimecorr","Average time C side vs. A side",200,0,100,200,0,100,"Time V0A (ns)","Time V0C (ns");
178
179 fhAdcTimeA = CreateHisto2D("hAdcTimeA","ADC vs Time V0A",1000,-100,100,200,0,200,"Time (ns)","ADC charge");
180 fhAdcTimeC = CreateHisto2D("hAdcTimeC","ADC vs Time V0C",1000,-100,100,200,0,200,"Time (ns)","ADC charge");
181
182 fV0a = CreateHisto1D("hV0a","Number of fired PMTs (V0A)",65,-0.5,64.5);
183 fV0c = CreateHisto1D("hV0c","Number of fired PMTs (V0C)",65,-0.5,64.5);
184 fV0multA = CreateHisto1D("hV0multA","Total reconstructed multiplicity (V0A)",100,0.,1000.);
185 fV0multC = CreateHisto1D("hV0multC","Total reconstructed multiplicity (V0C)",100,0.,1000.);
186 fV0ampl = CreateHisto1D("hV0ampl","V0 multiplicity in single channel (all V0 channels)",400,-0.5,99.5);
187
188 fListOfHistos->Add(fhAdcNoTimeA);
189 fListOfHistos->Add(fhAdcWithTimeA);
190 fListOfHistos->Add(fhAdcNoTimeC);
191 fListOfHistos->Add(fhAdcWithTimeC);
192
193 fListOfHistos->Add(fhAdcPMTNoTime);
194 fListOfHistos->Add(fhAdcPMTWithTime);
195
196 fListOfHistos->Add(fhTimeA);
197 fListOfHistos->Add(fhTimeC);
198
199 fListOfHistos->Add(fhWidthA);
200 fListOfHistos->Add(fhWidthC);
201
202 fListOfHistos->Add(fhTimePMT);
203 fListOfHistos->Add(fhWidthPMT);
204
205 fListOfHistos->Add(fhAdcWidthA);
206 fListOfHistos->Add(fhAdcWidthC);
207
208 fListOfHistos->Add(fhTimeCorr);
209
210 fListOfHistos->Add(fhAdcTimeA);
211 fListOfHistos->Add(fhAdcTimeC);
212
213 fListOfHistos->Add(fV0a);
214 fListOfHistos->Add(fV0c);
215 fListOfHistos->Add(fV0multA);
216 fListOfHistos->Add(fV0multC);
217 fListOfHistos->Add(fV0ampl);
218}
219
220void AliAnaVZEROQA::UserExec(Option_t */*option*/)
221{
222 AliVEvent* event = InputEvent();
223 if (!event) {
224 Printf("ERROR: Could not retrieve event");
225 return;
226 }
227
228 AliESDEvent* esd = dynamic_cast<AliESDEvent*>(event);
229 AliESDVZERO* esdV0 = esd->GetVZEROData();
230
231 Float_t timeA = 0,timeC = 0;
232 Int_t ntimeA = 0, ntimeC = 0;
233 for (Int_t i=0; i<64; ++i) {
234 if (esdV0->GetTime(i) < 1e-6) {
235 if (i >= 32) {
236 fhAdcNoTimeA->Fill(esdV0->GetAdc(i));
237 }
238 else {
239 fhAdcNoTimeC->Fill(esdV0->GetAdc(i));
240 }
241 fhAdcPMTNoTime->Fill(i,esdV0->GetAdc(i));
242 }
243 else {
244 if (i >= 32) {
245 fhAdcWithTimeA->Fill(esdV0->GetAdc(i));
246 }
247 else {
248 fhAdcWithTimeC->Fill(esdV0->GetAdc(i));
249 }
250 fhAdcPMTWithTime->Fill(i,esdV0->GetAdc(i));
251 }
252
253 if (i >= 32) {
254 fhTimeA->Fill(esdV0->GetTime(i));
255 fhWidthA->Fill(esdV0->GetWidth(i));
256 fhAdcWidthA->Fill(esdV0->GetAdc(i),esdV0->GetTime(i));
257 fhAdcTimeA->Fill(esdV0->GetTime(i),esdV0->GetAdc(i));
258 }
259 else {
260 fhTimeC->Fill(esdV0->GetTime(i));
261 fhWidthC->Fill(esdV0->GetWidth(i));
262 fhAdcWidthC->Fill(esdV0->GetAdc(i),esdV0->GetTime(i));
263 fhAdcTimeC->Fill(esdV0->GetTime(i),esdV0->GetAdc(i));
264 }
265 fhTimePMT->Fill(i,esdV0->GetTime(i));
266 fhWidthPMT->Fill(i,esdV0->GetWidth(i));
267
268 if (esdV0->GetTime(i) > 1e-6) {
269 if (i >= 32) {
270 timeA += esdV0->GetTime(i);
271 ntimeA++;
272 }
273 else {
274 timeC += esdV0->GetTime(i);
275 ntimeC++;
276 }
277 }
278 }
279
280 if (ntimeA > 0) timeA = timeA/ntimeA;
281 if (ntimeC > 0) timeC = timeC/ntimeC;
282
283 fhTimeCorr->Fill(timeA,timeC);
284
285 fV0a->Fill(esdV0->GetNbPMV0A());
286 fV0c->Fill(esdV0->GetNbPMV0C());
287 fV0multA->Fill(esdV0->GetMTotV0A());
288 fV0multC->Fill(esdV0->GetMTotV0C());
289 for(Int_t i = 0; i < 64; i++) {
290 fV0ampl->Fill(esdV0->GetMultiplicity(i));
291 }
292
293 // Post output data.
294 PostData(1, fListOfHistos);
295}
296
297void AliAnaVZEROQA::Terminate(Option_t *)
298{
299 fListOfHistos = dynamic_cast<TList*>(GetOutputData(1));
300 if (!fListOfHistos) {
301 Printf("ERROR: fListOfHistos not available");
302 return;
303 }
304
305 fhAdcNoTimeA = dynamic_cast<TH1F*>(fListOfHistos->At(0));
306 fhAdcWithTimeA = dynamic_cast<TH1F*>(fListOfHistos->At(1));
307 fhAdcNoTimeC = dynamic_cast<TH1F*>(fListOfHistos->At(2));
308 fhAdcWithTimeC = dynamic_cast<TH1F*>(fListOfHistos->At(3));
309
310 fhAdcPMTNoTime = dynamic_cast<TH2F*>(fListOfHistos->At(4));
311 fhAdcPMTWithTime = dynamic_cast<TH2F*>(fListOfHistos->At(5));
312
313 fhTimeA = dynamic_cast<TH1F*>(fListOfHistos->At(6));
314 fhTimeC = dynamic_cast<TH1F*>(fListOfHistos->At(7));
315
316 fhWidthA = dynamic_cast<TH1F*>(fListOfHistos->At(8));
317 fhWidthC = dynamic_cast<TH1F*>(fListOfHistos->At(9));
318
319 fhTimePMT = dynamic_cast<TH2F*>(fListOfHistos->At(10));
320 fhWidthPMT = dynamic_cast<TH2F*>(fListOfHistos->At(11));
321
322 fhAdcWidthA = dynamic_cast<TH2F*>(fListOfHistos->At(12));
323 fhAdcWidthC = dynamic_cast<TH2F*>(fListOfHistos->At(13));
324
325 fhTimeCorr = dynamic_cast<TH2F*>(fListOfHistos->At(14));
326
327 fhAdcTimeA = dynamic_cast<TH2F*>(fListOfHistos->At(15));
328 fhAdcTimeC = dynamic_cast<TH2F*>(fListOfHistos->At(16));
329
330 fV0a = dynamic_cast<TH1F*>(fListOfHistos->At(17));
331 fV0c = dynamic_cast<TH1F*>(fListOfHistos->At(18));
332 fV0multA = dynamic_cast<TH1F*>(fListOfHistos->At(19));
333 fV0multC = dynamic_cast<TH1F*>(fListOfHistos->At(20));
334 fV0ampl = dynamic_cast<TH1F*>(fListOfHistos->At(21));
335
336 // draw the histograms if not in batch mode
337 if (!gROOT->IsBatch()) {
338 new TCanvas;
339 fhTimePMT->DrawCopy();
340 new TCanvas;
341 fhAdcTimeA->DrawCopy();
342 new TCanvas;
343 fhAdcTimeC->DrawCopy();
344 new TCanvas;
345 fhAdcPMTNoTime->DrawCopy();
346 new TCanvas;
347 fhAdcPMTWithTime->DrawCopy();
348 new TCanvas;
349 fhTimeCorr->DrawCopy("E");
350 new TCanvas;
351 fV0ampl->DrawCopy("E");
352 }
353
354 // write the output histograms to a file
355 TFile* outputFile = TFile::Open("VZEROQA.root", "recreate");
356 if (!outputFile || !outputFile->IsOpen())
357 {
358 Error("AliAnaVZEROQA", "opening output file VZEROQA.root failed");
359 return;
360 }
361
362 fhAdcNoTimeA->Write();
363 fhAdcWithTimeA->Write();
364 fhAdcNoTimeC->Write();
365 fhAdcWithTimeC->Write();
366
367 fhAdcPMTNoTime->Write();
368 fhAdcPMTWithTime->Write();
369
370 fhTimeA->Write();
371 fhTimeC->Write();
372
373 fhWidthA->Write();
374 fhWidthC->Write();
375
376 fhTimePMT->Write();
377 fhWidthPMT->Write();
378
379 fhAdcWidthA->Write();
380 fhAdcWidthC->Write();
381
382 fhTimeCorr->Write();
383
384 fhAdcTimeA->Write();
385 fhAdcTimeC->Write();
386
387 fV0a->Write();
388 fV0c->Write();
389 fV0multA->Write();
390 fV0multC->Write();
391 fV0ampl->Write();
392
393 outputFile->Close();
394 delete outputFile;
395
396 //delete esd;
397 Info("AliAnaVZEROQA", "Successfully finished");
398}
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460