Put all the naming conventions into AlIQA
[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),
4ecde5fc 74 fRawsQAList(qadm.fRawsQAList),
6c18591a 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
5b188f2f 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
421ab0fb 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 {
808b7099 150 AliDebug(1, "Processing Raws QA") ;
312e6f8d 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 {
808b7099 160 AliDebug(1, "Processing Hits QA") ;
312e6f8d 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 {
808b7099 176 AliDebug(1, "Processing SDigits QA") ;
312e6f8d 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 {
808b7099 192 AliDebug(1, "Processing Digits QA") ;
312e6f8d 193 TClonesArray * arr = dynamic_cast<TClonesArray *>(data) ;
194 if (arr) {
195 MakeDigits(arr) ;
196 } else {
197 TTree * tree = dynamic_cast<TTree *>(data) ;
198 if (tree) {
199 MakeDigits(tree) ;
200 } else {
201 AliWarning("data are neither a TClonesArray nor a TTree") ;
202 }
203 }
204 break ;
205 }
206 case AliQA::kRECPOINTS:
207 {
808b7099 208 AliDebug(1, "Processing RecPoints QA") ;
312e6f8d 209 TTree * tree = dynamic_cast<TTree *>(data) ;
210 if (tree) {
211 MakeRecPoints(tree) ;
212 } else {
213 AliWarning("data are not a TTree") ;
214 }
215 break ;
216 }
217 case AliQA::kTRACKSEGMENTS:
218 AliInfo("Processing Track Segments QA: not existing anymore") ;
219 // MakeTrackSegments(ts) ;
220 break ;
421ab0fb 221
312e6f8d 222 case AliQA::kRECPARTICLES:
223 AliInfo("Processing RecParticles QA: not existing anymore") ;
224 // MakeRecParticles(recpar) ;
225 break ;
226 case AliQA::kESDS:
227 {
808b7099 228 AliDebug(1, "Processing ESDs QA") ;
312e6f8d 229 AliESDEvent * esd = dynamic_cast<AliESDEvent *>(data) ;
230 if (esd)
231 MakeESDs(esd) ;
232 else
233 AliError("Wrong type of esd container") ;
234 break ;
235 }
236 }
421ab0fb 237}
238
239//____________________________________________________________________________
c65c502a 240void AliQADataMaker::Finish() const
421ab0fb 241{
5b188f2f 242 // write to the output File
d62f9368 243 fOutput->Close() ;
421ab0fb 244}
245
246//____________________________________________________________________________
2e42b4d4 247TList * AliQADataMaker::Init(AliQA::TASKINDEX task, Int_t run, Int_t cycles)
421ab0fb 248{
249 // general intialisation
421ab0fb 250
5b188f2f 251 fRun = run ;
252 if (cycles > 0)
253 SetCycle(cycles) ;
254
d62f9368 255 switch (task) {
2e42b4d4 256 case AliQA::kRAWS:
986931a6 257 {
6c18591a 258 fRawsQAList = new TList() ;
259 InitRaws() ;
260 return fRawsQAList ;
261 break ;
986931a6 262 }
2e42b4d4 263 case AliQA::kHITS:
986931a6 264 {
6c18591a 265 fHitsQAList = new TList() ;
421ab0fb 266 InitHits() ;
6c18591a 267 return fHitsQAList ;
421ab0fb 268 break ;
986931a6 269 }
2e42b4d4 270 case AliQA::kSDIGITS:
986931a6 271 {
6c18591a 272 fSDigitsQAList = new TList() ;
421ab0fb 273 InitSDigits() ;
6c18591a 274 return fSDigitsQAList ;
421ab0fb 275 break ;
986931a6 276 }
2e42b4d4 277 case AliQA::kDIGITS:
986931a6 278 {
6c18591a 279 fDigitsQAList = new TList();
421ab0fb 280 InitDigits() ;
6c18591a 281 return fDigitsQAList ;
421ab0fb 282 break ;
986931a6 283 }
2e42b4d4 284 case AliQA::kRECPOINTS:
986931a6 285 {
312e6f8d 286 fRecPointsQAList = new TList() ;
421ab0fb 287 InitRecPoints() ;
6c18591a 288 return fRecPointsQAList ;
421ab0fb 289 break ;
986931a6 290 }
2e42b4d4 291 case AliQA::kTRACKSEGMENTS:
6c18591a 292// InitTrackSegments() ;
421ab0fb 293 break ;
294
2e42b4d4 295 case AliQA::kRECPARTICLES:
6c18591a 296// InitRecParticles() ;
421ab0fb 297 break ;
298
2e42b4d4 299 case AliQA::kESDS:
986931a6 300 {
301 fESDsQAList = new TList() ;
6c18591a 302 InitESDs() ;
303 return fRecPointsQAList ;
421ab0fb 304 break ;
986931a6 305 }
421ab0fb 306 }
6c18591a 307 return 0x0 ;
421ab0fb 308}
5b188f2f 309
312e6f8d 310//____________________________________________________________________________
311void AliQADataMaker::Init(AliQA::TASKINDEX task, TList * list, Int_t run, Int_t cycles)
312{
313 // Intialisation by passing the list of QA data booked elsewhere
314
315 fRun = run ;
316 if (cycles > 0)
317 SetCycle(cycles) ;
318
319 switch (task) {
320 case AliQA::kRAWS:
321 {
322 fRawsQAList = list ;
323 break ;
324 }
325 case AliQA::kHITS:
326 {
327 fHitsQAList = list ;
328 break ;
329 }
330 case AliQA::kSDIGITS:
331 {
332 fSDigitsQAList = list ;
333 break ;
334 }
335 case AliQA::kDIGITS:
336 {
337 fDigitsQAList = list ;
338 break ;
339 }
340 case AliQA::kRECPOINTS:
341 {
342 fRecPointsQAList = list ;
343 break ;
344 }
345 case AliQA::kTRACKSEGMENTS:
346 break ;
347
348 case AliQA::kRECPARTICLES:
349 break ;
350
351 case AliQA::kESDS:
352 {
353 fESDsQAList = list ;
354 break ;
355 }
356 }
357}
358
5b188f2f 359//____________________________________________________________________________
c65c502a 360void AliQADataMaker::Reset()
361{
362 // Resets defaut value of data members
363 fCurrentCycle = -1 ;
364 fCycleCounter = 0 ;
365}
366
367//____________________________________________________________________________
368void AliQADataMaker::StartOfCycle(AliQA::TASKINDEX task, const Bool_t sameCycle)
5b188f2f 369{
370 // Finishes a cycle of QA data acquistion
371
c65c502a 372 if ( !sameCycle ) {
312e6f8d 373 ResetCycle() ;
374 if (fOutput)
375 fOutput->Close() ;
376 fOutput = AliQA::GetQADMOutFile(GetName(), fRun, fCurrentCycle) ;
377 }
5b188f2f 378 AliInfo(Form(" Run %d Cycle %d task %s file %s",
2e42b4d4 379 fRun, fCurrentCycle, AliQA::GetTaskName(task).Data(), fOutput->GetName() )) ;
5b188f2f 380
381 fDetectorDir = fOutput->GetDirectory(GetDetectorDirName()) ;
382 if (!fDetectorDir)
383 fDetectorDir = fOutput->mkdir(GetDetectorDirName()) ;
384
2e42b4d4 385 TDirectory * subDir = fDetectorDir->GetDirectory(AliQA::GetTaskName(task)) ;
5b188f2f 386 if (!subDir)
2e42b4d4 387 subDir = fDetectorDir->mkdir(AliQA::GetTaskName(task)) ;
5b188f2f 388 subDir->cd() ;
389
390 TList * list = 0x0 ;
391
392 switch (task) {
2e42b4d4 393 case AliQA::kRAWS:
5b188f2f 394 list = fRawsQAList ;
395 break ;
396
2e42b4d4 397 case AliQA::kHITS:
5b188f2f 398 list = fHitsQAList ;
399 break ;
400
2e42b4d4 401 case AliQA::kSDIGITS:
5b188f2f 402 list = fSDigitsQAList ;
403 break ;
404
2e42b4d4 405 case AliQA::kDIGITS:
5b188f2f 406 list = fDigitsQAList ;
407 break ;
408
2e42b4d4 409 case AliQA::kRECPOINTS:
5b188f2f 410 list = fRecPointsQAList ;
411 break ;
412
2e42b4d4 413 case AliQA::kTRACKSEGMENTS:
5b188f2f 414 break ;
415
2e42b4d4 416 case AliQA::kRECPARTICLES:
5b188f2f 417 break ;
418
2e42b4d4 419 case AliQA::kESDS:
5b188f2f 420 list = fESDsQAList ;
421 break ;
422 }
423
424 TIter next(list) ;
425 TH1 * h ;
426 while ( (h = dynamic_cast<TH1 *>(next())) )
427 h->Reset() ;
428
429 StartOfDetectorCycle() ;
430
431}