removing T00 DPs for FDR
[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)
312e6f8d 43
421ab0fb 44//____________________________________________________________________________
2e42b4d4 45AliQADataMaker::AliQADataMaker(const char * name, const char * title) :
421ab0fb 46 TNamed(name, title),
47 fOutput(0x0),
6c18591a 48 fDetectorDir(0x0),
312e6f8d 49 fDetectorDirName(""),
6c18591a 50 fDigitsQAList(0x0),
51 fESDsQAList(0x0),
52 fHitsQAList(0x0),
53 fRawsQAList(0x0),
54 fRecPointsQAList(0x0),
5b188f2f 55 fSDigitsQAList(0x0),
56 fCurrentCycle(-1),
57 fCycle(9999999),
58 fCycleCounter(0),
59 fRun(0)
421ab0fb 60{
61 // ctor
421ab0fb 62 fDetectorDirName = GetName() ;
63}
64
65//____________________________________________________________________________
2e42b4d4 66AliQADataMaker::AliQADataMaker(const AliQADataMaker& qadm) :
421ab0fb 67 TNamed(qadm.GetName(), qadm.GetTitle()),
68 fOutput(qadm.fOutput),
6c18591a 69 fDetectorDir(qadm.fDetectorDir),
312e6f8d 70 fDetectorDirName(qadm.fDetectorDirName),
6c18591a 71 fDigitsQAList(qadm.fDigitsQAList),
72 fESDsQAList(qadm.fESDsQAList),
73 fHitsQAList(qadm.fHitsQAList),
4ecde5fc 74 fRawsQAList(qadm.fRawsQAList),
6c18591a 75 fRecPointsQAList(qadm.fRecPointsQAList),
5b188f2f 76 fSDigitsQAList(qadm.fSDigitsQAList),
77 fCurrentCycle(qadm.fCurrentCycle),
78 fCycle(qadm.fCycle),
79 fCycleCounter(qadm.fCycleCounter),
a4976ef3 80 fRun(qadm.fRun)
421ab0fb 81{
82 //copy ctor
83 fDetectorDirName = GetName() ;
84}
85
86//__________________________________________________________________
2e42b4d4 87AliQADataMaker& AliQADataMaker::operator = (const AliQADataMaker& qadm )
421ab0fb 88{
312e6f8d 89 // Assignment operator.
2e42b4d4 90 this->~AliQADataMaker();
91 new(this) AliQADataMaker(qadm);
421ab0fb 92 return *this;
93}
94
95//____________________________________________________________________________
4edbc5bc 96Int_t AliQADataMaker::Add2List(TH1 * hist, const Int_t index, TObjArray * list)
ba7aca7d 97{
98 // Set histograms memory resident and add to the list
99 hist->SetDirectory(0) ;
f73f556a 100 list->AddAtAndExpand(hist, index) ;
4edbc5bc 101 return list->GetLast() ;
ba7aca7d 102}
103
104//____________________________________________________________________________
2e42b4d4 105void AliQADataMaker::EndOfCycle(AliQA::TASKINDEX task)
5b188f2f 106{
107 // Finishes a cycle of QA data acquistion
a4976ef3 108
4edbc5bc 109 TObjArray * list = 0x0 ;
a4976ef3 110
5b188f2f 111 switch (task) {
112
2e42b4d4 113 case AliQA::kRAWS:
a4976ef3 114 list = fRawsQAList ;
5b188f2f 115 break ;
116
2e42b4d4 117 case AliQA::kHITS:
a4976ef3 118 list = fHitsQAList ;
5b188f2f 119 break ;
120
2e42b4d4 121 case AliQA::kSDIGITS:
a4976ef3 122 list = fSDigitsQAList ;
5b188f2f 123 break ;
124
2e42b4d4 125 case AliQA::kDIGITS:
a4976ef3 126 list = fDigitsQAList ;
5b188f2f 127 break ;
128
2e42b4d4 129 case AliQA::kRECPOINTS:
a4976ef3 130 list = fRecPointsQAList ;
5b188f2f 131 break ;
132
2e42b4d4 133 case AliQA::kTRACKSEGMENTS:
5b188f2f 134 break ;
135
2e42b4d4 136 case AliQA::kRECPARTICLES:
5b188f2f 137 break ;
138
2e42b4d4 139 case AliQA::kESDS:
a4976ef3 140 list = fESDsQAList ;
5b188f2f 141 break ;
4edbc5bc 142
143 case AliQA::kNTASKINDEX:
144 break ;
5b188f2f 145 }
a4976ef3 146
147 EndOfDetectorCycle(task, list) ;
2e42b4d4 148 TDirectory * subDir = fDetectorDir->GetDirectory(AliQA::GetTaskName(task)) ;
a4976ef3 149 subDir->cd() ;
150 list->Write() ;
5b188f2f 151}
152
153//____________________________________________________________________________
2e42b4d4 154void AliQADataMaker::Exec(AliQA::TASKINDEX task, TObject * data)
421ab0fb 155{
156 // creates the quality assurance data for the various tasks (Hits, SDigits, Digits, ESDs)
5b188f2f 157
312e6f8d 158 switch (task) {
6c18591a 159
312e6f8d 160 case AliQA::kRAWS:
161 {
808b7099 162 AliDebug(1, "Processing Raws QA") ;
312e6f8d 163 AliRawReader * rawReader = dynamic_cast<AliRawReader *>(data) ;
164 if (rawReader)
165 MakeRaws(rawReader) ;
166 else
167 AliError("Wrong data type") ;
168 break ;
169 }
170 case AliQA::kHITS:
171 {
808b7099 172 AliDebug(1, "Processing Hits QA") ;
312e6f8d 173 TClonesArray * arr = dynamic_cast<TClonesArray *>(data) ;
174 if (arr) {
175 MakeHits(arr) ;
176 } else {
177 TTree * tree = dynamic_cast<TTree *>(data) ;
178 if (tree) {
179 MakeHits(tree) ;
180 } else {
181 AliWarning("data are neither a TClonesArray nor a TTree") ;
182 }
183 }
184 break ;
185 }
186 case AliQA::kSDIGITS:
187 {
808b7099 188 AliDebug(1, "Processing SDigits QA") ;
312e6f8d 189 TClonesArray * arr = dynamic_cast<TClonesArray *>(data) ;
190 if (arr) {
191 MakeSDigits(arr) ;
192 } else {
193 TTree * tree = dynamic_cast<TTree *>(data) ;
194 if (tree) {
195 MakeSDigits(tree) ;
196 } else {
197 AliWarning("data are neither a TClonesArray nor a TTree") ;
198 }
199 }
200 break ;
201 }
202 case AliQA::kDIGITS:
203 {
808b7099 204 AliDebug(1, "Processing Digits QA") ;
312e6f8d 205 TClonesArray * arr = dynamic_cast<TClonesArray *>(data) ;
206 if (arr) {
207 MakeDigits(arr) ;
208 } else {
209 TTree * tree = dynamic_cast<TTree *>(data) ;
210 if (tree) {
211 MakeDigits(tree) ;
212 } else {
213 AliWarning("data are neither a TClonesArray nor a TTree") ;
214 }
215 }
216 break ;
217 }
218 case AliQA::kRECPOINTS:
219 {
808b7099 220 AliDebug(1, "Processing RecPoints QA") ;
312e6f8d 221 TTree * tree = dynamic_cast<TTree *>(data) ;
222 if (tree) {
223 MakeRecPoints(tree) ;
224 } else {
225 AliWarning("data are not a TTree") ;
226 }
227 break ;
228 }
229 case AliQA::kTRACKSEGMENTS:
230 AliInfo("Processing Track Segments QA: not existing anymore") ;
231 // MakeTrackSegments(ts) ;
232 break ;
421ab0fb 233
312e6f8d 234 case AliQA::kRECPARTICLES:
235 AliInfo("Processing RecParticles QA: not existing anymore") ;
236 // MakeRecParticles(recpar) ;
4edbc5bc 237 break ;
312e6f8d 238 case AliQA::kESDS:
239 {
808b7099 240 AliDebug(1, "Processing ESDs QA") ;
312e6f8d 241 AliESDEvent * esd = dynamic_cast<AliESDEvent *>(data) ;
242 if (esd)
243 MakeESDs(esd) ;
244 else
245 AliError("Wrong type of esd container") ;
246 break ;
247 }
f73f556a 248 case AliQA::kNTASKINDEX:
249 break ;
312e6f8d 250 }
421ab0fb 251}
252
253//____________________________________________________________________________
c65c502a 254void AliQADataMaker::Finish() const
421ab0fb 255{
5b188f2f 256 // write to the output File
d62f9368 257 fOutput->Close() ;
421ab0fb 258}
259
260//____________________________________________________________________________
4edbc5bc 261TObjArray * AliQADataMaker::Init(AliQA::TASKINDEX task, Int_t run, Int_t cycles)
421ab0fb 262{
263 // general intialisation
421ab0fb 264
5b188f2f 265 fRun = run ;
266 if (cycles > 0)
267 SetCycle(cycles) ;
268
d62f9368 269 switch (task) {
2e42b4d4 270 case AliQA::kRAWS:
986931a6 271 {
4edbc5bc 272 fRawsQAList = new TObjArray(100) ;
6c18591a 273 InitRaws() ;
274 return fRawsQAList ;
275 break ;
986931a6 276 }
2e42b4d4 277 case AliQA::kHITS:
986931a6 278 {
4edbc5bc 279 fHitsQAList = new TObjArray(100) ;
421ab0fb 280 InitHits() ;
6c18591a 281 return fHitsQAList ;
421ab0fb 282 break ;
986931a6 283 }
2e42b4d4 284 case AliQA::kSDIGITS:
986931a6 285 {
4edbc5bc 286 fSDigitsQAList = new TObjArray(100) ;
421ab0fb 287 InitSDigits() ;
6c18591a 288 return fSDigitsQAList ;
421ab0fb 289 break ;
986931a6 290 }
2e42b4d4 291 case AliQA::kDIGITS:
986931a6 292 {
4edbc5bc 293 fDigitsQAList = new TObjArray(100);
421ab0fb 294 InitDigits() ;
6c18591a 295 return fDigitsQAList ;
421ab0fb 296 break ;
986931a6 297 }
2e42b4d4 298 case AliQA::kRECPOINTS:
986931a6 299 {
4edbc5bc 300 fRecPointsQAList = new TObjArray(100) ;
421ab0fb 301 InitRecPoints() ;
6c18591a 302 return fRecPointsQAList ;
421ab0fb 303 break ;
986931a6 304 }
2e42b4d4 305 case AliQA::kTRACKSEGMENTS:
6c18591a 306// InitTrackSegments() ;
421ab0fb 307 break ;
308
2e42b4d4 309 case AliQA::kRECPARTICLES:
6c18591a 310// InitRecParticles() ;
421ab0fb 311 break ;
312
2e42b4d4 313 case AliQA::kESDS:
986931a6 314 {
4edbc5bc 315 fESDsQAList = new TObjArray(100) ;
6c18591a 316 InitESDs() ;
ba7aca7d 317 return fESDsQAList ;
421ab0fb 318 break ;
986931a6 319 }
4edbc5bc 320 case AliQA::kNTASKINDEX:
321 break ;
421ab0fb 322 }
6c18591a 323 return 0x0 ;
421ab0fb 324}
5b188f2f 325
312e6f8d 326//____________________________________________________________________________
4edbc5bc 327void AliQADataMaker::Init(AliQA::TASKINDEX task, TObjArray * list, Int_t run, Int_t cycles)
312e6f8d 328{
329 // Intialisation by passing the list of QA data booked elsewhere
330
331 fRun = run ;
332 if (cycles > 0)
333 SetCycle(cycles) ;
334
335 switch (task) {
336 case AliQA::kRAWS:
337 {
338 fRawsQAList = list ;
339 break ;
340 }
341 case AliQA::kHITS:
342 {
343 fHitsQAList = list ;
344 break ;
345 }
346 case AliQA::kSDIGITS:
347 {
348 fSDigitsQAList = list ;
349 break ;
350 }
351 case AliQA::kDIGITS:
352 {
353 fDigitsQAList = list ;
354 break ;
355 }
356 case AliQA::kRECPOINTS:
357 {
358 fRecPointsQAList = list ;
359 break ;
360 }
361 case AliQA::kTRACKSEGMENTS:
362 break ;
363
364 case AliQA::kRECPARTICLES:
365 break ;
366
367 case AliQA::kESDS:
368 {
369 fESDsQAList = list ;
370 break ;
371 }
4edbc5bc 372 case AliQA::kNTASKINDEX:
373 break ;
312e6f8d 374 }
375}
376
5b188f2f 377//____________________________________________________________________________
c65c502a 378void AliQADataMaker::Reset()
379{
380 // Resets defaut value of data members
381 fCurrentCycle = -1 ;
382 fCycleCounter = 0 ;
383}
384
385//____________________________________________________________________________
386void AliQADataMaker::StartOfCycle(AliQA::TASKINDEX task, const Bool_t sameCycle)
5b188f2f 387{
388 // Finishes a cycle of QA data acquistion
389
be834f15 390 if ( !sameCycle || fCurrentCycle == -1) {
312e6f8d 391 ResetCycle() ;
392 if (fOutput)
393 fOutput->Close() ;
8bea2de0 394 fOutput = AliQA::GetQADataFile(GetName(), fRun, fCurrentCycle) ;
395}
5b188f2f 396 AliInfo(Form(" Run %d Cycle %d task %s file %s",
2e42b4d4 397 fRun, fCurrentCycle, AliQA::GetTaskName(task).Data(), fOutput->GetName() )) ;
5b188f2f 398
399 fDetectorDir = fOutput->GetDirectory(GetDetectorDirName()) ;
400 if (!fDetectorDir)
401 fDetectorDir = fOutput->mkdir(GetDetectorDirName()) ;
402
2e42b4d4 403 TDirectory * subDir = fDetectorDir->GetDirectory(AliQA::GetTaskName(task)) ;
5b188f2f 404 if (!subDir)
2e42b4d4 405 subDir = fDetectorDir->mkdir(AliQA::GetTaskName(task)) ;
5b188f2f 406 subDir->cd() ;
407
4edbc5bc 408 TObjArray * list = 0x0 ;
5b188f2f 409
410 switch (task) {
2e42b4d4 411 case AliQA::kRAWS:
5b188f2f 412 list = fRawsQAList ;
413 break ;
414
2e42b4d4 415 case AliQA::kHITS:
5b188f2f 416 list = fHitsQAList ;
417 break ;
418
2e42b4d4 419 case AliQA::kSDIGITS:
5b188f2f 420 list = fSDigitsQAList ;
421 break ;
422
2e42b4d4 423 case AliQA::kDIGITS:
5b188f2f 424 list = fDigitsQAList ;
425 break ;
426
2e42b4d4 427 case AliQA::kRECPOINTS:
5b188f2f 428 list = fRecPointsQAList ;
429 break ;
430
2e42b4d4 431 case AliQA::kTRACKSEGMENTS:
5b188f2f 432 break ;
433
2e42b4d4 434 case AliQA::kRECPARTICLES:
5b188f2f 435 break ;
436
2e42b4d4 437 case AliQA::kESDS:
5b188f2f 438 list = fESDsQAList ;
439 break ;
4edbc5bc 440
441 case AliQA::kNTASKINDEX:
442 break ;
443}
5b188f2f 444
445 TIter next(list) ;
446 TH1 * h ;
447 while ( (h = dynamic_cast<TH1 *>(next())) )
448 h->Reset() ;
449
450 StartOfDetectorCycle() ;
451
452}