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