add ConnectionStatus and ConnectionError to virtual interface
[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
ba7aca7d 95//____________________________________________________________________________
96Int_t AliQADataMaker::Add2List(TH1 * hist, const Int_t index, TList * list)
97{
98 // Set histograms memory resident and add to the list
99 hist->SetDirectory(0) ;
ba7aca7d 100 list->AddAt(hist, index) ;
101 return list->LastIndex() ;
102}
103
5b188f2f 104//____________________________________________________________________________
2e42b4d4 105void AliQADataMaker::EndOfCycle(AliQA::TASKINDEX task)
5b188f2f 106{
107 // Finishes a cycle of QA data acquistion
a4976ef3 108
109 TList * list = 0x0 ;
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 ;
142 }
a4976ef3 143
144 EndOfDetectorCycle(task, list) ;
2e42b4d4 145 TDirectory * subDir = fDetectorDir->GetDirectory(AliQA::GetTaskName(task)) ;
a4976ef3 146 subDir->cd() ;
147 list->Write() ;
5b188f2f 148}
149
421ab0fb 150//____________________________________________________________________________
2e42b4d4 151void AliQADataMaker::Exec(AliQA::TASKINDEX task, TObject * data)
421ab0fb 152{
153 // creates the quality assurance data for the various tasks (Hits, SDigits, Digits, ESDs)
5b188f2f 154
312e6f8d 155 switch (task) {
6c18591a 156
312e6f8d 157 case AliQA::kRAWS:
158 {
808b7099 159 AliDebug(1, "Processing Raws QA") ;
312e6f8d 160 AliRawReader * rawReader = dynamic_cast<AliRawReader *>(data) ;
161 if (rawReader)
162 MakeRaws(rawReader) ;
163 else
164 AliError("Wrong data type") ;
165 break ;
166 }
167 case AliQA::kHITS:
168 {
808b7099 169 AliDebug(1, "Processing Hits QA") ;
312e6f8d 170 TClonesArray * arr = dynamic_cast<TClonesArray *>(data) ;
171 if (arr) {
172 MakeHits(arr) ;
173 } else {
174 TTree * tree = dynamic_cast<TTree *>(data) ;
175 if (tree) {
176 MakeHits(tree) ;
177 } else {
178 AliWarning("data are neither a TClonesArray nor a TTree") ;
179 }
180 }
181 break ;
182 }
183 case AliQA::kSDIGITS:
184 {
808b7099 185 AliDebug(1, "Processing SDigits QA") ;
312e6f8d 186 TClonesArray * arr = dynamic_cast<TClonesArray *>(data) ;
187 if (arr) {
188 MakeSDigits(arr) ;
189 } else {
190 TTree * tree = dynamic_cast<TTree *>(data) ;
191 if (tree) {
192 MakeSDigits(tree) ;
193 } else {
194 AliWarning("data are neither a TClonesArray nor a TTree") ;
195 }
196 }
197 break ;
198 }
199 case AliQA::kDIGITS:
200 {
808b7099 201 AliDebug(1, "Processing Digits QA") ;
312e6f8d 202 TClonesArray * arr = dynamic_cast<TClonesArray *>(data) ;
203 if (arr) {
204 MakeDigits(arr) ;
205 } else {
206 TTree * tree = dynamic_cast<TTree *>(data) ;
207 if (tree) {
208 MakeDigits(tree) ;
209 } else {
210 AliWarning("data are neither a TClonesArray nor a TTree") ;
211 }
212 }
213 break ;
214 }
215 case AliQA::kRECPOINTS:
216 {
808b7099 217 AliDebug(1, "Processing RecPoints QA") ;
312e6f8d 218 TTree * tree = dynamic_cast<TTree *>(data) ;
219 if (tree) {
220 MakeRecPoints(tree) ;
221 } else {
222 AliWarning("data are not a TTree") ;
223 }
224 break ;
225 }
226 case AliQA::kTRACKSEGMENTS:
227 AliInfo("Processing Track Segments QA: not existing anymore") ;
228 // MakeTrackSegments(ts) ;
229 break ;
421ab0fb 230
312e6f8d 231 case AliQA::kRECPARTICLES:
232 AliInfo("Processing RecParticles QA: not existing anymore") ;
233 // MakeRecParticles(recpar) ;
234 break ;
235 case AliQA::kESDS:
236 {
808b7099 237 AliDebug(1, "Processing ESDs QA") ;
312e6f8d 238 AliESDEvent * esd = dynamic_cast<AliESDEvent *>(data) ;
239 if (esd)
240 MakeESDs(esd) ;
241 else
242 AliError("Wrong type of esd container") ;
243 break ;
244 }
245 }
421ab0fb 246}
247
248//____________________________________________________________________________
c65c502a 249void AliQADataMaker::Finish() const
421ab0fb 250{
5b188f2f 251 // write to the output File
d62f9368 252 fOutput->Close() ;
421ab0fb 253}
254
255//____________________________________________________________________________
2e42b4d4 256TList * AliQADataMaker::Init(AliQA::TASKINDEX task, Int_t run, Int_t cycles)
421ab0fb 257{
258 // general intialisation
421ab0fb 259
5b188f2f 260 fRun = run ;
261 if (cycles > 0)
262 SetCycle(cycles) ;
263
d62f9368 264 switch (task) {
2e42b4d4 265 case AliQA::kRAWS:
986931a6 266 {
6c18591a 267 fRawsQAList = new TList() ;
268 InitRaws() ;
269 return fRawsQAList ;
270 break ;
986931a6 271 }
2e42b4d4 272 case AliQA::kHITS:
986931a6 273 {
6c18591a 274 fHitsQAList = new TList() ;
421ab0fb 275 InitHits() ;
6c18591a 276 return fHitsQAList ;
421ab0fb 277 break ;
986931a6 278 }
2e42b4d4 279 case AliQA::kSDIGITS:
986931a6 280 {
6c18591a 281 fSDigitsQAList = new TList() ;
421ab0fb 282 InitSDigits() ;
6c18591a 283 return fSDigitsQAList ;
421ab0fb 284 break ;
986931a6 285 }
2e42b4d4 286 case AliQA::kDIGITS:
986931a6 287 {
6c18591a 288 fDigitsQAList = new TList();
421ab0fb 289 InitDigits() ;
6c18591a 290 return fDigitsQAList ;
421ab0fb 291 break ;
986931a6 292 }
2e42b4d4 293 case AliQA::kRECPOINTS:
986931a6 294 {
312e6f8d 295 fRecPointsQAList = new TList() ;
421ab0fb 296 InitRecPoints() ;
6c18591a 297 return fRecPointsQAList ;
421ab0fb 298 break ;
986931a6 299 }
2e42b4d4 300 case AliQA::kTRACKSEGMENTS:
6c18591a 301// InitTrackSegments() ;
421ab0fb 302 break ;
303
2e42b4d4 304 case AliQA::kRECPARTICLES:
6c18591a 305// InitRecParticles() ;
421ab0fb 306 break ;
307
2e42b4d4 308 case AliQA::kESDS:
986931a6 309 {
310 fESDsQAList = new TList() ;
6c18591a 311 InitESDs() ;
ba7aca7d 312 return fESDsQAList ;
421ab0fb 313 break ;
986931a6 314 }
421ab0fb 315 }
6c18591a 316 return 0x0 ;
421ab0fb 317}
5b188f2f 318
312e6f8d 319//____________________________________________________________________________
320void AliQADataMaker::Init(AliQA::TASKINDEX task, TList * list, Int_t run, Int_t cycles)
321{
322 // Intialisation by passing the list of QA data booked elsewhere
323
324 fRun = run ;
325 if (cycles > 0)
326 SetCycle(cycles) ;
327
328 switch (task) {
329 case AliQA::kRAWS:
330 {
331 fRawsQAList = list ;
332 break ;
333 }
334 case AliQA::kHITS:
335 {
336 fHitsQAList = list ;
337 break ;
338 }
339 case AliQA::kSDIGITS:
340 {
341 fSDigitsQAList = list ;
342 break ;
343 }
344 case AliQA::kDIGITS:
345 {
346 fDigitsQAList = list ;
347 break ;
348 }
349 case AliQA::kRECPOINTS:
350 {
351 fRecPointsQAList = list ;
352 break ;
353 }
354 case AliQA::kTRACKSEGMENTS:
355 break ;
356
357 case AliQA::kRECPARTICLES:
358 break ;
359
360 case AliQA::kESDS:
361 {
362 fESDsQAList = list ;
363 break ;
364 }
365 }
366}
367
5b188f2f 368//____________________________________________________________________________
c65c502a 369void AliQADataMaker::Reset()
370{
371 // Resets defaut value of data members
372 fCurrentCycle = -1 ;
373 fCycleCounter = 0 ;
374}
375
376//____________________________________________________________________________
377void AliQADataMaker::StartOfCycle(AliQA::TASKINDEX task, const Bool_t sameCycle)
5b188f2f 378{
379 // Finishes a cycle of QA data acquistion
380
be834f15 381 if ( !sameCycle || fCurrentCycle == -1) {
312e6f8d 382 ResetCycle() ;
383 if (fOutput)
384 fOutput->Close() ;
8bea2de0 385 fOutput = AliQA::GetQADataFile(GetName(), fRun, fCurrentCycle) ;
386}
5b188f2f 387 AliInfo(Form(" Run %d Cycle %d task %s file %s",
2e42b4d4 388 fRun, fCurrentCycle, AliQA::GetTaskName(task).Data(), fOutput->GetName() )) ;
5b188f2f 389
390 fDetectorDir = fOutput->GetDirectory(GetDetectorDirName()) ;
391 if (!fDetectorDir)
392 fDetectorDir = fOutput->mkdir(GetDetectorDirName()) ;
393
2e42b4d4 394 TDirectory * subDir = fDetectorDir->GetDirectory(AliQA::GetTaskName(task)) ;
5b188f2f 395 if (!subDir)
2e42b4d4 396 subDir = fDetectorDir->mkdir(AliQA::GetTaskName(task)) ;
5b188f2f 397 subDir->cd() ;
398
399 TList * list = 0x0 ;
400
401 switch (task) {
2e42b4d4 402 case AliQA::kRAWS:
5b188f2f 403 list = fRawsQAList ;
404 break ;
405
2e42b4d4 406 case AliQA::kHITS:
5b188f2f 407 list = fHitsQAList ;
408 break ;
409
2e42b4d4 410 case AliQA::kSDIGITS:
5b188f2f 411 list = fSDigitsQAList ;
412 break ;
413
2e42b4d4 414 case AliQA::kDIGITS:
5b188f2f 415 list = fDigitsQAList ;
416 break ;
417
2e42b4d4 418 case AliQA::kRECPOINTS:
5b188f2f 419 list = fRecPointsQAList ;
420 break ;
421
2e42b4d4 422 case AliQA::kTRACKSEGMENTS:
5b188f2f 423 break ;
424
2e42b4d4 425 case AliQA::kRECPARTICLES:
5b188f2f 426 break ;
427
2e42b4d4 428 case AliQA::kESDS:
5b188f2f 429 list = fESDsQAList ;
430 break ;
431 }
432
433 TIter next(list) ;
434 TH1 * h ;
435 while ( (h = dynamic_cast<TH1 *>(next())) )
436 h->Reset() ;
437
438 StartOfDetectorCycle() ;
439
440}