]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliQADataMaker.cxx
The standalone QA data maker is called from AliSimulation and AliReconstruction outsi...
[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 //____________________________________________________________________________ 
45 AliQADataMaker::AliQADataMaker(const char * name, const char * title) : 
46   TNamed(name, title), 
47   fOutput(0x0),
48   fDetectorDir(0x0),
49   fDetectorDirName(""), 
50   fDigitsQAList(0x0), 
51   fESDsQAList(0x0), 
52   fHitsQAList(0x0),
53   fRawsQAList(0x0), 
54   fRecPointsQAList(0x0), 
55   fSDigitsQAList(0x0), 
56   fCurrentCycle(-1), 
57   fCycle(9999999), 
58   fCycleCounter(0), 
59   fRun(0)
60 {
61   // ctor
62   fDetectorDirName = GetName() ; 
63 }
64
65 //____________________________________________________________________________ 
66 AliQADataMaker::AliQADataMaker(const AliQADataMaker& qadm) :
67   TNamed(qadm.GetName(), qadm.GetTitle()),
68   fOutput(qadm.fOutput),
69   fDetectorDir(qadm.fDetectorDir),
70   fDetectorDirName(qadm.fDetectorDirName),
71   fDigitsQAList(qadm.fDigitsQAList),
72   fESDsQAList(qadm.fESDsQAList),
73   fHitsQAList(qadm.fHitsQAList),
74   fRawsQAList(qadm.fRecPointsQAList),
75   fRecPointsQAList(qadm.fRecPointsQAList),
76   fSDigitsQAList(qadm.fSDigitsQAList), 
77   fCurrentCycle(qadm.fCurrentCycle), 
78   fCycle(qadm.fCycle), 
79   fCycleCounter(qadm.fCycleCounter), 
80   fRun(qadm.fRun)
81 {
82   //copy ctor
83   fDetectorDirName = GetName() ; 
84 }
85
86 //__________________________________________________________________
87 AliQADataMaker& AliQADataMaker::operator = (const AliQADataMaker& qadm )
88 {
89   // Assignment operator.
90   this->~AliQADataMaker();
91   new(this) AliQADataMaker(qadm);
92   return *this;
93 }
94
95 //____________________________________________________________________________
96 void AliQADataMaker::EndOfCycle(AliQA::TASKINDEX task) 
97
98   // Finishes a cycle of QA data acquistion
99   
100  TList * list = 0x0 ; 
101   
102  switch (task) { 
103   
104   case AliQA::kRAWS:    
105         list = fRawsQAList ; 
106   break ; 
107
108   case AliQA::kHITS:
109         list = fHitsQAList ; 
110   break ; 
111
112   case AliQA::kSDIGITS:
113         list = fSDigitsQAList ; 
114   break ; 
115     
116   case AliQA::kDIGITS:
117         list = fDigitsQAList ; 
118   break ;  
119  
120    case AliQA::kRECPOINTS:
121         list = fRecPointsQAList ; 
122    break ;  
123
124    case AliQA::kTRACKSEGMENTS:
125    break ;  
126   
127    case AliQA::kRECPARTICLES:
128    break ;  
129     
130    case AliQA::kESDS:
131         list = fESDsQAList ; 
132    break ;  
133   }     
134   
135  EndOfDetectorCycle(task, list) ; 
136  TDirectory * subDir = fDetectorDir->GetDirectory(AliQA::GetTaskName(task)) ; 
137  subDir->cd() ; 
138  list->Write() ; 
139 }
140  
141 //____________________________________________________________________________
142 void AliQADataMaker::Exec(AliQA::TASKINDEX task, TObject * data) 
143
144   // creates the quality assurance data for the various tasks (Hits, SDigits, Digits, ESDs)
145     
146         switch (task) { 
147   
148                 case AliQA::kRAWS:
149                 {
150                         AliInfo("Processing Raws QA") ; 
151                         AliRawReader * rawReader = dynamic_cast<AliRawReader *>(data) ; 
152                         if (rawReader) 
153                                 MakeRaws(rawReader) ;
154                         else
155                         AliError("Wrong data type") ;     
156                         break ; 
157                 }
158                 case AliQA::kHITS:
159                 {  
160                         AliInfo("Processing Hits QA") ; 
161                         TClonesArray * arr = dynamic_cast<TClonesArray *>(data) ; 
162                         if (arr) { 
163                                 MakeHits(arr) ;
164                         } else {
165                                 TTree * tree = dynamic_cast<TTree *>(data) ; 
166                                 if (tree) {
167                                         MakeHits(tree) ; 
168                                 } else {
169                                         AliWarning("data are neither a TClonesArray nor a TTree") ; 
170                                 }
171                         }
172                         break ; 
173                 }
174                 case AliQA::kSDIGITS:
175                 {
176                         AliInfo("Processing SDigits QA") ; 
177                         TClonesArray * arr = dynamic_cast<TClonesArray *>(data) ; 
178                         if (arr) { 
179                                 MakeSDigits(arr) ;
180                         } else {
181                                 TTree * tree = dynamic_cast<TTree *>(data) ; 
182                                 if (tree) {
183                                         MakeSDigits(tree) ; 
184                                 } else {
185                                         AliWarning("data are neither a TClonesArray nor a TTree") ; 
186                                 }
187                         }
188                         break ; 
189                 }  
190                 case AliQA::kDIGITS:
191                 {
192                         TClonesArray * arr = dynamic_cast<TClonesArray *>(data) ; 
193                         if (arr) { 
194                                 MakeDigits(arr) ;
195                         } else {
196                                 TTree * tree = dynamic_cast<TTree *>(data) ; 
197                                 if (tree) {
198                                         MakeDigits(tree) ; 
199                                 } else {
200                                         AliWarning("data are neither a TClonesArray nor a TTree") ; 
201                                 }
202                         }
203                         break ;  
204                 }
205                 case AliQA::kRECPOINTS:
206                 {
207                         AliInfo("Processing RecPoints QA") ; 
208                         TTree * tree = dynamic_cast<TTree *>(data) ; 
209                         if (tree) {
210                                 MakeRecPoints(tree) ; 
211                         } else {
212                                 AliWarning("data are not a TTree") ; 
213                         }
214                         break ;  
215                 }
216                 case AliQA::kTRACKSEGMENTS:
217                         AliInfo("Processing Track Segments QA: not existing anymore") ; 
218                 //       MakeTrackSegments(ts) ;
219                 break ;  
220   
221                 case AliQA::kRECPARTICLES:
222                         AliInfo("Processing RecParticles QA: not existing anymore") ; 
223                         //       MakeRecParticles(recpar) ;
224                 break ;  
225                 case AliQA::kESDS:
226                 {
227                         AliInfo("Processing ESDs QA") ; 
228                         AliESDEvent * esd = dynamic_cast<AliESDEvent *>(data) ; 
229                         if (esd) 
230                                 MakeESDs(esd) ;
231                         else 
232                                 AliError("Wrong type of esd container") ; 
233                         break ;
234                 }  
235         }         
236 }
237
238 //____________________________________________________________________________ 
239 void AliQADataMaker::Finish() const 
240
241   // write to the output File
242   fOutput->Close() ; 
243
244
245 //____________________________________________________________________________ 
246 TList *  AliQADataMaker::Init(AliQA::TASKINDEX task, Int_t run, Int_t cycles)
247 {
248   // general intialisation
249   
250   fRun = run ;
251   if (cycles > 0)
252     SetCycle(cycles) ;  
253         
254   switch (task) {
255   case AliQA::kRAWS: 
256    {
257         fRawsQAList = new TList() ;      
258     InitRaws() ;
259         return fRawsQAList ;
260     break ; 
261    }
262   case AliQA::kHITS: 
263    {
264         fHitsQAList = new TList() ;      
265     InitHits() ;
266         return fHitsQAList ;
267     break ; 
268    }
269   case AliQA::kSDIGITS: 
270    {
271         fSDigitsQAList = new TList() ; 
272     InitSDigits() ;
273         return fSDigitsQAList ;
274     break ; 
275    }
276   case AliQA::kDIGITS: 
277    {
278         fDigitsQAList = new TList(); 
279         InitDigits() ;
280         return fDigitsQAList ;
281         break ; 
282    }      
283   case AliQA::kRECPOINTS: 
284    {
285         fRecPointsQAList = new TList() ; 
286     InitRecPoints() ;
287         return fRecPointsQAList ;
288     break ; 
289   }
290   case AliQA::kTRACKSEGMENTS: 
291 //  InitTrackSegments() ;
292     break ; 
293     
294   case AliQA::kRECPARTICLES: 
295 //    InitRecParticles() ;
296     break ; 
297     
298   case AliQA::kESDS: 
299    {
300         fESDsQAList = new TList() ; 
301         InitESDs() ;
302         return fRecPointsQAList ;
303     break ; 
304    }
305   }  
306   return 0x0 ; 
307 }
308
309 //____________________________________________________________________________ 
310 void AliQADataMaker::Init(AliQA::TASKINDEX task, TList * list, Int_t run, Int_t cycles)
311 {
312   // Intialisation by passing the list of QA data booked elsewhere
313   
314   fRun = run ;
315   if (cycles > 0)
316     SetCycle(cycles) ;  
317         
318   switch (task) {
319   case AliQA::kRAWS: 
320    {
321         fRawsQAList = list ;     
322     break ; 
323    }
324   case AliQA::kHITS: 
325    {
326         fHitsQAList = list ;     
327     break ; 
328    }
329   case AliQA::kSDIGITS: 
330    {
331         fSDigitsQAList = list ; 
332     break ; 
333    }
334   case AliQA::kDIGITS: 
335    {
336         fDigitsQAList = list ; 
337         break ; 
338    }      
339   case AliQA::kRECPOINTS: 
340    {
341         fRecPointsQAList = list ; 
342     break ; 
343   }
344   case AliQA::kTRACKSEGMENTS: 
345     break ; 
346     
347   case AliQA::kRECPARTICLES: 
348     break ; 
349     
350   case AliQA::kESDS: 
351    {
352         fESDsQAList = list ; 
353     break ; 
354    }
355   }  
356 }
357
358 //____________________________________________________________________________
359 void AliQADataMaker::Reset() 
360
361   // Resets defaut value of data members 
362   fCurrentCycle = -1 ;  
363   fCycleCounter = 0 ; 
364 }
365
366 //____________________________________________________________________________
367 void AliQADataMaker::StartOfCycle(AliQA::TASKINDEX task, const Bool_t sameCycle) 
368
369   // Finishes a cycle of QA data acquistion
370  
371  if ( !sameCycle ) {
372         ResetCycle() ;
373         if (fOutput) 
374                 fOutput->Close() ; 
375         fOutput = AliQA::GetQADMOutFile(GetName(), fRun, fCurrentCycle) ;       
376  }      
377  AliInfo(Form(" Run %d Cycle %d task %s file %s", 
378         fRun, fCurrentCycle, AliQA::GetTaskName(task).Data(), fOutput->GetName() )) ;
379
380  fDetectorDir = fOutput->GetDirectory(GetDetectorDirName()) ; 
381  if (!fDetectorDir)
382    fDetectorDir = fOutput->mkdir(GetDetectorDirName()) ; 
383
384  TDirectory * subDir = fDetectorDir->GetDirectory(AliQA::GetTaskName(task)) ; 
385  if (!subDir)
386    subDir = fDetectorDir->mkdir(AliQA::GetTaskName(task)) ;  
387  subDir->cd() ; 
388
389   TList * list = 0x0 ; 
390   
391   switch (task) { 
392   case AliQA::kRAWS: 
393         list = fRawsQAList ; 
394     break ; 
395
396   case AliQA::kHITS: 
397         list = fHitsQAList ; 
398     break ; 
399   
400   case AliQA::kSDIGITS: 
401         list = fSDigitsQAList ;
402     break ; 
403
404   case AliQA::kDIGITS: 
405         list = fDigitsQAList ;
406         break ; 
407           
408   case AliQA::kRECPOINTS: 
409         list = fRecPointsQAList ;
410         break ; 
411
412   case AliQA::kTRACKSEGMENTS: 
413     break ; 
414     
415   case AliQA::kRECPARTICLES: 
416     break ; 
417     
418   case AliQA::kESDS: 
419         list = fESDsQAList ;
420     break ; 
421   }  
422
423  TIter next(list) ;
424  TH1 * h ; 
425  while ( (h = dynamic_cast<TH1 *>(next())) )
426     h->Reset() ;  
427
428  StartOfDetectorCycle() ; 
429
430 }