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