]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PHOS/AliPHOSQADataMaker.cxx
Changing name QualAss to QA
[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
48 ClassImp(AliPHOSQADataMaker)
49            
50 //____________________________________________________________________________ 
51   AliPHOSQADataMaker::AliPHOSQADataMaker() : 
52   AliQADataMaker(AliQA::GetDetName(AliQA::kPHOS), "PHOS Quality Assurance Data Maker")
53 {
54   // ctor
55 }
56
57 //____________________________________________________________________________ 
58 AliPHOSQADataMaker::AliPHOSQADataMaker(const AliPHOSQADataMaker& qadm) :
59   AliQADataMaker()
60 {
61   //copy ctor 
62   SetName((const char*)qadm.GetName()) ; 
63   SetTitle((const char*)qadm.GetTitle()); 
64 }
65
66 //__________________________________________________________________
67 AliPHOSQADataMaker& AliPHOSQADataMaker::operator = (const AliPHOSQADataMaker& qadm )
68 {
69   // Equal operator.
70   this->~AliPHOSQADataMaker();
71   new(this) AliPHOSQADataMaker(qadm);
72   return *this;
73 }
74  
75 //____________________________________________________________________________ 
76 void AliPHOSQADataMaker::EndOfDetectorCycle(AliQA::TASKINDEX task, TList * list)
77 {
78   //Detector specific actions at end of cycle
79   // do the QA checking
80   AliQAChecker::Instance()->Run(AliQA::kPHOS, task, list) ;  
81 }
82
83 //____________________________________________________________________________ 
84 void AliPHOSQADataMaker::InitESDs()
85 {
86   //create ESDs histograms in ESDs subdir
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) ;
93 }
94
95 //____________________________________________________________________________ 
96 void AliPHOSQADataMaker::InitHits()
97 {
98   // create Hits histograms in Hits subdir
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) ;
105 }
106
107 //____________________________________________________________________________ 
108 void AliPHOSQADataMaker::InitDigits()
109 {
110   // create Digits histograms in Digits subdir
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) ;
117 }
118
119 //____________________________________________________________________________ 
120 //void AliPHOSQADataMaker::InitRecParticles()
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 //}
128
129 //____________________________________________________________________________ 
130 void AliPHOSQADataMaker::InitRecPoints()
131 {
132   // create Reconstructed Points histograms in RecPoints subdir
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) ;
139
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) ;
146 }
147
148 //____________________________________________________________________________ 
149 void AliPHOSQADataMaker::InitRaws()
150 {
151   // create Raws histograms in Raws subdir
152   const Int_t modMax = 5 ; 
153   TH2I * h0[modMax*2] ; 
154   char name[32] ; 
155   char title[32] ; 
156   for (Int_t mod = 0; mod < modMax; mod++) {
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) ;
165   }
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) ;
184  
185 }
186
187 //____________________________________________________________________________ 
188 void AliPHOSQADataMaker::InitSDigits()
189 {
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) ;
197 }
198
199 //____________________________________________________________________________ 
200 //void AliPHOSQADataMaker::InitTrackSegments()
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
209 //____________________________________________________________________________
210 void AliPHOSQADataMaker::MakeESDs(AliESDEvent * esd)
211 {
212   // make QA data from ESDs
213   
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) ;
218     GetESDsData(0)->Fill(clu->E()) ;
219     count++ ; 
220   }
221   GetESDsData(1)->Fill(count) ;
222 }
223
224 //____________________________________________________________________________
225 void AliPHOSQADataMaker::MakeHits(TClonesArray * hits)
226 {
227   //make QA data from Hits
228
229     GetHitsData(1)->Fill(hits->GetEntriesFast()) ; 
230     TIter next(hits) ; 
231     AliPHOSHit * hit ; 
232     while ( (hit = dynamic_cast<AliPHOSHit *>(next())) ) {
233       GetHitsData(0)->Fill( hit->GetEnergy()) ;
234     }
235 }
236 //____________________________________________________________________________
237 void AliPHOSQADataMaker::MakeDigits(TClonesArray * digits)
238 {
239   // makes data from Digits
240
241     GetDigitsData(1)->Fill(digits->GetEntriesFast()) ; 
242     TIter next(digits) ; 
243     AliPHOSDigit * digit ; 
244     while ( (digit = dynamic_cast<AliPHOSDigit *>(next())) ) {
245       GetDigitsData(0)->Fill( digit->GetEnergy()) ;
246     }  
247 }
248
249 //____________________________________________________________________________
250 // void AliPHOSQADataMaker::MakeRecParticles(TTree * recpar)
251 // {
252 //   // makes data from RecParticles
253
254 //   TClonesArray * recparticles = dynamic_cast<TClonesArray*>(fData) ; 
255 //   fhRecParticlesMul->Fill(recparticles->GetEntriesFast()) ; 
256 //   TIter next(recparticles) ; 
257 //   AliPHOSRecParticle * recparticle ; 
258 //   while ( (recparticle = dynamic_cast<AliPHOSRecParticle *>(next())) ) {
259 //     fhRecParticles->Fill( recparticle->Energy()) ;
260 //   }
261 // }
262
263 //____________________________________________________________________________
264 void AliPHOSQADataMaker::MakeRaws(AliRawReader* rawReader)
265 {
266   const Int_t modMax = 5 ; 
267   rawReader->Reset() ; 
268   AliPHOSRawDecoder decoder(rawReader);
269   decoder.SetOldRCUFormat(kTRUE);
270   decoder.SubtractPedestals(kTRUE);
271
272   Int_t count = 0 ; 
273   while (decoder.NextDigit()) {
274    Int_t module  = decoder.GetModule() ;
275    Int_t row     = decoder.GetRow() ;
276    Int_t col     = decoder.GetColumn() ;
277    Double_t time = decoder.GetTime() ;
278    Double_t energy  = decoder.GetEnergy() ;     
279    Bool_t lowGain = decoder.IsLowGain();
280    if (lowGain) {
281      GetRawsData(module)->Fill(row, col) ; 
282          GetRawsData(10)->Fill(module) ; 
283      GetRawsData(12)->Fill(time) ; 
284      GetRawsData(14)->Fill(energy) ; 
285    } else {
286          GetRawsData(module+modMax)->Fill(row, col) ; 
287          GetRawsData(11)->Fill(module) ; 
288      GetRawsData(13)->Fill(time) ; 
289      GetRawsData(15)->Fill(energy) ; 
290    }
291    //AliInfo(Form(" %d %d %d %d %f %f\n", count, module, row, col, time, energy)) ;
292    count++ ; 
293   } 
294 }
295
296 //____________________________________________________________________________
297 void AliPHOSQADataMaker::MakeRecPoints(TTree * clustersTree)
298 {
299   {
300     // makes data from RecPoints
301     TBranch *emcbranch = clustersTree->GetBranch("PHOSEmcRP");
302     if (!emcbranch) { 
303       AliError("can't get the branch with the PHOS EMC clusters !");
304       return;
305     }
306     TObjArray * emcrecpoints = new TObjArray(100) ;
307     emcbranch->SetAddress(&emcrecpoints);
308     emcbranch->GetEntry(0);
309     
310     GetRecPointsData(1)->Fill(emcrecpoints->GetEntriesFast()) ; 
311     TIter next(emcrecpoints) ; 
312     AliPHOSEmcRecPoint * rp ; 
313     while ( (rp = dynamic_cast<AliPHOSEmcRecPoint *>(next())) ) {
314       GetRecPointsData(0)->Fill( rp->GetEnergy()) ;
315     }
316     emcrecpoints->Delete();
317     delete emcrecpoints;
318   }
319   {
320     TBranch *cpvbranch = clustersTree->GetBranch("PHOSCpvRP");
321     if (!cpvbranch) { 
322       AliError("can't get the branch with the PHOS CPV clusters !");
323       return;
324     }
325     TObjArray *cpvrecpoints = new TObjArray(100) ;
326     cpvbranch->SetAddress(&cpvrecpoints);
327     cpvbranch->GetEntry(0);
328     
329     GetRecPointsData(1)->Fill(cpvrecpoints->GetEntriesFast()) ; 
330     TIter next(cpvrecpoints) ; 
331     AliPHOSCpvRecPoint * rp ; 
332     while ( (rp = dynamic_cast<AliPHOSCpvRecPoint *>(next())) ) {
333       GetRecPointsData(0)->Fill( rp->GetEnergy()) ;
334     }
335     cpvrecpoints->Delete();
336     delete cpvrecpoints;
337   }
338 }
339
340 //____________________________________________________________________________
341 void AliPHOSQADataMaker::MakeSDigits(TClonesArray * sdigits)
342 {
343   // makes data from SDigits
344   
345         GetSDigitsData(1)->Fill(sdigits->GetEntriesFast()) ; 
346     TIter next(sdigits) ; 
347     AliPHOSDigit * sdigit ; 
348     while ( (sdigit = dynamic_cast<AliPHOSDigit *>(next())) ) {
349       GetSDigitsData(0)->Fill( sdigit->GetEnergy()) ;
350     } 
351 }
352
353 //____________________________________________________________________________
354 // void AliPHOSQADataMaker::MakeTrackSegments(TTree * ts)
355 // {
356 //   // makes data from TrackSegments
357
358 //   TClonesArray * tracksegments = dynamic_cast<TClonesArray*>(fData) ;
359
360 //   fhTrackSegmentsMul->Fill(tracksegments->GetEntriesFast()) ; 
361 //   TIter next(tracksegments) ; 
362 //   AliPHOSTrackSegment * ts ; 
363 //   while ( (ts = dynamic_cast<AliPHOSTrackSegment *>(next())) ) {
364 //     fhTrackSegments->Fill( ts->GetCpvDistance()) ;
365 //   } 
366 // }
367
368 //____________________________________________________________________________ 
369 void AliPHOSQADataMaker::StartOfDetectorCycle()
370 {
371   //Detector specific actions at start of cycle
372   
373 }