]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliQA.cxx
QA works during reconstruction in and outside the event loop
[u/mrichter/AliRoot.git] / STEER / AliQA.cxx
index daa921b6694edafcf98c99f5aeabf25cbfc1ae26..69825003cdea6537fd7e1950f6fa1bc755bcf1ba 100644 (file)
@@ -54,15 +54,16 @@ TFile    * AliQA::fgQAResultFile         = 0x0 ;
 TString    AliQA::fgQAResultDirName      = "" ;  
 TString    AliQA::fgQAResultFileName     = "QA.root" ; 
 TString    AliQA::fgDetNames[]           = {"ITS", "TPC", "TRD", "TOF", "PHOS", "HMPID", "EMCAL", "MUON", "FMD",
-                                                                                   "ZDC", "PMD", "T0", "VZERO", "ACORDE", "HLT"} ;   
+                                                                                   "ZDC", "PMD", "T0", "VZERO", "ACORDE", "HLT", "Global"} ;   
 TString       AliQA::fgTaskNames[]       = {"Raws", "Hits", "SDigits", "Digits", "RecPoints", "TrackSegments", "RecParticles", "ESDs"} ;   
 const TString AliQA::fkgLabLocalFile     = "file://"  ; 
 const TString AliQA::fkgLabLocalOCDB     = "local://" ;  
 const TString AliQA::fkgLabAliEnOCDB     = "alien://" ;  
 const TString AliQA::fkgRefFileName      = "QA.root" ; 
-const TString AliQA::fkgQAOCDBDirName    = "QA"  ; 
+const TString AliQA::fkgQAName           = "QA"  ; 
 const TString AliQA::fkgRefOCDBDirName   = "Ref"  ; 
-const TString AliQA::fkgQARefOCDBDefault = "local://$ALICE_ROOT"  ; 
+TString AliQA::fkgRefDataDirName   = "Data"  ; 
+const TString AliQA::fkgQARefOCDBDefault = "alien://folder=/alice/QA/20"  ; 
 //____________________________________________________________________________
 AliQA::AliQA() : 
   TNamed("", ""), 
@@ -101,7 +102,7 @@ AliQA& AliQA::operator = (const AliQA& qa)
 }
 
 //_______________________________________________________________
-AliQA::AliQA(const DETECTORINDEX det) :
+AliQA::AliQA(const DETECTORINDEX_t det) :
   TNamed("QA", "Quality Assurance status"),
   fNdet(kNDET),  
   fQA(new ULong_t[fNdet]), 
@@ -119,7 +120,7 @@ AliQA::AliQA(const DETECTORINDEX det) :
 }
   
 //_______________________________________________________________
-AliQA::AliQA(const ALITASK tsk) :
+AliQA::AliQA(const ALITASK_t tsk) :
   TNamed("QA", "Quality Assurance status"), 
   fNdet(kNDET),
   fQA(new ULong_t[fNdet]), 
@@ -165,12 +166,12 @@ const Bool_t AliQA::CheckFatal() const
   Bool_t rv = kFALSE ;
   Int_t index ;
   for (index = 0; index < kNDET ; index++)
-    rv = rv || IsSet(DETECTORINDEX(index), fTask, kFATAL) ;
+    rv = rv || IsSet(DETECTORINDEX_t(index), fTask, kFATAL) ;
   return rv ;
 }
 
 //_______________________________________________________________
-const Bool_t AliQA::CheckRange(DETECTORINDEX det) const
+const Bool_t AliQA::CheckRange(DETECTORINDEX_t det) const
 { 
   // check if detector is in given detector range: 0-kNDET
 
@@ -181,7 +182,7 @@ const Bool_t AliQA::CheckRange(DETECTORINDEX det) const
 }
 
 //_______________________________________________________________
-const Bool_t AliQA::CheckRange(ALITASK task) const
+const Bool_t AliQA::CheckRange(ALITASK_t task) const
 { 
   // check if task is given taskk range: 0:kNTASK
   Bool_t rv = ( task < kRAW || task > kNTASK )  ? kFALSE : kTRUE ;
@@ -191,7 +192,7 @@ const Bool_t AliQA::CheckRange(ALITASK task) const
 }
 
 //_______________________________________________________________
-const Bool_t AliQA::CheckRange(QABIT bit) const
+const Bool_t AliQA::CheckRange(QABIT_t bit) const
 { 
   // check if bit is in given bit range: 0-kNBit
 
@@ -204,7 +205,7 @@ const Bool_t AliQA::CheckRange(QABIT bit) const
 
 
 //_______________________________________________________________
-const char * AliQA::GetAliTaskName(ALITASK tsk)
+const char * AliQA::GetAliTaskName(ALITASK_t tsk)
 {
   // returns the char name corresponding to module index
   TString tskName ;
@@ -233,11 +234,26 @@ const char * AliQA::GetAliTaskName(ALITASK tsk)
   return tskName.Data() ;
 }
 
+//_______________________________________________________________
+const AliQA::DETECTORINDEX_t AliQA::GetDetIndex(const char * name) 
+{
+       // returns the detector index corresponding to a given name
+       TString sname(name) ; 
+       DETECTORINDEX_t rv = kNULLDET ; 
+       for (Int_t det = 0; det < kNDET ; det++) {
+               if ( GetDetName(det) == sname ) {
+                       rv = DETECTORINDEX_t(det) ; 
+                       break ; 
+               }
+       }
+       return rv ;             
+}
+
 //_______________________________________________________________
 const char * AliQA::GetDetName(Int_t det) 
 {
        // returns the detector name corresponding to a given index (needed in a loop)
-
+       
        if ( det >= 0 &&  det < kNDET) 
                return (fgDetNames[det]).Data() ; 
        else 
@@ -248,28 +264,27 @@ const char * AliQA::GetDetName(Int_t det)
 TFile * AliQA::GetQADataFile(const char * name, const Int_t run, const Int_t cycle) 
 {
   // opens the file to store the detectors Quality Assurance Data Maker results
-  char temp[20] ; 
-  sprintf(temp, "%s.%s.%d.%d.root", name, fgQADataFileName.Data(), run, cycle) ; 
-  TString opt ; 
-  if (! fgQADataFile ) {     
-    if  (gSystem->AccessPathName(temp))
-      opt = "NEW" ;
-    else 
-      opt = "UPDATE" ; 
-    fgQADataFile = TFile::Open(temp, opt.Data()) ;
-  } else {
-         if ( strcmp(temp, fgQADataFile->GetName()) != 0 ) {
-                 fgQADataFile = dynamic_cast<TFile *>(gROOT->FindObject(temp)) ; 
-                 if ( !fgQADataFile ) {
-                         if  (gSystem->AccessPathName(temp))
-                                 opt = "NEW" ;
-                         else 
-                                 opt = "UPDATE" ; 
-                         fgQADataFile = TFile::Open(temp, opt.Data()) ;
-                 }
-         }
+       const char * temp = Form("%s.%s.%d.%d.root", name, fgQADataFileName.Data(), run, cycle) ; 
+       TString opt ; 
+       if (! fgQADataFile ) {     
+               if  (gSystem->AccessPathName(temp))
+                       opt = "NEW" ;
+               else 
+                       opt = "UPDATE" ; 
+               fgQADataFile = TFile::Open(temp, opt.Data()) ;
+       } else {
+               if ( strcmp(temp, fgQADataFile->GetName()) != 0 ) {
+                       fgQADataFile = dynamic_cast<TFile *>(gROOT->FindObject(temp)) ; 
+                       if ( !fgQADataFile ) {
+                               if  (gSystem->AccessPathName(temp))
+                                       opt = "NEW" ;
+                               else 
+                                       opt = "UPDATE" ; 
+                               fgQADataFile = TFile::Open(temp, opt.Data()) ;
+                       }
+               }
   }
-  return fgQADataFile ; 
+       return fgQADataFile ;
 } 
 
 //_____________________________________________________________________________
@@ -293,8 +308,10 @@ TFile * AliQA::GetQADataFile(const char * fileName)
 TFile * AliQA::GetQAResultFile() 
 {
   // opens the file to store the  Quality Assurance Data Checker results
-   
-       if (!fgQAResultFile) { 
+       if (fgQAResultFile) 
+               fgQAResultFile->Close() ; 
+       fgQAResultFile = 0x0 ; 
+//     if (!fgQAResultFile) { 
                TString dirName(fgQAResultDirName) ; 
                if ( dirName.Contains(fkgLabLocalFile)) 
                        dirName.ReplaceAll(fkgLabLocalFile, "") ;
@@ -308,13 +325,13 @@ TFile * AliQA::GetQAResultFile()
                        opt = "NEW" ; 
                }
                fgQAResultFile = TFile::Open(fileName, opt) ;   
-       }
+//     }
        
        return fgQAResultFile ;
 }
 
 //_______________________________________________________________
-const Bool_t AliQA::IsSet(DETECTORINDEX det, ALITASK tsk, QABIT bit) const
+const Bool_t AliQA::IsSet(DETECTORINDEX_t det, ALITASK_t tsk, QABIT_t bit) const
 {
   // Checks is the requested bit is set
 
@@ -339,7 +356,7 @@ AliQA * AliQA::Instance()
 }
 
 //_______________________________________________________________
-AliQA * AliQA::Instance(const DETECTORINDEX det)
+AliQA * AliQA::Instance(const DETECTORINDEX_t det)
 {
   // Get an instance of the singleton. The only authorized way to call the ctor
   
@@ -354,7 +371,7 @@ AliQA * AliQA::Instance(const DETECTORINDEX det)
 }
 
 //_______________________________________________________________
-AliQA * AliQA::Instance(const ALITASK tsk)
+AliQA * AliQA::Instance(const ALITASK_t tsk)
 {
   // get an instance of the singleton.
 
@@ -386,7 +403,26 @@ AliQA * AliQA::Instance(const ALITASK tsk)
 }
 
 //_______________________________________________________________
-const ULong_t AliQA::Offset(ALITASK tsk) const
+AliQA *  AliQA::Instance(const TASKINDEX_t tsk) 
+{
+       // get an instance of the singleton.
+       
+       ALITASK_t index = kNULLTASK ; 
+
+       if ( tsk == kRAWS )
+               index = kRAW ;
+       else if (tsk < kDIGITS)
+               index = kSIM ;
+       else if (tsk < kRECPARTICLES)
+               index = kREC ; 
+       else if (tsk == kESDS) 
+               index = kESD ; 
+
+       return Instance(index) ; 
+}
+
+//_______________________________________________________________
+const ULong_t AliQA::Offset(ALITASK_t tsk) const
 {
   // Calculates the bit offset for a given module (SIM, REC, ESD, ANA)
 
@@ -419,7 +455,7 @@ const ULong_t AliQA::Offset(ALITASK tsk) const
 }
 
 //_______________________________________________________________
-void AliQA::Set(QABIT bit)
+void AliQA::Set(QABIT_t bit)
 {
   // Set the status bit of the current detector in the current module
   
@@ -429,19 +465,22 @@ void AliQA::Set(QABIT bit)
 //_____________________________________________________________________________
 void AliQA::SetQARefStorage(const char * name)
 {
-  // Set the root directory where the QA reference data are stored
+       // Set the root directory where the QA reference data are stored
+
+       fgQARefDirName = name ; 
+       if ( fgQARefDirName.Contains(fkgLabLocalFile) )
+               fgQARefFileName =  fkgRefFileName ; 
+       else if ( fgQARefDirName.Contains(fkgLabLocalOCDB) )
+               fgQARefFileName =  fkgQAName ; 
+       else if ( fgQARefDirName.Contains(fkgLabAliEnOCDB) )
+               fgQARefFileName =  fkgQAName ; 
 
-  fgQARefDirName = name ; 
-  if ( fgQARefDirName.Contains(fkgLabLocalFile) )
-        fgQARefFileName =  fkgRefFileName ; 
-  else if (    fgQARefDirName.Contains(fkgLabLocalOCDB) )
-         fgQARefFileName =  fkgQAOCDBDirName ; 
   else {
          printf("ERROR: %s is an invalid storage definition\n", name) ; 
          fgQARefDirName  = "" ; 
          fgQARefFileName = "" ; 
   }    
-       TString tmp(fgQARefDirName + fgQARefFileName) ;
+       TString tmp(fgQARefDirName) ; // + fgQARefFileName) ;
        printf("AliQA::SetQARefDir: QA references are in  %s\n", tmp.Data() ) ;
 }
 
@@ -458,7 +497,7 @@ void AliQA::SetQAResultDirName(const char * name)
 }
 
 //_______________________________________________________________
-void AliQA::SetStatusBit(DETECTORINDEX det, ALITASK tsk, QABIT bit)
+void AliQA::SetStatusBit(DETECTORINDEX_t det, ALITASK_t tsk, QABIT_t bit)
 {
  // Set the status bit for a given detector and a given task
 
@@ -479,11 +518,11 @@ void AliQA::ShowAll() const
   // dispplay the QA status word
   Int_t index ;
   for (index = 0 ; index < kNDET ; index++)
-    ShowStatus(DETECTORINDEX(index)) ;
+    ShowStatus(DETECTORINDEX_t(index)) ;
 }
 
 //_______________________________________________________________
-void AliQA::ShowStatus(DETECTORINDEX det) const
+void AliQA::ShowStatus(DETECTORINDEX_t det) const
 {
   // Prints the full QA status of a given detector
   CheckRange(det) ;
@@ -494,6 +533,29 @@ void AliQA::ShowStatus(DETECTORINDEX det) const
   ULong_t esdStatus = status & 0x0f000 ;
   ULong_t anaStatus = status & 0xf0000 ;
 
-  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 )) ;
+  AliInfo(Form("QA Status for %8s raw =0x%x, sim=0x%x, rec=0x%x, esd=0x%x, ana=0x%x\n", GetDetName(det).Data(), rawStatus, simStatus, recStatus, esdStatus, anaStatus )) ;
 }
 
+//_______________________________________________________________
+void AliQA::UnSet(QABIT_t bit)
+{
+       // UnSet the status bit of the current detector in the current module
+       
+       UnSetStatusBit(fDet, fTask, bit) ;
+}
+
+//_______________________________________________________________
+void AliQA::UnSetStatusBit(DETECTORINDEX_t det, ALITASK_t tsk, QABIT_t bit)
+{
+       // UnSet the status bit for a given detector and a given task
+       
+       CheckRange(det) ;
+       CheckRange(tsk) ;
+       CheckRange(bit) ;
+       
+       ULong_t offset = Offset(tsk) ;
+       ULong_t status = GetStatus(det) ;
+       offset+= bit ;
+       status = status & 0 << offset ;
+       SetStatus(det, status) ;
+}