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