]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliQA.h
Several Changes:
[u/mrichter/AliRoot.git] / STEER / AliQA.h
1 #ifndef ALIQA_H
2 #define ALIQA_H
3 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4  * See cxx source for full Copyright notice                               */
5
6 /* $Id$ */
7
8 //
9 // Quality Assurance Object
10 //
11
12 #include <TNamed.h> 
13 #include <TMath.h> 
14 class TFile ; 
15
16 #include "AliLog.h"
17 #include "AliRecoParam.h"
18
19 class AliQA : public TNamed {
20 public:
21   
22   enum DETECTORINDEX_t {
23     kNULLDET=-1, kITS, kTPC, kTRD, kTOF, kPHOS, kHMPID, kEMCAL, kMUON, kFMD,
24     kZDC, kPMD, kT0, kVZERO, kACORDE, kHLT, kGLOBAL, kCORR, kNDET};
25   enum ALITASK_t {
26     kNULLTASK=-1, kRAW, kSIM, kREC, kESD, kANA, kNTASK };
27   enum QABIT_t {
28     kNULLBit=-1, kINFO, kWARNING, kERROR, kFATAL, kNBIT };
29   enum TASKINDEX_t {
30     kNULLTASKINDEX=-1, kRAWS, kHITS, kSDIGITS, kDIGITS, kRECPOINTS, kTRACKSEGMENTS, kRECPARTICLES, kESDS, kNTASKINDEX };
31   
32   // Creators - destructors
33   AliQA(); // beware singleton, not to be used
34   AliQA(const ALITASK_t tsk) ;
35   AliQA(const DETECTORINDEX_t det) ;
36   AliQA(const AliQA& qa) ;   
37   AliQA& operator = (const AliQA& qa) ;
38   virtual ~AliQA();
39   
40   static  AliQA *        Instance() ;
41   static  AliQA *        Instance(const DETECTORINDEX_t det) ;
42   static  AliQA *        Instance(const ALITASK_t tsk) ;
43   static  AliQA *        Instance(const TASKINDEX_t tsk) ;
44   Bool_t                 CheckFatal() const ;
45   static void            Close() ; 
46   static const char *    GetAliTaskName(ALITASK_t tsk) ;
47   static const TString   GetExpert() { return fgkExpert ; }
48   static       UInt_t    GetExpertBit() { return fgkExpertBit ; }
49   static const TString   GetLabLocalFile() { return fgkLabLocalFile ; } 
50   static const TString   GetLabLocalOCDB() { return fgkLabLocalOCDB ; } 
51   static const TString   GetLabAliEnOCDB() { return fgkLabAliEnOCDB ; } 
52   static DETECTORINDEX_t GetDetIndex(const char * name) ; 
53   static const TString   GetDetName(DETECTORINDEX_t det) { return fgDetNames[det] ; }
54   static const char *    GetDetName(Int_t det) ;
55   static const TString   GetGRPPath() { return fgGRPPath ; }  
56   static       UInt_t    GetQABit() { return fgkQABit ; }
57   static TFile *         GetQADataFile(const char * name, Int_t run) ; 
58   static TFile *               GetQADataFile(const char * fileName) ;
59   static const char *    GetQADataFileName(const char * name, Int_t run) 
60   {return Form("%s.%s.%d.root", name, fgQADataFileName.Data(), run)  ; }
61   static const char *    GetQADataFileName() { return fgQADataFileName.Data() ; }
62   static const char *    GetQAName() { return fgkQAName ; } 
63   static const char *    GetQACorrName() { return fgkQACorrNtName ; }
64   static TFile *         GetQAResultFile() ; 
65   static const char  *   GetQAResultFileName() { return (fgQAResultDirName + fgQAResultFileName).Data() ; }
66   static const char  *   GetQARefDefaultStorage() { return fgkQARefOCDBDefault.Data() ; }
67   static const char  *   GetQARefFileName() { return fgQARefFileName ; }
68   static const char  *   GetQARefStorage() { return fgQARefDirName.Data() ; }
69   static const char  *   GetRefOCDBDirName() { return fgkRefOCDBDirName.Data() ; }
70   static const char  *   GetRefDataDirName() { return fgRefDataDirName.Data() ; }
71   static     TASKINDEX_t GetTaskIndex(const char * name) ; 
72   static       TString   GetTaskName(UInt_t tsk) { return fgTaskNames[tsk] ; }
73   Bool_t                 IsEventSpecieSet(AliRecoParam::EventSpecie_t es) const 
74   {Int_t ibit=0; while(es!=1<<ibit) ++ibit; return fEventSpecies[ibit];}
75   Bool_t                 IsEventSpecieSet(Int_t es) const { return fEventSpecies[es] ; }
76   Bool_t                 IsSet(DETECTORINDEX_t det, ALITASK_t tsk, AliRecoParam::EventSpecie_t es, QABIT_t bit) const ;
77   Bool_t                 IsSet(DETECTORINDEX_t det, ALITASK_t tsk, Int_t es, QABIT_t bit) const ;
78   Bool_t                 IsSetAny(DETECTORINDEX_t det, ALITASK_t tsk, AliRecoParam::EventSpecie_t es) const ;
79   Bool_t                 IsSetAny(DETECTORINDEX_t det, AliRecoParam::EventSpecie_t es) const ;
80   void                   Merge(TCollection * list) ; 
81   void                   Set(QABIT_t bit, AliRecoParam::EventSpecie_t es) ;
82   void                   Set(QABIT_t bit, Int_t es) ;
83   void                   SetEventSpecie(AliRecoParam::EventSpecie_t es) 
84   {Int_t ibit=0; while(es!=1<<ibit) ++ibit; fEventSpecies[ibit] = kTRUE ; }
85   static void            SetQAResultDirName(const char * name) ; 
86   static void            SetQARefStorage(const char * name) ; 
87   static void            SetQARefDataDirName(AliRecoParam::EventSpecie_t es) { fgRefDataDirName = AliRecoParam::GetEventSpecieName(es) ; }
88   static void            SetQARefDataDirName(Int_t es) { fgRefDataDirName = AliRecoParam::GetEventSpecieName(es) ; }
89   void                   Show() const ; 
90   void                   Show(DETECTORINDEX_t det) const ;
91   void                   ShowAll() const ;
92   void                   ShowStatus(DETECTORINDEX_t det, ALITASK_t tsk=kNULLTASK, AliRecoParam::EventSpecie_t es=AliRecoParam::kDefault) const ;
93   void                   UnSet(QABIT_t bit, AliRecoParam::EventSpecie_t es) ;
94   void                   UnSet(QABIT_t bit, Int_t es) ;
95   
96 private:      
97   
98   Bool_t         CheckRange(DETECTORINDEX_t det) const ;
99   Bool_t         CheckRange(ALITASK_t tsk) const ;
100   Bool_t         CheckRange(QABIT_t bit) const ;
101   Bool_t         CheckRange(AliRecoParam::EventSpecie_t es) const ;
102   const char *         GetBitName(QABIT_t bit) const ;
103   ULong_t        GetStatus(DETECTORINDEX_t det, AliRecoParam::EventSpecie_t es) const  { return fQA[det*fNEventSpecies+(Int_t)TMath::Log2(es)] ;}
104   void                 Finish() const ;  
105   ULong_t        Offset(ALITASK_t tsk) const ;
106   void                 ShowASCIIStatus(AliRecoParam::EventSpecie_t es, DETECTORINDEX_t det, ALITASK_t tsk, ULong_t status) const ; 
107   void                 ResetStatus(DETECTORINDEX_t det) ; 
108   void                 Set(DETECTORINDEX_t det) { fDet = det ;}
109   void                 Set(ALITASK_t tsk) { fTask = tsk ; AliDebug(1, Form("Ready to set QA status in %s", GetAliTaskName(tsk) )) ; }
110   void                 SetStatus(DETECTORINDEX_t det, AliRecoParam::EventSpecie_t es, ULong_t status) { fQA[det*fNEventSpecies+(Int_t)TMath::Log2(es)] = status ; }
111   void                 SetStatusBit(DETECTORINDEX_t det, ALITASK_t tsk, AliRecoParam::EventSpecie_t es, QABIT_t bit) ;
112   void                 UnSetStatusBit(DETECTORINDEX_t det, ALITASK_t tsk, AliRecoParam::EventSpecie_t es, QABIT_t bit) ;
113   
114   static AliQA *       fgQA                             ; // pointer to the instance of the singleton
115   Int_t                fNdet                        ; // number of detectors
116   Int_t                fNEventSpecies          ; // number of Event Species (see AliRecoParam)
117   Int_t                fLengthQA              ; // Auxiliary length of fQA
118   ULong_t    *        fQA                               ; //[fNdet][fNEventSpecie] the status word 4 bits for SIM, REC, ESD, ANA each
119   DETECTORINDEX_t      fDet                             ; //! the current detector (ITS, TPC, ....)
120   ALITASK_t            fTask                    ; //! the current environment (SIM, REC, ESD, ANA)
121   AliRecoParam::EventSpecie_t fEventSpecie    ; //! the current event specie
122   static TString       fgDetNames[]               ; //! list of detector names   
123   static TString       fgGRPPath              ; //! path of the GRP object in OCDB
124   static TFile *       fgQADataFile               ; //! the output file where the quality assurance maker store their results
125   static TString       fgQADataFileName       ; //! the name of the file where the quality assurance maker store their results
126   static TFile *       fgQARefFile                ; //! the output file where the quality assurance maker store their results
127   static TString       fgQARefDirName           ; //! name of directory where to find the reference data file
128   static TString       fgQARefFileName        ; //! file name where to find the reference data
129   static TFile *       fgQAResultFile         ; //! File where to find the QA result
130   static TString       fgQAResultDirName      ; //! the location of the output file where the QA results are stored  
131   static TString       fgQAResultFileName     ; //! the output file where the QA results are stored  
132   static TString       fgRTNames[]                ; //! list of Run Type names   
133   static TString       fgTaskNames[]            ; //! list of tasks names   
134   static const TString fgkExpert              ; //! name for the expert directory
135   static const UInt_t  fgkExpertBit           ; //! TObject bit identifing the object as "expert"
136   static const TString fgkLabLocalFile        ; //! label to identify a file as local 
137   static const TString fgkLabLocalOCDB        ; //! label to identify a file as local OCDB 
138   static const TString fgkLabAliEnOCDB        ; //! label to identify a file as AliEn OCDB 
139   static const TString fgkRefFileName         ; //! name of Reference File Name 
140   static const UInt_t  fgkQABit               ; //! bit in the QA data object which is set when Checker does not return 0
141   static const TString fgkQAName              ; //! name of QA object 
142   static const TString fgkQACorrNtName        ; //! name of QA Correlation Ntuple
143   static const TString fgkRefOCDBDirName      ; //! name of Reference directory name in OCDB    
144   static       TString fgRefDataDirName       ; //! name of Reference directory name in OCDB for data   
145   static const TString fgkQARefOCDBDefault    ; //! default storage for QA in OCDB 
146   Bool_t *             fEventSpecies          ; //[fNEventSpecies] list of event species encountered in a run
147
148  ClassDef(AliQA,2)  //ALICE Quality Assurance Object
149 };
150 #endif