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