]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PHOS/AliPHOSQADataMakerRec.cxx
bugfix: external interface was calling AliHLTComponent::Init twice since r27483
[u/mrichter/AliRoot.git] / PHOS / AliPHOSQADataMakerRec.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 "AliPHOSQADataMakerRec.h"
39 #include "AliQAChecker.h"
40 #include "AliPHOSCpvRecPoint.h" 
41 #include "AliPHOSEmcRecPoint.h" 
42 #include "AliPHOSRecParticle.h" 
43 #include "AliPHOSTrackSegment.h" 
44 #include "AliPHOSRawDecoder.h"
45 #include "AliPHOSRawDecoderv1.h"
46 #include "AliPHOSRawDecoderv2.h"
47 #include "AliPHOSReconstructor.h"
48
49 ClassImp(AliPHOSQADataMakerRec)
50            
51 //____________________________________________________________________________ 
52   AliPHOSQADataMakerRec::AliPHOSQADataMakerRec() : 
53   AliQADataMakerRec(AliQA::GetDetName(AliQA::kPHOS), "PHOS Quality Assurance Data Maker")
54 {
55   // ctor
56 }
57
58 //____________________________________________________________________________ 
59 AliPHOSQADataMakerRec::AliPHOSQADataMakerRec(const AliPHOSQADataMakerRec& qadm) :
60   AliQADataMakerRec()
61 {
62   //copy ctor 
63   SetName((const char*)qadm.GetName()) ; 
64   SetTitle((const char*)qadm.GetTitle()); 
65 }
66
67 //__________________________________________________________________
68 AliPHOSQADataMakerRec& AliPHOSQADataMakerRec::operator = (const AliPHOSQADataMakerRec& qadm )
69 {
70   // Equal operator.
71   this->~AliPHOSQADataMakerRec();
72   new(this) AliPHOSQADataMakerRec(qadm);
73   return *this;
74 }
75  
76 //____________________________________________________________________________ 
77 void AliPHOSQADataMakerRec::EndOfDetectorCycle(AliQA::TASKINDEX_t task, TObjArray * list)
78 {
79   //Detector specific actions at end of cycle
80   // do the QA checking
81   AliQAChecker::Instance()->Run(AliQA::kPHOS, task, list) ;  
82 }
83
84 //____________________________________________________________________________ 
85 void AliPHOSQADataMakerRec::InitESDs()
86 {
87   //Create histograms to controll ESD
88  
89   TH1F * h1 = new TH1F("hESDPhosSpectrum",  "ESDs spectrum in PHOS"                ,  200, 0.,   20.) ;
90   h1->Sumw2() ;
91   Add2ESDsList(h1, kESDSpec)  ;
92
93   TH1I * h2 = new TH1I("hESDPhosMul",       "ESDs multiplicity distribution in PHOS", 100, 0,   100 ) ; 
94   h2->Sumw2() ;
95   Add2ESDsList(h2, kESDNtot) ;
96  
97   TH1F * h3 = new TH1F("hESDPhosEtot",      "ESDs total energy"                     , 100, 0,  1000.) ; 
98   h3->Sumw2() ;
99   Add2ESDsList(h3, kESDEtot) ;
100  
101   TH1F * h4 = new TH1F("hESDpid",           "ESDs PID distribution in PHOS"         , 100, 0.,    1.) ;
102   h4->Sumw2() ;
103   Add2ESDsList(h4, kESDpid) ;
104         
105 }
106
107 //____________________________________________________________________________ 
108 void AliPHOSQADataMakerRec::InitRecPoints()
109 {
110   // create Reconstructed Points histograms in RecPoints subdir
111   TH2I * h0 = new TH2I("hRpPHOSxyMod1","RecPoints Rows x Columns for PHOS module 1", 64, -72., 72., 56, -63., 63.) ;                             
112   Add2RecPointsList(h0,kRPmod1) ;
113   TH2I * h1 = new TH2I("hRpPHOSxyMod2","RecPoints Rows x Columns for PHOS module 2", 64, -72., 72., 56, -63., 63.) ;                             
114   Add2RecPointsList(h1,kRPmod2) ;
115   TH2I * h2 = new TH2I("hRpPHOSxyMod3","RecPoints Rows x Columns for PHOS module 3", 64, -72., 72., 56, -63., 63.) ;                             
116   Add2RecPointsList(h2,kRPmod3) ;
117   TH2I * h3 = new TH2I("hRpPHOSxyMod4","RecPoints Rows x Columns for PHOS module 4", 64, -72., 72., 56, -63., 63.) ;                             
118   Add2RecPointsList(h3,kRPmod4) ;
119   TH2I * h4 = new TH2I("hRpPHOSxyMod5","RecPoints Rows x Columns for PHOS module 5", 64, -72., 72., 56, -63., 63.) ;                             
120   Add2RecPointsList(h4,kRPmod5) ;
121  
122   TH1F * h5 = new TH1F("hEmcPhosRecPointsSpectrum",  "EMC RecPoints spectrum in PHOS",   2000, 0., 20.) ; 
123   h5->Sumw2() ;
124   Add2RecPointsList(h5, kRPSpec)  ;
125
126   TH1I * h6 = new TH1I("hEmcPhosRecPointsMul", "EMCA RecPoints multiplicity distribution in PHOS", 100, 0,  100) ; 
127   h6->Sumw2() ;
128   Add2RecPointsList(h6, kRPNtot) ;
129
130   TH1I * h7 = new TH1I("hEmcPhosRecPointsEtot", "EMC RecPoints Etot", 200, 0,  200.) ; 
131   h7->Sumw2() ;
132   Add2RecPointsList(h7, kRPEtot) ;
133
134   TH1I * h8 = new TH1I("hCpvPhosRecPointsMul", "CPV RecPoints multiplicity distribution in PHOS", 100, 0,  100) ; 
135   h8->Sumw2() ;
136   Add2RecPointsList(h8, kRPNcpv) ;
137 }
138
139 //____________________________________________________________________________ 
140 void AliPHOSQADataMakerRec::InitRaws()
141 {
142   // create Raws histograms in Raws subdir
143   TH2I * h0 = new TH2I("hHighPHOSxyMod1","High Gain Rows x Columns for PHOS module 1", 64, 0, 64, 56, 0, 56) ;
144   Add2RawsList(h0,kHGmod1) ;
145   TH2I * h1 = new TH2I("hHighPHOSxyMod2","High Gain Rows x Columns for PHOS module 2", 64, 0, 64, 56, 0, 56) ;
146   Add2RawsList(h1,kHGmod2) ;
147   TH2I * h2 = new TH2I("hHighPHOSxyMod3","High Gain Rows x Columns for PHOS module 3", 64, 0, 64, 56, 0, 56) ;
148   Add2RawsList(h2,kHGmod3) ;
149   TH2I * h3 = new TH2I("hHighPHOSxyMod4","High Gain Rows x Columns for PHOS module 4", 64, 0, 64, 56, 0, 56) ;
150   Add2RawsList(h3,kHGmod4) ;
151   TH2I * h4 = new TH2I("hHighPHOSxyMod5","High Gain Rows x Columns for PHOS module 5", 64, 0, 64, 56, 0, 56) ;
152   Add2RawsList(h4,kHGmod5) ;
153   TH2I * h5 = new TH2I("hLowPHOSxyMod1","Low Gain Rows x Columns for PHOS module 1", 64, 0, 64, 56, 0, 56) ;
154   Add2RawsList(h5,kLGmod1) ;
155   TH2I * h6 = new TH2I("hLowPHOSxyMod2","Low Gain Rows x Columns for PHOS module 2", 64, 0, 64, 56, 0, 56) ;
156   Add2RawsList(h6,kLGmod2) ;
157   TH2I * h7 = new TH2I("hLowPHOSxyMod3","Low Gain Rows x Columns for PHOS module 3", 64, 0, 64, 56, 0, 56) ;
158   Add2RawsList(h7,kLGmod3) ;
159   TH2I * h8 = new TH2I("hLowPHOSxyMod4","Low Gain Rows x Columns for PHOS module 4", 64, 0, 64, 56, 0, 56) ;
160   Add2RawsList(h8,kLGmod4) ;                                                                                                               
161   TH2I * h9 = new TH2I("hLowPHOSxyMod5","Low Gain Rows x Columns for PHOS module 5", 64, 0, 64, 56, 0, 56) ;                               
162   Add2RawsList(h9,kLGmod5) ;                                                                                                               
163                                                                                                                                            
164                                                                                                                                            
165   TH1I * h10 = new TH1I("hLowPhosModules",    "Low Gain Hits in EMCA PHOS modules",       6, 0, 6) ;                                       
166   h10->Sumw2() ;                                                                                                                           
167   Add2RawsList(h10, kNmodLG) ;                                                                                                             
168   TH1I * h11 = new TH1I("hHighPhosModules",   "High Gain Hits in EMCA PHOS modules",       6, 0, 6) ;                                      
169   h11->Sumw2() ;                                                                                                                           
170   Add2RawsList(h11, kNmodHG) ;                                                                                                             
171                                                                                                                                            
172   TH1F * h12 = new TH1F("hLowPhosRawtime", "Low Gain Time of raw hits in PHOS", 500, -50., 200.) ;                                            
173   h12->Sumw2() ;                                                                                                                           
174   Add2RawsList(h12, kLGtime) ;                                                                                                             
175   TH1F * h13 = new TH1F("hHighPhosRawtime", "High Gain Time of raw hits in PHOS", 500, -50., 200.) ;                                          
176   h13->Sumw2() ;                                                                                                                           
177   Add2RawsList(h13, kHGtime) ;                                                                                                             
178                                                                                                                                            
179   TH1F * h14 = new TH1F("hLowPhosRawEnergy", "Low Gain Energy of raw hits in PHOS", 500, 0., 1000.) ;                                      
180   h14->Sumw2() ;                                                                                                                           
181   Add2RawsList(h14, kSpecLG) ;                                                                                                             
182   TH1F * h15 = new TH1F("hHighPhosRawEnergy", "High Gain Energy of raw hits in PHOS",500,0., 1000.) ;                                      
183   h15->Sumw2() ;                                                                                                                           
184   Add2RawsList(h15, kSpecHG) ;                                                                                                             
185                                                                                                                                            
186   TH1F * h16 = new TH1F("hLowNtot", "Low Gain Total Number of raw hits in PHOS", 500, 0., 5000.) ;                                         
187   h16->Sumw2() ;                                                                                                                           
188   Add2RawsList(h16, kNtotLG) ;                                                                                                             
189   TH1F * h17 = new TH1F("hHighNtot", "High Gain Total Number of raw hits in PHOS",500,0., 5000.) ;                                         
190   h17->Sumw2() ;                                                                                                                           
191   Add2RawsList(h17, kNtotHG) ;                                                                                                             
192                                                                                                                                            
193   TH1F * h18 = new TH1F("hLowEtot", "Low Gain Total Energy of raw hits in PHOS", 500, 0., 5000.) ;                                       
194   h18->Sumw2() ;                                                                                                                           
195   Add2RawsList(h18, kEtotLG) ;                                                                                                             
196   TH1F * h19 = new TH1F("hHighEtot", "High Gain Total Energy of raw hits in PHOS",500,0., 100000.) ;                                       
197   h19->Sumw2() ;                                                                                                                           
198   Add2RawsList(h19, kEtotHG) ;                                                                                                             
199   
200 }
201
202 //____________________________________________________________________________
203 void AliPHOSQADataMakerRec::MakeESDs(AliESDEvent * esd)
204 {
205   // make QA data from ESDs
206
207   Int_t nTot = 0 ; 
208   Double_t eTot = 0 ; 
209   for ( Int_t index = 0; index < esd->GetNumberOfCaloClusters() ; index++ ) {
210     AliESDCaloCluster * clu = esd->GetCaloCluster(index) ;
211     if( clu->IsPHOS() ) {
212       GetESDsData(kESDSpec)->Fill(clu->E()) ;
213       Double_t *pid=clu->GetPid() ;
214       GetESDsData(kESDpid)->Fill(pid[AliPID::kPhoton]) ;
215       eTot+=clu->E() ;
216       nTot++ ;
217     } 
218   }
219   GetESDsData(kESDNtot)->Fill(nTot) ;
220   GetESDsData(kESDEtot)->Fill(eTot) ;
221 }
222
223 //____________________________________________________________________________
224 void AliPHOSQADataMakerRec::MakeRaws(AliRawReader* rawReader)
225 {
226   //Fill prepared histograms with Raw digit properties
227   rawReader->Reset() ;
228   AliPHOSRawDecoder * decoder ;
229   if(strcmp(GetRecoParam()->EMCDecoderVersion(),"v1")==0)
230     decoder=new AliPHOSRawDecoderv1(rawReader);
231   else
232     if(strcmp(GetRecoParam()->EMCDecoderVersion(),"v2")==0)
233       decoder=new AliPHOSRawDecoderv2(rawReader);
234     else
235       decoder=new AliPHOSRawDecoder(rawReader);
236   decoder->SubtractPedestals(GetRecoParam()->EMCSubtractPedestals());
237   Double_t lgEtot=0. ;
238   Double_t hgEtot=0. ;
239   Int_t lgNtot=0 ;
240   Int_t hgNtot=0 ;
241
242   while (decoder->NextDigit()) {
243    Int_t module  = decoder->GetModule() ;
244    Int_t row     = decoder->GetRow() ;
245    Int_t col     = decoder->GetColumn() ;
246    Double_t time = decoder->GetTime() ;
247    Double_t energy  = decoder->GetEnergy() ;
248    Bool_t lowGain = decoder->IsLowGain();
249    if (lowGain) {
250      if(energy<2.)
251        continue ;
252      switch(module){
253         case 1: GetRawsData(kLGmod1)->Fill(row-0.5,col-0.5) ; break ;
254         case 2: GetRawsData(kLGmod2)->Fill(row-0.5,col-0.5) ; break ;
255         case 3: GetRawsData(kLGmod3)->Fill(row-0.5,col-0.5) ; break ;
256         case 4: GetRawsData(kLGmod4)->Fill(row-0.5,col-0.5) ; break ;
257         case 5: GetRawsData(kLGmod5)->Fill(row-0.5,col-0.5) ; break ;
258      }                                  
259      GetRawsData(kNmodLG)->Fill(module) ;
260      GetRawsData(kLGtime)->Fill(time) ; 
261      GetRawsData(kSpecLG)->Fill(energy) ;    
262      lgEtot+=energy ;
263      lgNtot++ ;   
264    } else {        
265      if(energy<8.)
266        continue ;
267      switch (module){
268          case 1: GetRawsData(kHGmod1)->Fill(row-0.5,col-0.5) ; break ;
269          case 2: GetRawsData(kHGmod2)->Fill(row-0.5,col-0.5) ; break ;
270          case 3: GetRawsData(kHGmod3)->Fill(row-0.5,col-0.5) ; break ;
271          case 4: GetRawsData(kHGmod4)->Fill(row-0.5,col-0.5) ; break ;
272          case 5: GetRawsData(kHGmod5)->Fill(row-0.5,col-0.5) ; break ;
273      }              
274      GetRawsData(kNmodHG)->Fill(module) ; 
275      GetRawsData(kHGtime)->Fill(time) ;  
276      GetRawsData(kSpecHG)->Fill(energy) ;
277      hgEtot+=energy ; 
278      hgNtot++ ;  
279    }                 
280   }                    
281   GetRawsData(kEtotLG)->Fill(lgEtot) ; 
282   GetRawsData(kEtotHG)->Fill(hgEtot) ;  
283   GetRawsData(kNtotLG)->Fill(lgNtot) ;
284   GetRawsData(kNtotHG)->Fill(hgNtot) ;
285 }
286 //____________________________________________________________________________
287 void AliPHOSQADataMakerRec::MakeRecPoints(TTree * clustersTree)
288 {
289   {
290     // makes data from RecPoints
291     TBranch *emcbranch = clustersTree->GetBranch("PHOSEmcRP");
292     if (!emcbranch) { 
293       AliError("can't get the branch with the PHOS EMC clusters !");
294       return;
295     }
296     TObjArray * emcrecpoints = new TObjArray(100) ;
297     emcbranch->SetAddress(&emcrecpoints);
298     emcbranch->GetEntry(0);
299     
300     GetRecPointsData(kRPNtot)->Fill(emcrecpoints->GetEntriesFast()) ; 
301     TIter next(emcrecpoints) ; 
302     AliPHOSEmcRecPoint * rp ; 
303     Double_t eTot = 0. ; 
304     while ( (rp = dynamic_cast<AliPHOSEmcRecPoint *>(next())) ) {
305       GetRecPointsData(kRPSpec)->Fill( rp->GetEnergy()) ;
306       Int_t mod = rp->GetPHOSMod() ;
307       TVector3 pos ;
308       rp->GetLocalPosition(pos) ;
309       switch(mod){
310         case 1: GetRecPointsData(kRPmod1)->Fill(pos.X(),pos.Z()) ; break ;
311         case 2: GetRecPointsData(kRPmod2)->Fill(pos.X(),pos.Z()) ; break ;
312         case 3: GetRecPointsData(kRPmod3)->Fill(pos.X(),pos.Z()) ; break ;
313         case 4: GetRecPointsData(kRPmod4)->Fill(pos.X(),pos.Z()) ; break ;
314         case 5: GetRecPointsData(kRPmod5)->Fill(pos.X(),pos.Z()) ; break ;
315       }
316       eTot+= rp->GetEnergy() ;
317     }
318     GetRecPointsData(kRPEtot)->Fill(eTot) ;
319     emcrecpoints->Delete();
320     delete emcrecpoints;
321   }
322   {
323     TBranch *cpvbranch = clustersTree->GetBranch("PHOSCpvRP");
324     if (!cpvbranch) { 
325       AliError("can't get the branch with the PHOS CPV clusters !");
326       return;
327     }
328     TObjArray *cpvrecpoints = new TObjArray(100) ;
329     cpvbranch->SetAddress(&cpvrecpoints);
330     cpvbranch->GetEntry(0);
331     
332     GetRecPointsData(kRPNcpv)->Fill(cpvrecpoints->GetEntriesFast()) ; 
333     cpvrecpoints->Delete();
334     delete cpvrecpoints;
335   }
336 }
337
338 //____________________________________________________________________________ 
339 void AliPHOSQADataMakerRec::StartOfDetectorCycle()
340 {
341   //Detector specific actions at start of cycle
342   
343 }