1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
17 //////////////////////////////////////////////////////////////////////////////
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 (SIM)
23 // bit 4-7 : QA raised during reconstruction (REC)
24 // bit 8-11 : QA raised during ESD checking (ESD)
25 // bit 12-15: QA raised during analysis (ANA)
26 // Each of the 4 bits corresponds to a severity level of increasing importance
27 // from lower to higher bit (INFO, WARNING, ERROR, FATAL)
29 //*-- Yves Schutz CERN, July 2007
30 //////////////////////////////////////////////////////////////////////////////
33 // --- ROOT system ---
37 // --- Standard library ---
39 // --- AliRoot header files ---
41 #include "AliQualAss.h"
46 AliQualAss * AliQualAss::fgQA = 0x0 ;
47 TFile * AliQualAss::fgDataFile = 0x0 ;
48 TString AliQualAss::fgDataName = "QA.root" ;
49 TString AliQualAss::fgDetNames[] = {"ITS", "TPC", "TRD", "TOF", "PHOS", "HMPID", "EMCAL", "MUON", "FMD",
50 "ZDC", "PMD", "T0", "VZERO", "ACORDE", "HLT"} ;
51 TString AliQualAss::fgTaskNames[] = {"Hits", "SDigits", "Digits", "RecPoints", "TrackSegments", "RecParticles", "ESDs"} ;
53 //____________________________________________________________________________
54 AliQualAss::AliQualAss() :
61 // default constructor
62 // beware singleton: not to be used
65 //____________________________________________________________________________
66 AliQualAss::AliQualAss(const AliQualAss& qa) :
76 //_____________________________________________________________________________
77 AliQualAss& AliQualAss::operator = (const AliQualAss& qa)
79 // assignment operator
82 new(this) AliQualAss(qa);
86 //_______________________________________________________________
87 AliQualAss::AliQualAss(const DETECTORINDEX det) :
88 TNamed("QA", "Quality Assurance status"),
94 // constructor to be used
95 if (! CheckRange(det) ) {
99 fQA = new ULong_t[kNDET] ;
101 for (index = 0; index < kNDET; index++)
105 //_______________________________________________________________
106 AliQualAss::AliQualAss(const ALITASK tsk) :
107 TNamed("QA", "Quality Assurance status"),
113 // constructor to be used in the AliRoot module (SIM, REC, ESD or ANA)
114 if (! CheckRange(tsk) ) {
118 fQA = new ULong_t[kNDET] ;
120 for (index = 0; index < kNDET; index++)
124 //____________________________________________________________________________
125 AliQualAss::~AliQualAss()
131 //_______________________________________________________________
132 const Bool_t AliQualAss::CheckRange(DETECTORINDEX det) const
134 // check if detector is in given detector range: 0-fNdet
136 Bool_t rv = ( det < 0 || det > kNDET ) ? kFALSE : kTRUE ;
138 AliFatal(Form("Detector index %d is out of range: 0 <= index <= %d", det, kNDET)) ;
142 //_______________________________________________________________
143 const Bool_t AliQualAss::CheckRange(ALITASK task) const
145 // check if task is given taskk range: 0:kNTASK
146 Bool_t rv = ( task < kSIM || task > kNTASK ) ? kFALSE : kTRUE ;
148 AliFatal(Form("Module index %d is out of range: 0 <= index <= %d", task, kNTASK)) ;
152 //_______________________________________________________________
153 const Bool_t AliQualAss::CheckRange(QABIT bit) const
155 // check if bit is in given bit range: 0-kNBit
157 Bool_t rv = ( bit < 0 || bit > kNBIT ) ? kFALSE : kTRUE ;
159 AliFatal(Form("Status bit %d is out of range: 0 <= bit <= %d", bit, kNBIT)) ;
164 //_______________________________________________________________
165 TFile * AliQualAss::GetQADMOutFile()
167 // opens the file to store the detectors Quality Assurance Data Maker results
171 if (gSystem->AccessPathName(fgDataName.Data()))
176 fgDataFile = TFile::Open(fgDataName.Data(), opt.Data()) ;
181 //_______________________________________________________________
182 const char * AliQualAss::GetDetName(Int_t det)
184 // returns the detector name corresponding to a given index (needed in a loop)
186 if ( det >= 0 && det < kNDET)
187 return (fgDetNames[det]).Data() ;
192 //_______________________________________________________________
193 const char * AliQualAss::GetAliTaskName(ALITASK tsk)
195 // returns the char name corresponding to module index
216 return tskName.Data() ;
219 //_______________________________________________________________
220 const Bool_t AliQualAss::CheckFatal() const
222 // check if any FATAL status is set
225 for (index = 0; index < kNDET ; index++)
226 rv = rv || IsSet(DETECTORINDEX(index), fTask, kFATAL) ;
230 //_______________________________________________________________
231 const Bool_t AliQualAss::IsSet(DETECTORINDEX det, ALITASK tsk, QABIT bit) const
233 // Checks is the requested bit is set
239 ULong_t offset = Offset(tsk) ;
240 ULong_t status = GetStatus(det) ;
242 status = (status & 1 << offset) != 0 ;
246 //_______________________________________________________________
247 AliQualAss * AliQualAss::Instance()
249 // Get an instance of the singleton.
250 // Object must have been instantiated with Instance(ALITASK) first
255 //_______________________________________________________________
256 AliQualAss * AliQualAss::Instance(const DETECTORINDEX det)
258 // Get an instance of the singleton. The only authorized way to call the ctor
261 fgQA = new AliQualAss(det) ;
266 //_______________________________________________________________
267 AliQualAss * AliQualAss::Instance(const ALITASK tsk)
269 // get an instance of the singleton.
276 fgQA = new AliQualAss(tsk) ;
279 printf("fgQA = gAlice->GetQA()") ;
282 printf("fgQA = dynamic_cast<AliQA *> (esdFile->Get(\"QA\")") ;
285 printf("fgQA = dynamic_cast<AliQA *> (esdFile->Get(\"QA\")") ;
295 //_______________________________________________________________
296 const ULong_t AliQualAss::Offset(ALITASK tsk) const
298 // Calculates the bit offset for a given module (SIM, REC, ESD, ANA)
325 //_______________________________________________________________
326 void AliQualAss::Set(QABIT bit)
328 // Set the status bit of the current detector in the current module
330 SetStatusBit(fDet, fTask, bit) ;
333 //_______________________________________________________________
334 void AliQualAss::SetStatusBit(DETECTORINDEX det, ALITASK tsk, QABIT bit)
336 // Set the status bit for a given detector and a given task
342 ULong_t offset = Offset(tsk) ;
343 ULong_t status = GetStatus(det) ;
345 status = status | 1 << offset ;
346 SetStatus(det, status) ;
349 //_______________________________________________________________
350 void AliQualAss::ShowAll() const
352 // dispplay the QA status word
354 for (index = 0 ; index < kNDET ; index++)
355 ShowStatus(DETECTORINDEX(index)) ;
358 //_______________________________________________________________
359 void AliQualAss::ShowStatus(DETECTORINDEX det) const
361 // Prints the full QA status of a given detector
363 ULong_t status = GetStatus(det) ;
364 ULong_t simStatus = status & 0x000f ;
365 ULong_t recStatus = status & 0x00f0 ;
366 ULong_t esdStatus = status & 0x0f00 ;
367 ULong_t anaStatus = status & 0xf000 ;
369 AliInfo(Form("QA Status for %s sim=0x%x, rec=0x%x, esd=0x%x, ana=0x%x\n", GetDetName(det).Data(), simStatus, recStatus, esdStatus, anaStatus )) ;