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