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