added static method to retrieve a QA data object from a given list
[u/mrichter/AliRoot.git] / STEER / AliQAv1.cxx
CommitLineData
4e25ac79 1
2/**************************************************************************
3 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * *
5 * Author: The ALICE Off-line Project. *
6 * Contributors are mentioned in the code where appropriate. *
7 * *
8 * Permission to use, copy, modify and distribute this software and its *
9 * documentation strictly for non-commercial purposes is hereby granted *
10 * without fee, provided that the above copyright notice appears in all *
11 * copies and that both the copyright notice and this permission notice *
12 * appear in the supporting documentation. The authors make no claims *
13 * about the suitability of this software for any purpose. It is *
14 * provided "as is" without express or implied warranty. *
15 **************************************************************************/
16/* $Id: AliQAv1.cxx 31503 2009-03-16 11:01:16Z schutz $ */
17
18//////////////////////////////////////////////////////////////////////////////
19//
20// Quality Assurance Object//_________________________________________________________________________
21// Quality Assurance object. The QA status is held in one word per detector,
22// each bit corresponds to a different status.
23// bit 0-3 : QA raised during simulation (RAW)
24// bit 4-7 : QA raised during simulation (SIM)
25// bit 8-11 : QA raised during reconstruction (REC)
26// bit 12-15 : QA raised during ESD checking (ESD)
27// bit 16-19 : QA raised during analysis (ANA)
28// Each of the 4 bits corresponds to a severity level of increasing importance
29// from lower to higher bit (INFO, WARNING, ERROR, FATAL)
30//
31//*-- Yves Schutz CERN, July 2007
32//////////////////////////////////////////////////////////////////////////////
33
34
35#include <cstdlib>
36// --- ROOT system ---
34709735 37#include <TClass.h>
4e25ac79 38#include <TFile.h>
6188eeaf 39#include <TH1.h>
4e25ac79 40#include <TSystem.h>
41#include <TROOT.h>
42
43// --- Standard library ---
44
45// --- AliRoot header files ---
46#include "AliLog.h"
47#include "AliQAv1.h"
48
49
50ClassImp(AliQAv1)
49466ea2 51AliQAv1 * AliQAv1::fgQA = 0x0 ;
52TFile * AliQAv1::fgQADataFile = 0x0 ;
53TString AliQAv1::fgQADataFileName = "QA" ; // will transform into Det.QA.run.root
54TFile * AliQAv1::fgQARefFile = 0x0 ;
55TString AliQAv1::fgQARefDirName = "" ;
56TString AliQAv1::fgQARefFileName = "QA.root" ;
57TFile * AliQAv1::fgQAResultFile = 0x0 ;
58TString AliQAv1::fgQAResultDirName = "" ;
59TString AliQAv1::fgQAResultFileName = "QA.root" ;
60TString AliQAv1::fgDetNames[] = {"ITS", "TPC", "TRD", "TOF", "PHOS", "HMPID", "EMCAL", "MUON", "FMD",
61 "ZDC", "PMD", "T0", "VZERO", "ACORDE", "HLT", "Global", "CORR"} ;
62TString AliQAv1::fgGRPPath = "GRP/GRP/Data" ;
63TString AliQAv1::fgTaskNames[] = {"Raws", "Hits", "SDigits", "Digits", "DigitsR", "RecPoints", "TrackSegments", "RecParticles", "ESDs"} ;
634696f5 64TString AliQAv1::fgModeNames[] = {"", "Sim", "Rec"} ;
49466ea2 65const TString AliQAv1::fgkLabLocalFile = "file://" ;
66const TString AliQAv1::fgkLabLocalOCDB = "local://" ;
67const TString AliQAv1::fgkLabAliEnOCDB = "alien://" ;
68const TString AliQAv1::fgkRefFileName = "QA.root" ;
69const TString AliQAv1::fgkQAName = "QA" ;
70const TString AliQAv1::fgkQACorrNtName = "CorrQA" ;
71const TString AliQAv1::fgkRefOCDBDirName = "QA" ;
72TString AliQAv1::fgRefDataDirName = "" ;
73const TString AliQAv1::fgkQARefOCDBDefault = "alien://folder=/alice/QA/20" ;
74const TString AliQAv1::fgkExpert = "Expert" ;
75const UInt_t AliQAv1::fgkExpertBit = 0x40000 ;
76const UInt_t AliQAv1::fgkQABit = 0x80000 ;
77const UInt_t AliQAv1::fgkImageBit = 0x100000 ;
78const Int_t AliQAv1::fgkQADebugLevel = 99 ;
79const TString AliQAv1::fImageFileName = "QAImage" ;
99737f39 80const TString AliQAv1::fImageFileFormat = "ps" ;
49466ea2 81const UShort_t AliQAv1::fgkMaxQAObjects = 10000 ;
fec0891b 82
4e25ac79 83//____________________________________________________________________________
84AliQAv1::AliQAv1() :
85 TNamed("", ""),
86 fNdet(kNDET),
87 fNEventSpecies(AliRecoParam::kNSpecies),
88 fLengthQA(fNdet*fNEventSpecies),
89 fQA(new ULong_t[fLengthQA]),
90 fDet(kNULLDET),
91 fTask(kNULLTASK),
92 fEventSpecie(AliRecoParam::kDefault),
93 fEventSpecies(new Bool_t[fNEventSpecies])
94{
95 // default constructor
96 memset(fQA,0,fLengthQA*sizeof(ULong_t));
97 memset(fEventSpecies,kFALSE,fNEventSpecies*sizeof(Bool_t));
98}
99
100//____________________________________________________________________________
101AliQAv1::AliQAv1(const AliQAv1& qa) :
102 TNamed(qa),
103 fNdet(qa.fNdet),
104 fNEventSpecies(qa.fNEventSpecies),
105 fLengthQA(qa.fLengthQA),
106 fQA(new ULong_t[fLengthQA]),
107 fDet(qa.fDet),
108 fTask(qa.fTask),
109 fEventSpecie(qa.fEventSpecie),
110 fEventSpecies(new Bool_t[fNEventSpecies])
111{
112 // cpy ctor
113 memcpy(fQA,qa.fQA,fLengthQA*sizeof(ULong_t));
114 memcpy(fEventSpecies,qa.fEventSpecies,fNEventSpecies*sizeof(Bool_t));
115}
116
117//_____________________________________________________________________________
118AliQAv1& AliQAv1::operator = (const AliQAv1& qa)
119{
120 // assignment operator
121 if(&qa != this) {
122 TNamed::operator=(qa);
123 fNdet = qa.fNdet;
124 fNEventSpecies = qa.fNEventSpecies;
125 fLengthQA = qa.fLengthQA;
126
127 if(fQA) delete [] fQA;
128 fQA = new ULong_t[fLengthQA];
129 memcpy(fQA,qa.fQA,fLengthQA*sizeof(ULong_t));
130
131 fDet = qa.fDet;
132 fTask = qa.fTask;
133 fEventSpecie = qa.fEventSpecie;
134 if(fEventSpecies) delete [] fEventSpecies;
135 fEventSpecies = new Bool_t[fNEventSpecies];
136 memcpy(fEventSpecies,qa.fEventSpecies,fNEventSpecies*sizeof(Bool_t));
137 }
138 return *this;
139}
140
141//_______________________________________________________________
142AliQAv1::AliQAv1(const Int_t qalength, ULong_t * qa, const Int_t eslength, Bool_t * es) :
143TNamed("QA", "Quality Assurance status"),
144fNdet(kNDET),
145fNEventSpecies(eslength),
146fLengthQA(qalength),
147fQA(new ULong_t[fLengthQA]),
148fDet(kNULLDET),
149fTask(kNULLTASK),
150fEventSpecie(AliRecoParam::kDefault),
151fEventSpecies(new Bool_t[fNEventSpecies])
152{
153 // constructor to be used
154 memcpy(fQA, qa, fLengthQA*sizeof(ULong_t));
155 memcpy(fEventSpecies, es, fNEventSpecies*sizeof(Bool_t));
156}
157
158//_______________________________________________________________
159AliQAv1::AliQAv1(const DETECTORINDEX_t det) :
160 TNamed("QA", "Quality Assurance status"),
161 fNdet(kNDET),
162 fNEventSpecies(AliRecoParam::kNSpecies),
163 fLengthQA(fNdet*fNEventSpecies),
164 fQA(new ULong_t[fLengthQA]),
165 fDet(det),
166 fTask(kNULLTASK),
167 fEventSpecie(AliRecoParam::kDefault),
168 fEventSpecies(new Bool_t[fNEventSpecies])
169{
170 // constructor to be used
171 if (! CheckRange(det) ) fDet = kNULLDET ;
172 memset(fQA,0,fLengthQA*sizeof(ULong_t));
173 memset(fEventSpecies,kFALSE,fNEventSpecies*sizeof(Bool_t));
174}
175
176//_______________________________________________________________
177AliQAv1::AliQAv1(const ALITASK_t tsk) :
178 TNamed("QA", "Quality Assurance status"),
179 fNdet(kNDET),
180 fNEventSpecies(AliRecoParam::kNSpecies),
181 fLengthQA(fNdet*fNEventSpecies),
182 fQA(new ULong_t[fLengthQA]),
183 fDet(kNULLDET),
184 fTask(tsk),
185 fEventSpecie(AliRecoParam::kDefault),
186 fEventSpecies(new Bool_t[fNEventSpecies])
187{
188 // constructor to be used in the AliRoot module (SIM, REC, ESD or ANA)
189 if (! CheckRange(tsk) ) fTask = kNULLTASK ;
190 memset(fQA,0,fLengthQA*sizeof(ULong_t));
191 memset(fEventSpecies,kFALSE,fNEventSpecies*sizeof(Bool_t));
192}
193
194//____________________________________________________________________________
195AliQAv1::~AliQAv1()
196{
197 // dtor
198 delete [] fQA;
199 delete [] fEventSpecies;
200}
201
202//_______________________________________________________________
203void AliQAv1::Close()
204{
205 // close the open files
206 if (fgQADataFile)
207 if (fgQADataFile->IsOpen())
208 fgQADataFile->Close() ;
209 if (fgQAResultFile)
210 if (fgQAResultFile->IsOpen())
211 fgQAResultFile->Close() ;
212 if (fgQARefFile)
213 if (fgQARefFile->IsOpen())
214 fgQARefFile->Close() ;
215}
216
217//_______________________________________________________________
218Bool_t AliQAv1::CheckFatal() const
219{
220 // check if any FATAL status is set
221 Bool_t rv = kFALSE ;
222 Int_t index ;
223 for (index = 0; index < kNDET ; index++)
224 rv = rv || IsSet(DETECTORINDEX_t(index), fTask, fEventSpecie, kFATAL) ;
225 return rv ;
226}
227
228//_______________________________________________________________
229Bool_t AliQAv1::CheckRange(DETECTORINDEX_t det) const
230{
231 // check if detector is in given detector range: 0-kNDET
232
233 Bool_t rv = ( det < 0 || det > kNDET ) ? kFALSE : kTRUE ;
234 if (!rv)
235 AliFatal(Form("Detector index %d is out of range: 0 <= index <= %d", det, kNDET)) ;
236 return rv ;
237}
238
239//_______________________________________________________________
240Bool_t AliQAv1::CheckRange(ALITASK_t task) const
241{
242 // check if task is given taskk range: 0:kNTASK
243 Bool_t rv = ( task < kRAW || task > kNTASK ) ? kFALSE : kTRUE ;
244 if (!rv)
245 AliFatal(Form("Module index %d is out of range: 0 <= index <= %d", task, kNTASK)) ;
246 return rv ;
247}
248
249//_______________________________________________________________
250Bool_t AliQAv1::CheckRange(QABIT_t bit) const
251{
252 // check if bit is in given bit range: 0-kNBit
253
254 Bool_t rv = ( bit < 0 || bit > kNBIT ) ? kFALSE : kTRUE ;
255 if (!rv)
256 AliFatal(Form("Status bit %d is out of range: 0 <= bit <= %d", bit, kNBIT)) ;
257 return rv ;
258}
259
260//_______________________________________________________________
261Bool_t AliQAv1::CheckRange(AliRecoParam::EventSpecie_t es) const
262{
263 // check if bit is in given bit range: 0-kNBit
264 Bool_t rv = kFALSE ;
265 switch (es) {
266 case AliRecoParam::kDefault:
267 rv = kTRUE ;
268 break ;
269 case AliRecoParam::kLowMult:
270 rv = kTRUE ;
271 break ;
272 case AliRecoParam::kHighMult:
273 rv = kTRUE ;
274 break ;
275 case AliRecoParam::kCosmic:
276 rv = kTRUE ;
277 break ;
278 case AliRecoParam::kCalib:
279 rv = kTRUE ;
280 break ;
281 }
282 if (!rv)
283 AliFatal(Form("Event Specie %d is not valid", es)) ;
284 return rv ;
285}
286
287//_______________________________________________________________
288const char * AliQAv1::GetAliTaskName(ALITASK_t tsk)
289{
290 // returns the char name corresponding to module index
291 TString tskName ;
292 switch (tsk) {
293 case kNULLTASK:
294 break ;
295 case kRAW:
296 tskName = "RAW" ;
297 break ;
298 case kSIM:
299 tskName = "SIM" ;
300 break ;
301 case kREC:
302 tskName = "REC" ;
303 break ;
304 case kESD:
305 tskName = "ESD" ;
306 break ;
307 case kANA:
308 tskName = "ANA" ;
309 break ;
310 default:
311 tsk = kNULLTASK ;
312 break ;
313 }
314 return tskName.Data() ;
315}
316
317//_______________________________________________________________
318const char * AliQAv1::GetBitName(QABIT_t bit) const
319{
320 // returns the char name corresponding to bit
321 TString bitName ;
322 switch (bit) {
323 case kNULLBit:
324 break ;
325 case kINFO:
326 bitName = "INFO" ;
327 break ;
328 case kWARNING:
329 bitName = "WARNING" ;
330 break ;
331 case kERROR:
332 bitName = "ERROR" ;
333 break ;
334 case kFATAL:
335 bitName = "FATAL" ;
336 break ;
337 default:
338 bit = kNULLBit ;
339 break ;
340 }
341 return bitName.Data() ;
342}
343
6188eeaf 344//_______________________________________________________________
345TH1 * AliQAv1::GetData(TObjArray** list, Int_t index, AliRecoParam::EventSpecie_t eventSpecie)
346{
347 // retrieve QA data from the list at a given index and for a given event specie
348 TH1 * rv = NULL ;
349 Int_t esindex = AliRecoParam::AConvert(eventSpecie) ;
350 TObjArray * arr = list[esindex] ;
351 if (arr) {
352 if ( index > AliQAv1::GetMaxQAObj() ) {
353 AliErrorClass(Form("Max number of authorized QA objects is %d", AliQAv1::GetMaxQAObj())) ;
354 } else {
355 if ( arr->At(index) ) {
356 rv = static_cast<TH1*>(arr->At(index)) ;
357 }
358 }
359 }
360 return rv ;
361}
362
4e25ac79 363//_______________________________________________________________
364AliQAv1::DETECTORINDEX_t AliQAv1::GetDetIndex(const char * name)
365{
366 // returns the detector index corresponding to a given name
367 TString sname(name) ;
368 DETECTORINDEX_t rv = kNULLDET ;
369 for (Int_t det = 0; det < kNDET ; det++) {
370 if ( GetDetName(det) == sname ) {
371 rv = DETECTORINDEX_t(det) ;
372 break ;
373 }
374 }
375 return rv ;
376}
377
378//_______________________________________________________________
379const char * AliQAv1::GetDetName(Int_t det)
380{
381 // returns the detector name corresponding to a given index (needed in a loop)
382
383 if ( det >= 0 && det < kNDET)
384 return (fgDetNames[det]).Data() ;
385 else
386 return NULL ;
387}
388
389//_______________________________________________________________
390TFile * AliQAv1::GetQADataFile(const char * name, Int_t run)
391{
392 // opens the file to store the detectors Quality Assurance Data Maker results
393 const char * temp = Form("%s.%s.%d.root", name, fgQADataFileName.Data(), run) ;
394 TString opt ;
395 if (! fgQADataFile ) {
396 if (gSystem->AccessPathName(temp))
397 opt = "NEW" ;
398 else
399 opt = "UPDATE" ;
400 fgQADataFile = TFile::Open(temp, opt.Data()) ;
401 } else {
402 if ( strcmp(temp, fgQADataFile->GetName()) != 0 ) {
eca4fa66 403 fgQADataFile = static_cast<TFile *>(gROOT->FindObject(temp)) ;
4e25ac79 404 if ( !fgQADataFile ) {
eca4fa66 405 if (gSystem->AccessPathName(temp))
406 opt = "NEW" ;
407 else
408 opt = "UPDATE" ;
4e25ac79 409 fgQADataFile = TFile::Open(temp, opt.Data()) ;
410 }
411 }
412 }
413 return fgQADataFile ;
414}
415
634696f5 416//_____________________________________________________________________________
417AliQAv1::MODE_t AliQAv1::Mode(TASKINDEX_t task) {
418 // return "rec" or "sim" depending on the task
419
420 switch (task) {
421 case AliQAv1::kRAWS:
422 return kRECMODE ;
423 break;
424 case AliQAv1::kHITS:
425 return kSIMMODE ;
426 break;
427 case AliQAv1::kSDIGITS:
428 return kSIMMODE ;
429 break;
430 case AliQAv1::kDIGITS:
431 return kSIMMODE ;
432 break;
433 case AliQAv1::kDIGITSR:
434 return kRECMODE ;
435 break;
436 case AliQAv1::kRECPOINTS:
437 return kRECMODE ;
438 break ;
439 case AliQAv1::kTRACKSEGMENTS:
440 return kRECMODE ;
441 break;
442 case AliQAv1::kRECPARTICLES:
443 return kRECMODE ;
444 break;
445 case AliQAv1::kESDS:
446 return kRECMODE ;
447 break;
448 default:
449 break;
450 }
0f0c06de 451 return AliQAv1::kNULLMODE;
634696f5 452}
453
4e25ac79 454//_____________________________________________________________________________
455TFile * AliQAv1::GetQADataFile(const char * fileName)
456{
457 // Open if necessary the Data file and return its pointer
458
cf5fddb1 459 if (!fgQADataFile) {
460 if (!fileName)
461 fileName = AliQAv1::GetQADataFileName() ;
462 if (!gSystem->AccessPathName(fileName)) {
463 fgQADataFile = TFile::Open(fileName) ;
464 } else {
465 AliFatalClass(Form("File %s not found", fileName)) ;
466 }
467 }
4e25ac79 468 return fgQADataFile ;
469}
470
471//_______________________________________________________________
472TFile * AliQAv1::GetQAResultFile()
473{
474 // opens the file to store the Quality Assurance Data Checker results
475 if (fgQAResultFile)
476 fgQAResultFile->Close() ;
477 fgQAResultFile = 0x0 ;
478// if (!fgQAResultFile) {
479 TString dirName(fgQAResultDirName) ;
480 if ( dirName.Contains(fgkLabLocalFile))
481 dirName.ReplaceAll(fgkLabLocalFile, "") ;
482 TString fileName(dirName + fgQAResultFileName) ;
483 TString opt("") ;
484 if ( !gSystem->AccessPathName(fileName) )
485 opt = "UPDATE" ;
486 else {
487 if ( gSystem->AccessPathName(dirName) )
488 gSystem->mkdir(dirName) ;
489 opt = "NEW" ;
490 }
491 fgQAResultFile = TFile::Open(fileName, opt) ;
492// }
493
494 return fgQAResultFile ;
495}
496
497//_______________________________________________________________
498AliQAv1::TASKINDEX_t AliQAv1::GetTaskIndex(const char * name)
499{
500 // returns the detector index corresponding to a given name
501 TString sname(name) ;
502 TASKINDEX_t rv = kNULLTASKINDEX ;
503 for (Int_t tsk = 0; tsk < kNTASKINDEX ; tsk++) {
504 if ( GetTaskName(tsk) == sname ) {
505 rv = TASKINDEX_t(tsk) ;
506 break ;
507 }
508 }
509 return rv ;
510}
511
512//_______________________________________________________________
513Bool_t AliQAv1::IsSet(DETECTORINDEX_t det, ALITASK_t tsk, Int_t ies, QABIT_t bit) const
514{
515 // Checks is the requested bit is set
516
517 const AliRecoParam::EventSpecie_t es = AliRecoParam::Convert(ies) ;
518 return IsSet(det, tsk, es, bit) ;
519
520}
521
522//_______________________________________________________________
523Bool_t AliQAv1::IsSet(DETECTORINDEX_t det, ALITASK_t tsk, AliRecoParam::EventSpecie_t es, QABIT_t bit) const
524{
525 // Checks is the requested bit is set
526
527 CheckRange(det) ;
528 CheckRange(tsk) ;
529 CheckRange(bit) ;
530 CheckRange(es) ;
531
532 ULong_t offset = Offset(tsk) ;
533 ULong_t status = GetStatus(det, es) ;
534 offset+= bit ;
535 status = (status & 1 << offset) != 0 ;
536 return status ;
537}
538
539//_______________________________________________________________
540Bool_t AliQAv1::IsSetAny(DETECTORINDEX_t det, ALITASK_t tsk, AliRecoParam::EventSpecie_t es) const
541{
542 // Checks is the requested bit is set
543
544 CheckRange(det) ;
545 CheckRange(tsk) ;
546 CheckRange(es) ;
547
548 ULong_t offset = Offset(tsk) ;
549 ULong_t status = GetStatus(det, es) ;
550 ULong_t st = 0 ;
551 for ( Int_t bit = 0 ; bit < kNBIT ; bit++) {
552 offset+= bit ;
553 st += (status & 1 << offset) != 0 ;
554 }
555 if ( st == 0 )
556 return kFALSE ;
557 else
558 return kTRUE ;
559}
560//_______________________________________________________________
561Bool_t AliQAv1::IsSetAny(DETECTORINDEX_t det, AliRecoParam::EventSpecie_t es) const
562{
563 // Checks is the requested bit is set
564
565 CheckRange(det) ;
566 CheckRange(es) ;
567
568 ULong_t status = GetStatus(det, es) ;
569 ULong_t st = 0 ;
570 for ( Int_t tsk = 0 ; tsk < kNTASK ; tsk++) {
571 ULong_t offset = Offset(ALITASK_t(tsk)) ;
572 for ( Int_t bit = 0 ; bit < kNBIT ; bit++) {
573 offset+= bit ;
574 st += (status & 1 << offset) != 0 ;
575 }
576 }
577 if ( st == 0 )
578 return kFALSE ;
579 else
580 return kTRUE ;
581}
582
583//_______________________________________________________________
584AliQAv1 * AliQAv1::Instance()
585{
586 // Get an instance of the singleton. The only authorized way to call the ctor
587
588 if ( ! fgQA) {
589 TFile * f = GetQAResultFile() ;
eca4fa66 590 fgQA = static_cast<AliQAv1 *>(f->Get("QA")) ;
4e25ac79 591 if ( ! fgQA )
592 fgQA = new AliQAv1() ;
eca4fa66 593 }
4e25ac79 594 return fgQA ;
595}
596
597//_______________________________________________________________
598AliQAv1 * AliQAv1::Instance(const Int_t qalength, ULong_t * qa, const Int_t eslength, Bool_t * es)
599{
600 // Get an instance of the singleton. The only authorized way to call the ctor
601
602 if ( ! fgQA)
603 fgQA = new AliQAv1(qalength, qa, eslength, es) ;
604 return fgQA ;
605}
606
607//_______________________________________________________________
608AliQAv1 * AliQAv1::Instance(const DETECTORINDEX_t det)
609{
610 // Get an instance of the singleton. The only authorized way to call the ctor
611
612 if ( ! fgQA) {
613 TFile * f = GetQAResultFile() ;
eca4fa66 614 fgQA = static_cast<AliQAv1 *>(f->Get("QA")) ;
4e25ac79 615 if ( ! fgQA )
eca4fa66 616 fgQA = new AliQAv1(det) ;
4e25ac79 617 }
618 fgQA->Set(det) ;
619 return fgQA ;
620}
621
622//_______________________________________________________________
623AliQAv1 * AliQAv1::Instance(const ALITASK_t tsk)
624{
625 // Get an instance of the singleton. The only authorized way to call the ctor
626
627 if ( ! fgQA)
628 switch (tsk) {
629 case kNULLTASK:
630 break ;
631 case kRAW:
632 fgQA = new AliQAv1(tsk) ;
633 break ;
634 case kSIM:
635 fgQA = new AliQAv1(tsk) ;
636 break ;
637 case kREC:
34709735 638 AliInfoClass("fgQA = gAlice->GetQA()") ;
4e25ac79 639 break ;
640 case kESD:
eca4fa66 641 AliInfoClass("fgQA = static_cast<AliQAv1 *> (esdFile->Get(\"QA\")") ;
4e25ac79 642 break ;
643 case kANA:
eca4fa66 644 AliInfoClass("fgQA = static_cast<AliQAv1 *> (esdFile->Get(\"QA\")") ;
4e25ac79 645 break ;
646 case kNTASK:
647 break ;
648 }
649 if (fgQA)
650 fgQA->Set(tsk) ;
651 return fgQA ;
652}
653
654//_______________________________________________________________
655AliQAv1 * AliQAv1::Instance(const TASKINDEX_t tsk)
656{
657 // get an instance of the singleton.
658
659 ALITASK_t index = kNULLTASK ;
660
661 if ( tsk == kRAWS )
662 index = kRAW ;
663 else if (tsk < kDIGITS)
664 index = kSIM ;
665 else if (tsk < kRECPARTICLES)
666 index = kREC ;
667 else if (tsk == kESDS)
668 index = kESD ;
669
670 return Instance(index) ;
671}
672
673//_______________________________________________________________
674void AliQAv1::Merge(TCollection * list) {
675 // Merge the QA resuls in the list into this single AliQAv1 object
676
677 for (Int_t det = 0 ; det < kNDET ; det++) {
678 Set(DETECTORINDEX_t(det)) ;
679 for (Int_t task = 0 ; task < kNTASK ; task++) {
680 Set(ALITASK_t(task)) ;
681 for (Int_t bit = 0 ; bit < kNBIT ; bit++) {
682 TIter next(list) ;
683 AliQAv1 * qa ;
684 while ( (qa = (AliQAv1*)next() ) ) {
685 for (Int_t es = 0 ; es < fNEventSpecies ; es++) {
686 if (qa->IsSet(DETECTORINDEX_t(det), ALITASK_t(task), es, QABIT_t(bit)))
687 Set(QABIT_t(bit), es) ;
688 }
689 } // qa list
690 } // bit
691 } // task
692 } // detector
693}
694
695//_______________________________________________________________
696ULong_t AliQAv1::Offset(ALITASK_t tsk) const
697{
698 // Calculates the bit offset for a given module (SIM, REC, ESD, ANA)
699
700 CheckRange(tsk) ;
701
702 ULong_t offset = 0 ;
703 switch (tsk) {
704 case kNULLTASK:
705 break ;
706 case kRAW:
707 offset+= 0 ;
708 break ;
709 case kSIM:
710 offset+= 4 ;
711 break ;
712 case kREC:
713 offset+= 8 ;
714 break ;
715 case kESD:
716 offset+= 12 ;
717 break ;
718 case kANA:
719 offset+= 16 ;
720 break ;
721 case kNTASK:
722 break ;
723 }
724
725 return offset ;
726}
727
728//_______________________________________________________________
729void AliQAv1::ResetStatus(DETECTORINDEX_t det)
730{
731 // reset the status of det for all event specie
732 for (Int_t es = 0 ; es < fNEventSpecies ; es++)
733 fQA[det*fNdet+es] = 0 ;
734}
735
736//_______________________________________________________________
737void AliQAv1::Set(QABIT_t bit, Int_t ies)
738{
739 // Set the status bit of the current detector in the current module and for the current event specie
740 Set(bit, AliRecoParam::Convert(ies)) ;
741}
742
743//_______________________________________________________________
744void AliQAv1::Set(QABIT_t bit, AliRecoParam::EventSpecie_t es)
745{
746 // Set the status bit of the current detector in the current module and for the current event specie
747
748 SetStatusBit(fDet, fTask, es, bit) ;
749}
750
751//_____________________________________________________________________________
752void AliQAv1::SetQARefStorage(const char * name)
753{
754 // Set the root directory where the QA reference data are stored
755
756 fgQARefDirName = name ;
757 if ( fgQARefDirName.Contains(fgkLabLocalFile) )
758 fgQARefFileName = fgkRefFileName ;
759 else if ( fgQARefDirName.Contains(fgkLabLocalOCDB) )
760 fgQARefFileName = fgkQAName ;
761 else if ( fgQARefDirName.Contains(fgkLabAliEnOCDB) )
762 fgQARefFileName = fgkQAName ;
763
764 else {
34709735 765 AliErrorClass(Form("ERROR: %s is an invalid storage definition\n", name)) ;
4e25ac79 766 fgQARefDirName = "" ;
767 fgQARefFileName = "" ;
768 }
769 TString tmp(fgQARefDirName) ; // + fgQARefFileName) ;
34709735 770 AliInfoClass(Form("AliQAv1::SetQARefDir: QA references are in %s\n", tmp.Data() )) ;
4e25ac79 771}
772
773//_____________________________________________________________________________
774void AliQAv1::SetQAResultDirName(const char * name)
775{
776 // Set the root directory where to store the QA status object
777
778 fgQAResultDirName.Prepend(name) ;
34709735 779 AliInfoClass(Form("AliQAv1::SetQAResultDirName: QA results are in %s\n", fgQAResultDirName.Data())) ;
4e25ac79 780 if ( fgQAResultDirName.Contains(fgkLabLocalFile))
781 fgQAResultDirName.ReplaceAll(fgkLabLocalFile, "") ;
782 fgQAResultFileName.Prepend(fgQAResultDirName) ;
783}
784
785//_______________________________________________________________
786void AliQAv1::SetStatusBit(DETECTORINDEX_t det, ALITASK_t tsk, AliRecoParam::EventSpecie_t es, QABIT_t bit)
787{
788 // Set the status bit for a given detector and a given task
789
790 CheckRange(det) ;
791 CheckRange(tsk) ;
792 CheckRange(bit) ;
793 CheckRange(es) ;
794
795 ULong_t offset = Offset(tsk) ;
796 ULong_t status = GetStatus(det, es) ;
797 offset+= bit ;
798 status = status | 1 << offset ;
799 SetStatus(det, es, status) ;
800}
801
802//_______________________________________________________________
803void AliQAv1::Show(DETECTORINDEX_t det) const
804{
805 // dispplay the QA status word
806 if ( det == kNULLDET)
807 det = fDet ;
808 for (Int_t ies = 0 ; ies < fNEventSpecies ; ies++) {
eca4fa66 809 if ( IsEventSpecieSet(ies) )
810 ShowStatus(det, kNULLTASK, AliRecoParam::ConvertIndex(ies)) ;
4e25ac79 811 }
812}
813
814//_______________________________________________________________
815void AliQAv1::ShowAll() const
816{
817 // dispplay the QA status word
818 Int_t index ;
819 for (index = 0 ; index < kNDET ; index++) {
820 for (Int_t tsk = kRAW ; tsk < kNTASK ; tsk++) {
821 for (Int_t ies = 0 ; ies < fNEventSpecies ; ies++) {
eca4fa66 822 if ( IsEventSpecieSet(ies) )
823 ShowStatus(DETECTORINDEX_t(index), ALITASK_t(tsk), AliRecoParam::ConvertIndex(ies)) ;
4e25ac79 824 }
825 }
826 }
827}
828
829//_______________________________________________________________
830void AliQAv1::ShowStatus(DETECTORINDEX_t det, ALITASK_t tsk, AliRecoParam::EventSpecie_t es) const
831{
832 // Prints the full QA status of a given detector
833 CheckRange(det) ;
834 CheckRange(es) ;
835 ULong_t status = GetStatus(det, es) ;
836 ULong_t tskStatus[kNTASK] ;
837 tskStatus[kRAW] = status & 0x0000f ;
838 tskStatus[kSIM] = status & 0x000f0 ;
839 tskStatus[kREC] = status & 0x00f00 ;
840 tskStatus[kESD] = status & 0x0f000 ;
841 tskStatus[kANA] = status & 0xf0000 ;
842
843 AliInfo(Form("====> QA Status for %8s %8s raw =0x%x, sim=0x%x, rec=0x%x, esd=0x%x, ana=0x%x", GetDetName(det).Data(), AliRecoParam::GetEventSpecieName(es),
844 tskStatus[kRAW], tskStatus[kSIM], tskStatus[kREC], tskStatus[kESD], tskStatus[kANA] )) ;
845 if (tsk == kNULLTASK) {
846 for (Int_t itsk = kRAW ; itsk < kNTASK ; itsk++) {
847 ShowASCIIStatus(es, det, ALITASK_t(itsk), tskStatus[itsk]) ;
848 }
849 } else {
850 ShowASCIIStatus(es, det, tsk, tskStatus[tsk]) ;
851 }
852}
853
854//_______________________________________________________________
855void AliQAv1::ShowASCIIStatus(AliRecoParam::EventSpecie_t es, DETECTORINDEX_t det, ALITASK_t tsk, const ULong_t status) const
856{
857 // print the QA status in human readable format
858 TString text;
859 for (Int_t bit = kINFO ; bit < kNBIT ; bit++) {
860 if (IsSet(det, tsk, es, QABIT_t(bit))) {
861 text = GetBitName(QABIT_t(bit)) ;
862 text += " " ;
863 }
864 }
865 if (! text.IsNull())
34709735 866 AliInfoClass(Form(" %8s %8s %4s 0x%4lx, Problem signalled: %8s \n", AliRecoParam::GetEventSpecieName(es), GetDetName(det).Data(), GetAliTaskName(tsk), status, text.Data())) ;
4e25ac79 867}
868
869//_______________________________________________________________
870void AliQAv1::UnSet(QABIT_t bit, Int_t ies)
871{
872 // UnSet the status bit of the current detector in the current module
873 UnSet(bit, AliRecoParam::Convert(ies)) ;
874}
875
876//_______________________________________________________________
877void AliQAv1::UnSet(QABIT_t bit, AliRecoParam::EventSpecie_t es)
878{
879 // UnSet the status bit of the current detector in the current module
880
881 UnSetStatusBit(fDet, fTask, es, bit) ;
882}
883
884//_______________________________________________________________
885void AliQAv1::UnSetStatusBit(DETECTORINDEX_t det, ALITASK_t tsk, AliRecoParam::EventSpecie_t es, QABIT_t bit)
886{
887 // UnSet the status bit for a given detector and a given task
888
889 CheckRange(det) ;
890 CheckRange(tsk) ;
891 CheckRange(bit) ;
892 CheckRange(es) ;
893
894 ULong_t offset = Offset(tsk) ;
895 ULong_t status = GetStatus(det, es) ;
896 offset+= bit ;
897 status = status & 0 << offset ;
898 SetStatus(det, es, status) ;
899}