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