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