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