2 /**************************************************************************
3 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5 * Author: The ALICE Off-line Project. *
6 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 //////////////////////////////////////////////////////////////////////////////
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 (SIM)
24 // bit 4-7 : QA raised during reconstruction (REC)
25 // bit 8-11 : QA raised during ESD checking (ESD)
26 // bit 12-15: 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)
30 //*-- Yves Schutz CERN, July 2007
31 //////////////////////////////////////////////////////////////////////////////
34 // --- ROOT system ---
38 // --- Standard library ---
40 // --- AliRoot header files ---
43 #include "AliQAChecker.h"
47 AliQA * AliQA::fgQA = 0x0 ;
48 TFile * AliQA::fgDataFile = 0x0 ;
49 TString AliQA::fgDataName = "QA" ;
50 TString AliQA::fgDetNames[] = {"ITS", "TPC", "TRD", "TOF", "PHOS", "HMPID", "EMCAL", "MUON", "FMD",
51 "ZDC", "PMD", "T0", "VZERO", "ACORDE", "HLT"} ;
52 TString AliQA::fgTaskNames[] = {"Raws", "Hits", "SDigits", "Digits", "RecPoints", "TrackSegments", "RecParticles", "ESDs"} ;
54 //____________________________________________________________________________
58 fQA(new ULong_t[fNdet]),
62 // default constructor
63 // beware singleton: not to be used
64 for (Int_t index = 0 ; index < fNdet ; index++)
68 //____________________________________________________________________________
69 AliQA::AliQA(const AliQA& qa) :
79 //_____________________________________________________________________________
80 AliQA& AliQA::operator = (const AliQA& qa)
82 // assignment operator
89 //_______________________________________________________________
90 AliQA::AliQA(const DETECTORINDEX det) :
91 TNamed("QA", "Quality Assurance status"),
93 fQA(new ULong_t[fNdet]),
97 // constructor to be used
98 if (! CheckRange(det) ) {
103 for (index = 0; index < fNdet; index++)
107 //_______________________________________________________________
108 AliQA::AliQA(const ALITASK tsk) :
109 TNamed("QA", "Quality Assurance status"),
111 fQA(new ULong_t[fNdet]),
115 // constructor to be used in the AliRoot module (SIM, REC, ESD or ANA)
116 if (! CheckRange(tsk) ) {
121 for (index = 0; index < fNdet; index++)
125 //____________________________________________________________________________
132 //_______________________________________________________________
133 const Bool_t AliQA::CheckRange(DETECTORINDEX det) const
135 // check if detector is in given detector range: 0-kNDET
137 Bool_t rv = ( det < 0 || det > kNDET ) ? kFALSE : kTRUE ;
139 AliFatal(Form("Detector index %d is out of range: 0 <= index <= %d", det, kNDET)) ;
143 //_______________________________________________________________
144 const Bool_t AliQA::CheckRange(ALITASK task) const
146 // check if task is given taskk range: 0:kNTASK
147 Bool_t rv = ( task < kRAW || task > kNTASK ) ? kFALSE : kTRUE ;
149 AliFatal(Form("Module index %d is out of range: 0 <= index <= %d", task, kNTASK)) ;
153 //_______________________________________________________________
154 const Bool_t AliQA::CheckRange(QABIT bit) const
156 // check if bit is in given bit range: 0-kNBit
158 Bool_t rv = ( bit < 0 || bit > kNBIT ) ? kFALSE : kTRUE ;
160 AliFatal(Form("Status bit %d is out of range: 0 <= bit <= %d", bit, kNBIT)) ;
165 //_______________________________________________________________
166 TFile * AliQA::GetQADMOutFile(const char * name, const Int_t run, const Int_t cycle)
168 // opens the file to store the detectors Quality Assurance Data Maker results
170 sprintf(temp, "%s.%s.%d.%d.root", name, fgDataName.Data(), run, cycle) ;
173 if (gSystem->AccessPathName(temp))
177 fgDataFile = TFile::Open(temp, opt.Data()) ;
179 if ( (strcmp(temp, fgDataFile->GetName()) != 0) ) {
180 if (gSystem->AccessPathName(temp))
184 fgDataFile = TFile::Open(temp, opt.Data()) ;
190 //_______________________________________________________________
191 const char * AliQA::GetDetName(Int_t det)
193 // returns the detector name corresponding to a given index (needed in a loop)
195 if ( det >= 0 && det < kNDET)
196 return (fgDetNames[det]).Data() ;
201 //_______________________________________________________________
202 const char * AliQA::GetAliTaskName(ALITASK tsk)
204 // returns the char name corresponding to module index
228 return tskName.Data() ;
231 //_______________________________________________________________
232 const Bool_t AliQA::CheckFatal() const
234 // check if any FATAL status is set
237 for (index = 0; index < kNDET ; index++)
238 rv = rv || IsSet(DETECTORINDEX(index), fTask, kFATAL) ;
242 //_______________________________________________________________
243 const Bool_t AliQA::IsSet(DETECTORINDEX det, ALITASK tsk, QABIT bit) const
245 // Checks is the requested bit is set
251 ULong_t offset = Offset(tsk) ;
252 ULong_t status = GetStatus(det) ;
254 status = (status & 1 << offset) != 0 ;
258 //_______________________________________________________________
259 AliQA * AliQA::Instance()
261 // Get an instance of the singleton.
262 // Object must have been instantiated with Instance(ALITASK) first
267 //_______________________________________________________________
268 AliQA * AliQA::Instance(const DETECTORINDEX det)
270 // Get an instance of the singleton. The only authorized way to call the ctor
273 TFile * f = AliQAChecker::GetQAResultFile() ;
274 fgQA = dynamic_cast<AliQA *>(f->Get("QA")) ;
276 fgQA = new AliQA(det) ;
282 //_______________________________________________________________
283 AliQA * AliQA::Instance(const ALITASK tsk)
285 // get an instance of the singleton.
292 fgQA = new AliQA(tsk) ;
295 fgQA = new AliQA(tsk) ;
298 printf("fgQA = gAlice->GetQA()") ;
301 printf("fgQA = dynamic_cast<AliQA *> (esdFile->Get(\"QA\")") ;
304 printf("fgQA = dynamic_cast<AliQA *> (esdFile->Get(\"QA\")") ;
314 //_______________________________________________________________
315 const ULong_t AliQA::Offset(ALITASK tsk) const
317 // Calculates the bit offset for a given module (SIM, REC, ESD, ANA)
347 //_______________________________________________________________
348 void AliQA::Set(QABIT bit)
350 // Set the status bit of the current detector in the current module
352 SetStatusBit(fDet, fTask, bit) ;
355 //_______________________________________________________________
356 void AliQA::SetStatusBit(DETECTORINDEX det, ALITASK tsk, QABIT bit)
358 // Set the status bit for a given detector and a given task
364 ULong_t offset = Offset(tsk) ;
365 ULong_t status = GetStatus(det) ;
367 status = status | 1 << offset ;
368 SetStatus(det, status) ;
371 //_______________________________________________________________
372 void AliQA::ShowAll() const
374 // dispplay the QA status word
376 for (index = 0 ; index < kNDET ; index++)
377 ShowStatus(DETECTORINDEX(index)) ;
380 //_______________________________________________________________
381 void AliQA::ShowStatus(DETECTORINDEX det) const
383 // Prints the full QA status of a given detector
385 ULong_t status = GetStatus(det) ;
386 ULong_t rawStatus = status & 0x0000f ;
387 ULong_t simStatus = status & 0x000f0 ;
388 ULong_t recStatus = status & 0x00f00 ;
389 ULong_t esdStatus = status & 0x0f000 ;
390 ULong_t anaStatus = status & 0xf0000 ;
392 AliInfo(Form("QA Status for %s raw =0x%x, sim=0x%x, rec=0x%x, esd=0x%x, ana=0x%x\n", GetDetName(det).Data(), rawStatus, simStatus, recStatus, esdStatus, anaStatus )) ;