bug fix in T00 alias names
[u/mrichter/AliRoot.git] / STEER / AliQualAssDataMaker.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"
37#include "AliQualAssDataMaker.h"
a4976ef3 38#include "AliQualAssChecker.h"
d76c31f4 39#include "AliESDEvent.h"
d5cf81bd 40#include "AliRawReader.h"
421ab0fb 41
42ClassImp(AliQualAssDataMaker)
43
44TString AliQualAssDataMaker::fDetectorDirName("") ;
45
46
47//____________________________________________________________________________
48AliQualAssDataMaker::AliQualAssDataMaker(const char * name, const char * title) :
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//____________________________________________________________________________
68AliQualAssDataMaker::AliQualAssDataMaker(const AliQualAssDataMaker& qadm) :
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//____________________________________________________________________________
88AliQualAssDataMaker::~AliQualAssDataMaker()
89{
90// dtor
91}
92
421ab0fb 93//__________________________________________________________________
94AliQualAssDataMaker& AliQualAssDataMaker::operator = (const AliQualAssDataMaker& qadm )
95{
96 // Equal operator.
97 this->~AliQualAssDataMaker();
98 new(this) AliQualAssDataMaker(qadm);
99 return *this;
100}
101
5b188f2f 102//____________________________________________________________________________
103void AliQualAssDataMaker::EndOfCycle(AliQualAss::TASKINDEX task)
104{
105 // Finishes a cycle of QA data acquistion
a4976ef3 106
107 TList * list = 0x0 ;
108
5b188f2f 109 switch (task) {
110
a4976ef3 111 case AliQualAss::kRAWS:
112 list = fRawsQAList ;
5b188f2f 113 break ;
114
115 case AliQualAss::kHITS:
a4976ef3 116 list = fHitsQAList ;
5b188f2f 117 break ;
118
119 case AliQualAss::kSDIGITS:
a4976ef3 120 list = fSDigitsQAList ;
5b188f2f 121 break ;
122
123 case AliQualAss::kDIGITS:
a4976ef3 124 list = fDigitsQAList ;
5b188f2f 125 break ;
126
127 case AliQualAss::kRECPOINTS:
a4976ef3 128 list = fRecPointsQAList ;
5b188f2f 129 break ;
130
131 case AliQualAss::kTRACKSEGMENTS:
132 break ;
133
134 case AliQualAss::kRECPARTICLES:
135 break ;
136
137 case AliQualAss::kESDS:
a4976ef3 138 list = fESDsQAList ;
5b188f2f 139 break ;
140 }
a4976ef3 141
142 EndOfDetectorCycle(task, list) ;
143 TDirectory * subDir = fDetectorDir->GetDirectory(AliQualAss::GetTaskName(task)) ;
144 subDir->cd() ;
145 list->Write() ;
5b188f2f 146}
147
421ab0fb 148//____________________________________________________________________________
d76c31f4 149void AliQualAssDataMaker::Exec(AliQualAss::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
155 case AliQualAss::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 }
421ab0fb 165 case AliQualAss::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 }
d76c31f4 175 case AliQualAss::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 }
d76c31f4 185 case AliQualAss::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 }
194 case AliQualAss::kRECPOINTS:
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 }
421ab0fb 204 case AliQualAss::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
986931a6 213 case AliQualAss::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
421ab0fb 222 case AliQualAss::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//____________________________________________________________________________
5b188f2f 236void AliQualAssDataMaker::Finish(AliQualAss::TASKINDEX) const
421ab0fb 237{
5b188f2f 238 // write to the output File
d62f9368 239 fOutput->Close() ;
421ab0fb 240}
241
242//____________________________________________________________________________
5b188f2f 243TList * AliQualAssDataMaker::Init(AliQualAss::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) {
6c18591a 252 case AliQualAss::kRAWS:
986931a6 253 {
6c18591a 254 fRawsQAList = new TList() ;
255 InitRaws() ;
256 return fRawsQAList ;
257 break ;
986931a6 258 }
421ab0fb 259 case AliQualAss::kHITS:
986931a6 260 {
6c18591a 261 fHitsQAList = new TList() ;
421ab0fb 262 InitHits() ;
6c18591a 263 return fHitsQAList ;
421ab0fb 264 break ;
986931a6 265 }
421ab0fb 266 case AliQualAss::kSDIGITS:
986931a6 267 {
6c18591a 268 fSDigitsQAList = new TList() ;
421ab0fb 269 InitSDigits() ;
6c18591a 270 return fSDigitsQAList ;
421ab0fb 271 break ;
986931a6 272 }
421ab0fb 273 case AliQualAss::kDIGITS:
986931a6 274 {
6c18591a 275 fDigitsQAList = new TList();
421ab0fb 276 InitDigits() ;
6c18591a 277 return fDigitsQAList ;
421ab0fb 278 break ;
986931a6 279 }
421ab0fb 280 case AliQualAss::kRECPOINTS:
986931a6 281 {
6c18591a 282 fRecPointsQAList = new TList ;
421ab0fb 283 InitRecPoints() ;
6c18591a 284 return fRecPointsQAList ;
421ab0fb 285 break ;
986931a6 286 }
421ab0fb 287 case AliQualAss::kTRACKSEGMENTS:
6c18591a 288// InitTrackSegments() ;
421ab0fb 289 break ;
290
291 case AliQualAss::kRECPARTICLES:
6c18591a 292// InitRecParticles() ;
421ab0fb 293 break ;
294
295 case AliQualAss::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//____________________________________________________________________________
307void AliQualAssDataMaker::StartOfCycle(AliQualAss::TASKINDEX task, Option_t * sameCycle)
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() ;
315 fOutput = AliQualAss::GetQADMOutFile(GetName(), fRun, fCurrentCycle) ;
316 }
317
5b188f2f 318 AliInfo(Form(" Run %d Cycle %d task %s file %s",
319 fRun, fCurrentCycle, AliQualAss::GetTaskName(task).Data(), fOutput->GetName() )) ;
320
321 fDetectorDir = fOutput->GetDirectory(GetDetectorDirName()) ;
322 if (!fDetectorDir)
323 fDetectorDir = fOutput->mkdir(GetDetectorDirName()) ;
324
325 TDirectory * subDir = fDetectorDir->GetDirectory(AliQualAss::GetTaskName(task)) ;
326 if (!subDir)
327 subDir = fDetectorDir->mkdir(AliQualAss::GetTaskName(task)) ;
328 subDir->cd() ;
329
330 TList * list = 0x0 ;
331
332 switch (task) {
333 case AliQualAss::kRAWS:
334 list = fRawsQAList ;
335 break ;
336
337 case AliQualAss::kHITS:
338 list = fHitsQAList ;
339 break ;
340
341 case AliQualAss::kSDIGITS:
342 list = fSDigitsQAList ;
343 break ;
344
345 case AliQualAss::kDIGITS:
346 list = fDigitsQAList ;
347 break ;
348
349 case AliQualAss::kRECPOINTS:
350 list = fRecPointsQAList ;
351 break ;
352
353 case AliQualAss::kTRACKSEGMENTS:
354 break ;
355
356 case AliQualAss::kRECPARTICLES:
357 break ;
358
359 case AliQualAss::kESDS:
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}