]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - STEER/AliQAv1.cxx
Processing SPD Mean Vertex only in PHYSICS runs.
[u/mrichter/AliRoot.git] / STEER / AliQAv1.cxx
... / ...
CommitLineData
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 ---
37#include <TClass.h>
38#include <TFile.h>
39#include <TH1.h>
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)
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"} ;
64TString AliQAv1::fgModeNames[] = {"", "Sim", "Rec"} ;
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" ;
75const UInt_t AliQAv1::fgkExpertBit = BIT(19);
76const UInt_t AliQAv1::fgkQABit = BIT(20) ;
77const UInt_t AliQAv1::fgkImageBit = BIT(21) ;
78const Int_t AliQAv1::fgkQADebugLevel = 99 ;
79const TString AliQAv1::fImageFileName = "QAImage" ;
80const TString AliQAv1::fImageFileFormat = "ps" ;
81const UShort_t AliQAv1::fgkMaxQAObjects = 10000 ;
82
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:
324 bitName = "NONE" ;
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
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
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 ) {
404 fgQADataFile = static_cast<TFile *>(gROOT->FindObject(temp)) ;
405 if ( !fgQADataFile ) {
406 if (gSystem->AccessPathName(temp))
407 opt = "NEW" ;
408 else
409 opt = "UPDATE" ;
410 fgQADataFile = TFile::Open(temp, opt.Data()) ;
411 }
412 }
413 }
414 return fgQADataFile ;
415}
416
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 }
452 return AliQAv1::kNULLMODE;
453}
454
455//_____________________________________________________________________________
456TFile * AliQAv1::GetQADataFile(const char * fileName)
457{
458 // Open if necessary the Data file and return its pointer
459
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 }
469 return fgQADataFile ;
470}
471
472//_______________________________________________________________
473TFile * AliQAv1::GetQAResultFile()
474{
475 // opens the file to store the Quality Assurance Data Checker results
476 if (fgQAResultFile && fgQAResultFile->IsOpen())
477 {
478 fgQAResultFile->Close();
479 }
480 delete fgQAResultFile;
481 fgQAResultFile=0x0;
482
483 TString dirName(fgQAResultDirName) ;
484 if ( dirName.Contains(fgkLabLocalFile))
485 dirName.ReplaceAll(fgkLabLocalFile, "") ;
486 TString fileName(dirName + fgQAResultFileName) ;
487 TString opt("") ;
488 if ( !gSystem->AccessPathName(fileName) )
489 opt = "UPDATE" ;
490 else {
491 if ( gSystem->AccessPathName(dirName) )
492 gSystem->mkdir(dirName) ;
493 opt = "NEW" ;
494 }
495 fgQAResultFile = TFile::Open(fileName, opt) ;
496
497 return fgQAResultFile ;
498}
499
500//_______________________________________________________________
501AliQAv1::QABIT_t AliQAv1::GetQAStatusBit(AliRecoParam::EventSpecie_t es, DETECTORINDEX_t det, ALITASK_t tsk) const
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//_______________________________________________________________
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) {
610 TFile * f = GetQAResultFile() ;
611 fgQA = static_cast<AliQAv1 *>(f->Get("QA")) ;
612 f->Close() ;
613 if ( ! fgQA )
614 fgQA = new AliQAv1() ;
615 }
616 return fgQA ;
617}
618
619//_______________________________________________________________
620AliQAv1 * AliQAv1::Instance(const Int_t qalength, ULong_t * qa, const Int_t eslength, Bool_t * es)
621{
622 // Get an instance of the singleton. The only authorized way to call the ctor
623
624 if ( ! fgQA)
625 fgQA = new AliQAv1(qalength, qa, eslength, es) ;
626 return fgQA ;
627}
628
629//_______________________________________________________________
630AliQAv1 * AliQAv1::Instance(const DETECTORINDEX_t det)
631{
632 // Get an instance of the singleton. The only authorized way to call the ctor
633
634 if ( ! fgQA) {
635 TFile * f = GetQAResultFile() ;
636 fgQA = static_cast<AliQAv1 *>(f->Get(GetQAName())) ;
637 if ( ! fgQA )
638 fgQA = new AliQAv1(det) ;
639 }
640 fgQA->Set(det) ;
641 return fgQA ;
642}
643
644//_______________________________________________________________
645AliQAv1 * AliQAv1::Instance(const ALITASK_t tsk)
646{
647 // Get an instance of the singleton. The only authorized way to call the ctor
648
649 if ( ! fgQA)
650 switch (tsk) {
651 case kNULLTASK:
652 break ;
653 case kRAW:
654 fgQA = new AliQAv1(tsk) ;
655 break ;
656 case kSIM:
657 fgQA = new AliQAv1(tsk) ;
658 break ;
659 case kREC:
660 AliInfoClass("fgQA = gAlice->GetQA()") ;
661 break ;
662 case kESD:
663 AliInfoClass("fgQA = static_cast<AliQAv1 *> (esdFile->Get(\"QA\")") ;
664 break ;
665 case kANA:
666 AliInfoClass("fgQA = static_cast<AliQAv1 *> (esdFile->Get(\"QA\")") ;
667 break ;
668 case kNTASK:
669 break ;
670 }
671 if (fgQA)
672 fgQA->Set(tsk) ;
673 return fgQA ;
674}
675
676//_______________________________________________________________
677AliQAv1 * AliQAv1::Instance(const TASKINDEX_t tsk)
678{
679 // get an instance of the singleton.
680
681 ALITASK_t index = kNULLTASK ;
682
683 if ( tsk == kRAWS )
684 index = kRAW ;
685 else if (tsk < kDIGITS)
686 index = kSIM ;
687 else if (tsk < kRECPARTICLES)
688 index = kREC ;
689 else if (tsk == kESDS)
690 index = kESD ;
691
692 return Instance(index) ;
693}
694
695//_______________________________________________________________
696void AliQAv1::Merge(TCollection * list) {
697 // Merge the QA resuls in the list into this single AliQAv1 object
698
699 for (Int_t det = 0 ; det < kNDET ; det++) {
700 Set(DETECTORINDEX_t(det)) ;
701 for (Int_t task = 0 ; task < kNTASK ; task++) {
702 Set(ALITASK_t(task)) ;
703 for (Int_t bit = 0 ; bit < kNBIT ; bit++) {
704 TIter next(list) ;
705 AliQAv1 * qa ;
706 while ( (qa = (AliQAv1*)next() ) ) {
707 for (Int_t es = 0 ; es < fNEventSpecies ; es++) {
708 if (qa->IsSet(DETECTORINDEX_t(det), ALITASK_t(task), es, QABIT_t(bit)))
709 Set(QABIT_t(bit), es) ;
710 }
711 } // qa list
712 } // bit
713 } // task
714 } // detector
715}
716
717//_______________________________________________________________
718ULong_t AliQAv1::Offset(ALITASK_t tsk) const
719{
720 // Calculates the bit offset for a given module (SIM, REC, ESD, ANA)
721
722 CheckRange(tsk) ;
723
724 ULong_t offset = 0 ;
725 switch (tsk) {
726 case kNULLTASK:
727 break ;
728 case kRAW:
729 offset+= 0 ;
730 break ;
731 case kSIM:
732 offset+= 4 ;
733 break ;
734 case kREC:
735 offset+= 8 ;
736 break ;
737 case kESD:
738 offset+= 12 ;
739 break ;
740 case kANA:
741 offset+= 16 ;
742 break ;
743 case kNTASK:
744 break ;
745 }
746
747 return offset ;
748}
749
750//_______________________________________________________________
751void AliQAv1::Reset(DETECTORINDEX_t det, ALITASK_t tsk, AliRecoParam::EventSpecie_t es)
752{
753 // resets all the bits for a given tsk and event specie
754 CheckRange(det) ;
755 CheckRange(tsk) ;
756 CheckRange(es) ;
757
758 ULong_t offset = Offset(tsk) ;
759 ULong_t status = GetStatus(det, es) ;
760 for ( Int_t bit = 0 ; bit < kNBIT ; bit++) {
761 offset+= bit ;
762 status = status & ~1 << offset ;
763 }
764 SetStatus(det, es, status) ;
765}
766
767//_______________________________________________________________
768void AliQAv1::ResetStatus(DETECTORINDEX_t det)
769{
770 // reset the status of det for all event specie
771 for (Int_t es = 0 ; es < fNEventSpecies ; es++)
772 fQA[det*fNdet+es] = 0 ;
773}
774
775//_______________________________________________________________
776void AliQAv1::Set(QABIT_t bit, Int_t ies)
777{
778 // Set the status bit of the current detector in the current module and for the current event specie
779 Set(bit, AliRecoParam::Convert(ies)) ;
780}
781
782//_______________________________________________________________
783void AliQAv1::Set(QABIT_t bit, AliRecoParam::EventSpecie_t es)
784{
785 // Set the status bit of the current detector in the current module and for the current event specie
786
787 SetStatusBit(fDet, fTask, es, bit) ;
788}
789
790//_____________________________________________________________________________
791void AliQAv1::SetQARefStorage(const char * name)
792{
793 // Set the root directory where the QA reference data are stored
794
795 fgQARefDirName = name ;
796 if ( fgQARefDirName.Contains(fgkLabLocalFile) )
797 fgQARefFileName = fgkRefFileName ;
798 else if ( fgQARefDirName.Contains(fgkLabLocalOCDB) )
799 fgQARefFileName = fgkQAName ;
800 else if ( fgQARefDirName.Contains(fgkLabAliEnOCDB) )
801 fgQARefFileName = fgkQAName ;
802
803 else {
804 AliErrorClass(Form("ERROR: %s is an invalid storage definition\n", name)) ;
805 fgQARefDirName = "" ;
806 fgQARefFileName = "" ;
807 }
808 TString tmp(fgQARefDirName) ; // + fgQARefFileName) ;
809 AliInfoClass(Form("AliQAv1::SetQARefDir: QA references are in %s\n", tmp.Data() )) ;
810}
811
812//_____________________________________________________________________________
813void AliQAv1::SetQAResultDirName(const char * name)
814{
815 // Set the root directory where to store the QA status object
816
817 fgQAResultDirName.Prepend(name) ;
818 AliInfoClass(Form("AliQAv1::SetQAResultDirName: QA results are in %s\n", fgQAResultDirName.Data())) ;
819 if ( fgQAResultDirName.Contains(fgkLabLocalFile))
820 fgQAResultDirName.ReplaceAll(fgkLabLocalFile, "") ;
821 fgQAResultFileName.Prepend(fgQAResultDirName) ;
822}
823
824//_______________________________________________________________
825void AliQAv1::SetStatusBit(DETECTORINDEX_t det, ALITASK_t tsk, AliRecoParam::EventSpecie_t es, QABIT_t bit)
826{
827 // Set the status bit for a given detector and a given task
828
829 CheckRange(det) ;
830 CheckRange(tsk) ;
831 CheckRange(bit) ;
832 CheckRange(es) ;
833
834 Reset(det, tsk, es) ;
835
836 ULong_t offset = Offset(tsk) ;
837 ULong_t status = GetStatus(det, es) ;
838 offset+= bit ;
839 status = status | 1 << offset ;
840 SetStatus(det, es, status) ;
841}
842
843//_______________________________________________________________
844void AliQAv1::Show(DETECTORINDEX_t det) const
845{
846 // dispplay the QA status word
847 if ( det == kNULLDET)
848 det = fDet ;
849 for (Int_t ies = 0 ; ies < fNEventSpecies ; ies++) {
850 if ( IsEventSpecieSet(ies) )
851 ShowStatus(det, kNULLTASK, AliRecoParam::ConvertIndex(ies)) ;
852 }
853}
854
855//_______________________________________________________________
856void AliQAv1::ShowAll() const
857{
858 // dispplay the QA status word
859 Int_t index ;
860 for (index = 0 ; index < kNDET ; index++) {
861 for (Int_t tsk = kRAW ; tsk < kNTASK ; tsk++) {
862 for (Int_t ies = 0 ; ies < fNEventSpecies ; ies++) {
863 if ( IsEventSpecieSet(ies) )
864 ShowStatus(DETECTORINDEX_t(index), ALITASK_t(tsk), AliRecoParam::ConvertIndex(ies)) ;
865 }
866 }
867 }
868}
869
870//_______________________________________________________________
871void AliQAv1::ShowStatus(DETECTORINDEX_t det, ALITASK_t tsk, AliRecoParam::EventSpecie_t es) const
872{
873 // Prints the full QA status of a given detector
874 CheckRange(det) ;
875 CheckRange(es) ;
876 ULong_t status = GetStatus(det, es) ;
877 ULong_t tskStatus[kNTASK] ;
878 tskStatus[kRAW] = status & 0x0000f ;
879 tskStatus[kSIM] = status & 0x000f0 ;
880 tskStatus[kREC] = status & 0x00f00 ;
881 tskStatus[kESD] = status & 0x0f000 ;
882 tskStatus[kANA] = status & 0xf0000 ;
883
884 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),
885 tskStatus[kRAW], tskStatus[kSIM], tskStatus[kREC], tskStatus[kESD], tskStatus[kANA] )) ;
886 if (tsk == kNULLTASK) {
887 for (Int_t itsk = kRAW ; itsk < kNTASK ; itsk++) {
888 ShowASCIIStatus(es, det, ALITASK_t(itsk), tskStatus[itsk]) ;
889 }
890 } else {
891 ShowASCIIStatus(es, det, tsk, tskStatus[tsk]) ;
892 }
893}
894
895//_______________________________________________________________
896void AliQAv1::ShowASCIIStatus(AliRecoParam::EventSpecie_t es, DETECTORINDEX_t det, ALITASK_t tsk, const ULong_t status) const
897{
898 // print the QA status in human readable format
899 TString text;
900 QABIT_t bit = GetQAStatusBit(es, det, tsk) ;
901 if ( bit != kNULLBit ) {
902 text = GetBitName(bit) ;
903 text += " " ;
904 AliInfoClass(Form(" %8s %8s %4s 0x%4lx, Problem signalled: %8s \n", AliRecoParam::GetEventSpecieName(es), GetDetName(det).Data(), GetAliTaskName(tsk), status, text.Data())) ;
905 }
906}
907
908//_______________________________________________________________
909void AliQAv1::UnSet(QABIT_t bit, Int_t ies)
910{
911 // UnSet the status bit of the current detector in the current module
912 UnSet(bit, AliRecoParam::Convert(ies)) ;
913}
914
915//_______________________________________________________________
916void AliQAv1::UnSet(QABIT_t bit, AliRecoParam::EventSpecie_t es)
917{
918 // UnSet the status bit of the current detector in the current module
919
920 UnSetStatusBit(fDet, fTask, es, bit) ;
921}
922
923//_______________________________________________________________
924void AliQAv1::UnSetStatusBit(DETECTORINDEX_t det, ALITASK_t tsk, AliRecoParam::EventSpecie_t es, QABIT_t bit)
925{
926 // UnSet the status bit for a given detector and a given task
927
928 CheckRange(det) ;
929 CheckRange(tsk) ;
930 CheckRange(bit) ;
931 CheckRange(es) ;
932
933 ULong_t offset = Offset(tsk) ;
934 ULong_t status = GetStatus(det, es) ;
935 offset+= bit ;
936 status = status & 0 << offset ;
937 SetStatus(det, es, status) ;
938}