]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliQAv1.cxx
Added possibility to invert the sign of the parametization
[u/mrichter/AliRoot.git] / STEER / AliQAv1.cxx
index 24be2719f45530b3e3440d671156b98722de52d0..0ebf5fc02bad67541b80cc58e4a56724e6624410 100644 (file)
@@ -36,6 +36,7 @@
 // --- ROOT system ---
 #include <TClass.h>
 #include <TFile.h>
+#include <TH1.h>
 #include <TSystem.h>
 #include <TROOT.h>
 
@@ -60,7 +61,7 @@ TString        AliQAv1::fgDetNames[]           = {"ITS", "TPC", "TRD", "TOF", "P
                                                   "ZDC", "PMD", "T0", "VZERO", "ACORDE", "HLT", "Global", "CORR"} ;   
 TString        AliQAv1::fgGRPPath              = "GRP/GRP/Data" ; 
 TString        AliQAv1::fgTaskNames[]          = {"Raws", "Hits", "SDigits", "Digits", "DigitsR", "RecPoints", "TrackSegments", "RecParticles", "ESDs"} ;   
-TString        AliQAv1::fgModeNames[]          = {"", "Sim", "Rec"} ;   
+TString        AliQAv1::fgModeNames[]          = {"", "Sim", "Rec", "QA"} ;   
 const TString  AliQAv1::fgkLabLocalFile        = "file://"  ; 
 const TString  AliQAv1::fgkLabLocalOCDB        = "local://" ;  
 const TString  AliQAv1::fgkLabAliEnOCDB        = "alien://" ;  
@@ -71,9 +72,9 @@ const TString  AliQAv1::fgkRefOCDBDirName      = "QA"  ;
 TString AliQAv1::fgRefDataDirName                   = ""  ; 
 const TString  AliQAv1::fgkQARefOCDBDefault    = "alien://folder=/alice/QA/20"  ; 
 const TString  AliQAv1::fgkExpert              = "Expert" ; 
-const UInt_t   AliQAv1::fgkExpertBit           = 0x40000 ; 
-const UInt_t   AliQAv1::fgkQABit               = 0x80000 ; 
-const UInt_t   AliQAv1::fgkImageBit            = 0x100000 ; 
+const UInt_t   AliQAv1::fgkExpertBit           = BIT(19);  
+const UInt_t   AliQAv1::fgkQABit               = BIT(20) ; 
+const UInt_t   AliQAv1::fgkImageBit            = BIT(21) ; 
 const Int_t    AliQAv1::fgkQADebugLevel        = 99 ; 
 const TString  AliQAv1::fImageFileName         = "QAImage" ; 
 const TString  AliQAv1::fImageFileFormat       = "ps" ; 
@@ -320,6 +321,7 @@ const char * AliQAv1::GetBitName(QABIT_t bit) const
        TString bitName ;
        switch (bit) {
                case kNULLBit:
+                       bitName = "NONE" ;
                        break ; 
                case kINFO:
                        bitName = "INFO" ;
@@ -340,6 +342,25 @@ const char * AliQAv1::GetBitName(QABIT_t bit) const
        return bitName.Data() ;
 }
 
+//_______________________________________________________________
+TH1 * AliQAv1::GetData(TObjArray** list, Int_t index, AliRecoParam::EventSpecie_t eventSpecie)
+{
+    // retrieve QA data from the list at a given index and for a given event specie 
+  TH1 * rv = NULL ; 
+  Int_t esindex = AliRecoParam::AConvert(eventSpecie) ; 
+  TObjArray * arr = list[esindex] ;
+  if (arr) {
+    if ( index > AliQAv1::GetMaxQAObj() ) {
+                       AliErrorClass(Form("Max number of authorized QA objects is %d", AliQAv1::GetMaxQAObj())) ; 
+               } else {
+      if ( arr->At(index) )  {
+        rv = static_cast<TH1*>(arr->At(index)) ; 
+      }        
+    }
+  }  
+  return rv ; 
+}
+
 //_______________________________________________________________
 AliQAv1::DETECTORINDEX_t AliQAv1::GetDetIndex(const char * name) 
 {
@@ -451,29 +472,49 @@ TFile * AliQAv1::GetQADataFile(const char * fileName)
 //_______________________________________________________________
 TFile * AliQAv1::GetQAResultFile() 
 {
-  // opens the file to store the  Quality Assurance Data Checker results
-       if (fgQAResultFile) 
-               fgQAResultFile->Close() ; 
-       fgQAResultFile = 0x0 ; 
-//     if (!fgQAResultFile) { 
-               TString dirName(fgQAResultDirName) ; 
-               if ( dirName.Contains(fgkLabLocalFile)) 
-                       dirName.ReplaceAll(fgkLabLocalFile, "") ;
-               TString fileName(dirName + fgQAResultFileName) ; 
-               TString opt("") ; 
-               if ( !gSystem->AccessPathName(fileName) )
-                       opt = "UPDATE" ; 
-               else { 
-                       if ( gSystem->AccessPathName(dirName) )
-                               gSystem->mkdir(dirName) ; 
-                       opt = "NEW" ; 
-               }
-               fgQAResultFile = TFile::Open(fileName, opt) ;   
-//     }
+  // opens the file to store the  Quality Assurance Data Checker results       
+  if (fgQAResultFile && fgQAResultFile->IsOpen()) 
+  {
+    fgQAResultFile->Close();
+  }
+  delete fgQAResultFile;
+  fgQAResultFile=0x0;
+  
+  TString dirName(fgQAResultDirName) ; 
+  if ( dirName.Contains(fgkLabLocalFile)) 
+    dirName.ReplaceAll(fgkLabLocalFile, "") ;
+  TString fileName(dirName + fgQAResultFileName) ; 
+  TString opt("") ; 
+  if ( !gSystem->AccessPathName(fileName) )
+    opt = "UPDATE" ; 
+  else { 
+    if ( gSystem->AccessPathName(dirName) )
+      gSystem->mkdir(dirName) ; 
+    opt = "NEW" ; 
+  }
+  fgQAResultFile = TFile::Open(fileName, opt) ;   
        
        return fgQAResultFile ;
 }
 
+//_______________________________________________________________
+AliQAv1::QABIT_t AliQAv1::GetQAStatusBit(AliRecoParam::EventSpecie_t es, DETECTORINDEX_t det, ALITASK_t tsk) const
+{
+    // returns the QA bit set
+  QABIT_t rv = kNULLBit ; 
+  if ( es == AliRecoParam::kDefault) 
+    es = fEventSpecie ; 
+  if ( det == kNULLDET ) 
+    det = fDet ; 
+  if ( tsk == kNULLTASK ) 
+    tsk = fTask ; 
+  for (Int_t bit = kINFO ; bit < kNBIT ; bit++) {
+               if (IsSet(det, tsk, es, QABIT_t(bit))) 
+      rv = QABIT_t(bit) ;
+       }
+  return rv ; 
+}
+
 //_______________________________________________________________
 AliQAv1::TASKINDEX_t AliQAv1::GetTaskIndex(const char * name) 
 {
@@ -568,6 +609,7 @@ AliQAv1 * AliQAv1::Instance()
   if ( ! fgQA) {
     TFile * f = GetQAResultFile() ; 
     fgQA = static_cast<AliQAv1 *>(f->Get("QA")) ; 
+    f->Close() ; 
     if ( ! fgQA ) 
       fgQA = new AliQAv1() ;
   }
@@ -591,7 +633,7 @@ AliQAv1 * AliQAv1::Instance(const DETECTORINDEX_t det)
   
   if ( ! fgQA) {
     TFile * f = GetQAResultFile() ; 
-    fgQA = static_cast<AliQAv1 *>(f->Get("QA")) ; 
+    fgQA = static_cast<AliQAv1 *>(f->Get(GetQAName())) ; 
     if ( ! fgQA ) 
       fgQA = new AliQAv1(det) ;
   }            
@@ -705,6 +747,23 @@ ULong_t AliQAv1::Offset(ALITASK_t tsk) const
   return offset ;
 }
 
+//_______________________________________________________________
+void AliQAv1::Reset(DETECTORINDEX_t det, ALITASK_t tsk, AliRecoParam::EventSpecie_t es)
+{
+    // resets all the bits for a given tsk and event specie
+  CheckRange(det) ; 
+  CheckRange(tsk) ;
+  CheckRange(es) ;
+       
+  ULong_t offset = Offset(tsk) ;
+  ULong_t status = GetStatus(det, es) ;
+       for ( Int_t bit = 0 ; bit < kNBIT ; bit++) {
+               offset+= bit ;
+               status = status & ~1 << offset ;                
+       }  
+  SetStatus(det, es, status) ;
+}
+
 //_______________________________________________________________
 void AliQAv1::ResetStatus(DETECTORINDEX_t det) 
 { 
@@ -771,7 +830,9 @@ void AliQAv1::SetStatusBit(DETECTORINDEX_t det, ALITASK_t tsk, AliRecoParam::Eve
   CheckRange(tsk) ;
   CheckRange(bit) ;
   CheckRange(es) ;
-
+  
+  Reset(det, tsk, es) ; 
+  
   ULong_t offset = Offset(tsk) ;
   ULong_t status = GetStatus(det, es) ;
   offset+= bit ;
@@ -836,14 +897,12 @@ void AliQAv1::ShowASCIIStatus(AliRecoParam::EventSpecie_t es, DETECTORINDEX_t de
 {
        // print the QA status in human readable format
        TString text; 
-       for (Int_t bit = kINFO ; bit < kNBIT ; bit++) {
-               if (IsSet(det, tsk, es, QABIT_t(bit))) {
-                       text = GetBitName(QABIT_t(bit)) ; 
-                       text += " " ; 
-               }
-       }
-       if (! text.IsNull())
-               AliInfoClass(Form("           %8s %8s %4s 0x%4lx, Problem signalled: %8s \n", AliRecoParam::GetEventSpecieName(es), GetDetName(det).Data(), GetAliTaskName(tsk), status, text.Data())) ; 
+  QABIT_t bit = GetQAStatusBit(es, det, tsk) ; 
+  if ( bit != kNULLBit ) {
+    text = GetBitName(bit) ; 
+    text += " " ; 
+    AliInfoClass(Form("           %8s %8s %4s 0x%4lx, Problem signalled: %8s \n", AliRecoParam::GetEventSpecieName(es), GetDetName(det).Data(), GetAliTaskName(tsk), status, text.Data())) ; 
+  }
 }
 
 //_______________________________________________________________