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::fgOutput = 0x0 ;
48 TString AliQualAss::fgOutputName = "QA.root" ;
50 //____________________________________________________________________________
51 AliQualAss::AliQualAss() :
58 // default constructor
59 // beware singleton: not to be used
62 //____________________________________________________________________________
63 AliQualAss::AliQualAss(const AliQualAss& qa) :
73 //_____________________________________________________________________________
74 AliQualAss& AliQualAss::operator = (const AliQualAss& qa)
76 // assignment operator
79 new(this) AliQualAss(qa);
83 //_______________________________________________________________
84 AliQualAss::AliQualAss(ALITASK tsk) :
85 TNamed("QA", "Quality Assurance status"),
91 // constructor to be used in the AliRoot module (SIM, REC, ESD or ANA)
92 if (! CheckRange(tsk) ) {
96 fQA = new ULong_t[fNdet] ;
98 for ( index = 0 ; index <= fNdet ; index++)
99 ResetStatus(DETECTORINDEX(index)) ;
103 //____________________________________________________________________________
104 AliQualAss::~AliQualAss()
110 //_______________________________________________________________
111 const Bool_t AliQualAss::CheckRange(DETECTORINDEX det) const
113 // check if detector is in given detector range: 0-fNdet
115 Bool_t rv = ( det < 0 || det > fNdet ) ? kFALSE : kTRUE ;
117 AliFatal(Form("Detector index %d is out of range: 0 <= index <= %d", det, kNDET)) ;
121 //_______________________________________________________________
122 const Bool_t AliQualAss::CheckRange(ALITASK task) const
124 // check if task is given taskk range: 0:kNTASK
125 Bool_t rv = ( task < kSIM || task > kNTASK ) ? kFALSE : kTRUE ;
127 AliFatal(Form("Module index %d is out of range: 0 <= index <= %d", task, kNTASK)) ;
131 //_______________________________________________________________
132 const Bool_t AliQualAss::CheckRange(QABIT bit) const
134 // check if bit is in given bit range: 0-kNBit
136 Bool_t rv = ( bit < 0 || bit > kNBIT ) ? kFALSE : kTRUE ;
138 AliFatal(Form("Status bit %d is out of range: 0 <= bit <= %d", bit, kNBIT)) ;
142 //_______________________________________________________________
143 const char * AliQualAss::GetDetectorName(DETECTORINDEX det) const
145 // returns the char name corresponding to detector index
197 AliError(Form("%d is not a valid detector index %d <= index <= %d\n", det, 0, kNDET-1)) ;
203 //_______________________________________________________________
204 TFile * AliQualAss::GetQADMOutFile()
206 // opens the file to store the detectors Quality Assurance Data Maker results
210 if (gSystem->AccessPathName(fgOutputName.Data()))
211 sprintf(opt, "%s", "NEW") ;
213 sprintf(opt, "%s", "UPDATE") ;
215 fgOutput = TFile::Open(fgOutputName.Data(), opt) ;
220 //_______________________________________________________________
221 const char * AliQualAss::GetTaskName(ALITASK tsk) const
223 // returns the char name corresponding to module index
224 char * tskName = "" ;
241 AliError(Form("%d is not a valid module index %d <= index <= %d\n", tsk, 0, kNTASK-1)) ;
247 //_______________________________________________________________
248 const Bool_t AliQualAss::CheckFatal() const
250 // check if any FATAL status is set
253 for (index = 0; index < kNDET ; index++)
254 rv = rv || IsSet(DETECTORINDEX(index), fTask, kFATAL) ;
258 //_______________________________________________________________
259 const Bool_t AliQualAss::IsSet(DETECTORINDEX det, ALITASK tsk, QABIT bit) const
261 // Checks is the requested bit is set
267 ULong_t offset = Offset(tsk) ;
268 ULong_t status = GetStatus(det) ;
270 status = (status & 1 << offset) != 0 ;
274 //_______________________________________________________________
275 AliQualAss * AliQualAss::Instance()
277 // Get an instance of the singleton.
278 // Object must have been instantiated with Instance(ALITASK) first
283 //_______________________________________________________________
284 AliQualAss * AliQualAss::Instance(DETECTORINDEX det)
286 // Get an instance of the singleton. The only authorized way to call the ctor
292 //_______________________________________________________________
293 AliQualAss * AliQualAss::Instance(ALITASK tsk)
295 // get an instance of the singleton.
302 fgQA = new AliQualAss(tsk) ;
305 printf("fgQA = gAlice->GetQA()") ;
308 printf("fgQA = dynamic_cast<AliQA *> (esdFile->Get(\"QA\")") ;
311 printf("fgQA = dynamic_cast<AliQA *> (esdFile->Get(\"QA\")") ;
321 //_______________________________________________________________
322 const ULong_t AliQualAss::Offset(ALITASK tsk) const
324 // Calculates the bit offset for a given module (SIM, REC, ESD, ANA)
351 //_______________________________________________________________
352 void AliQualAss::Set(QABIT bit)
354 // Set the status bit of the current detector in the current module
356 SetStatusBit(fDet, fTask, bit) ;
359 //_______________________________________________________________
360 void AliQualAss::SetStatusBit(DETECTORINDEX det, ALITASK tsk, QABIT bit)
362 // Set the status bit for a given detector and a given task
368 ULong_t offset = Offset(tsk) ;
369 ULong_t status = GetStatus(det) ;
371 status = status | 1 << offset ;
372 SetStatus(det, status) ;
375 //_______________________________________________________________
376 void AliQualAss::ShowAll() const
378 // dispplay the QA status word
380 for (index = 0 ; index < kNDET ; index++)
381 ShowStatus(DETECTORINDEX(index)) ;
384 //_______________________________________________________________
385 void AliQualAss::ShowStatus(DETECTORINDEX det) const
387 // Prints the full QA status of a given detector
389 ULong_t status = GetStatus(det) ;
390 ULong_t simStatus = status & 0x000f ;
391 ULong_t recStatus = status & 0x00f0 ;
392 ULong_t esdStatus = status & 0x0f00 ;
393 ULong_t anaStatus = status & 0xf000 ;
395 AliInfo(Form("QA Status for %s sim=0x%x, rec=0x%x, esd=0x%x, ana=0x%x\n", GetDetectorName(det), simStatus, recStatus, esdStatus, anaStatus )) ;