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