]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliQADataMakerRec.cxx
49fd2c90b48caf44cf48ad9f16d3151005f25617
[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 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 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(0x0), 
44   fRawsQAList(0x0), 
45   fRecPointsQAList(0x0)
46 {
47   // ctor
48         fDetectorDirName = GetName() ; 
49 }
50
51 //____________________________________________________________________________ 
52 AliQADataMakerRec::AliQADataMakerRec(const AliQADataMakerRec& qadm) :
53     AliQADataMaker(qadm.GetName(), qadm.GetTitle()), 
54     fESDsQAList(qadm.fESDsQAList),
55         fRawsQAList(qadm.fRawsQAList),
56         fRecPointsQAList(qadm.fRecPointsQAList)
57   
58 {
59   //copy ctor
60         SetName(qadm.GetName()) ; 
61         SetTitle(qadm.GetTitle()) ; 
62         fDetectorDirName = GetName() ; 
63 }
64
65 //____________________________________________________________________________ 
66 AliQADataMakerRec::~AliQADataMakerRec()
67 {
68         //dtor: delete the TObjArray and thei content
69         if ( fESDsQAList ) {
70                 fESDsQAList->Delete() ;     
71                 delete fESDsQAList ;     
72         }
73         if ( fRawsQAList ) {
74                 fRawsQAList->Delete() ;
75                 delete fRawsQAList ;
76         }
77         if ( fRecPointsQAList ) {
78                 fRecPointsQAList->Delete() ; 
79                 delete fRecPointsQAList ; 
80         }
81 }
82
83 //__________________________________________________________________
84 AliQADataMakerRec& AliQADataMakerRec::operator = (const AliQADataMakerRec& qadm )
85 {
86   // Assignment operator.
87   this->~AliQADataMakerRec();
88   new(this) AliQADataMakerRec(qadm);
89   return *this;
90 }
91
92 //____________________________________________________________________________
93 void AliQADataMakerRec::EndOfCycle(AliQA::TASKINDEX_t task) 
94 {
95         // Finishes a cycle of QA data acquistion
96         
97         TObjArray * list = 0x0 ; 
98         
99         if ( task == AliQA::kRAWS )     
100                 list = fRawsQAList ; 
101         else if ( task == AliQA::kRECPOINTS ) 
102                 list = fRecPointsQAList ; 
103         else if ( task == AliQA::kESDS )
104                 list = fESDsQAList ; 
105
106         DefaultEndOfDetectorCycle(task) ;
107         EndOfDetectorCycle(task, list) ;
108         TDirectory * subDir = 0x0 ;
109         if (fDetectorDir) 
110                 subDir = fDetectorDir->GetDirectory(AliQA::GetTaskName(task)) ; 
111         if ( subDir ) {
112                 subDir->cd() ; 
113                 if (list) 
114                         list->Write() ;
115         }
116         Finish() ; 
117 }
118  
119 //____________________________________________________________________________
120 void AliQADataMakerRec::Exec(AliQA::TASKINDEX_t task, TObject * data) 
121
122   // creates the quality assurance data for the various tasks (Hits, SDigits, Digits, ESDs)
123         
124         if ( task == AliQA::kRAWS ) {
125                 AliDebug(1, "Processing Raws QA") ; 
126                 AliRawReader * rawReader = dynamic_cast<AliRawReader *>(data) ; 
127                 if (rawReader) 
128                         MakeRaws(rawReader) ;
129                 else
130                 AliError("Wrong data type") ;     
131         } else if ( task == AliQA::kRECPOINTS ) {
132                 AliDebug(1, "Processing RecPoints QA") ; 
133                 TTree * tree = dynamic_cast<TTree *>(data) ; 
134                 if (tree) {
135                         MakeRecPoints(tree) ; 
136                 } else {
137                         AliWarning("data are not a TTree") ; 
138                 }
139         } else if ( task == AliQA::kESDS ) {
140                 AliDebug(1, "Processing ESDs QA") ; 
141                 AliESDEvent * esd = dynamic_cast<AliESDEvent *>(data) ; 
142                 if (esd) 
143                         MakeESDs(esd) ;
144                 else 
145                         AliError("Wrong type of esd container") ; 
146         }  
147 }
148
149 //____________________________________________________________________________ 
150 TObjArray *  AliQADataMakerRec::Init(AliQA::TASKINDEX_t task, Int_t run, Int_t cycles)
151 {
152   // general intialisation
153         
154         TObjArray * rv = NULL ; 
155   
156         fRun = run ;
157         if (cycles > 0)
158                 SetCycle(cycles) ;  
159         
160         if ( task == AliQA::kRAWS ) {
161                 if (! fRawsQAList ) { 
162                         fRawsQAList = new TObjArray(100) ;       
163                         InitRaws() ;
164                 }
165                 rv = fRawsQAList ;
166         } else if ( task == AliQA::kRECPOINTS ) {
167                 if ( ! fRecPointsQAList ) {
168                         fRecPointsQAList = new TObjArray(100) ; 
169                         InitRecPoints() ;
170                 }
171                 rv = fRecPointsQAList ;
172         } else if ( task == AliQA::kESDS ) {
173                 if ( ! fESDsQAList ) {
174                         fESDsQAList = new TObjArray(100) ; 
175                         InitESDs() ;
176                 }
177                 rv = fESDsQAList ;
178         }
179         
180         return rv ; 
181 }
182
183 //____________________________________________________________________________ 
184 void AliQADataMakerRec::Init(AliQA::TASKINDEX_t task, TObjArray * list, Int_t run, Int_t cycles)
185 {
186   // Intialisation by passing the list of QA data booked elsewhere
187   
188         fRun = run ;
189         if (cycles > 0)
190                 SetCycle(cycles) ;  
191         
192         if ( task == AliQA::kRAWS ) {
193                 fRawsQAList = list ;     
194         } else if ( task == AliQA::kRECPOINTS ) {
195                 fRecPointsQAList = list ; 
196         } else if ( task == AliQA::kESDS ) {
197                 fESDsQAList = list ; 
198         }
199 }
200
201 //____________________________________________________________________________
202 void AliQADataMakerRec::StartOfCycle(AliQA::TASKINDEX_t task, const Bool_t sameCycle) 
203
204   // Finishes a cycle of QA data acquistion
205         if ( !sameCycle || fCurrentCycle == -1) {
206                 ResetCycle() ;
207                 if (fOutput) 
208                         fOutput->Close() ; 
209                 fOutput = AliQA::GetQADataFile(GetName(), fRun, fCurrentCycle) ;        
210         }       
211         AliInfo(Form(" Run %d Cycle %d task %s file %s", 
212                                  fRun, fCurrentCycle, AliQA::GetTaskName(task).Data(), fOutput->GetName() )) ;
213
214         fDetectorDir = fOutput->GetDirectory(GetDetectorDirName()) ; 
215         if (!fDetectorDir)
216                 fDetectorDir = fOutput->mkdir(GetDetectorDirName()) ; 
217
218         TDirectory * subDir = fDetectorDir->GetDirectory(AliQA::GetTaskName(task)) ; 
219         if (!subDir)
220                 subDir = fDetectorDir->mkdir(AliQA::GetTaskName(task)) ;  
221         subDir->cd() ; 
222
223         TObjArray * list = 0x0 ; 
224   
225   if ( task == AliQA::kRAWS ) 
226           list = fRawsQAList ; 
227   else if ( task == AliQA::kRECPOINTS)  
228           list = fRecPointsQAList ;
229   else if ( task == AliQA::kESDS )  
230           list = fESDsQAList ;
231         
232 // Should be the choice of detectors
233 //      TIter next(list) ;
234 //      TH1 * h ; 
235 //      while ( (h = dynamic_cast<TH1 *>(next())) )
236 //              h->Reset() ;  
237
238         StartOfDetectorCycle() ; 
239 }