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