]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliQADataMakerRec.cxx
expert QA data are written on demand only. The cycles array has been extended to...
[u/mrichter/AliRoot.git] / STEER / AliQADataMakerRec.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 notifce   *
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 for Reconstruction
22 //  All data must be mergeable objects.
23 //  Y. Schutz CERN July 2007
24 //
25
26 // --- ROOT system ---
27 #include <TFile.h>
28 #include <TTree.h>
29
30 // --- Standard library ---
31
32 // --- AliRoot header files ---
33 #include "AliLog.h"
34 #include "AliQADataMakerRec.h"
35 #include "AliESDEvent.h"
36 #include "AliRawReader.h"
37
38 ClassImp(AliQADataMakerRec)
39              
40 //____________________________________________________________________________ 
41 AliQADataMakerRec::AliQADataMakerRec(const char * name, const char * title) : 
42   AliQADataMaker(name, title), 
43   fESDsQAList(NULL), 
44   fRawsQAList(NULL), 
45   fRecPointsQAList(NULL),
46   fObject(NULL), 
47   fRecoParam(NULL) 
48 {
49   // ctor
50         fDetectorDirName = GetName() ; 
51 }
52
53 //____________________________________________________________________________ 
54 AliQADataMakerRec::AliQADataMakerRec(const AliQADataMakerRec& qadm) :
55   AliQADataMaker(qadm.GetName(), qadm.GetTitle()), 
56   fESDsQAList(qadm.fESDsQAList),
57   fRawsQAList(qadm.fRawsQAList),
58   fRecPointsQAList(qadm.fRecPointsQAList),
59   fObject(qadm.fObject),  
60   fRecoParam(qadm.fRecoParam) 
61 {
62   //copy ctor
63         SetName(qadm.GetName()) ; 
64         SetTitle(qadm.GetTitle()) ; 
65         fDetectorDirName = GetName() ; 
66 }
67
68 //____________________________________________________________________________ 
69 AliQADataMakerRec::~AliQADataMakerRec()
70 {
71         //dtor: delete the TObjArray and thei content
72         if ( fESDsQAList ) {
73                 if ( fESDsQAList->IsOwner() ) 
74                         fESDsQAList->Delete() ;     
75                 delete fESDsQAList ;     
76         }
77         if ( fRawsQAList ) {
78                 if ( fRawsQAList->IsOwner() ) 
79                         fRawsQAList->Delete() ;
80                 delete fRawsQAList ;
81         }
82         if ( fRecPointsQAList ) {
83                 if ( fRecPointsQAList->IsOwner() ) 
84                         fRecPointsQAList->Delete() ; 
85                 delete fRecPointsQAList ; 
86         }
87 }
88
89 //__________________________________________________________________
90 AliQADataMakerRec& AliQADataMakerRec::operator = (const AliQADataMakerRec& qadm )
91 {
92   // Assignment operator.
93   this->~AliQADataMakerRec();
94   new(this) AliQADataMakerRec(qadm);
95   return *this;
96 }
97
98 //____________________________________________________________________________
99 void AliQADataMakerRec::EndOfCycle() 
100 {
101   // Finishes a cycle of QA for all the tasks
102   EndOfCycle(AliQA::kRAWS) ; 
103   EndOfCycle(AliQA::kRECPOINTS) ; 
104   EndOfCycle(AliQA::kESDS) ; 
105   ResetCycle() ; 
106 }
107
108 //____________________________________________________________________________
109 void AliQADataMakerRec::EndOfCycle(AliQA::TASKINDEX_t task) 
110 {
111         // Finishes a cycle of QA 
112         
113         TObjArray * list = NULL ; 
114         
115         if ( task == AliQA::kRAWS )     
116                 list = fRawsQAList ; 
117         else if ( task == AliQA::kRECPOINTS ) 
118                 list = fRecPointsQAList ; 
119         else if ( task == AliQA::kESDS )
120                 list = fESDsQAList ; 
121
122  
123         if ( ! list && ! fObject ) 
124     return ; 
125   //DefaultEndOfDetectorCycle(task) ;
126         EndOfDetectorCycle(task, list) ;
127         TDirectory * subDir = NULL ;
128         if (fDetectorDir) 
129                 subDir = fDetectorDir->GetDirectory(AliQA::GetTaskName(task)) ; 
130         if ( subDir ) {
131                 subDir->cd() ; 
132                 if (list) {
133       TIter next(list) ; 
134       TH1 * obj ; 
135       while ( (obj = dynamic_cast<TH1 *>(next())) ) {
136         TString name(obj->GetTitle()) ;
137         if (!name.Contains(AliQA::GetExpert())) {
138           obj->Write() ;
139         }
140       }
141       if (WriteExpert()) {
142         TDirectory * expertDir = subDir->GetDirectory(AliQA::GetExpert()) ; 
143         if ( expertDir ) { // Write only if requested
144           expertDir->cd() ;
145           next.Reset() ; 
146           while ( (obj = dynamic_cast<TH1 *>(next())) ) {
147             TString name(obj->GetTitle()) ;
148             if (!name.Contains(AliQA::GetExpert())) 
149               continue ; 
150             name.ReplaceAll(AliQA::GetExpert(), "") ;
151             obj->SetTitle(name) ; 
152           obj->Write() ;
153           }      
154         }
155       }
156     }
157     if (fObject && GetName() == AliQA::kCORR) {
158       subDir->cd() ; 
159       fObject->Write() ; 
160     }
161         }
162 }
163  
164 //____________________________________________________________________________
165 void AliQADataMakerRec::Exec(AliQA::TASKINDEX_t task, TObject * data) 
166
167   // creates the quality assurance data for the various tasks (Hits, SDigits, Digits, ESDs)
168         
169         if ( task == AliQA::kRAWS ) {
170                 AliDebug(1, "Processing Raws QA") ; 
171                 AliRawReader * rawReader = dynamic_cast<AliRawReader *>(data) ; 
172                 if (rawReader) 
173                         MakeRaws(rawReader) ;
174                 else
175                 AliInfo("Raw data are not processed") ;     
176         } else if ( task == AliQA::kRECPOINTS ) {
177                 AliDebug(1, "Processing RecPoints QA") ; 
178                 TTree * tree = dynamic_cast<TTree *>(data) ; 
179                 if (tree) {
180                         MakeRecPoints(tree) ; 
181                 } else {
182                         AliWarning("data are not a TTree") ; 
183                 }
184         } else if ( task == AliQA::kESDS ) {
185                 AliDebug(1, "Processing ESDs QA") ; 
186                 AliESDEvent * esd = dynamic_cast<AliESDEvent *>(data) ; 
187                 if (esd) 
188                         MakeESDs(esd) ;
189                 else 
190                         AliError("Wrong type of esd container") ; 
191         }  
192 }
193
194 //____________________________________________________________________________ 
195 TObjArray *  AliQADataMakerRec::Init(AliQA::TASKINDEX_t task, Int_t cycles)
196 {
197   // general intialisation
198         
199         TObjArray * rv = NULL ; 
200   
201         if (cycles > 0)
202                 SetCycle(cycles) ;  
203         
204         if ( task == AliQA::kRAWS ) {
205                 if (! fRawsQAList ) { 
206                         fRawsQAList = new TObjArray(100) ;       
207       fRawsQAList->SetName(Form("%s_%s", GetName(), AliQA::GetTaskName(task).Data())) ; 
208                         InitRaws() ;
209                 }
210                 rv = fRawsQAList ;
211         } else if ( task == AliQA::kRECPOINTS ) {
212                 if ( ! fRecPointsQAList ) {
213                         fRecPointsQAList = new TObjArray(100) ; 
214       fRecPointsQAList->SetName(Form("%s_%s", GetName(), AliQA::GetTaskName(task).Data())) ; 
215                         InitRecPoints() ;
216                 }
217                 rv = fRecPointsQAList ;
218         } else if ( task == AliQA::kESDS ) {
219                 if ( ! fESDsQAList ) {
220                         fESDsQAList = new TObjArray(100) ;
221       fESDsQAList->SetName(Form("%s_%s", GetName(), AliQA::GetTaskName(task).Data())) ; 
222                         InitESDs() ;
223                 }
224                 rv = fESDsQAList ;
225         }
226         
227         return rv ; 
228 }
229
230 //____________________________________________________________________________ 
231 void AliQADataMakerRec::Init(AliQA::TASKINDEX_t task, TObjArray * list, Int_t run, Int_t cycles)
232 {
233   // Intialisation by passing the list of QA data booked elsewhere
234   
235         fRun = run ;
236         if (cycles > 0)
237                 SetCycle(cycles) ;  
238         
239         if ( task == AliQA::kRAWS ) {
240                 fRawsQAList = list ;     
241         } else if ( task == AliQA::kRECPOINTS ) {
242                 fRecPointsQAList = list ; 
243         } else if ( task == AliQA::kESDS ) {
244                 fESDsQAList = list ; 
245         }
246 }
247
248 //____________________________________________________________________________
249 void AliQADataMakerRec::StartOfCycle(Int_t run) 
250 {
251   // Finishes a cycle of QA for all the tasks
252   Bool_t samecycle = kFALSE ; 
253   StartOfCycle(AliQA::kRAWS,      run, samecycle) ;
254   samecycle = kTRUE ; 
255   StartOfCycle(AliQA::kRECPOINTS, run, samecycle) ; 
256   StartOfCycle(AliQA::kESDS,      run, samecycle) ; 
257 }
258
259 //____________________________________________________________________________
260 void AliQADataMakerRec::StartOfCycle(AliQA::TASKINDEX_t task, Int_t run, const Bool_t sameCycle) 
261
262   // Finishes a cycle of QA data acquistion
263   if ( run > 0 ) 
264     fRun = run ; 
265         if ( !sameCycle || fCurrentCycle == -1) {
266                 ResetCycle() ;
267                 if (fOutput) 
268                         fOutput->Close() ; 
269                 fOutput = AliQA::GetQADataFile(GetName(), fRun) ;       
270         }       
271         AliInfo(Form(" Run %d Cycle %d task %s file %s", 
272                                  fRun, fCurrentCycle, AliQA::GetTaskName(task).Data(), fOutput->GetName() )) ;
273
274         fDetectorDir = fOutput->GetDirectory(GetDetectorDirName()) ; 
275         if (!fDetectorDir)
276                 fDetectorDir = fOutput->mkdir(GetDetectorDirName()) ; 
277
278         TDirectory * subDir = fDetectorDir->GetDirectory(AliQA::GetTaskName(task)) ; 
279         if (!subDir)
280                 subDir = fDetectorDir->mkdir(AliQA::GetTaskName(task)) ;  
281  
282   TDirectory * expertDir = subDir->GetDirectory(AliQA::GetExpert()) ; 
283   if (!expertDir)
284     expertDir = subDir->mkdir(AliQA::GetExpert()) ; 
285   
286         subDir->cd() ; 
287   
288
289         StartOfDetectorCycle() ; 
290 }