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