]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliQADataMaker.cxx
Removal of AliAODTowers (will appear as AliAODCaloCells again).
[u/mrichter/AliRoot.git] / STEER / AliQADataMaker.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   Base Class
21   Produces the data needed to calculate the quality assurance. 
22   All data must be mergeable objects.
23   Y. Schutz CERN July 2007
24 */
25
26 // --- ROOT system ---
27 #include <TSystem.h> 
28 #include <TFile.h>
29 #include <TList.h> 
30 #include <TTree.h>
31 #include <TClonesArray.h>
32
33 // --- Standard library ---
34
35 // --- AliRoot header files ---
36 #include "AliLog.h"
37 #include "AliQADataMaker.h"
38 #include "AliQAChecker.h"
39 #include "AliESDEvent.h"
40 #include "AliRawReader.h"
41
42 ClassImp(AliQADataMaker)
43   
44 TString AliQADataMaker::fDetectorDirName("") ;
45
46            
47 //____________________________________________________________________________ 
48 AliQADataMaker::AliQADataMaker(const char * name, const char * title) : 
49   TNamed(name, title), 
50   fOutput(0x0),
51   fDetectorDir(0x0),
52   fDigitsQAList(0x0), 
53   fESDsQAList(0x0), 
54   fHitsQAList(0x0),
55   fRawsQAList(0x0), 
56   fRecPointsQAList(0x0), 
57   fSDigitsQAList(0x0), 
58   fCurrentCycle(-1), 
59   fCycle(9999999), 
60   fCycleCounter(0), 
61   fRun(0)
62 {
63   // ctor
64   fDetectorDirName = GetName() ; 
65 }
66
67 //____________________________________________________________________________ 
68 AliQADataMaker::AliQADataMaker(const AliQADataMaker& qadm) :
69   TNamed(qadm.GetName(), qadm.GetTitle()),
70   fOutput(qadm.fOutput),
71   fDetectorDir(qadm.fDetectorDir),
72   fDigitsQAList(qadm.fDigitsQAList),
73   fESDsQAList(qadm.fESDsQAList),
74   fHitsQAList(qadm.fHitsQAList),
75   fRawsQAList(qadm.fRecPointsQAList),
76   fRecPointsQAList(qadm.fRecPointsQAList),
77   fSDigitsQAList(qadm.fSDigitsQAList), 
78   fCurrentCycle(qadm.fCurrentCycle), 
79   fCycle(qadm.fCycle), 
80   fCycleCounter(qadm.fCycleCounter), 
81   fRun(qadm.fRun)
82 {
83   //copy ctor
84   fDetectorDirName = GetName() ; 
85 }
86
87 //____________________________________________________________________________ 
88 AliQADataMaker::~AliQADataMaker() 
89 {
90 // dtor
91
92
93 //__________________________________________________________________
94 AliQADataMaker& AliQADataMaker::operator = (const AliQADataMaker& qadm )
95 {
96   // Equal operator.
97   this->~AliQADataMaker();
98   new(this) AliQADataMaker(qadm);
99   return *this;
100 }
101
102 //____________________________________________________________________________
103 void AliQADataMaker::EndOfCycle(AliQA::TASKINDEX task) 
104
105   // Finishes a cycle of QA data acquistion
106   
107  TList * list = 0x0 ; 
108   
109  switch (task) { 
110   
111   case AliQA::kRAWS:    
112         list = fRawsQAList ; 
113   break ; 
114
115   case AliQA::kHITS:
116         list = fHitsQAList ; 
117   break ; 
118
119   case AliQA::kSDIGITS:
120         list = fSDigitsQAList ; 
121   break ; 
122     
123   case AliQA::kDIGITS:
124         list = fDigitsQAList ; 
125   break ;  
126  
127    case AliQA::kRECPOINTS:
128         list = fRecPointsQAList ; 
129    break ;  
130
131    case AliQA::kTRACKSEGMENTS:
132    break ;  
133   
134    case AliQA::kRECPARTICLES:
135    break ;  
136     
137    case AliQA::kESDS:
138         list = fESDsQAList ; 
139    break ;  
140   }     
141   
142  EndOfDetectorCycle(task, list) ; 
143  TDirectory * subDir = fDetectorDir->GetDirectory(AliQA::GetTaskName(task)) ; 
144  subDir->cd() ; 
145  list->Write() ; 
146 }
147  
148 //____________________________________________________________________________
149 void AliQADataMaker::Exec(AliQA::TASKINDEX task, TObject * data) 
150
151   // creates the quality assurance data for the various tasks (Hits, SDigits, Digits, ESDs)
152     
153   switch (task) { 
154   
155   case AliQA::kRAWS:
156   {
157     AliInfo("Processing Raws QA") ; 
158         AliRawReader * rawReader = dynamic_cast<AliRawReader *>(data) ; 
159     if (rawReader) 
160           MakeRaws(rawReader) ;
161          else
162           AliError("Wrong data type") ;     
163     break ; 
164   }
165   case AliQA::kHITS:
166   {  
167         AliInfo("Processing Hits QA") ; 
168         TClonesArray * hits = dynamic_cast<TClonesArray *>(data) ; 
169     if (hits) 
170      MakeHits(hits) ;
171         else 
172      AliError("Wrong type of hits container") ;
173     break ; 
174   }
175   case AliQA::kSDIGITS:
176   {
177     AliInfo("Processing SDigits QA") ; 
178     TClonesArray * sdigits = dynamic_cast<TClonesArray *>(data) ; 
179         if (sdigits) 
180       MakeSDigits(sdigits) ;
181          else    
182       AliError("Wrong type of sdigits container") ; 
183     break ; 
184   }  
185   case AliQA::kDIGITS:
186   {
187     TClonesArray * digits = dynamic_cast<TClonesArray *>(data) ; 
188     if (digits) 
189           MakeDigits(digits) ;
190          else 
191       AliError("Wrong type of digits container") ; 
192     break ;  
193   }
194   case AliQA::kRECPOINTS:
195   {
196      AliInfo("Processing RecPoints QA") ; 
197      TTree * recpoints = dynamic_cast<TTree *>(data) ; 
198     if (recpoints) 
199       MakeRecPoints(recpoints) ;
200     else 
201       AliError("Wrong type of recpoints container") ; 
202     break ;  
203   }
204    case AliQA::kTRACKSEGMENTS:
205     AliInfo("Processing Track Segments QA: not existing anymore") ; 
206 //     TTree * ts = dynamic_cast<TTree *>(data) ; 
207 //     if (ts) 
208 //       MakeTrackSegments(ts) ;
209 //     else 
210 //       AliError("Wrong type of track segments container") ; 
211     break ;  
212   
213     case AliQA::kRECPARTICLES:
214     AliInfo("Processing RecParticles QA: not existing anymore") ; 
215 //     TTree * recpar = dynamic_cast<TTree *>(data) ; 
216 //     if (recpar) 
217 //       MakeRecParticles(recpar) ;
218 //     else 
219 //       AliError("Wrong type of recparticles container") ; 
220     break ;  
221     
222   case AliQA::kESDS:
223    {
224     AliInfo("Processing ESDs QA") ; 
225     AliESDEvent * esd = dynamic_cast<AliESDEvent *>(data) ; 
226     if (esd) 
227       MakeESDs(esd) ;
228     else 
229       AliError("Wrong type of esd container") ; 
230     break ;
231    }  
232   }       
233 }
234
235 //____________________________________________________________________________ 
236 void AliQADataMaker::Finish(AliQA::TASKINDEX) const 
237
238   // write to the output File
239   fOutput->Close() ; 
240
241
242 //____________________________________________________________________________ 
243 TList *  AliQADataMaker::Init(AliQA::TASKINDEX task, Int_t run, Int_t cycles)
244 {
245   // general intialisation
246   
247   fRun = run ;
248   if (cycles > 0)
249     SetCycle(cycles) ;  
250         
251   switch (task) {
252   case AliQA::kRAWS: 
253    {
254         fRawsQAList = new TList() ;      
255     InitRaws() ;
256         return fRawsQAList ;
257     break ; 
258    }
259   case AliQA::kHITS: 
260    {
261         fHitsQAList = new TList() ;      
262     InitHits() ;
263         return fHitsQAList ;
264     break ; 
265    }
266   case AliQA::kSDIGITS: 
267    {
268         fSDigitsQAList = new TList() ; 
269     InitSDigits() ;
270         return fSDigitsQAList ;
271     break ; 
272    }
273   case AliQA::kDIGITS: 
274    {
275         fDigitsQAList = new TList(); 
276         InitDigits() ;
277         return fDigitsQAList ;
278         break ; 
279    }      
280   case AliQA::kRECPOINTS: 
281    {
282         fRecPointsQAList = new TList ; 
283     InitRecPoints() ;
284         return fRecPointsQAList ;
285     break ; 
286   }
287   case AliQA::kTRACKSEGMENTS: 
288 //  InitTrackSegments() ;
289     break ; 
290     
291   case AliQA::kRECPARTICLES: 
292 //    InitRecParticles() ;
293     break ; 
294     
295   case AliQA::kESDS: 
296    {
297         fESDsQAList = new TList() ; 
298         InitESDs() ;
299         return fRecPointsQAList ;
300     break ; 
301    }
302   }  
303   return 0x0 ; 
304 }
305
306 //____________________________________________________________________________
307 void AliQADataMaker::StartOfCycle(AliQA::TASKINDEX task, Option_t * sameCycle) 
308
309   // Finishes a cycle of QA data acquistion
310  
311  if ( (strcmp(sameCycle, "new") == 0) )  {
312    ResetCycle() ;
313    if (fOutput) 
314         fOutput->Close() ; 
315    fOutput = AliQA::GetQADMOutFile(GetName(), fRun, fCurrentCycle) ;    
316  }
317         
318  AliInfo(Form(" Run %d Cycle %d task %s file %s", 
319         fRun, fCurrentCycle, AliQA::GetTaskName(task).Data(), fOutput->GetName() )) ;
320
321  fDetectorDir = fOutput->GetDirectory(GetDetectorDirName()) ; 
322  if (!fDetectorDir)
323    fDetectorDir = fOutput->mkdir(GetDetectorDirName()) ; 
324
325  TDirectory * subDir = fDetectorDir->GetDirectory(AliQA::GetTaskName(task)) ; 
326  if (!subDir)
327    subDir = fDetectorDir->mkdir(AliQA::GetTaskName(task)) ;  
328  subDir->cd() ; 
329
330   TList * list = 0x0 ; 
331   
332   switch (task) { 
333   case AliQA::kRAWS: 
334         list = fRawsQAList ; 
335     break ; 
336
337   case AliQA::kHITS: 
338         list = fHitsQAList ; 
339     break ; 
340   
341   case AliQA::kSDIGITS: 
342         list = fSDigitsQAList ;
343     break ; 
344
345   case AliQA::kDIGITS: 
346         list = fDigitsQAList ;
347         break ; 
348           
349   case AliQA::kRECPOINTS: 
350         list = fRecPointsQAList ;
351         break ; 
352
353   case AliQA::kTRACKSEGMENTS: 
354     break ; 
355     
356   case AliQA::kRECPARTICLES: 
357     break ; 
358     
359   case AliQA::kESDS: 
360         list = fESDsQAList ;
361     break ; 
362   }  
363
364  TIter next(list) ;
365  TH1 * h ; 
366  while ( (h = dynamic_cast<TH1 *>(next())) )
367     h->Reset() ;  
368
369  StartOfDetectorCycle() ; 
370
371 }