Coding conventions
[u/mrichter/AliRoot.git] / STEER / AliQADataMaker.cxx
CommitLineData
421ab0fb 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 <TSystem.h>
28#include <TFile.h>
6c18591a 29#include <TList.h>
d76c31f4 30#include <TTree.h>
d5cf81bd 31#include <TClonesArray.h>
421ab0fb 32
33// --- Standard library ---
34
35// --- AliRoot header files ---
36#include "AliLog.h"
2e42b4d4 37#include "AliQADataMaker.h"
38#include "AliQAChecker.h"
d76c31f4 39#include "AliESDEvent.h"
d5cf81bd 40#include "AliRawReader.h"
421ab0fb 41
2e42b4d4 42ClassImp(AliQADataMaker)
312e6f8d 43
421ab0fb 44//____________________________________________________________________________
2e42b4d4 45AliQADataMaker::AliQADataMaker(const char * name, const char * title) :
421ab0fb 46 TNamed(name, title),
47 fOutput(0x0),
6c18591a 48 fDetectorDir(0x0),
312e6f8d 49 fDetectorDirName(""),
6c18591a 50 fDigitsQAList(0x0),
51 fESDsQAList(0x0),
52 fHitsQAList(0x0),
53 fRawsQAList(0x0),
54 fRecPointsQAList(0x0),
5b188f2f 55 fSDigitsQAList(0x0),
56 fCurrentCycle(-1),
57 fCycle(9999999),
58 fCycleCounter(0),
59 fRun(0)
421ab0fb 60{
61 // ctor
421ab0fb 62 fDetectorDirName = GetName() ;
63}
64
65//____________________________________________________________________________
2e42b4d4 66AliQADataMaker::AliQADataMaker(const AliQADataMaker& qadm) :
421ab0fb 67 TNamed(qadm.GetName(), qadm.GetTitle()),
68 fOutput(qadm.fOutput),
6c18591a 69 fDetectorDir(qadm.fDetectorDir),
312e6f8d 70 fDetectorDirName(qadm.fDetectorDirName),
6c18591a 71 fDigitsQAList(qadm.fDigitsQAList),
72 fESDsQAList(qadm.fESDsQAList),
73 fHitsQAList(qadm.fHitsQAList),
74 fRawsQAList(qadm.fRecPointsQAList),
75 fRecPointsQAList(qadm.fRecPointsQAList),
5b188f2f 76 fSDigitsQAList(qadm.fSDigitsQAList),
77 fCurrentCycle(qadm.fCurrentCycle),
78 fCycle(qadm.fCycle),
79 fCycleCounter(qadm.fCycleCounter),
a4976ef3 80 fRun(qadm.fRun)
421ab0fb 81{
82 //copy ctor
83 fDetectorDirName = GetName() ;
84}
85
86//__________________________________________________________________
2e42b4d4 87AliQADataMaker& AliQADataMaker::operator = (const AliQADataMaker& qadm )
421ab0fb 88{
312e6f8d 89 // Assignment operator.
2e42b4d4 90 this->~AliQADataMaker();
91 new(this) AliQADataMaker(qadm);
421ab0fb 92 return *this;
93}
94
95//____________________________________________________________________________
2e42b4d4 96void AliQADataMaker::EndOfCycle(AliQA::TASKINDEX task)
5b188f2f 97{
98 // Finishes a cycle of QA data acquistion
a4976ef3 99
100 TList * list = 0x0 ;
101
5b188f2f 102 switch (task) {
103
2e42b4d4 104 case AliQA::kRAWS:
a4976ef3 105 list = fRawsQAList ;
5b188f2f 106 break ;
107
2e42b4d4 108 case AliQA::kHITS:
a4976ef3 109 list = fHitsQAList ;
5b188f2f 110 break ;
111
2e42b4d4 112 case AliQA::kSDIGITS:
a4976ef3 113 list = fSDigitsQAList ;
5b188f2f 114 break ;
115
2e42b4d4 116 case AliQA::kDIGITS:
a4976ef3 117 list = fDigitsQAList ;
5b188f2f 118 break ;
119
2e42b4d4 120 case AliQA::kRECPOINTS:
a4976ef3 121 list = fRecPointsQAList ;
5b188f2f 122 break ;
123
2e42b4d4 124 case AliQA::kTRACKSEGMENTS:
5b188f2f 125 break ;
126
2e42b4d4 127 case AliQA::kRECPARTICLES:
5b188f2f 128 break ;
129
2e42b4d4 130 case AliQA::kESDS:
a4976ef3 131 list = fESDsQAList ;
5b188f2f 132 break ;
133 }
a4976ef3 134
135 EndOfDetectorCycle(task, list) ;
2e42b4d4 136 TDirectory * subDir = fDetectorDir->GetDirectory(AliQA::GetTaskName(task)) ;
a4976ef3 137 subDir->cd() ;
138 list->Write() ;
5b188f2f 139}
140
141//____________________________________________________________________________
2e42b4d4 142void AliQADataMaker::Exec(AliQA::TASKINDEX task, TObject * data)
421ab0fb 143{
144 // creates the quality assurance data for the various tasks (Hits, SDigits, Digits, ESDs)
5b188f2f 145
312e6f8d 146 switch (task) {
6c18591a 147
312e6f8d 148 case AliQA::kRAWS:
149 {
150 AliInfo("Processing Raws QA") ;
151 AliRawReader * rawReader = dynamic_cast<AliRawReader *>(data) ;
152 if (rawReader)
153 MakeRaws(rawReader) ;
154 else
155 AliError("Wrong data type") ;
156 break ;
157 }
158 case AliQA::kHITS:
159 {
160 AliInfo("Processing Hits QA") ;
161 TClonesArray * arr = dynamic_cast<TClonesArray *>(data) ;
162 if (arr) {
163 MakeHits(arr) ;
164 } else {
165 TTree * tree = dynamic_cast<TTree *>(data) ;
166 if (tree) {
167 MakeHits(tree) ;
168 } else {
169 AliWarning("data are neither a TClonesArray nor a TTree") ;
170 }
171 }
172 break ;
173 }
174 case AliQA::kSDIGITS:
175 {
176 AliInfo("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 break ;
189 }
190 case AliQA::kDIGITS:
191 {
192 TClonesArray * arr = dynamic_cast<TClonesArray *>(data) ;
193 if (arr) {
194 MakeDigits(arr) ;
195 } else {
196 TTree * tree = dynamic_cast<TTree *>(data) ;
197 if (tree) {
198 MakeDigits(tree) ;
199 } else {
200 AliWarning("data are neither a TClonesArray nor a TTree") ;
201 }
202 }
203 break ;
204 }
205 case AliQA::kRECPOINTS:
206 {
207 AliInfo("Processing RecPoints QA") ;
208 TTree * tree = dynamic_cast<TTree *>(data) ;
209 if (tree) {
210 MakeRecPoints(tree) ;
211 } else {
212 AliWarning("data are not a TTree") ;
213 }
214 break ;
215 }
216 case AliQA::kTRACKSEGMENTS:
217 AliInfo("Processing Track Segments QA: not existing anymore") ;
218 // MakeTrackSegments(ts) ;
219 break ;
421ab0fb 220
312e6f8d 221 case AliQA::kRECPARTICLES:
222 AliInfo("Processing RecParticles QA: not existing anymore") ;
223 // MakeRecParticles(recpar) ;
224 break ;
225 case AliQA::kESDS:
226 {
227 AliInfo("Processing ESDs QA") ;
228 AliESDEvent * esd = dynamic_cast<AliESDEvent *>(data) ;
229 if (esd)
230 MakeESDs(esd) ;
231 else
232 AliError("Wrong type of esd container") ;
233 break ;
234 }
235 }
421ab0fb 236}
237
238//____________________________________________________________________________
2e42b4d4 239void AliQADataMaker::Finish(AliQA::TASKINDEX) const
421ab0fb 240{
5b188f2f 241 // write to the output File
d62f9368 242 fOutput->Close() ;
421ab0fb 243}
244
245//____________________________________________________________________________
2e42b4d4 246TList * AliQADataMaker::Init(AliQA::TASKINDEX task, Int_t run, Int_t cycles)
421ab0fb 247{
248 // general intialisation
421ab0fb 249
5b188f2f 250 fRun = run ;
251 if (cycles > 0)
252 SetCycle(cycles) ;
253
d62f9368 254 switch (task) {
2e42b4d4 255 case AliQA::kRAWS:
986931a6 256 {
6c18591a 257 fRawsQAList = new TList() ;
258 InitRaws() ;
259 return fRawsQAList ;
260 break ;
986931a6 261 }
2e42b4d4 262 case AliQA::kHITS:
986931a6 263 {
6c18591a 264 fHitsQAList = new TList() ;
421ab0fb 265 InitHits() ;
6c18591a 266 return fHitsQAList ;
421ab0fb 267 break ;
986931a6 268 }
2e42b4d4 269 case AliQA::kSDIGITS:
986931a6 270 {
6c18591a 271 fSDigitsQAList = new TList() ;
421ab0fb 272 InitSDigits() ;
6c18591a 273 return fSDigitsQAList ;
421ab0fb 274 break ;
986931a6 275 }
2e42b4d4 276 case AliQA::kDIGITS:
986931a6 277 {
6c18591a 278 fDigitsQAList = new TList();
421ab0fb 279 InitDigits() ;
6c18591a 280 return fDigitsQAList ;
421ab0fb 281 break ;
986931a6 282 }
2e42b4d4 283 case AliQA::kRECPOINTS:
986931a6 284 {
312e6f8d 285 fRecPointsQAList = new TList() ;
421ab0fb 286 InitRecPoints() ;
6c18591a 287 return fRecPointsQAList ;
421ab0fb 288 break ;
986931a6 289 }
2e42b4d4 290 case AliQA::kTRACKSEGMENTS:
6c18591a 291// InitTrackSegments() ;
421ab0fb 292 break ;
293
2e42b4d4 294 case AliQA::kRECPARTICLES:
6c18591a 295// InitRecParticles() ;
421ab0fb 296 break ;
297
2e42b4d4 298 case AliQA::kESDS:
986931a6 299 {
300 fESDsQAList = new TList() ;
6c18591a 301 InitESDs() ;
302 return fRecPointsQAList ;
421ab0fb 303 break ;
986931a6 304 }
421ab0fb 305 }
6c18591a 306 return 0x0 ;
421ab0fb 307}
5b188f2f 308
312e6f8d 309//____________________________________________________________________________
310void AliQADataMaker::Init(AliQA::TASKINDEX task, TList * list, Int_t run, Int_t cycles)
311{
312 // Intialisation by passing the list of QA data booked elsewhere
313
314 fRun = run ;
315 if (cycles > 0)
316 SetCycle(cycles) ;
317
318 switch (task) {
319 case AliQA::kRAWS:
320 {
321 fRawsQAList = list ;
322 break ;
323 }
324 case AliQA::kHITS:
325 {
326 fHitsQAList = list ;
327 break ;
328 }
329 case AliQA::kSDIGITS:
330 {
331 fSDigitsQAList = list ;
332 break ;
333 }
334 case AliQA::kDIGITS:
335 {
336 fDigitsQAList = list ;
337 break ;
338 }
339 case AliQA::kRECPOINTS:
340 {
341 fRecPointsQAList = list ;
342 break ;
343 }
344 case AliQA::kTRACKSEGMENTS:
345 break ;
346
347 case AliQA::kRECPARTICLES:
348 break ;
349
350 case AliQA::kESDS:
351 {
352 fESDsQAList = list ;
353 break ;
354 }
355 }
356}
357
5b188f2f 358//____________________________________________________________________________
2e42b4d4 359void AliQADataMaker::StartOfCycle(AliQA::TASKINDEX task, Option_t * sameCycle)
5b188f2f 360{
361 // Finishes a cycle of QA data acquistion
362
312e6f8d 363 if ( (strcmp(sameCycle, "new") == 0) ) {
364 ResetCycle() ;
365 if (fOutput)
366 fOutput->Close() ;
367 fOutput = AliQA::GetQADMOutFile(GetName(), fRun, fCurrentCycle) ;
368 }
5b188f2f 369 AliInfo(Form(" Run %d Cycle %d task %s file %s",
2e42b4d4 370 fRun, fCurrentCycle, AliQA::GetTaskName(task).Data(), fOutput->GetName() )) ;
5b188f2f 371
372 fDetectorDir = fOutput->GetDirectory(GetDetectorDirName()) ;
373 if (!fDetectorDir)
374 fDetectorDir = fOutput->mkdir(GetDetectorDirName()) ;
375
2e42b4d4 376 TDirectory * subDir = fDetectorDir->GetDirectory(AliQA::GetTaskName(task)) ;
5b188f2f 377 if (!subDir)
2e42b4d4 378 subDir = fDetectorDir->mkdir(AliQA::GetTaskName(task)) ;
5b188f2f 379 subDir->cd() ;
380
381 TList * list = 0x0 ;
382
383 switch (task) {
2e42b4d4 384 case AliQA::kRAWS:
5b188f2f 385 list = fRawsQAList ;
386 break ;
387
2e42b4d4 388 case AliQA::kHITS:
5b188f2f 389 list = fHitsQAList ;
390 break ;
391
2e42b4d4 392 case AliQA::kSDIGITS:
5b188f2f 393 list = fSDigitsQAList ;
394 break ;
395
2e42b4d4 396 case AliQA::kDIGITS:
5b188f2f 397 list = fDigitsQAList ;
398 break ;
399
2e42b4d4 400 case AliQA::kRECPOINTS:
5b188f2f 401 list = fRecPointsQAList ;
402 break ;
403
2e42b4d4 404 case AliQA::kTRACKSEGMENTS:
5b188f2f 405 break ;
406
2e42b4d4 407 case AliQA::kRECPARTICLES:
5b188f2f 408 break ;
409
2e42b4d4 410 case AliQA::kESDS:
5b188f2f 411 list = fESDsQAList ;
412 break ;
413 }
414
415 TIter next(list) ;
416 TH1 * h ;
417 while ( (h = dynamic_cast<TH1 *>(next())) )
418 h->Reset() ;
419
420 StartOfDetectorCycle() ;
421
422}