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