Introducing event specie in QA (Yves)
[u/mrichter/AliRoot.git] / STEER / AliQA.cxx
CommitLineData
8661738e 1
421ab0fb 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$ */
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.
12581b04 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)
421ab0fb 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
b09247a2 35#include <cstdlib>
421ab0fb 36// --- ROOT system ---
37#include <TFile.h>
38#include <TSystem.h>
0d13dd63 39#include <TROOT.h>
421ab0fb 40
41// --- Standard library ---
42
43// --- AliRoot header files ---
44#include "AliLog.h"
2e42b4d4 45#include "AliQA.h"
421ab0fb 46
47
2e42b4d4 48ClassImp(AliQA)
f73f556a 49AliQA * AliQA::fgQA = 0x0 ;
50TFile * AliQA::fgQADataFile = 0x0 ;
57acd2d2 51TString AliQA::fgQADataFileName = "QA" ; // will transform into Det.QA.run.root
f73f556a 52TFile * AliQA::fgQARefFile = 0x0 ;
147c1c84 53TString AliQA::fgQARefDirName = "" ;
f73f556a 54TString AliQA::fgQARefFileName = "QA.root" ;
55TFile * AliQA::fgQAResultFile = 0x0 ;
56TString AliQA::fgQAResultDirName = "" ;
57TString AliQA::fgQAResultFileName = "QA.root" ;
58TString AliQA::fgDetNames[] = {"ITS", "TPC", "TRD", "TOF", "PHOS", "HMPID", "EMCAL", "MUON", "FMD",
a2b64fbd 59 "ZDC", "PMD", "T0", "VZERO", "ACORDE", "HLT", "Global", "CORR"} ;
4fb24ca4 60TString AliQA::fgGRPPath = "GRP/GRP/Data" ;
f73f556a 61TString AliQA::fgTaskNames[] = {"Raws", "Hits", "SDigits", "Digits", "RecPoints", "TrackSegments", "RecParticles", "ESDs"} ;
62const TString AliQA::fkgLabLocalFile = "file://" ;
63const TString AliQA::fkgLabLocalOCDB = "local://" ;
64const TString AliQA::fkgLabAliEnOCDB = "alien://" ;
65const TString AliQA::fkgRefFileName = "QA.root" ;
96d67a8d 66const TString AliQA::fkgQAName = "QA" ;
a2b64fbd 67const TString AliQA::fkgQACorrNtName = "CorrQA" ;
57acd2d2 68const TString AliQA::fkgRefOCDBDirName = "QA" ;
147c1c84 69TString AliQA::fkgRefDataDirName = "" ;
13c8b505 70const TString AliQA::fkgQARefOCDBDefault = "alien://folder=/alice/QA/20" ;
750730d8 71const TString AliQA::fkgExpert = "Expert" ;
72const UInt_t AliQA::fkgExpertBit = 16 ;
4038d5ed 73const UInt_t AliQA::fkgQABit = 17 ;
930e6e3e 74
421ab0fb 75//____________________________________________________________________________
2e42b4d4 76AliQA::AliQA() :
421ab0fb 77 TNamed("", ""),
9a223722 78 fNdet(kNDET),
57acd2d2 79 fNEventSpecie(AliRecoParam::kNSpecies),
80 fQA(new ULong_t*[fNdet]),
421ab0fb 81 fDet(kNULLDET),
57acd2d2 82 fTask(kNULLTASK),
83 fEventSpecie(AliRecoParam::kDefault),
84 fEventSpecies(new Bool_t[fNEventSpecie])
421ab0fb 85{
86 // default constructor
57acd2d2 87 Int_t det ;
88 for (det = 0 ; det < fNdet ; det++) {
89 fQA[det] = new ULong_t[fNEventSpecie] ;
90 for (Int_t es = 0 ; es < fNEventSpecie ; es++)
91 fQA[det][es] = 0 ;
92 }
93 for (Int_t es = 0 ; es < fNEventSpecie ; es++)
94 fEventSpecies[es] = kFALSE ;
421ab0fb 95}
96
97//____________________________________________________________________________
2e42b4d4 98AliQA::AliQA(const AliQA& qa) :
421ab0fb 99 TNamed(qa),
9a223722 100 fNdet(qa.fNdet),
57acd2d2 101 fNEventSpecie(qa.fNEventSpecie),
421ab0fb 102 fQA(qa.fQA),
103 fDet(qa.fDet),
57acd2d2 104 fTask(qa.fTask),
105 fEventSpecie(qa.fEventSpecie),
106 fEventSpecies(qa.fEventSpecies)
421ab0fb 107{
108 // cpy ctor
109}
110
111//_____________________________________________________________________________
2e42b4d4 112AliQA& AliQA::operator = (const AliQA& qa)
421ab0fb 113{
57acd2d2 114 // assignment operator
115 if(&qa == this) return *this;
291e3bcb 116
57acd2d2 117 fNdet = qa.fNdet;
118 fNEventSpecie = qa.fNEventSpecie;
119 for (Int_t det = 0 ; det < fNdet ; det++)
120 for (Int_t es = 0 ; es < fNEventSpecie ; es++)
121 fQA[det][es] = qa.fQA[det][es];
122
123 fNEventSpecie = qa.fNEventSpecie ;
124 for (Int_t es = 0 ; es < fNEventSpecie ; es++)
125 fEventSpecies[es] = qa. fEventSpecies[es] ;
126
127 return *this;
421ab0fb 128}
129
130//_______________________________________________________________
96d67a8d 131AliQA::AliQA(const DETECTORINDEX_t det) :
9a223722 132 TNamed("QA", "Quality Assurance status"),
133 fNdet(kNDET),
57acd2d2 134 fNEventSpecie(AliRecoParam::kNSpecies),
135 fQA(new ULong_t*[fNdet]),
a5fa6165 136 fDet(det),
57acd2d2 137 fTask(kNULLTASK),
138 fEventSpecie(AliRecoParam::kDefault),
139 fEventSpecies(new Bool_t[fNEventSpecie])
a5fa6165 140{
141 // constructor to be used
142 if (! CheckRange(det) ) {
143 fDet = kNULLDET ;
144 return ;
a4976ef3 145 }
57acd2d2 146 Int_t idet ;
147 for (idet = 0; idet < fNdet; idet++) {
148 fQA[det] = new ULong_t[fNEventSpecie] ;
149 for (Int_t es = 0 ; es < fNEventSpecie ; es++)
150 fQA[idet][es] = 0 ;
151 }
152 for (Int_t es = 0 ; es < fNEventSpecie ; es++)
153 fEventSpecies[es] = kFALSE ;
a5fa6165 154}
155
156//_______________________________________________________________
96d67a8d 157AliQA::AliQA(const ALITASK_t tsk) :
421ab0fb 158 TNamed("QA", "Quality Assurance status"),
9a223722 159 fNdet(kNDET),
57acd2d2 160 fNEventSpecie(AliRecoParam::kNSpecies),
161 fQA(new ULong_t*[fNdet]),
421ab0fb 162 fDet(kNULLDET),
57acd2d2 163 fTask(tsk),
164 fEventSpecie(AliRecoParam::kDefault),
165 fEventSpecies(new Bool_t[fNEventSpecie])
421ab0fb 166{
167 // constructor to be used in the AliRoot module (SIM, REC, ESD or ANA)
168 if (! CheckRange(tsk) ) {
169 fTask = kNULLTASK ;
170 return ;
a4976ef3 171 }
57acd2d2 172 Int_t det ;
173 for (det = 0; det < fNdet; det++) {
174 fQA[det] = new ULong_t[fNEventSpecie] ;
175 for (Int_t es = 0 ; es < fNEventSpecie ; es++)
176 fQA[det][es] = 0 ;
177 }
178 for (Int_t es = 0 ; es < fNEventSpecie ; es++)
179 fEventSpecies[es] = kFALSE ;
421ab0fb 180}
181
182//____________________________________________________________________________
2e42b4d4 183AliQA::~AliQA()
421ab0fb 184{
185 // dtor
57acd2d2 186 for (Int_t idet = 0; idet < fNdet; idet++)
187 delete fQA[idet] ;
421ab0fb 188 delete[] fQA ;
189}
190
191//_______________________________________________________________
46ca5304 192void AliQA::Close()
193{
194 // close the open files
195 if (fgQADataFile)
196 if (fgQADataFile->IsOpen())
197 fgQADataFile->Close() ;
198 if (fgQAResultFile)
199 if (fgQAResultFile->IsOpen())
200 fgQAResultFile->Close() ;
201 if (fgQARefFile)
202 if (fgQARefFile->IsOpen())
203 fgQARefFile->Close() ;
204}
205
206//_______________________________________________________________
f12d42ce 207Bool_t AliQA::CheckFatal() const
4ecde5fc 208{
209 // check if any FATAL status is set
210 Bool_t rv = kFALSE ;
211 Int_t index ;
212 for (index = 0; index < kNDET ; index++)
57acd2d2 213 rv = rv || IsSet(DETECTORINDEX_t(index), fTask, fEventSpecie, kFATAL) ;
4ecde5fc 214 return rv ;
215}
216
217//_______________________________________________________________
f12d42ce 218Bool_t AliQA::CheckRange(DETECTORINDEX_t det) const
421ab0fb 219{
a4976ef3 220 // check if detector is in given detector range: 0-kNDET
421ab0fb 221
a5fa6165 222 Bool_t rv = ( det < 0 || det > kNDET ) ? kFALSE : kTRUE ;
421ab0fb 223 if (!rv)
224 AliFatal(Form("Detector index %d is out of range: 0 <= index <= %d", det, kNDET)) ;
225 return rv ;
226}
227
228//_______________________________________________________________
f12d42ce 229Bool_t AliQA::CheckRange(ALITASK_t task) const
421ab0fb 230{
231 // check if task is given taskk range: 0:kNTASK
6c18591a 232 Bool_t rv = ( task < kRAW || task > kNTASK ) ? kFALSE : kTRUE ;
421ab0fb 233 if (!rv)
234 AliFatal(Form("Module index %d is out of range: 0 <= index <= %d", task, kNTASK)) ;
235 return rv ;
236}
237
238//_______________________________________________________________
f12d42ce 239Bool_t AliQA::CheckRange(QABIT_t bit) const
421ab0fb 240{
241 // check if bit is in given bit range: 0-kNBit
242
243 Bool_t rv = ( bit < 0 || bit > kNBIT ) ? kFALSE : kTRUE ;
244 if (!rv)
245 AliFatal(Form("Status bit %d is out of range: 0 <= bit <= %d", bit, kNBIT)) ;
246 return rv ;
247}
248
57acd2d2 249//_______________________________________________________________
250Bool_t AliQA::CheckRange(AliRecoParam::EventSpecie_t es) const
251{
252 // check if bit is in given bit range: 0-kNBit
253 Bool_t rv = kFALSE ;
254 switch (es) {
255 case AliRecoParam::kDefault:
256 rv = kTRUE ;
257 break ;
258 case AliRecoParam::kLowMult:
259 rv = kTRUE ;
260 break ;
261 case AliRecoParam::kHighMult:
262 rv = kTRUE ;
263 break ;
264 case AliRecoParam::kCosmic:
265 rv = kTRUE ;
266 break ;
267 case AliRecoParam::kCalib:
268 rv = kTRUE ;
269 break ;
270 }
271 if (!rv)
272 AliFatal(Form("Event Specie %d is not valid", es)) ;
273 return rv ;
274}
4ecde5fc 275
421ab0fb 276//_______________________________________________________________
96d67a8d 277const char * AliQA::GetAliTaskName(ALITASK_t tsk)
421ab0fb 278{
0b96c27c 279 // returns the char name corresponding to module index
280 TString tskName ;
281 switch (tsk) {
282 case kNULLTASK:
283 break ;
284 case kRAW:
285 tskName = "RAW" ;
286 break ;
287 case kSIM:
288 tskName = "SIM" ;
289 break ;
290 case kREC:
291 tskName = "REC" ;
292 break ;
293 case kESD:
294 tskName = "ESD" ;
295 break ;
296 case kANA:
297 tskName = "ANA" ;
298 break ;
299 default:
300 tsk = kNULLTASK ;
301 break ;
302 }
303 return tskName.Data() ;
304}
0acdb2bb 305
0b96c27c 306//_______________________________________________________________
307const char * AliQA::GetBitName(QABIT_t bit) const
308{
309 // returns the char name corresponding to bit
310 TString bitName ;
311 switch (bit) {
312 case kNULLBit:
313 break ;
314 case kINFO:
315 bitName = "INFO" ;
316 break ;
317 case kWARNING:
318 bitName = "WARNING" ;
319 break ;
320 case kERROR:
321 bitName = "ERROR" ;
322 break ;
323 case kFATAL:
324 bitName = "FATAL" ;
325 break ;
326 default:
327 bit = kNULLBit ;
328 break ;
329 }
330 return bitName.Data() ;
421ab0fb 331}
332
333//_______________________________________________________________
f12d42ce 334AliQA::DETECTORINDEX_t AliQA::GetDetIndex(const char * name)
96d67a8d 335{
336 // returns the detector index corresponding to a given name
337 TString sname(name) ;
338 DETECTORINDEX_t rv = kNULLDET ;
339 for (Int_t det = 0; det < kNDET ; det++) {
340 if ( GetDetName(det) == sname ) {
341 rv = DETECTORINDEX_t(det) ;
342 break ;
343 }
344 }
345 return rv ;
346}
347
348//_______________________________________________________________
7c002d48 349const char * AliQA::GetDetName(Int_t det)
350{
351 // returns the detector name corresponding to a given index (needed in a loop)
352
353 if ( det >= 0 && det < kNDET)
354 return (fgDetNames[det]).Data() ;
355 else
356 return NULL ;
357}
358
359//_______________________________________________________________
930e6e3e 360TFile * AliQA::GetQADataFile(const char * name, const Int_t run)
46ca5304 361{
362 // opens the file to store the detectors Quality Assurance Data Maker results
930e6e3e 363 const char * temp = Form("%s.%s.%d.root", name, fgQADataFileName.Data(), run) ;
96d67a8d 364 TString opt ;
365 if (! fgQADataFile ) {
366 if (gSystem->AccessPathName(temp))
367 opt = "NEW" ;
368 else
369 opt = "UPDATE" ;
370 fgQADataFile = TFile::Open(temp, opt.Data()) ;
371 } else {
372 if ( strcmp(temp, fgQADataFile->GetName()) != 0 ) {
373 fgQADataFile = dynamic_cast<TFile *>(gROOT->FindObject(temp)) ;
374 if ( !fgQADataFile ) {
375 if (gSystem->AccessPathName(temp))
376 opt = "NEW" ;
377 else
378 opt = "UPDATE" ;
379 fgQADataFile = TFile::Open(temp, opt.Data()) ;
380 }
381 }
46ca5304 382 }
96d67a8d 383 return fgQADataFile ;
46ca5304 384}
385
386//_____________________________________________________________________________
387TFile * AliQA::GetQADataFile(const char * fileName)
388{
389 // Open if necessary the Data file and return its pointer
390
391 if (!fgQADataFile)
392 if (!fileName)
393 fileName = AliQA::GetQADataFileName() ;
394 if (!gSystem->AccessPathName(fileName)) {
395 fgQADataFile = TFile::Open(fileName) ;
396 } else {
397 printf("File %s not found", fileName) ;
398 exit(1) ;
399 }
400 return fgQADataFile ;
401}
402
403//_______________________________________________________________
4ecde5fc 404TFile * AliQA::GetQAResultFile()
405{
406 // opens the file to store the Quality Assurance Data Checker results
2ba0b5f5 407 if (fgQAResultFile)
408 fgQAResultFile->Close() ;
409 fgQAResultFile = 0x0 ;
410// if (!fgQAResultFile) {
1c0190ec 411 TString dirName(fgQAResultDirName) ;
4edbc5bc 412 if ( dirName.Contains(fkgLabLocalFile))
413 dirName.ReplaceAll(fkgLabLocalFile, "") ;
1c0190ec 414 TString fileName(dirName + fgQAResultFileName) ;
46ca5304 415 TString opt("") ;
416 if ( !gSystem->AccessPathName(fileName) )
417 opt = "UPDATE" ;
5bd22145 418 else {
1c0190ec 419 if ( gSystem->AccessPathName(dirName) )
420 gSystem->mkdir(dirName) ;
46ca5304 421 opt = "NEW" ;
5bd22145 422 }
46ca5304 423 fgQAResultFile = TFile::Open(fileName, opt) ;
2ba0b5f5 424// }
46ca5304 425
426 return fgQAResultFile ;
421ab0fb 427}
428
429//_______________________________________________________________
f12d42ce 430AliQA::TASKINDEX_t AliQA::GetTaskIndex(const char * name)
940d8e5f 431{
432 // returns the detector index corresponding to a given name
433 TString sname(name) ;
750730d8 434 TASKINDEX_t rv = kNULLTASKINDEX ;
75f6ebf0 435 for (Int_t tsk = 0; tsk < kNTASKINDEX ; tsk++) {
940d8e5f 436 if ( GetTaskName(tsk) == sname ) {
437 rv = TASKINDEX_t(tsk) ;
438 break ;
439 }
440 }
441 return rv ;
442}
443
444//_______________________________________________________________
57acd2d2 445Bool_t AliQA::IsSet(DETECTORINDEX_t det, ALITASK_t tsk, Int_t ies, QABIT_t bit) const
446{
447 // Checks is the requested bit is set
448
449 const AliRecoParam::EventSpecie_t es = AliRecoParam::Convert(ies) ;
450 return IsSet(det, tsk, es, bit) ;
451
452}
453
454//_______________________________________________________________
455Bool_t AliQA::IsSet(DETECTORINDEX_t det, ALITASK_t tsk, AliRecoParam::EventSpecie_t es, QABIT_t bit) const
421ab0fb 456{
457 // Checks is the requested bit is set
384c0618 458
421ab0fb 459 CheckRange(det) ;
460 CheckRange(tsk) ;
461 CheckRange(bit) ;
57acd2d2 462 CheckRange(es) ;
384c0618 463
421ab0fb 464 ULong_t offset = Offset(tsk) ;
57acd2d2 465 ULong_t status = GetStatus(det, es) ;
421ab0fb 466 offset+= bit ;
467 status = (status & 1 << offset) != 0 ;
468 return status ;
469}
470
471//_______________________________________________________________
57acd2d2 472Bool_t AliQA::IsSetAny(DETECTORINDEX_t det, ALITASK_t tsk, AliRecoParam::EventSpecie_t es) const
384c0618 473{
474 // Checks is the requested bit is set
475
476 CheckRange(det) ;
477 CheckRange(tsk) ;
57acd2d2 478 CheckRange(es) ;
384c0618 479
480 ULong_t offset = Offset(tsk) ;
57acd2d2 481 ULong_t status = GetStatus(det, es) ;
1aaf4118 482 ULong_t st = 0 ;
384c0618 483 for ( Int_t bit = 0 ; bit < kNBIT ; bit++) {
484 offset+= bit ;
485 st += (status & 1 << offset) != 0 ;
486 }
487 if ( st == 0 )
488 return kFALSE ;
489 else
490 return kTRUE ;
491}
492//_______________________________________________________________
57acd2d2 493Bool_t AliQA::IsSetAny(DETECTORINDEX_t det, AliRecoParam::EventSpecie_t es) const
384c0618 494{
495 // Checks is the requested bit is set
496
497 CheckRange(det) ;
57acd2d2 498 CheckRange(es) ;
384c0618 499
57acd2d2 500 ULong_t status = GetStatus(det, es) ;
1aaf4118 501 ULong_t st = 0 ;
384c0618 502 for ( Int_t tsk = 0 ; tsk < kNTASK ; tsk++) {
503 ULong_t offset = Offset(ALITASK_t(tsk)) ;
504 for ( Int_t bit = 0 ; bit < kNBIT ; bit++) {
505 offset+= bit ;
506 st += (status & 1 << offset) != 0 ;
507 }
508 }
509 if ( st == 0 )
510 return kFALSE ;
511 else
512 return kTRUE ;
513}
514
515//_______________________________________________________________
2e42b4d4 516AliQA * AliQA::Instance()
421ab0fb 517{
57acd2d2 518 // Get an instance of the singleton. The only authorized way to call the ctor
421ab0fb 519
57acd2d2 520 if ( ! fgQA) {
521 TFile * f = GetQAResultFile() ;
522 fgQA = dynamic_cast<AliQA *>(f->Get("QA")) ;
523 if ( ! fgQA )
524 fgQA = new AliQA() ;
525 }
421ab0fb 526 return fgQA ;
527}
528
529//_______________________________________________________________
96d67a8d 530AliQA * AliQA::Instance(const DETECTORINDEX_t det)
421ab0fb 531{
532 // Get an instance of the singleton. The only authorized way to call the ctor
533
9a223722 534 if ( ! fgQA) {
46ca5304 535 TFile * f = GetQAResultFile() ;
9a223722 536 fgQA = dynamic_cast<AliQA *>(f->Get("QA")) ;
537 if ( ! fgQA )
538 fgQA = new AliQA(det) ;
539 }
421ab0fb 540 fgQA->Set(det) ;
541 return fgQA ;
542}
543
544//_______________________________________________________________
96d67a8d 545AliQA * AliQA::Instance(const ALITASK_t tsk)
421ab0fb 546{
57acd2d2 547 // Get an instance of the singleton. The only authorized way to call the ctor
421ab0fb 548
549 if ( ! fgQA)
550 switch (tsk) {
551 case kNULLTASK:
552 break ;
6c18591a 553 case kRAW:
2e42b4d4 554 fgQA = new AliQA(tsk) ;
6c18591a 555 break ;
556 case kSIM:
2e42b4d4 557 fgQA = new AliQA(tsk) ;
421ab0fb 558 break ;
559 case kREC:
560 printf("fgQA = gAlice->GetQA()") ;
561 break ;
562 case kESD:
563 printf("fgQA = dynamic_cast<AliQA *> (esdFile->Get(\"QA\")") ;
564 break ;
565 case kANA:
566 printf("fgQA = dynamic_cast<AliQA *> (esdFile->Get(\"QA\")") ;
567 break ;
568 case kNTASK:
569 break ;
570 }
571 if (fgQA)
572 fgQA->Set(tsk) ;
573 return fgQA ;
574}
575
576//_______________________________________________________________
96d67a8d 577AliQA * AliQA::Instance(const TASKINDEX_t tsk)
578{
579 // get an instance of the singleton.
580
581 ALITASK_t index = kNULLTASK ;
582
583 if ( tsk == kRAWS )
584 index = kRAW ;
585 else if (tsk < kDIGITS)
586 index = kSIM ;
587 else if (tsk < kRECPARTICLES)
588 index = kREC ;
589 else if (tsk == kESDS)
590 index = kESD ;
591
592 return Instance(index) ;
593}
594
595//_______________________________________________________________
0acdb2bb 596void AliQA::Merge(TCollection * list) {
597 // Merge the QA resuls in the list into this single AliQA object
598
599 for (Int_t det = 0 ; det < kNDET ; det++) {
600 Set(DETECTORINDEX_t(det)) ;
601 for (Int_t task = 0 ; task < kNTASK ; task++) {
602 Set(ALITASK_t(task)) ;
603 for (Int_t bit = 0 ; bit < kNBIT ; bit++) {
604 TIter next(list) ;
605 AliQA * qa ;
606 while ( (qa = (AliQA*)next() ) ) {
57acd2d2 607 for (Int_t es = 0 ; es < fNEventSpecie ; es++) {
608 if (qa->IsSet(DETECTORINDEX_t(det), ALITASK_t(task), es, QABIT_t(bit)))
609 Set(QABIT_t(bit), es) ;
610 }
0acdb2bb 611 } // qa list
612 } // bit
613 } // task
614 } // detector
615}
616
617//_______________________________________________________________
f12d42ce 618ULong_t AliQA::Offset(ALITASK_t tsk) const
421ab0fb 619{
620 // Calculates the bit offset for a given module (SIM, REC, ESD, ANA)
621
622 CheckRange(tsk) ;
623
624 ULong_t offset = 0 ;
625 switch (tsk) {
626 case kNULLTASK:
627 break ;
6c18591a 628 case kRAW:
421ab0fb 629 offset+= 0 ;
630 break ;
6c18591a 631 case kSIM:
421ab0fb 632 offset+= 4 ;
633 break ;
6c18591a 634 case kREC:
421ab0fb 635 offset+= 8 ;
636 break ;
6c18591a 637 case kESD:
421ab0fb 638 offset+= 12 ;
639 break ;
6c18591a 640 case kANA:
641 offset+= 16 ;
642 break ;
421ab0fb 643 case kNTASK:
644 break ;
645 }
646
647 return offset ;
648}
649
650//_______________________________________________________________
57acd2d2 651void AliQA::ResetStatus(DETECTORINDEX_t det)
652{
653 // reset the status of det for all event specie
654 for (Int_t es = 0 ; es < fNEventSpecie ; es++)
655 fQA[det][es] = 0 ;
656}
657
658//_______________________________________________________________
659void AliQA::Set(QABIT_t bit, Int_t ies)
421ab0fb 660{
57acd2d2 661 // Set the status bit of the current detector in the current module and for the current event specie
662 Set(bit, AliRecoParam::Convert(ies)) ;
663}
664
665//_______________________________________________________________
666void AliQA::Set(QABIT_t bit, AliRecoParam::EventSpecie_t es)
667{
668 // Set the status bit of the current detector in the current module and for the current event specie
421ab0fb 669
57acd2d2 670 SetStatusBit(fDet, fTask, es, bit) ;
421ab0fb 671}
672
4ecde5fc 673//_____________________________________________________________________________
4edbc5bc 674void AliQA::SetQARefStorage(const char * name)
4ecde5fc 675{
72c25501 676 // Set the root directory where the QA reference data are stored
677
678 fgQARefDirName = name ;
679 if ( fgQARefDirName.Contains(fkgLabLocalFile) )
680 fgQARefFileName = fkgRefFileName ;
681 else if ( fgQARefDirName.Contains(fkgLabLocalOCDB) )
96d67a8d 682 fgQARefFileName = fkgQAName ;
72c25501 683 else if ( fgQARefDirName.Contains(fkgLabAliEnOCDB) )
96d67a8d 684 fgQARefFileName = fkgQAName ;
4ecde5fc 685
4edbc5bc 686 else {
687 printf("ERROR: %s is an invalid storage definition\n", name) ;
688 fgQARefDirName = "" ;
689 fgQARefFileName = "" ;
690 }
72c25501 691 TString tmp(fgQARefDirName) ; // + fgQARefFileName) ;
4edbc5bc 692 printf("AliQA::SetQARefDir: QA references are in %s\n", tmp.Data() ) ;
4ecde5fc 693}
694
695//_____________________________________________________________________________
696void AliQA::SetQAResultDirName(const char * name)
697{
698 // Set the root directory where to store the QA status object
699
700 fgQAResultDirName.Prepend(name) ;
701 printf("AliQA::SetQAResultDirName: QA results are in %s\n", fgQAResultDirName.Data()) ;
4edbc5bc 702 if ( fgQAResultDirName.Contains(fkgLabLocalFile))
703 fgQAResultDirName.ReplaceAll(fkgLabLocalFile, "") ;
4ecde5fc 704 fgQAResultFileName.Prepend(fgQAResultDirName) ;
705}
706
421ab0fb 707//_______________________________________________________________
57acd2d2 708void AliQA::SetStatusBit(DETECTORINDEX_t det, ALITASK_t tsk, AliRecoParam::EventSpecie_t es, QABIT_t bit)
421ab0fb 709{
710 // Set the status bit for a given detector and a given task
711
712 CheckRange(det) ;
713 CheckRange(tsk) ;
714 CheckRange(bit) ;
57acd2d2 715 CheckRange(es) ;
421ab0fb 716
717 ULong_t offset = Offset(tsk) ;
57acd2d2 718 ULong_t status = GetStatus(det, es) ;
421ab0fb 719 offset+= bit ;
720 status = status | 1 << offset ;
57acd2d2 721 SetStatus(det, es, status) ;
722}
723
724//_______________________________________________________________
725void AliQA::Show() const
726{
727 // dispplay the QA status word
728
729 for (Int_t ies = 0 ; ies < fNEventSpecie ; ies++) {
730 const Bool_t what = IsEventSpecieSet(ies) ;
731 if ( what )
732 ShowStatus(fDet, fTask, AliRecoParam::Convert(ies)) ;
733 }
734}
735
736//_______________________________________________________________
737void AliQA::Show(DETECTORINDEX_t det) const
738{
739 // dispplay the QA status word
740
741 for (Int_t ies = 0 ; ies < fNEventSpecie ; ies++) {
742 const Bool_t what = IsEventSpecieSet(ies) ;
743 if ( what )
744 ShowStatus(fDet, kNULLTASK, AliRecoParam::Convert(ies)) ;
745 }
421ab0fb 746}
747
748//_______________________________________________________________
57acd2d2 749void AliQA::ShowAll() const
421ab0fb 750{
751 // dispplay the QA status word
752 Int_t index ;
15df7cc8 753 for (index = 0 ; index < kNDET ; index++) {
754 for (Int_t tsk = kRAW ; tsk < kNTASK ; tsk++) {
57acd2d2 755 for (Int_t ies = 0 ; ies < fNEventSpecie ; ies++) {
756 const Bool_t what = IsEventSpecieSet(ies) ;
757 if ( what )
758 ShowStatus(DETECTORINDEX_t(index), ALITASK_t(tsk), AliRecoParam::Convert(ies)) ;
759 }
760 }
15df7cc8 761 }
421ab0fb 762}
763
764//_______________________________________________________________
57acd2d2 765void AliQA::ShowStatus(DETECTORINDEX_t det, ALITASK_t tsk, AliRecoParam::EventSpecie_t es) const
421ab0fb 766{
0b96c27c 767 // Prints the full QA status of a given detector
768 CheckRange(det) ;
57acd2d2 769 CheckRange(es) ;
770 ULong_t status = GetStatus(det, es) ;
0b96c27c 771 ULong_t tskStatus[kNTASK] ;
772 tskStatus[kRAW] = status & 0x0000f ;
773 tskStatus[kSIM] = status & 0x000f0 ;
774 tskStatus[kREC] = status & 0x00f00 ;
775 tskStatus[kESD] = status & 0x0f000 ;
776 tskStatus[kANA] = status & 0xf0000 ;
777
57acd2d2 778 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),
0b96c27c 779 tskStatus[kRAW], tskStatus[kSIM], tskStatus[kREC], tskStatus[kESD], tskStatus[kANA] )) ;
15df7cc8 780 if (tsk == kNULLTASK) {
781 for (Int_t itsk = kRAW ; itsk < kNTASK ; itsk++) {
57acd2d2 782 ShowASCIIStatus(es, det, ALITASK_t(itsk), tskStatus[itsk]) ;
15df7cc8 783 }
784 } else {
57acd2d2 785 ShowASCIIStatus(es, det, tsk, tskStatus[tsk]) ;
0b96c27c 786 }
787}
421ab0fb 788
0b96c27c 789//_______________________________________________________________
57acd2d2 790void AliQA::ShowASCIIStatus(AliRecoParam::EventSpecie_t es, DETECTORINDEX_t det, ALITASK_t tsk, const ULong_t status) const
0b96c27c 791{
792 // print the QA status in human readable format
793 TString text;
794 for (Int_t bit = kINFO ; bit < kNBIT ; bit++) {
57acd2d2 795 if (IsSet(det, tsk, es, QABIT_t(bit))) {
0b96c27c 796 text = GetBitName(QABIT_t(bit)) ;
797 text += " " ;
798 }
799 }
800 if (! text.IsNull())
57acd2d2 801 printf(" %8s %8s %4s 0x%4lx, Problem signalled: %8s \n", AliRecoParam::GetEventSpecieName(es), GetDetName(det).Data(), GetAliTaskName(tsk), status, text.Data()) ;
802}
803
804//_______________________________________________________________
805void AliQA::UnSet(QABIT_t bit, Int_t ies)
806{
807 // UnSet the status bit of the current detector in the current module
808 UnSet(bit, AliRecoParam::Convert(ies)) ;
421ab0fb 809}
810
96d67a8d 811//_______________________________________________________________
57acd2d2 812void AliQA::UnSet(QABIT_t bit, AliRecoParam::EventSpecie_t es)
96d67a8d 813{
814 // UnSet the status bit of the current detector in the current module
815
57acd2d2 816 UnSetStatusBit(fDet, fTask, es, bit) ;
96d67a8d 817}
818
819//_______________________________________________________________
57acd2d2 820void AliQA::UnSetStatusBit(DETECTORINDEX_t det, ALITASK_t tsk, AliRecoParam::EventSpecie_t es, QABIT_t bit)
96d67a8d 821{
822 // UnSet the status bit for a given detector and a given task
823
824 CheckRange(det) ;
825 CheckRange(tsk) ;
826 CheckRange(bit) ;
57acd2d2 827 CheckRange(es) ;
96d67a8d 828
829 ULong_t offset = Offset(tsk) ;
57acd2d2 830 ULong_t status = GetStatus(det, es) ;
96d67a8d 831 offset+= bit ;
832 status = status & 0 << offset ;
57acd2d2 833 SetStatus(det, es, status) ;
92a357bf 834}