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