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