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