]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliQA.cxx
bug fixed
[u/mrichter/AliRoot.git] / STEER / AliQA.cxx
index bc91179d692150d5b0b05ff10fb50a9cec41ee5a..50f0a740b4a41587970789ef6f224082288eb4d0 100644 (file)
@@ -59,133 +59,136 @@ TString    AliQA::fgDetNames[]           = {"ITS", "TPC", "TRD", "TOF", "PHOS",
                                             "ZDC", "PMD", "T0", "VZERO", "ACORDE", "HLT", "Global", "CORR"} ;   
 TString    AliQA::fgGRPPath              = "GRP/GRP/Data" ; 
 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::fkgQAName           = "QA"  ; 
-const TString AliQA::fkgQACorrNtName     = "CorrQA" ;  
-const TString AliQA::fkgRefOCDBDirName   = "QA"  ; 
-TString AliQA::fkgRefDataDirName              = ""  ; 
-const TString AliQA::fkgQARefOCDBDefault = "alien://folder=/alice/QA/20"  ; 
-const TString AliQA::fkgExpert           = "Expert" ; 
-const UInt_t  AliQA::fkgExpertBit        = 16 ; 
-const UInt_t  AliQA::fkgQABit            = 17 ; 
+const TString AliQA::fgkLabLocalFile     = "file://"  ; 
+const TString AliQA::fgkLabLocalOCDB     = "local://" ;  
+const TString AliQA::fgkLabAliEnOCDB     = "alien://" ;  
+const TString AliQA::fgkRefFileName      = "QA.root" ; 
+const TString AliQA::fgkQAName           = "QA"  ; 
+const TString AliQA::fgkQACorrNtName     = "CorrQA" ;  
+const TString AliQA::fgkRefOCDBDirName   = "QA"  ; 
+TString AliQA::fgRefDataDirName                 = ""  ; 
+const TString AliQA::fgkQARefOCDBDefault = "alien://folder=/alice/QA/20"  ; 
+const TString AliQA::fgkExpert           = "Expert" ; 
+const UInt_t  AliQA::fgkExpertBit        = 16 ; 
+const UInt_t  AliQA::fgkQABit            = 17 ; 
 
 //____________________________________________________________________________
 AliQA::AliQA() : 
   TNamed("", ""), 
   fNdet(kNDET), 
-  fNEventSpecie(AliRecoParam::kNSpecies), 
-  fQA(new ULong_t*[fNdet]), 
+  fNEventSpecies(AliRecoParam::kNSpecies), 
+  fLengthQA(fNdet*fNEventSpecies),
+  fQA(new ULong_t[fLengthQA]), 
   fDet(kNULLDET),
   fTask(kNULLTASK), 
   fEventSpecie(AliRecoParam::kDefault), 
-  fEventSpecies(new Bool_t[fNEventSpecie])
+  fEventSpecies(new Bool_t[fNEventSpecies])
 {
   // default constructor
-  Int_t det ; 
-  for (det = 0 ; det < fNdet ; det++) {
-    fQA[det] = new ULong_t[fNEventSpecie] ; 
-    for (Int_t es = 0 ; es < fNEventSpecie ; es++) 
-      fQA[det][es] = 0 ; 
-  }
-  for (Int_t es = 0 ; es < fNEventSpecie ; es++)
-    fEventSpecies[es] = kFALSE ; 
+  memset(fQA,0,fLengthQA*sizeof(ULong_t));
+  memset(fEventSpecies,kFALSE,fNEventSpecies*sizeof(Bool_t));
 }
 
 //____________________________________________________________________________
 AliQA::AliQA(const AliQA& qa) :
   TNamed(qa),
   fNdet(qa.fNdet), 
-  fNEventSpecie(qa.fNEventSpecie), 
-  fQA(qa.fQA), 
+  fNEventSpecies(qa.fNEventSpecies), 
+  fLengthQA(qa.fLengthQA),
+  fQA(new ULong_t[fLengthQA]), 
   fDet(qa.fDet),
   fTask(qa.fTask), 
   fEventSpecie(qa.fEventSpecie), 
-  fEventSpecies(qa.fEventSpecies)
+  fEventSpecies(new Bool_t[fNEventSpecies])
 { 
   // cpy ctor
+  memcpy(fQA,qa.fQA,fLengthQA*sizeof(ULong_t));
+  memcpy(fEventSpecies,qa.fEventSpecies,fNEventSpecies*sizeof(Bool_t));
 }
 
 //_____________________________________________________________________________
 AliQA& AliQA::operator = (const AliQA& qa)
 {
   // assignment operator
-  if(&qa == this) return *this;
-    
-  fNdet         = qa.fNdet;
-  fNEventSpecie = qa.fNEventSpecie; 
-  for (Int_t det = 0 ; det < fNdet ; det++) 
-    for (Int_t es = 0 ; es < fNEventSpecie ; es++) 
-        fQA[det][es] = qa.fQA[det][es]; 
-  
-  fNEventSpecie = qa.fNEventSpecie ; 
-  for (Int_t es = 0 ; es < fNEventSpecie ; es++)
-    fEventSpecies[es] = qa. fEventSpecies[es] ; 
-  
+  if(&qa != this) {
+    TNamed::operator=(qa);
+    fNdet          = qa.fNdet;
+    fNEventSpecies = qa.fNEventSpecies; 
+    fLengthQA      = qa.fLengthQA;
+
+    if(fQA) delete [] fQA;
+    fQA = new ULong_t[fLengthQA];
+    memcpy(fQA,qa.fQA,fLengthQA*sizeof(ULong_t));
+
+    fDet = qa.fDet;
+    fTask = qa.fTask;
+    fEventSpecie = qa.fEventSpecie; 
+    if(fEventSpecies) delete [] fEventSpecies;
+    fEventSpecies = new Bool_t[fNEventSpecies];
+    memcpy(fEventSpecies,qa.fEventSpecies,fNEventSpecies*sizeof(Bool_t));
+  }  
   return *this;
 }
 
+//_______________________________________________________________
+AliQA::AliQA(const Int_t qalength, ULong_t * qa, const Int_t eslength, Bool_t * es) :
+TNamed("QA", "Quality Assurance status"),
+fNdet(kNDET), 
+fNEventSpecies(eslength), 
+fLengthQA(qalength),
+fQA(new ULong_t[fLengthQA]), 
+fDet(kNULLDET),
+fTask(kNULLTASK), 
+fEventSpecie(AliRecoParam::kDefault), 
+fEventSpecies(new Bool_t[fNEventSpecies])
+{
+  // constructor to be used
+  memcpy(fQA, qa, fLengthQA*sizeof(ULong_t));
+  memcpy(fEventSpecies, es, fNEventSpecies*sizeof(Bool_t));
+}
+
 //_______________________________________________________________
 AliQA::AliQA(const DETECTORINDEX_t det) :
   TNamed("QA", "Quality Assurance status"),
-  fNdet(kNDET),  
-  fNEventSpecie(AliRecoParam::kNSpecies), 
-  fQA(new ULong_t*[fNdet]), 
+  fNdet(kNDET), 
+  fNEventSpecies(AliRecoParam::kNSpecies), 
+  fLengthQA(fNdet*fNEventSpecies),
+  fQA(new ULong_t[fLengthQA]), 
   fDet(det),
   fTask(kNULLTASK), 
   fEventSpecie(AliRecoParam::kDefault), 
-  fEventSpecies(new Bool_t[fNEventSpecie]) 
+  fEventSpecies(new Bool_t[fNEventSpecies])
 {
   // constructor to be used
-  if (! CheckRange(det) ) {
-    fDet = kNULLDET ; 
-    return ;
-  } 
-  Int_t idet ; 
-  for (idet = 0; idet < fNdet; idet++) {
-    fQA[det] = new ULong_t[fNEventSpecie] ; 
-    for (Int_t es = 0 ; es < fNEventSpecie ; es++) 
-      fQA[idet][es] = 0 ; 
-  }
-  for (Int_t es = 0 ; es < fNEventSpecie ; es++)
-    fEventSpecies[es] = kFALSE ; 
+  if (! CheckRange(det) ) fDet = kNULLDET ; 
+  memset(fQA,0,fLengthQA*sizeof(ULong_t));
+  memset(fEventSpecies,kFALSE,fNEventSpecies*sizeof(Bool_t));
 }
   
 //_______________________________________________________________
 AliQA::AliQA(const ALITASK_t tsk) :
-  TNamed("QA", "Quality Assurance status"), 
-  fNdet(kNDET),
-  fNEventSpecie(AliRecoParam::kNSpecies), 
-  fQA(new ULong_t*[fNdet]), 
+  TNamed("QA", "Quality Assurance status"),
+  fNdet(kNDET), 
+  fNEventSpecies(AliRecoParam::kNSpecies), 
+  fLengthQA(fNdet*fNEventSpecies),
+  fQA(new ULong_t[fLengthQA]), 
   fDet(kNULLDET),
   fTask(tsk), 
   fEventSpecie(AliRecoParam::kDefault), 
-  fEventSpecies(new Bool_t[fNEventSpecie])
+  fEventSpecies(new Bool_t[fNEventSpecies])
 {
   // constructor to be used in the AliRoot module (SIM, REC, ESD or ANA)
-  if (! CheckRange(tsk) ) {
-    fTask = kNULLTASK ; 
-    return ;
-  } 
-  Int_t det ; 
-  for (det = 0; det < fNdet; det++) {
-    fQA[det] = new ULong_t[fNEventSpecie] ; 
-    for (Int_t es = 0 ; es < fNEventSpecie ; es++) 
-      fQA[det][es] = 0 ; 
-  }
-  for (Int_t es = 0 ; es < fNEventSpecie ; es++)
-    fEventSpecies[es] = kFALSE ; 
+  if (! CheckRange(tsk) ) fTask = kNULLTASK ; 
+  memset(fQA,0,fLengthQA*sizeof(ULong_t));
+  memset(fEventSpecies,kFALSE,fNEventSpecies*sizeof(Bool_t));
 }
 
 //____________________________________________________________________________
 AliQA::~AliQA() 
 {
   // dtor  
-  for (Int_t idet = 0; idet < fNdet; idet++) 
-    delete fQA[idet] ;
-  delete[] fQA ;
+  delete [] fQA;
+  delete [] fEventSpecies;
 }
 
 //_______________________________________________________________
@@ -357,7 +360,7 @@ const char * AliQA::GetDetName(Int_t det)
 }
 
 //_______________________________________________________________
-TFile * AliQA::GetQADataFile(const char * name, const Int_t run) 
+TFile * AliQA::GetQADataFile(const char * name, Int_t run) 
 {
   // opens the file to store the detectors Quality Assurance Data Maker results
        const char * temp = Form("%s.%s.%d.root", name, fgQADataFileName.Data(), run) ; 
@@ -409,8 +412,8 @@ TFile * AliQA::GetQAResultFile()
        fgQAResultFile = 0x0 ; 
 //     if (!fgQAResultFile) { 
                TString dirName(fgQAResultDirName) ; 
-               if ( dirName.Contains(fkgLabLocalFile)) 
-                       dirName.ReplaceAll(fkgLabLocalFile, "") ;
+               if ( dirName.Contains(fgkLabLocalFile)) 
+                       dirName.ReplaceAll(fgkLabLocalFile, "") ;
                TString fileName(dirName + fgQAResultFileName) ; 
                TString opt("") ; 
                if ( !gSystem->AccessPathName(fileName) )
@@ -526,6 +529,16 @@ AliQA * AliQA::Instance()
   return fgQA ;
 }
 
+//_______________________________________________________________
+AliQA * AliQA::Instance(const Int_t qalength, ULong_t * qa, const Int_t eslength, Bool_t * es)
+{
+  // Get an instance of the singleton. The only authorized way to call the ctor
+  
+  if ( ! fgQA) 
+    fgQA = new AliQA(qalength, qa, eslength, es) ;
+  return fgQA ;
+}
+
 //_______________________________________________________________
 AliQA * AliQA::Instance(const DETECTORINDEX_t det)
 {
@@ -604,7 +617,7 @@ void AliQA::Merge(TCollection * list) {
                                TIter next(list) ;
                                AliQA * qa ; 
                                while ( (qa = (AliQA*)next() ) ) {
-          for (Int_t es = 0 ; es < fNEventSpecie ; es++) {
+          for (Int_t es = 0 ; es < fNEventSpecies ; es++) {
             if (qa->IsSet(DETECTORINDEX_t(det), ALITASK_t(task), es, QABIT_t(bit)))
               Set(QABIT_t(bit), es) ; 
           }
@@ -651,8 +664,8 @@ ULong_t AliQA::Offset(ALITASK_t tsk) const
 void AliQA::ResetStatus(DETECTORINDEX_t det) 
 { 
   // reset the status of det for all event specie
-  for (Int_t es = 0 ; es < fNEventSpecie ; es++)
-    fQA[det][es] = 0 ; 
+  for (Int_t es = 0 ; es < fNEventSpecies ; es++)
+    fQA[det*fNdet+es] = 0 ; 
 }
 
 //_______________________________________________________________
@@ -676,12 +689,12 @@ void AliQA::SetQARefStorage(const char * name)
        // 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 ; 
+       if ( fgQARefDirName.Contains(fgkLabLocalFile) )
+               fgQARefFileName =  fgkRefFileName ; 
+       else if ( fgQARefDirName.Contains(fgkLabLocalOCDB) )
+               fgQARefFileName =  fgkQAName ; 
+       else if ( fgQARefDirName.Contains(fgkLabAliEnOCDB) )
+               fgQARefFileName =  fgkQAName ; 
 
   else {
          printf("ERROR: %s is an invalid storage definition\n", name) ; 
@@ -699,8 +712,8 @@ void AliQA::SetQAResultDirName(const char * name)
 
   fgQAResultDirName.Prepend(name) ; 
   printf("AliQA::SetQAResultDirName: QA results are in  %s\n", fgQAResultDirName.Data()) ;
-  if ( fgQAResultDirName.Contains(fkgLabLocalFile)) 
-    fgQAResultDirName.ReplaceAll(fkgLabLocalFile, "") ;
+  if ( fgQAResultDirName.Contains(fgkLabLocalFile)) 
+    fgQAResultDirName.ReplaceAll(fgkLabLocalFile, "") ;
   fgQAResultFileName.Prepend(fgQAResultDirName) ;
 }
 
@@ -726,7 +739,7 @@ void AliQA::Show() const
 { 
   // dispplay the QA status word
 
-  for (Int_t ies = 0 ; ies < fNEventSpecie ; ies++) {
+  for (Int_t ies = 0 ; ies < fNEventSpecies ; ies++) {
     const Bool_t what = IsEventSpecieSet(ies) ;
     if ( what )
       ShowStatus(fDet, fTask, AliRecoParam::Convert(ies)) ; 
@@ -738,7 +751,7 @@ void AliQA::Show(DETECTORINDEX_t det) const
 { 
   // dispplay the QA status word
   
-  for (Int_t ies = 0 ; ies < fNEventSpecie ; ies++) {
+  for (Int_t ies = 0 ; ies < fNEventSpecies ; ies++) {
     const Bool_t what = IsEventSpecieSet(ies) ;
     if ( what )
       ShowStatus(fDet, kNULLTASK, AliRecoParam::Convert(ies)) ; 
@@ -752,7 +765,7 @@ void AliQA::ShowAll() const
   Int_t index ;
   for (index = 0 ; index < kNDET ; index++) {
                for (Int_t tsk = kRAW ; tsk < kNTASK ; tsk++) {
-      for (Int_t ies = 0 ; ies < fNEventSpecie ; ies++) {
+      for (Int_t ies = 0 ; ies < fNEventSpecies ; ies++) {
         const Bool_t what = IsEventSpecieSet(ies) ;
         if ( what )
           ShowStatus(DETECTORINDEX_t(index), ALITASK_t(tsk), AliRecoParam::Convert(ies)) ;