]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - STEER/AliQADataMakerSim.cxx
temporary workaround for circular dependency libSTEERbase <-> libRAWDatabase, see...
[u/mrichter/AliRoot.git] / STEER / AliQADataMakerSim.cxx
... / ...
CommitLineData
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.
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#include <TClonesArray.h>
30
31// --- Standard library ---
32
33// --- AliRoot header files ---
34#include "AliLog.h"
35#include "AliQADataMakerSim.h"
36
37ClassImp(AliQADataMakerSim)
38
39//____________________________________________________________________________
40AliQADataMakerSim::AliQADataMakerSim(const char * name, const char * title) :
41 AliQADataMaker(name, title),
42 fDigitsQAList(0x0),
43 fHitsQAList(0x0),
44 fSDigitsQAList(0x0)
45{
46 // ctor
47 fDetectorDirName = GetName() ;
48}
49
50//____________________________________________________________________________
51AliQADataMakerSim::AliQADataMakerSim(const AliQADataMakerSim& qadm) :
52 AliQADataMaker(qadm.GetName(), qadm.GetTitle()),
53 fDigitsQAList(qadm.fDigitsQAList),
54 fHitsQAList(qadm.fHitsQAList),
55 fSDigitsQAList(qadm.fSDigitsQAList)
56{
57 //copy ctor
58 fDetectorDirName = GetName() ;
59}
60
61//____________________________________________________________________________
62AliQADataMakerSim::~AliQADataMakerSim()
63{
64 //dtor: delete the TObjArray and thei content
65 if ( fDigitsQAList ) {
66 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
67 if ( fDigitsQAList[specie]->IsOwner() )
68 fDigitsQAList[specie]->Delete() ;
69 }
70 delete[] fDigitsQAList ;
71 }
72 if ( fHitsQAList ) {
73 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
74 if ( fHitsQAList[specie]->IsOwner() )
75 fHitsQAList[specie]->Delete() ;
76 }
77 delete[] fHitsQAList ;
78 }
79 if ( fSDigitsQAList ) {
80 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
81 if ( fSDigitsQAList[specie]->IsOwner() )
82 fSDigitsQAList[specie]->Delete() ;
83 }
84 delete[] fSDigitsQAList ;
85 }
86}
87
88//__________________________________________________________________
89AliQADataMakerSim& AliQADataMakerSim::operator = (const AliQADataMakerSim& qadm )
90{
91 // Assignment operator.
92 this->~AliQADataMakerSim();
93 new(this) AliQADataMakerSim(qadm);
94 return *this;
95}
96
97//____________________________________________________________________________
98void AliQADataMakerSim::EndOfCycle()
99{
100 // Finishes a cycle of QA for all tasks
101 EndOfCycle(AliQA::kHITS) ;
102 EndOfCycle(AliQA::kSDIGITS) ;
103 EndOfCycle(AliQA::kDIGITS) ;
104 ResetCycle() ;
105}
106
107//____________________________________________________________________________
108void AliQADataMakerSim::EndOfCycle(AliQA::TASKINDEX_t task)
109{
110 // Finishes a cycle of QA data acquistion
111 TObjArray ** list = NULL ;
112
113 if ( task == AliQA::kHITS )
114 list = fHitsQAList ;
115 else if ( task == AliQA::kSDIGITS )
116 list = fSDigitsQAList ;
117 else if ( task == AliQA::kDIGITS )
118 list = fDigitsQAList ;
119
120 if ( ! list )
121 return ;
122 EndOfDetectorCycle(task, list) ;
123 TDirectory * subDir = NULL ;
124 if (fDetectorDir)
125 subDir = fDetectorDir->GetDirectory(AliQA::GetTaskName(task)) ;
126 if (subDir) {
127 subDir->cd() ;
128 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
129 TDirectory * eventSpecieDir = subDir->GetDirectory(AliRecoParam::GetEventSpecieName(specie)) ;
130 if (eventSpecieDir) {
131 eventSpecieDir->cd() ;
132 TIter next(list[specie]) ;
133 TObject * obj ;
134 while ( (obj = next()) ) {
135 if (!obj->TestBit(AliQA::GetExpertBit()))
136 obj->Write() ;
137 }
138 if (WriteExpert()) {
139 TDirectory * expertDir = eventSpecieDir->GetDirectory(AliQA::GetExpert()) ;
140 if ( expertDir ) {
141 expertDir->cd() ;
142 next.Reset() ;
143 while ( (obj = next()) ) {
144 if (!obj->TestBit(AliQA::GetExpertBit()))
145 continue ;
146 obj->Write() ;
147 }
148 }
149 }
150 }
151 }
152 fOutput->Save() ;
153 }
154 ResetCycle() ;
155}
156
157//____________________________________________________________________________
158void AliQADataMakerSim::Exec(AliQA::TASKINDEX_t task, TObject * data)
159{
160 // creates the quality assurance data for the various tasks (Hits, SDigits, Digits, ESDs)
161
162 if ( task == AliQA::kHITS ) {
163 AliDebug(1, "Processing Hits QA") ;
164 TClonesArray * arr = dynamic_cast<TClonesArray *>(data) ;
165 if (arr) {
166 MakeHits(arr) ;
167 } else {
168 TTree * tree = dynamic_cast<TTree *>(data) ;
169 if (tree) {
170 MakeHits(tree) ;
171 } else {
172 AliWarning("data are neither a TClonesArray nor a TTree") ;
173 }
174 }
175 } else if ( task == AliQA::kSDIGITS ) {
176 AliDebug(1, "Processing SDigits QA") ;
177 TClonesArray * arr = dynamic_cast<TClonesArray *>(data) ;
178 if (arr) {
179 MakeSDigits(arr) ;
180 } else {
181 TTree * tree = dynamic_cast<TTree *>(data) ;
182 if (tree) {
183 MakeSDigits(tree) ;
184 } else {
185 AliWarning("data are neither a TClonesArray nor a TTree") ;
186 }
187 }
188 } else if ( task == AliQA::kDIGITS ) {
189 AliDebug(1, "Processing Digits QA") ;
190 TClonesArray * arr = dynamic_cast<TClonesArray *>(data) ;
191 if (arr) {
192 MakeDigits(arr) ;
193 } else {
194 TTree * tree = dynamic_cast<TTree *>(data) ;
195 if (tree) {
196 MakeDigits(tree) ;
197 } else {
198 AliWarning("data are neither a TClonesArray nor a TTree") ;
199 }
200 }
201 }
202}
203
204//____________________________________________________________________________
205TObjArray ** AliQADataMakerSim::Init(AliQA::TASKINDEX_t task, Int_t cycles)
206{
207 // general intialisation
208
209 if (cycles > 0)
210 SetCycle(cycles) ;
211 TObjArray ** rv = NULL ;
212 if ( task == AliQA::kHITS ) {
213 if ( ! fHitsQAList ) {
214 fHitsQAList = new TObjArray *[AliRecoParam::kNSpecies] ;
215 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
216 fHitsQAList[specie] = new TObjArray(100) ;
217 fHitsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQA::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ;
218 }
219 InitHits() ;
220 }
221 rv = fHitsQAList ;
222 } else if ( task == AliQA::kSDIGITS ) {
223 if ( ! fSDigitsQAList ) {
224 fSDigitsQAList = new TObjArray *[AliRecoParam::kNSpecies] ;
225 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
226 fSDigitsQAList[specie] = new TObjArray(100) ;
227 fSDigitsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQA::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ;
228 }
229 InitSDigits() ;
230 }
231 rv = fSDigitsQAList ;
232 } else if ( task == AliQA::kDIGITS ) {
233 if ( ! fDigitsQAList ) {
234 fDigitsQAList = new TObjArray *[AliRecoParam::kNSpecies] ;
235 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
236 fDigitsQAList[specie] = new TObjArray(100) ;
237 fDigitsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQA::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ;
238 }
239 InitDigits() ;
240 }
241 rv = fDigitsQAList ;
242 }
243
244 return rv ;
245}
246
247//____________________________________________________________________________
248void AliQADataMakerSim::Init(AliQA::TASKINDEX_t task, TObjArray ** list, Int_t run, Int_t cycles)
249{
250 // Intialisation by passing the list of QA data booked elsewhere
251
252 fRun = run ;
253 if (cycles > 0)
254 SetCycle(cycles) ;
255
256 if ( task == AliQA::kHITS ) {
257 fHitsQAList = list ;
258 } else if ( task == AliQA::kSDIGITS) {
259 fSDigitsQAList = list ;
260 } else if ( task == AliQA::kDIGITS ) {
261 fDigitsQAList = list ;
262 }
263}
264
265//____________________________________________________________________________
266void AliQADataMakerSim::StartOfCycle(Int_t run)
267{
268 // Finishes a cycle of QA for all tasks
269 Bool_t samecycle = kFALSE ;
270 StartOfCycle(AliQA::kHITS, run, samecycle) ;
271 samecycle = kTRUE ;
272 StartOfCycle(AliQA::kSDIGITS, run, samecycle) ;
273 StartOfCycle(AliQA::kDIGITS, run, samecycle) ;
274}
275
276//____________________________________________________________________________
277void AliQADataMakerSim::StartOfCycle(AliQA::TASKINDEX_t task, Int_t run, const Bool_t sameCycle)
278{
279 // Finishes a cycle of QA data acquistion
280 if ( run > 0 )
281 fRun = run ;
282 if ( !sameCycle || fCurrentCycle == -1) {
283 ResetCycle() ;
284 if (fOutput)
285 fOutput->Close() ;
286 fOutput = AliQA::GetQADataFile(GetName(), fRun) ;
287 }
288
289 AliInfo(Form(" Run %d Cycle %d task %s file %s",
290 fRun, fCurrentCycle, AliQA::GetTaskName(task).Data(), fOutput->GetName() )) ;
291
292 fDetectorDir = fOutput->GetDirectory(GetDetectorDirName()) ;
293 if (!fDetectorDir)
294 fDetectorDir = fOutput->mkdir(GetDetectorDirName()) ;
295
296 TDirectory * subDir = fDetectorDir->GetDirectory(AliQA::GetTaskName(task)) ;
297 if (!subDir)
298 subDir = fDetectorDir->mkdir(AliQA::GetTaskName(task)) ;
299
300 for ( Int_t index = AliRecoParam::kDefault ; index < AliRecoParam::kNSpecies ; index++ ) {
301 TDirectory * eventSpecieDir = subDir->GetDirectory(AliRecoParam::GetEventSpecieName(index)) ;
302 if (!eventSpecieDir)
303 eventSpecieDir = subDir->mkdir(AliRecoParam::GetEventSpecieName(index)) ;
304 TDirectory * expertDir = eventSpecieDir->GetDirectory(AliQA::GetExpert()) ;
305 if (!expertDir)
306 expertDir = eventSpecieDir->mkdir(AliQA::GetExpert()) ;
307 }
308 StartOfDetectorCycle() ;
309}