]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PHOS/AliPHOSQADataMaker.cxx
Shuttle debugging line removed.
[u/mrichter/AliRoot.git] / PHOS / AliPHOSQADataMaker.cxx
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> 
30 #include <TH2F.h> 
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"
40 #include "AliPHOSQADataMaker.h"
41 #include "AliQAChecker.h"
42 #include "AliPHOSCpvRecPoint.h" 
43 #include "AliPHOSEmcRecPoint.h" 
44 #include "AliPHOSRecParticle.h" 
45 #include "AliPHOSTrackSegment.h" 
46 #include "AliPHOSRawDecoder.h"
47 #include "AliPHOSReconstructor.h"
48 #include "AliPHOSRecoParam.h"
49
50 ClassImp(AliPHOSQADataMaker)
51            
52 //____________________________________________________________________________ 
53   AliPHOSQADataMaker::AliPHOSQADataMaker() : 
54   AliQADataMaker(AliQA::GetDetName(AliQA::kPHOS), "PHOS Quality Assurance Data Maker")
55 {
56   // ctor
57 }
58
59 //____________________________________________________________________________ 
60 AliPHOSQADataMaker::AliPHOSQADataMaker(const AliPHOSQADataMaker& qadm) :
61   AliQADataMaker()
62 {
63   //copy ctor 
64   SetName((const char*)qadm.GetName()) ; 
65   SetTitle((const char*)qadm.GetTitle()); 
66 }
67
68 //__________________________________________________________________
69 AliPHOSQADataMaker& AliPHOSQADataMaker::operator = (const AliPHOSQADataMaker& qadm )
70 {
71   // Equal operator.
72   this->~AliPHOSQADataMaker();
73   new(this) AliPHOSQADataMaker(qadm);
74   return *this;
75 }
76  
77 //____________________________________________________________________________ 
78 void AliPHOSQADataMaker::EndOfDetectorCycle(AliQA::TASKINDEX task, TObjArray * list)
79 {
80   //Detector specific actions at end of cycle
81   // do the QA checking
82   AliQAChecker::Instance()->Run(AliQA::kPHOS, task, list) ;  
83 }
84
85 //____________________________________________________________________________ 
86 void AliPHOSQADataMaker::InitESDs()
87 {
88   //create ESDs histograms in ESDs subdir
89         
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) ;
96 }
97
98 //____________________________________________________________________________ 
99 void AliPHOSQADataMaker::InitHits()
100 {
101   // create Hits histograms in Hits subdir
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) ;
108 }
109
110 //____________________________________________________________________________ 
111 void AliPHOSQADataMaker::InitDigits()
112 {
113   // create Digits histograms in Digits subdir
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() ;
119   Add2DigitsList(h1, 1) ;
120 }
121
122 //____________________________________________________________________________ 
123 //void AliPHOSQADataMaker::InitRecParticles()
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 //}
131
132 //____________________________________________________________________________ 
133 void AliPHOSQADataMaker::InitRecPoints()
134 {
135   // create Reconstructed Points histograms in RecPoints subdir
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) ;
142
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) ;
149 }
150
151 //____________________________________________________________________________ 
152 void AliPHOSQADataMaker::InitRaws()
153 {
154   // create Raws histograms in Raws subdir
155   const Int_t modMax = 5 ; 
156   TH2I * h0[modMax*2] ; 
157   char name[32] ; 
158   char title[32] ; 
159   for (Int_t mod = 0; mod < modMax; mod++) {
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) ;
168   }
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) ;
187  
188 }
189
190 //____________________________________________________________________________ 
191 void AliPHOSQADataMaker::InitSDigits()
192 {
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) ;
200 }
201
202 //____________________________________________________________________________ 
203 //void AliPHOSQADataMaker::InitTrackSegments()
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
212 //____________________________________________________________________________
213 void AliPHOSQADataMaker::MakeESDs(AliESDEvent * esd)
214 {
215   // make QA data from ESDs
216
217   Int_t count = 0 ; 
218   for ( Int_t index = 0; index < esd->GetNumberOfCaloClusters() ; index++ ) {
219         AliESDCaloCluster * clu = esd->GetCaloCluster(index) ;
220         if ( clu->IsPHOS() ) {
221                 GetESDsData(0)->Fill(clu->E()) ;
222                 count++ ;
223         } 
224   }
225   GetESDsData(1)->Fill(count) ;
226 }
227
228 //____________________________________________________________________________
229 void AliPHOSQADataMaker::MakeHits(TClonesArray * hits)
230 {
231         //make QA data from Hits
232
233     GetHitsData(1)->Fill(hits->GetEntriesFast()) ; 
234     TIter next(hits) ; 
235     AliPHOSHit * hit ; 
236     while ( (hit = dynamic_cast<AliPHOSHit *>(next())) ) {
237       GetHitsData(0)->Fill( hit->GetEnergy()) ;
238     }
239 }
240
241 //____________________________________________________________________________
242 void 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
269 //____________________________________________________________________________
270 void AliPHOSQADataMaker::MakeDigits(TClonesArray * digits)
271 {
272   // makes data from Digits
273
274     GetDigitsData(1)->Fill(digits->GetEntriesFast()) ; 
275     TIter next(digits) ; 
276     AliPHOSDigit * digit ; 
277     while ( (digit = dynamic_cast<AliPHOSDigit *>(next())) ) {
278       GetDigitsData(0)->Fill( digit->GetEnergy()) ;
279     }  
280 }
281
282 //____________________________________________________________________________
283 void 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 //____________________________________________________________________________
299 // void AliPHOSQADataMaker::MakeRecParticles(TTree * recpar)
300 // {
301 //   // makes data from RecParticles
302
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 // }
311
312 //____________________________________________________________________________
313 void AliPHOSQADataMaker::MakeRaws(AliRawReader* rawReader)
314 {
315   const Int_t modMax = 5 ; 
316   rawReader->Reset() ; 
317   AliPHOSRawDecoder decoder(rawReader);
318   decoder.SetOldRCUFormat  (AliPHOSReconstructor::GetRecoParamEmc()->IsOldRCUFormat());
319   decoder.SubtractPedestals(AliPHOSReconstructor::GetRecoParamEmc()->SubtractPedestals());
320   Int_t count = 0 ; 
321   while (decoder.NextDigit()) {
322    Int_t module  = decoder.GetModule() ;
323    Int_t row     = decoder.GetRow() ;
324    Int_t col     = decoder.GetColumn() ;
325    Double_t time = decoder.GetTime() ;
326    Double_t energy  = decoder.GetEnergy() ;     
327    Bool_t lowGain = decoder.IsLowGain();
328    if (lowGain) {
329      GetRawsData(module)->Fill(row, col) ; 
330          GetRawsData(10)->Fill(module) ; 
331      GetRawsData(12)->Fill(time) ; 
332      GetRawsData(14)->Fill(energy) ; 
333    } else {
334          GetRawsData(module+modMax)->Fill(row, col) ; 
335          GetRawsData(11)->Fill(module) ; 
336      GetRawsData(13)->Fill(time) ; 
337      GetRawsData(15)->Fill(energy) ; 
338    }
339    //AliInfo(Form(" %d %d %d %d %f %f\n", count, module, row, col, time, energy)) ;
340    count++ ; 
341   } 
342 }
343
344 //____________________________________________________________________________
345 void AliPHOSQADataMaker::MakeRecPoints(TTree * clustersTree)
346 {
347   {
348     // makes data from RecPoints
349     TBranch *emcbranch = clustersTree->GetBranch("PHOSEmcRP");
350     if (!emcbranch) { 
351       AliError("can't get the branch with the PHOS EMC clusters !");
352       return;
353     }
354     TObjArray * emcrecpoints = new TObjArray(100) ;
355     emcbranch->SetAddress(&emcrecpoints);
356     emcbranch->GetEntry(0);
357     
358     GetRecPointsData(1)->Fill(emcrecpoints->GetEntriesFast()) ; 
359     TIter next(emcrecpoints) ; 
360     AliPHOSEmcRecPoint * rp ; 
361     while ( (rp = dynamic_cast<AliPHOSEmcRecPoint *>(next())) ) {
362       GetRecPointsData(0)->Fill( rp->GetEnergy()) ;
363     }
364     emcrecpoints->Delete();
365     delete emcrecpoints;
366   }
367   {
368     TBranch *cpvbranch = clustersTree->GetBranch("PHOSCpvRP");
369     if (!cpvbranch) { 
370       AliError("can't get the branch with the PHOS CPV clusters !");
371       return;
372     }
373     TObjArray *cpvrecpoints = new TObjArray(100) ;
374     cpvbranch->SetAddress(&cpvrecpoints);
375     cpvbranch->GetEntry(0);
376     
377     GetRecPointsData(1)->Fill(cpvrecpoints->GetEntriesFast()) ; 
378     TIter next(cpvrecpoints) ; 
379     AliPHOSCpvRecPoint * rp ; 
380     while ( (rp = dynamic_cast<AliPHOSCpvRecPoint *>(next())) ) {
381       GetRecPointsData(0)->Fill( rp->GetEnergy()) ;
382     }
383     cpvrecpoints->Delete();
384     delete cpvrecpoints;
385   }
386 }
387
388 //____________________________________________________________________________
389 void AliPHOSQADataMaker::MakeSDigits(TClonesArray * sdigits)
390 {
391   // makes data from SDigits
392   
393         GetSDigitsData(1)->Fill(sdigits->GetEntriesFast()) ; 
394     TIter next(sdigits) ; 
395     AliPHOSDigit * sdigit ; 
396     while ( (sdigit = dynamic_cast<AliPHOSDigit *>(next())) ) {
397       GetSDigitsData(0)->Fill( sdigit->GetEnergy()) ;
398     } 
399 }
400
401 //____________________________________________________________________________
402 void AliPHOSQADataMaker::MakeSDigits(TTree * sdigitTree)
403 {
404         // makes data from SDigit Tree
405         TClonesArray * sdigits = new TClonesArray("AliPHOSDigit", 1000) ; 
406
407         TBranch * branch = sdigitTree->GetBranch("PHOS") ;
408         if ( ! branch ) {
409                 AliWarning("PHOS branch in SDigit Tree not found") ; 
410         } else {
411                 branch->SetAddress(&sdigits) ;
412                 branch->GetEntry(0) ;
413                 MakeSDigits(sdigits) ; 
414         }
415 }
416
417 //____________________________________________________________________________
418 // void AliPHOSQADataMaker::MakeTrackSegments(TTree * ts)
419 // {
420 //   // makes data from TrackSegments
421
422 //   TClonesArray * tracksegments = dynamic_cast<TClonesArray*>(fData) ;
423
424 //   fhTrackSegmentsMul->Fill(tracksegments->GetEntriesFast()) ; 
425 //   TIter next(tracksegments) ; 
426 //   AliPHOSTrackSegment * ts ; 
427 //   while ( (ts = dynamic_cast<AliPHOSTrackSegment *>(next())) ) {
428 //     fhTrackSegments->Fill( ts->GetCpvDistance()) ;
429 //   } 
430 // }
431
432 //____________________________________________________________________________ 
433 void AliPHOSQADataMaker::StartOfDetectorCycle()
434 {
435   //Detector specific actions at start of cycle
436   
437 }