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