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