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"
45 AliQualAss * AliQualAss::fgQA = 0x0 ;
46 TFile * AliQualAss::fgDataFile = 0x0 ;
47 TString AliQualAss::fgDataName = "QA" ;
48 TString AliQualAss::fgDetNames[] = {"ITS", "TPC", "TRD", "TOF", "PHOS", "HMPID", "EMCAL", "MUON", "FMD",
49 "ZDC", "PMD", "T0", "VZERO", "ACORDE", "HLT"} ;
50 TString AliQualAss::fgTaskNames[] = {"Raws", "Hits", "SDigits", "Digits", "RecPoints", "TrackSegments", "RecParticles", "ESDs"} ;
52 //____________________________________________________________________________
53 AliQualAss::AliQualAss() :
59 // default constructor
60 // beware singleton: not to be used
63 //____________________________________________________________________________
64 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(const DETECTORINDEX det) :
85 TNamed("QA", "Quality Assurance status"),
86 fQA(new ULong_t[kNDET]),
90 // constructor to be used
91 if (! CheckRange(det) ) {
96 for (index = 0; index < kNDET; index++)
100 //_______________________________________________________________
101 AliQualAss::AliQualAss(const ALITASK tsk) :
102 TNamed("QA", "Quality Assurance status"),
103 fQA(new ULong_t[kNDET]),
107 // constructor to be used in the AliRoot module (SIM, REC, ESD or ANA)
108 if (! CheckRange(tsk) ) {
113 for (index = 0; index < kNDET; index++)
117 //____________________________________________________________________________
118 AliQualAss::~AliQualAss()
124 //_______________________________________________________________
125 const Bool_t AliQualAss::CheckRange(DETECTORINDEX det) const
127 // check if detector is in given detector range: 0-kNDET
129 Bool_t rv = ( det < 0 || det > kNDET ) ? kFALSE : kTRUE ;
131 AliFatal(Form("Detector index %d is out of range: 0 <= index <= %d", det, kNDET)) ;
135 //_______________________________________________________________
136 const Bool_t AliQualAss::CheckRange(ALITASK task) const
138 // check if task is given taskk range: 0:kNTASK
139 Bool_t rv = ( task < kRAW || task > kNTASK ) ? kFALSE : kTRUE ;
141 AliFatal(Form("Module index %d is out of range: 0 <= index <= %d", task, kNTASK)) ;
145 //_______________________________________________________________
146 const Bool_t AliQualAss::CheckRange(QABIT bit) const
148 // check if bit is in given bit range: 0-kNBit
150 Bool_t rv = ( bit < 0 || bit > kNBIT ) ? kFALSE : kTRUE ;
152 AliFatal(Form("Status bit %d is out of range: 0 <= bit <= %d", bit, kNBIT)) ;
157 //_______________________________________________________________
158 TFile * AliQualAss::GetQADMOutFile(const char * name, const Int_t run, const Int_t cycle)
160 // opens the file to store the detectors Quality Assurance Data Maker results
162 sprintf(temp, "%s.%s.%d.%d.root", name, fgDataName.Data(), run, cycle) ;
165 if (gSystem->AccessPathName(temp))
169 fgDataFile = TFile::Open(temp, opt.Data()) ;
171 if ( (strcmp(temp, fgDataFile->GetName()) != 0) ) {
172 if (gSystem->AccessPathName(temp))
176 fgDataFile = TFile::Open(temp, opt.Data()) ;
182 //_______________________________________________________________
183 const char * AliQualAss::GetDetName(Int_t det)
185 // returns the detector name corresponding to a given index (needed in a loop)
187 if ( det >= 0 && det < kNDET)
188 return (fgDetNames[det]).Data() ;
193 //_______________________________________________________________
194 const char * AliQualAss::GetAliTaskName(ALITASK tsk)
196 // returns the char name corresponding to module index
220 return tskName.Data() ;
223 //_______________________________________________________________
224 const Bool_t AliQualAss::CheckFatal() const
226 // check if any FATAL status is set
229 for (index = 0; index < kNDET ; index++)
230 rv = rv || IsSet(DETECTORINDEX(index), fTask, kFATAL) ;
234 //_______________________________________________________________
235 const Bool_t AliQualAss::IsSet(DETECTORINDEX det, ALITASK tsk, QABIT bit) const
237 // Checks is the requested bit is set
243 ULong_t offset = Offset(tsk) ;
244 ULong_t status = GetStatus(det) ;
246 status = (status & 1 << offset) != 0 ;
250 //_______________________________________________________________
251 AliQualAss * AliQualAss::Instance()
253 // Get an instance of the singleton.
254 // Object must have been instantiated with Instance(ALITASK) first
259 //_______________________________________________________________
260 AliQualAss * AliQualAss::Instance(const DETECTORINDEX det)
262 // Get an instance of the singleton. The only authorized way to call the ctor
265 fgQA = new AliQualAss(det) ;
270 //_______________________________________________________________
271 AliQualAss * AliQualAss::Instance(const ALITASK tsk)
273 // get an instance of the singleton.
280 fgQA = new AliQualAss(tsk) ;
283 fgQA = new AliQualAss(tsk) ;
286 printf("fgQA = gAlice->GetQA()") ;
289 printf("fgQA = dynamic_cast<AliQA *> (esdFile->Get(\"QA\")") ;
292 printf("fgQA = dynamic_cast<AliQA *> (esdFile->Get(\"QA\")") ;
302 //_______________________________________________________________
303 const ULong_t AliQualAss::Offset(ALITASK tsk) const
305 // Calculates the bit offset for a given module (SIM, REC, ESD, ANA)
335 //_______________________________________________________________
336 void AliQualAss::Set(QABIT bit)
338 // Set the status bit of the current detector in the current module
340 SetStatusBit(fDet, fTask, bit) ;
343 //_______________________________________________________________
344 void AliQualAss::SetStatusBit(DETECTORINDEX det, ALITASK tsk, QABIT bit)
346 // Set the status bit for a given detector and a given task
352 ULong_t offset = Offset(tsk) ;
353 ULong_t status = GetStatus(det) ;
355 status = status | 1 << offset ;
356 SetStatus(det, status) ;
359 //_______________________________________________________________
360 void AliQualAss::ShowAll() const
362 // dispplay the QA status word
364 for (index = 0 ; index < kNDET ; index++)
365 ShowStatus(DETECTORINDEX(index)) ;
368 //_______________________________________________________________
369 void AliQualAss::ShowStatus(DETECTORINDEX det) const
371 // Prints the full QA status of a given detector
373 ULong_t status = GetStatus(det) ;
374 ULong_t rawStatus = status & 0x0000f ;
375 ULong_t simStatus = status & 0x000f0 ;
376 ULong_t recStatus = status & 0x00f00 ;
377 ULong_t esdStatus = status & 0x0f000 ;
378 ULong_t anaStatus = status & 0xf0000 ;
380 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 )) ;