ROOT logo
#ifndef ALIQAV1_H
#define ALIQAV1_H
/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
 * See cxx source for full Copyright notice                               */

/* $Id: AliQAv1.h 31503 2009-03-16 11:01:16Z schutz $ */

//
// Quality Assurance Object
//

#include <TNamed.h> 
#include <TMath.h> 
class TFile ; 
class TH1 ; 

#include "AliLog.h"
#include "AliRecoParam.h"

class AliQAv1 : public TNamed {
public:
  
  enum DETECTORINDEX_t {
    kNULLDET=-1, kITS, kTPC, kTRD, kTOF, kPHOS, kHMPID, kEMCAL, kMUON, kFMD,
    kZDC, kPMD, kT0, kVZERO, kACORDE, kAD, kFIT, kMFT, kHLT, kGLOBAL, kCORR, kNDET};
  enum ALITASK_t {
    kNULLTASK=-1, kRAW, kSIM, kREC, kESD, kANA, kNTASK };
  enum QABIT_t {
    kNULLBit=-1, kINFO, kWARNING, kERROR, kFATAL, kNBIT };
  enum TASKINDEX_t {
    kNULLTASKINDEX=-1, kRAWS, kHITS, kSDIGITS, kDIGITS, kDIGITSR, kRECPOINTS, kTRACKSEGMENTS, kRECPARTICLES, kESDS, kNTASKINDEX };
  enum MODE_t {kNULLMODE=0, kSIMMODE, kRECMODE, kQAMODE};
  
  // Creators - destructors
  AliQAv1(); // beware singleton, not to be used
  AliQAv1(const Int_t qalength, ULong_t * qa, const Int_t eslength, Bool_t * es) ;
  AliQAv1(const ALITASK_t tsk) ;
  AliQAv1(const DETECTORINDEX_t det) ;
  AliQAv1(const AliQAv1& qa) ;   
  AliQAv1& operator = (const AliQAv1& qa) ;
  virtual ~AliQAv1();
  
  static  AliQAv1 *      Instance() ;
  static  AliQAv1 *      Instance(const Int_t qalength, ULong_t * qa, const Int_t eslength, Bool_t * es) ;
  static  AliQAv1 *      Instance(const DETECTORINDEX_t det) ;
  static  AliQAv1 *      Instance(const ALITASK_t tsk) ;
  static  AliQAv1 *      Instance(const TASKINDEX_t tsk) ;
  Bool_t                 CheckFatal() const ;
  static void            Close() ; 
  static const char *    GetAliTaskName(ALITASK_t tsk) ;
  static  TH1 *          GetData(TObjArray** list, Int_t index, AliRecoParam::EventSpecie_t eventSpecie) ; 
  Bool_t *               GetEventSpecies() { return fEventSpecies ; }
  static const TString   GetExpert() { return fgkExpert ; }
  static       UInt_t    GetExpertBit() { return fgkExpertBit ; }
  static       UInt_t    GetImageBit()  { return fgkImageBit ; }
  static const char *    GetImageFileName() { return fgkImageFileName.Data() ; }
  static const char *    GetImageFileFormat() { return fImageFileFormat.Data() ; }
  static const TString   GetLabLocalFile() { return fgkLabLocalFile ; } 
  static const TString   GetLabLocalOCDB() { return fgkLabLocalOCDB ; } 
  static const TString   GetLabAliEnOCDB() { return fgkLabAliEnOCDB ; } 
  static DETECTORINDEX_t GetDetIndex(const char * name) ; 
  static const TString   GetDetName(DETECTORINDEX_t det) { return fgDetNames[det] ; }
  static const char *    GetDetName(Int_t det) ;
  static const TString   GetGRPPath() { return fgGRPPath ; }  
  ULong_t *              GetQA() { return fQA ; }
  static       UInt_t    GetQABit() { return fgkQABit ; }
  static TFile *         GetQADataFile(const char * name, Int_t run) ; 
  static TFile *	     GetQADataFile(const char * fileName) ;
  static const char *    GetQADataFileName(const char * name, Int_t run) 
  {return Form("%s.%s.%d.root", name, fgQADataFileName.Data(), run)  ; }
  static const char *    GetQADataFileName() { return fgQADataFileName.Data() ; }
  static Int_t           GetQADebugLevel() { return fgkQADebugLevel ; }
  static const char *    GetQAName() { return fgkQAName ; } 
  static const char *    GetQACorrName() { return fgkQACorrNtName ; }
  static  UShort_t       GetMaxQAObj() { return fgkMaxQAObjects ; }
  static TFile *         GetQAResultFile() ; 
  static const char  *   GetQAResultFileName() { return (fgQAResultDirName + fgQAResultFileName).Data() ; }
  static const char  *   GetQARefDefaultStorage() { return fgkQARefOCDBDefault.Data() ; }
  static const char  *   GetQARefFileName() { return fgQARefFileName ; }
  static const char  *   GetQARefStorage() { return fgQARefDirName.Data() ; }
  QABIT_t                GetQAStatusBit(AliRecoParam::EventSpecie_t es = AliRecoParam::kDefault, DETECTORINDEX_t det=kNULLDET, ALITASK_t tsk=kNULLTASK) const ; 
  static const char  *   GetRefOCDBDirName() { return fgkRefOCDBDirName.Data() ; }
  static const char  *   GetRefDataDirName() { return fgRefDataDirName.Data() ; }
  //
  static       UInt_t    GetClonedBit()               { return fgkQAClonedBit; }
  static       UInt_t    GetForbidCloningBit()        { return fgkForbidCloningBit; }
  static       UInt_t    GetOrigHistoKeptBit()        { return fgkOrigHistoKeptBit; }
  //
  static     TASKINDEX_t GetTaskIndex(const char * name) ; 
  static       TString   GetTaskName(UInt_t tsk) { return fgTaskNames[tsk] ; }
  static const char *    GetModeName(MODE_t mode) { return (mode == kSIMMODE || mode == kRECMODE || mode == kQAMODE) ? (fgModeNames[mode]).Data() : "" ; }
  Bool_t                 IsEventSpecieSet(AliRecoParam::EventSpecie_t es) const 
  {Int_t ibit=0; while(es!=1<<ibit) ++ibit; return fEventSpecies[ibit];}
  Bool_t                 IsEventSpecieSet(Int_t es) const { return fEventSpecies[es] ; }
  Bool_t                 IsSet(DETECTORINDEX_t det, ALITASK_t tsk, AliRecoParam::EventSpecie_t es, QABIT_t bit) const ;
  Bool_t                 IsSet(DETECTORINDEX_t det, ALITASK_t tsk, Int_t es, QABIT_t bit) const ;
  Bool_t                 IsSetAny(DETECTORINDEX_t det, ALITASK_t tsk, AliRecoParam::EventSpecie_t es) const ;
  Bool_t                 IsSetAny(DETECTORINDEX_t det, AliRecoParam::EventSpecie_t es) const ;
  Long64_t               Merge(const TCollection * list) ; 
  static MODE_t          Mode(TASKINDEX_t task) ;
  void                   Set(QABIT_t bit, AliRecoParam::EventSpecie_t es) ;
  void                   Set(QABIT_t bit, Int_t es) ;
  void                   SetEventSpecie(AliRecoParam::EventSpecie_t es) 
  {if(es==AliRecoParam::kDefault) return; Int_t ibit=0; while(es!=1<<ibit) ++ibit; fEventSpecies[ibit] = kTRUE ; }
  void                   UnSetEventSpecie(AliRecoParam::EventSpecie_t es) 
  {if(es==AliRecoParam::kDefault) return; Int_t ibit=0; while(es!=1<<ibit) ++ibit; fEventSpecies[ibit] = kFALSE ; }  
  static void            SetQADebug() { AliLog::SetGlobalDebugLevel(GetQADebugLevel()); }
  static void            SetQAResultDirName(const char * name) ; 
  static void            SetQARefStorage(const char * name) ; 
  static void            SetQARefDataDirName(AliRecoParam::EventSpecie_t es) { fgRefDataDirName = AliRecoParam::GetEventSpecieName(es) ; }
  static void            SetQARefDataDirName(Int_t es) { fgRefDataDirName = AliRecoParam::GetEventSpecieName(es) ; }
  void                   Show(DETECTORINDEX_t det = kNULLDET) const ;
  void                   ShowAll() const ;
  void                   ShowStatus(DETECTORINDEX_t det, ALITASK_t tsk=kNULLTASK, AliRecoParam::EventSpecie_t es=AliRecoParam::kDefault) const ;
  void                   UnSet(QABIT_t bit, AliRecoParam::EventSpecie_t es) ;
  void                   UnSet(QABIT_t bit, Int_t es) ;
  
private:      
  
  Bool_t                CheckRange(DETECTORINDEX_t det) const ;
  Bool_t                CheckRange(ALITASK_t tsk) const ;
  Bool_t                CheckRange(QABIT_t bit) const ;
  Bool_t                CheckRange(AliRecoParam::EventSpecie_t es) const ;
  const char *          GetBitName(QABIT_t bit) const ;
  ULong_t               GetStatus(DETECTORINDEX_t det, AliRecoParam::EventSpecie_t es) const  { return fQA[det*fNEventSpecies+AliRecoParam::AConvert(es)] ;}
  void                  Finish() const ;  
  ULong_t               Offset(ALITASK_t tsk) const ;
  void                  ShowASCIIStatus(AliRecoParam::EventSpecie_t es, DETECTORINDEX_t det, ALITASK_t tsk, ULong_t status) const ; 
  void                  Reset(DETECTORINDEX_t det, ALITASK_t tsk, AliRecoParam::EventSpecie_t es) ;  

  void                  ResetStatus(DETECTORINDEX_t det) ; 
  void                  Set(DETECTORINDEX_t det) { fDet = det ;}
  void                  Set(ALITASK_t tsk) { fTask = tsk ; AliDebug(GetQADebugLevel(), Form("Ready to set QA status in %s", GetAliTaskName(tsk) )) ; }
  void                  SetStatus(DETECTORINDEX_t det, AliRecoParam::EventSpecie_t es, ULong_t status) { fQA[det*fNEventSpecies+AliRecoParam::AConvert(es)] = status ; }
  void                  SetStatusBit(DETECTORINDEX_t det, ALITASK_t tsk, AliRecoParam::EventSpecie_t es, QABIT_t bit) ;
  void                  UnSetStatusBit(DETECTORINDEX_t det, ALITASK_t tsk, AliRecoParam::EventSpecie_t es, QABIT_t bit) ;
  
  static AliQAv1 *       fgQA		                  ; // pointer to the instance of the singleton
  Int_t                  fNdet     	              ; // number of detectors
  Int_t                  fNEventSpecies           ; // number of Event Species (see AliRecoParam)
  Int_t                  fLengthQA                ; // Auxiliary length of fQA
  ULong_t    *           fQA		                  ; //[fLengthQA]  the status word 4 bits for SIM, REC, ESD, ANA each
  DETECTORINDEX_t fDet		                        ; //! the current detector (ITS, TPC, ....)
  ALITASK_t       fTask	                          ; //! the current environment (SIM, REC, ESD, ANA)
  AliRecoParam::EventSpecie_t fEventSpecie        ; //! the current event specie
  static TString         fgDetNames[]	            ; //! list of detector names   
  static TString         fgGRPPath                ; //! path of the GRP object in OCDB
  static TFile *         fgQADataFile	            ; //! the output file where the quality assurance maker store their results
  static TString         fgQADataFileName         ; //! the name of the file where the quality assurance maker store their results
  static TFile *         fgQARefFile	            ; //! the output file where the quality assurance maker store their results
  static TString         fgQARefDirName	          ; //! name of directory where to find the reference data file
  static TString         fgQARefFileName          ; //! file name where to find the reference data
  static TFile *         fgQAResultFile           ; //! File where to find the QA result
  static TString         fgQAResultDirName        ; //! the location of the output file where the QA results are stored  
  static TString         fgQAResultFileName       ; //! the output file where the QA results are stored  
  static TString         fgRTNames[]	            ; //! list of Run Type names   
  static TString         fgTaskNames[]            ; //! list of tasks names   
  static TString         fgModeNames[]	          ; //! list of mode names   
  static const TString   fgkExpert                ; //! name for the expert directory
  static const UInt_t    fgkExpertBit             ; //! TObject bit identifing the object as "expert"
  static const UInt_t    fgkImageBit              ; //! TObject bit identifing the object to be plotted on the QA image
  static const TString   fgkLabLocalFile          ; //! label to identify a file as local 
  static const TString   fgkLabLocalOCDB          ; //! label to identify a file as local OCDB 
  static const TString   fgkLabAliEnOCDB          ; //! label to identify a file as AliEn OCDB 
  static const TString   fgkRefFileName           ; //! name of Reference File Name 
  static const UInt_t    fgkQABit                 ; //! bit in the QA data object which is set when Checker does not return 0
  static const Int_t     fgkQADebugLevel          ; //! debug level used for QA verbosity
  static const TString   fgkQAName                ; //! name of QA object 
  static const TString   fgkQACorrNtName          ; //! name of QA Correlation Ntuple
  static const TString   fgkRefOCDBDirName        ; //! name of Reference directory name in OCDB  	
  static       TString   fgRefDataDirName         ; //! name of Reference directory name in OCDB for data  	
  static const TString   fgkQARefOCDBDefault      ; //! default storage for QA in OCDB 
  Bool_t *               fEventSpecies            ; //[fNEventSpecies] list of event species encountered in a run
  static const TString   fgkImageFileName           ; //! name of the file that contains all the QA images
  static const TString   fImageFileFormat         ; //! format of the file that contains all the QA images
  static const UShort_t  fgkMaxQAObjects          ;//! maximum number of QA objects allowed dor each task (Raws, digits,....) 
  //
  static const UInt_t    fgkQAClonedBit           ;//! flag that the histrogram was cloned per trigger class
  static const UInt_t    fgkForbidCloningBit      ;//! flag that the histogram is forbiden to clone per trigger class
  static const UInt_t    fgkOrigHistoKeptBit      ;//! flag that the histogram was clonned but original is kept
 ClassDef(AliQAv1,3)  //ALICE Quality Assurance Object
};
#endif
 AliQAv1.h:1
 AliQAv1.h:2
 AliQAv1.h:3
 AliQAv1.h:4
 AliQAv1.h:5
 AliQAv1.h:6
 AliQAv1.h:7
 AliQAv1.h:8
 AliQAv1.h:9
 AliQAv1.h:10
 AliQAv1.h:11
 AliQAv1.h:12
 AliQAv1.h:13
 AliQAv1.h:14
 AliQAv1.h:15
 AliQAv1.h:16
 AliQAv1.h:17
 AliQAv1.h:18
 AliQAv1.h:19
 AliQAv1.h:20
 AliQAv1.h:21
 AliQAv1.h:22
 AliQAv1.h:23
 AliQAv1.h:24
 AliQAv1.h:25
 AliQAv1.h:26
 AliQAv1.h:27
 AliQAv1.h:28
 AliQAv1.h:29
 AliQAv1.h:30
 AliQAv1.h:31
 AliQAv1.h:32
 AliQAv1.h:33
 AliQAv1.h:34
 AliQAv1.h:35
 AliQAv1.h:36
 AliQAv1.h:37
 AliQAv1.h:38
 AliQAv1.h:39
 AliQAv1.h:40
 AliQAv1.h:41
 AliQAv1.h:42
 AliQAv1.h:43
 AliQAv1.h:44
 AliQAv1.h:45
 AliQAv1.h:46
 AliQAv1.h:47
 AliQAv1.h:48
 AliQAv1.h:49
 AliQAv1.h:50
 AliQAv1.h:51
 AliQAv1.h:52
 AliQAv1.h:53
 AliQAv1.h:54
 AliQAv1.h:55
 AliQAv1.h:56
 AliQAv1.h:57
 AliQAv1.h:58
 AliQAv1.h:59
 AliQAv1.h:60
 AliQAv1.h:61
 AliQAv1.h:62
 AliQAv1.h:63
 AliQAv1.h:64
 AliQAv1.h:65
 AliQAv1.h:66
 AliQAv1.h:67
 AliQAv1.h:68
 AliQAv1.h:69
 AliQAv1.h:70
 AliQAv1.h:71
 AliQAv1.h:72
 AliQAv1.h:73
 AliQAv1.h:74
 AliQAv1.h:75
 AliQAv1.h:76
 AliQAv1.h:77
 AliQAv1.h:78
 AliQAv1.h:79
 AliQAv1.h:80
 AliQAv1.h:81
 AliQAv1.h:82
 AliQAv1.h:83
 AliQAv1.h:84
 AliQAv1.h:85
 AliQAv1.h:86
 AliQAv1.h:87
 AliQAv1.h:88
 AliQAv1.h:89
 AliQAv1.h:90
 AliQAv1.h:91
 AliQAv1.h:92
 AliQAv1.h:93
 AliQAv1.h:94
 AliQAv1.h:95
 AliQAv1.h:96
 AliQAv1.h:97
 AliQAv1.h:98
 AliQAv1.h:99
 AliQAv1.h:100
 AliQAv1.h:101
 AliQAv1.h:102
 AliQAv1.h:103
 AliQAv1.h:104
 AliQAv1.h:105
 AliQAv1.h:106
 AliQAv1.h:107
 AliQAv1.h:108
 AliQAv1.h:109
 AliQAv1.h:110
 AliQAv1.h:111
 AliQAv1.h:112
 AliQAv1.h:113
 AliQAv1.h:114
 AliQAv1.h:115
 AliQAv1.h:116
 AliQAv1.h:117
 AliQAv1.h:118
 AliQAv1.h:119
 AliQAv1.h:120
 AliQAv1.h:121
 AliQAv1.h:122
 AliQAv1.h:123
 AliQAv1.h:124
 AliQAv1.h:125
 AliQAv1.h:126
 AliQAv1.h:127
 AliQAv1.h:128
 AliQAv1.h:129
 AliQAv1.h:130
 AliQAv1.h:131
 AliQAv1.h:132
 AliQAv1.h:133
 AliQAv1.h:134
 AliQAv1.h:135
 AliQAv1.h:136
 AliQAv1.h:137
 AliQAv1.h:138
 AliQAv1.h:139
 AliQAv1.h:140
 AliQAv1.h:141
 AliQAv1.h:142
 AliQAv1.h:143
 AliQAv1.h:144
 AliQAv1.h:145
 AliQAv1.h:146
 AliQAv1.h:147
 AliQAv1.h:148
 AliQAv1.h:149
 AliQAv1.h:150
 AliQAv1.h:151
 AliQAv1.h:152
 AliQAv1.h:153
 AliQAv1.h:154
 AliQAv1.h:155
 AliQAv1.h:156
 AliQAv1.h:157
 AliQAv1.h:158
 AliQAv1.h:159
 AliQAv1.h:160
 AliQAv1.h:161
 AliQAv1.h:162
 AliQAv1.h:163
 AliQAv1.h:164
 AliQAv1.h:165
 AliQAv1.h:166
 AliQAv1.h:167
 AliQAv1.h:168
 AliQAv1.h:169
 AliQAv1.h:170
 AliQAv1.h:171
 AliQAv1.h:172
 AliQAv1.h:173
 AliQAv1.h:174
 AliQAv1.h:175
 AliQAv1.h:176
 AliQAv1.h:177
 AliQAv1.h:178
 AliQAv1.h:179
 AliQAv1.h:180
 AliQAv1.h:181
 AliQAv1.h:182
 AliQAv1.h:183