Adapt to the New steering class ro run QA stand alone
[u/mrichter/AliRoot.git] / PHOS / AliPHOSQADataMaker.cxx
CommitLineData
ddd1a39c 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/* $Id$ */
18
19/*
20 Produces the data needed to calculate the quality assurance.
21 All data must be mergeable objects.
22 Y. Schutz CERN July 2007
23*/
24
25// --- ROOT system ---
26#include <TClonesArray.h>
27#include <TFile.h>
28#include <TH1F.h>
29#include <TH1I.h>
d5cf81bd 30#include <TH2F.h>
ddd1a39c 31
32// --- Standard library ---
33
34// --- AliRoot header files ---
35#include "AliESDCaloCluster.h"
36#include "AliESDEvent.h"
37#include "AliLog.h"
38#include "AliPHOSDigit.h"
39#include "AliPHOSHit.h"
b8274834 40#include "AliPHOSQADataMaker.h"
41#include "AliQAChecker.h"
ddd1a39c 42#include "AliPHOSCpvRecPoint.h"
43#include "AliPHOSEmcRecPoint.h"
44#include "AliPHOSRecParticle.h"
45#include "AliPHOSTrackSegment.h"
d5cf81bd 46#include "AliPHOSRawDecoder.h"
ddd1a39c 47
b8274834 48ClassImp(AliPHOSQADataMaker)
ddd1a39c 49
50//____________________________________________________________________________
b8274834 51 AliPHOSQADataMaker::AliPHOSQADataMaker() :
52 AliQADataMaker(AliQA::GetDetName(AliQA::kPHOS), "PHOS Quality Assurance Data Maker")
ddd1a39c 53{
54 // ctor
ddd1a39c 55}
56
57//____________________________________________________________________________
b8274834 58AliPHOSQADataMaker::AliPHOSQADataMaker(const AliPHOSQADataMaker& qadm) :
59 AliQADataMaker()
ddd1a39c 60{
61 //copy ctor
62 SetName((const char*)qadm.GetName()) ;
63 SetTitle((const char*)qadm.GetTitle());
64}
65
66//__________________________________________________________________
b8274834 67AliPHOSQADataMaker& AliPHOSQADataMaker::operator = (const AliPHOSQADataMaker& qadm )
ddd1a39c 68{
69 // Equal operator.
b8274834 70 this->~AliPHOSQADataMaker();
71 new(this) AliPHOSQADataMaker(qadm);
ddd1a39c 72 return *this;
73}
74
5b188f2f 75//____________________________________________________________________________
b8274834 76void AliPHOSQADataMaker::EndOfDetectorCycle(AliQA::TASKINDEX task, TList * list)
5b188f2f 77{
78 //Detector specific actions at end of cycle
a4976ef3 79 // do the QA checking
b8274834 80 AliQAChecker::Instance()->Run(AliQA::kPHOS, task, list) ;
5b188f2f 81}
82
ddd1a39c 83//____________________________________________________________________________
b8274834 84void AliPHOSQADataMaker::InitESDs()
ddd1a39c 85{
86 //create ESDs histograms in ESDs subdir
117e9d0d 87 TH1F * h0 = new TH1F("hPhosESDs", "ESDs energy distribution in PHOS", 100, 0., 100.) ;
88 h0->Sumw2() ;
89 Add2ESDsList(h0, 0) ;
90 TH1I * h1 = new TH1I("hPhosESDsMul", "ESDs multiplicity distribution in PHOS", 100, 0., 100) ;
91 h1->Sumw2() ;
92 Add2ESDsList(h1, 1) ;
ddd1a39c 93}
94
95//____________________________________________________________________________
b8274834 96void AliPHOSQADataMaker::InitHits()
ddd1a39c 97{
98 // create Hits histograms in Hits subdir
117e9d0d 99 TH1F * h0 = new TH1F("hPhosHits", "Hits energy distribution in PHOS", 100, 0., 100.) ;
100 h0->Sumw2() ;
101 Add2HitsList(h0, 0) ;
102 TH1I * h1 = new TH1I("hPhosHitsMul", "Hits multiplicity distribution in PHOS", 500, 0., 10000) ;
103 h1->Sumw2() ;
104 Add2HitsList(h1, 1) ;
ddd1a39c 105}
106
107//____________________________________________________________________________
b8274834 108void AliPHOSQADataMaker::InitDigits()
ddd1a39c 109{
110 // create Digits histograms in Digits subdir
117e9d0d 111 TH1I * h0 = new TH1I("hPhosDigits", "Digits amplitude distribution in PHOS", 500, 0, 5000) ;
112 h0->Sumw2() ;
113 Add2DigitsList(h0, 0) ;
114 TH1I * h1 = new TH1I("hPhosDigitsMul", "Digits multiplicity distribution in PHOS", 500, 0, 1000) ;
115 h1->Sumw2() ;
116 Add2DigitsList(h1, 0) ;
ddd1a39c 117}
118
119//____________________________________________________________________________
b8274834 120//void AliPHOSQADataMaker::InitRecParticles()
117e9d0d 121//{
122// // create Reconstructed particles histograms in RecParticles subdir
123// fhRecParticles = new TH1F("hPhosRecParticles", "RecParticles energy distribution in PHOS", 100, 0., 100.) ;
124// fhRecParticles->Sumw2() ;
125// fhRecParticlesMul = new TH1I("hPhosRecParticlesMul", "RecParticles multiplicity distribution in PHOS", 100, 0, 100) ;
126// fhRecParticlesMul->Sumw2() ;
127//}
ddd1a39c 128
129//____________________________________________________________________________
b8274834 130void AliPHOSQADataMaker::InitRecPoints()
ddd1a39c 131{
132 // create Reconstructed Points histograms in RecPoints subdir
117e9d0d 133 TH1F * h0 = new TH1F("hEmcPhosRecPoints", "EMCA RecPoints energy distribution in PHOS", 100, 0., 100.) ;
134 h0->Sumw2() ;
135 Add2RecPointsList(h0, 0) ;
136 TH1I * h1 = new TH1I("hEmcPhosRecPointsMul", "EMCA RecPoints multiplicity distribution in PHOS", 100, 0, 100) ;
137 h1->Sumw2() ;
138 Add2RecPointsList(h1, 1) ;
ddd1a39c 139
117e9d0d 140 TH1F * h2 = new TH1F("hCpvPhosRecPoints", "CPV RecPoints energy distribution in PHOS", 100, 0., 100.) ;
141 h2->Sumw2() ;
142 Add2RecPointsList(h2, 2) ;
143 TH1I * h3 = new TH1I("hCpvPhosRecPointsMul", "CPV RecPoints multiplicity distribution in PHOS", 100, 0, 100) ;
144 h3->Sumw2() ;
145 Add2RecPointsList(h3, 3) ;
ddd1a39c 146}
147
148//____________________________________________________________________________
b8274834 149void AliPHOSQADataMaker::InitRaws()
ddd1a39c 150{
117e9d0d 151 // create Raws histograms in Raws subdir
d5cf81bd 152 const Int_t modMax = 5 ;
a4976ef3 153 TH2I * h0[modMax*2] ;
f5c02bae 154 char name[32] ;
155 char title[32] ;
42ce5548 156 for (Int_t mod = 0; mod < modMax; mod++) {
a4976ef3 157 sprintf(title, "Low Gain Rows x Columns for PHOS module %d", mod) ;
158 sprintf(name, "hLowPHOSxyMod%d", mod) ;
159 h0[mod] = new TH2I(name, title, 64, 1, 65, 56, 1, 57) ;
160 Add2RawsList(h0[mod], mod) ;
161 sprintf(title, "High Gain Rows x Columns for PHOS module %d", mod) ;
162 sprintf(name, "hHighPHOSxyMod%d", mod) ;
163 h0[mod+modMax] = new TH2I(name, title, 64, 1, 65, 56, 1, 57) ;
164 Add2RawsList(h0[mod+modMax], mod+modMax) ;
d5cf81bd 165 }
a4976ef3 166 TH1I * h10 = new TH1I("hLowPhosModules", "Low Gain Hits in EMCA PHOS modules", 6, 0, 6) ;
167 h10->Sumw2() ;
168 Add2RawsList(h10, 10) ;
169 TH1I * h11 = new TH1I("hHighPhosModules", "High Gain Hits in EMCA PHOS modules", 6, 0, 6) ;
170 h11->Sumw2() ;
171 Add2RawsList(h11, 11) ;
172 TH1F * h12 = new TH1F("hLowPhosRawtime", "Low Gain Time of raw hits in PHOS", 100, 0, 100.) ;
173 h12->Sumw2() ;
174 Add2RawsList(h12, 12) ;
175 TH1F * h13 = new TH1F("hHighPhosRawtime", "High Gain Time of raw hits in PHOS", 100, 0, 100.) ;
176 h13->Sumw2() ;
177 Add2RawsList(h13, 13) ;
178 TH1F * h14 = new TH1F("hLowPhosRawEnergy", "Low Gain Energy of raw hits in PHOS", 100, 0., 100.) ;
179 h14->Sumw2() ;
180 Add2RawsList(h14, 14) ;
181 TH1F * h15 = new TH1F("hHighPhosRawEnergy", "High Gain Energy of raw hits in PHOS", 100, 0., 100.) ;
182 h15->Sumw2() ;
183 Add2RawsList(h15, 15) ;
d5cf81bd 184
ddd1a39c 185}
186
187//____________________________________________________________________________
b8274834 188void AliPHOSQADataMaker::InitSDigits()
ddd1a39c 189{
117e9d0d 190 // create SDigits histograms in SDigits subdir
191 TH1F * h0 = new TH1F("hPhosSDigits", "SDigits energy distribution in PHOS", 100, 0., 100.) ;
192 h0->Sumw2() ;
193 Add2SDigitsList(h0, 0) ;
194 TH1I * h1 = new TH1I("hPhosSDigitsMul", "SDigits multiplicity distribution in PHOS", 500, 0, 10000) ;
195 h1->Sumw2() ;
196 Add2SDigitsList(h1, 1) ;
ddd1a39c 197}
198
117e9d0d 199//____________________________________________________________________________
b8274834 200//void AliPHOSQADataMaker::InitTrackSegments()
117e9d0d 201//{
202// // create Track Segments histograms in TrackSegments subdir
203// fhTrackSegments = new TH1F("hPhosTrackSegments", "TrackSegments EMC-CPV distance in PHOS", 500, 0., 5000.) ;
204// fhTrackSegments->Sumw2() ;
205// fhTrackSegmentsMul = new TH1I("hPhosTrackSegmentsMul", "TrackSegments multiplicity distribution in PHOS", 100, 0, 100) ;
206// fhTrackSegmentsMul->Sumw2() ;
207//}
208
ddd1a39c 209//____________________________________________________________________________
b8274834 210void AliPHOSQADataMaker::MakeESDs(AliESDEvent * esd)
ddd1a39c 211{
212 // make QA data from ESDs
213
ddd1a39c 214 Int_t maxClu = esd->GetNumberOfPHOSClusters() ;
215 Int_t index = 0, count = 0 ;
216 for ( index = 0 ; index < maxClu; index++ ) {
217 AliESDCaloCluster * clu = esd->GetCaloCluster(index) ;
117e9d0d 218 GetESDsData(0)->Fill(clu->E()) ;
ddd1a39c 219 count++ ;
220 }
117e9d0d 221 GetESDsData(1)->Fill(count) ;
ddd1a39c 222}
223
224//____________________________________________________________________________
b8274834 225void AliPHOSQADataMaker::MakeHits(TClonesArray * hits)
ddd1a39c 226{
cffe9bac 227 //make QA data from Hits
ddd1a39c 228
117e9d0d 229 GetHitsData(1)->Fill(hits->GetEntriesFast()) ;
d76c31f4 230 TIter next(hits) ;
231 AliPHOSHit * hit ;
232 while ( (hit = dynamic_cast<AliPHOSHit *>(next())) ) {
117e9d0d 233 GetHitsData(0)->Fill( hit->GetEnergy()) ;
d76c31f4 234 }
d76c31f4 235}
cffe9bac 236
237//____________________________________________________________________________
238void AliPHOSQADataMaker::MakeHits(TTree * hitTree)
239{
240 // make QA data from Hit Tree
241
242 TClonesArray * hits = new TClonesArray("AliPHOSHit", 1000);
243
244 TBranch * branch = hitTree->GetBranch("PHOS") ;
245 if ( ! branch ) {
246 AliWarning("PHOS branch in Hit Tree not found") ;
247 } else {
248 TClonesArray * tmp = new TClonesArray("AliPHOSHit", 1000) ;
249 branch->SetAddress(&tmp) ;
250 Int_t index = 0 ;
251 for (Int_t ientry = 0 ; ientry < branch->GetEntries() ; ientry++) {
252 branch->GetEntry(ientry) ;
253 for (Int_t ihit = 0 ; ihit < tmp->GetEntries() ; ihit++) {
254 AliPHOSHit * hit = dynamic_cast<AliPHOSHit *> (tmp->At(ihit)) ;
255 new((*hits)[index]) AliPHOSHit(*hit) ;
256 index++ ;
257 }
258 }
259 tmp->Delete() ;
260 delete tmp ;
261 MakeHits(hits) ;
262 }
263}
264
ddd1a39c 265//____________________________________________________________________________
b8274834 266void AliPHOSQADataMaker::MakeDigits(TClonesArray * digits)
ddd1a39c 267{
268 // makes data from Digits
269
117e9d0d 270 GetDigitsData(1)->Fill(digits->GetEntriesFast()) ;
d76c31f4 271 TIter next(digits) ;
272 AliPHOSDigit * digit ;
273 while ( (digit = dynamic_cast<AliPHOSDigit *>(next())) ) {
117e9d0d 274 GetDigitsData(0)->Fill( digit->GetEnergy()) ;
d76c31f4 275 }
ddd1a39c 276}
277
cffe9bac 278//____________________________________________________________________________
279void AliPHOSQADataMaker::MakeDigits(TTree * digitTree)
280{
281 // makes data from Digit Tree
282 TClonesArray * digits = new TClonesArray("AliPHOSDigit", 1000) ;
283
284 TBranch * branch = digitTree->GetBranch("PHOS") ;
285 if ( ! branch ) {
286 AliWarning("PHOS branch in Digit Tree not found") ;
287 } else {
288 branch->SetAddress(&digits) ;
289 branch->GetEntry(0) ;
290 MakeDigits(digits) ;
291 }
292}
293
ddd1a39c 294//____________________________________________________________________________
b8274834 295// void AliPHOSQADataMaker::MakeRecParticles(TTree * recpar)
d76c31f4 296// {
297// // makes data from RecParticles
ddd1a39c 298
d76c31f4 299// TClonesArray * recparticles = dynamic_cast<TClonesArray*>(fData) ;
300// fhRecParticlesMul->Fill(recparticles->GetEntriesFast()) ;
301// TIter next(recparticles) ;
302// AliPHOSRecParticle * recparticle ;
303// while ( (recparticle = dynamic_cast<AliPHOSRecParticle *>(next())) ) {
304// fhRecParticles->Fill( recparticle->Energy()) ;
305// }
306// }
ddd1a39c 307
117e9d0d 308//____________________________________________________________________________
b8274834 309void AliPHOSQADataMaker::MakeRaws(AliRawReader* rawReader)
117e9d0d 310{
a4976ef3 311 const Int_t modMax = 5 ;
d5cf81bd 312 rawReader->Reset() ;
313 AliPHOSRawDecoder decoder(rawReader);
42ce5548 314 decoder.SetOldRCUFormat(kTRUE);
a4976ef3 315 decoder.SubtractPedestals(kTRUE);
316
42ce5548 317 Int_t count = 0 ;
d5cf81bd 318 while (decoder.NextDigit()) {
319 Int_t module = decoder.GetModule() ;
320 Int_t row = decoder.GetRow() ;
321 Int_t col = decoder.GetColumn() ;
322 Double_t time = decoder.GetTime() ;
a4976ef3 323 Double_t energy = decoder.GetEnergy() ;
324 Bool_t lowGain = decoder.IsLowGain();
325 if (lowGain) {
326 GetRawsData(module)->Fill(row, col) ;
327 GetRawsData(10)->Fill(module) ;
328 GetRawsData(12)->Fill(time) ;
329 GetRawsData(14)->Fill(energy) ;
330 } else {
331 GetRawsData(module+modMax)->Fill(row, col) ;
332 GetRawsData(11)->Fill(module) ;
333 GetRawsData(13)->Fill(time) ;
334 GetRawsData(15)->Fill(energy) ;
335 }
f5c02bae 336 //AliInfo(Form(" %d %d %d %d %f %f\n", count, module, row, col, time, energy)) ;
42ce5548 337 count++ ;
d5cf81bd 338 }
117e9d0d 339}
340
ddd1a39c 341//____________________________________________________________________________
b8274834 342void AliPHOSQADataMaker::MakeRecPoints(TTree * clustersTree)
ddd1a39c 343{
d76c31f4 344 {
345 // makes data from RecPoints
346 TBranch *emcbranch = clustersTree->GetBranch("PHOSEmcRP");
347 if (!emcbranch) {
348 AliError("can't get the branch with the PHOS EMC clusters !");
349 return;
350 }
351 TObjArray * emcrecpoints = new TObjArray(100) ;
352 emcbranch->SetAddress(&emcrecpoints);
353 emcbranch->GetEntry(0);
354
117e9d0d 355 GetRecPointsData(1)->Fill(emcrecpoints->GetEntriesFast()) ;
d76c31f4 356 TIter next(emcrecpoints) ;
ddd1a39c 357 AliPHOSEmcRecPoint * rp ;
358 while ( (rp = dynamic_cast<AliPHOSEmcRecPoint *>(next())) ) {
117e9d0d 359 GetRecPointsData(0)->Fill( rp->GetEnergy()) ;
ddd1a39c 360 }
d76c31f4 361 emcrecpoints->Delete();
362 delete emcrecpoints;
363 }
364 {
365 TBranch *cpvbranch = clustersTree->GetBranch("PHOSCpvRP");
366 if (!cpvbranch) {
367 AliError("can't get the branch with the PHOS CPV clusters !");
368 return;
369 }
370 TObjArray *cpvrecpoints = new TObjArray(100) ;
371 cpvbranch->SetAddress(&cpvrecpoints);
372 cpvbranch->GetEntry(0);
373
117e9d0d 374 GetRecPointsData(1)->Fill(cpvrecpoints->GetEntriesFast()) ;
d76c31f4 375 TIter next(cpvrecpoints) ;
ddd1a39c 376 AliPHOSCpvRecPoint * rp ;
377 while ( (rp = dynamic_cast<AliPHOSCpvRecPoint *>(next())) ) {
117e9d0d 378 GetRecPointsData(0)->Fill( rp->GetEnergy()) ;
ddd1a39c 379 }
d76c31f4 380 cpvrecpoints->Delete();
381 delete cpvrecpoints;
382 }
ddd1a39c 383}
384
385//____________________________________________________________________________
b8274834 386void AliPHOSQADataMaker::MakeSDigits(TClonesArray * sdigits)
ddd1a39c 387{
388 // makes data from SDigits
d76c31f4 389
d5cf81bd 390 GetSDigitsData(1)->Fill(sdigits->GetEntriesFast()) ;
d76c31f4 391 TIter next(sdigits) ;
392 AliPHOSDigit * sdigit ;
393 while ( (sdigit = dynamic_cast<AliPHOSDigit *>(next())) ) {
117e9d0d 394 GetSDigitsData(0)->Fill( sdigit->GetEnergy()) ;
d76c31f4 395 }
ddd1a39c 396}
397
cffe9bac 398//____________________________________________________________________________
399void AliPHOSQADataMaker::MakeSDigits(TTree * sdigitTree)
400{
401 // makes data from SDigit Tree
402 TClonesArray * sdigits = new TClonesArray("AliPHOSDigit", 1000) ;
403
404 TBranch * branch = sdigitTree->GetBranch("PHOS") ;
405 if ( ! branch ) {
406 AliWarning("PHOS branch in SDigit Tree not found") ;
407 } else {
408 branch->SetAddress(&sdigits) ;
409 branch->GetEntry(0) ;
410 MakeSDigits(sdigits) ;
411 }
412}
413
ddd1a39c 414//____________________________________________________________________________
b8274834 415// void AliPHOSQADataMaker::MakeTrackSegments(TTree * ts)
d76c31f4 416// {
417// // makes data from TrackSegments
ddd1a39c 418
d76c31f4 419// TClonesArray * tracksegments = dynamic_cast<TClonesArray*>(fData) ;
ddd1a39c 420
d76c31f4 421// fhTrackSegmentsMul->Fill(tracksegments->GetEntriesFast()) ;
422// TIter next(tracksegments) ;
423// AliPHOSTrackSegment * ts ;
424// while ( (ts = dynamic_cast<AliPHOSTrackSegment *>(next())) ) {
425// fhTrackSegments->Fill( ts->GetCpvDistance()) ;
426// }
427// }
5b188f2f 428
429//____________________________________________________________________________
b8274834 430void AliPHOSQADataMaker::StartOfDetectorCycle()
5b188f2f 431{
432 //Detector specific actions at start of cycle
433
434}