]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliQADataMaker.cxx
Possibility to convolute the original cov.matrix of the point with the matrix coming...
[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(AliQA::TASKINDEX) 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::StartOfCycle(AliQA::TASKINDEX task, Option_t * sameCycle) 
360
361   // Finishes a cycle of QA data acquistion
362  
363  if ( (strcmp(sameCycle, "new") == 0) ) {
364         ResetCycle() ;
365         if (fOutput) 
366                 fOutput->Close() ; 
367         fOutput = AliQA::GetQADMOutFile(GetName(), fRun, fCurrentCycle) ;       
368  }      
369  AliInfo(Form(" Run %d Cycle %d task %s file %s", 
370         fRun, fCurrentCycle, AliQA::GetTaskName(task).Data(), fOutput->GetName() )) ;
371
372  fDetectorDir = fOutput->GetDirectory(GetDetectorDirName()) ; 
373  if (!fDetectorDir)
374    fDetectorDir = fOutput->mkdir(GetDetectorDirName()) ; 
375
376  TDirectory * subDir = fDetectorDir->GetDirectory(AliQA::GetTaskName(task)) ; 
377  if (!subDir)
378    subDir = fDetectorDir->mkdir(AliQA::GetTaskName(task)) ;  
379  subDir->cd() ; 
380
381   TList * list = 0x0 ; 
382   
383   switch (task) { 
384   case AliQA::kRAWS: 
385         list = fRawsQAList ; 
386     break ; 
387
388   case AliQA::kHITS: 
389         list = fHitsQAList ; 
390     break ; 
391   
392   case AliQA::kSDIGITS: 
393         list = fSDigitsQAList ;
394     break ; 
395
396   case AliQA::kDIGITS: 
397         list = fDigitsQAList ;
398         break ; 
399           
400   case AliQA::kRECPOINTS: 
401         list = fRecPointsQAList ;
402         break ; 
403
404   case AliQA::kTRACKSEGMENTS: 
405     break ; 
406     
407   case AliQA::kRECPARTICLES: 
408     break ; 
409     
410   case AliQA::kESDS: 
411         list = fESDsQAList ;
412     break ; 
413   }  
414
415  TIter next(list) ;
416  TH1 * h ; 
417  while ( (h = dynamic_cast<TH1 *>(next())) )
418     h->Reset() ;  
419
420  StartOfDetectorCycle() ; 
421
422 }