]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliQAManager.cxx
Bug corrected.
[u/mrichter/AliRoot.git] / STEER / AliQAManager.cxx
index 03d000aeee3738ba2cd0d2dce3655509cce9d742..e1d7a6b67741892a02575e7fa773467e347fcc0b 100644 (file)
@@ -203,11 +203,7 @@ AliQAManager::~AliQAManager()
                delete fRawReader ;
                fRawReader = NULL ;
        }
-  TCanvas fakeCanvas ; 
-  if (fPrintImage) 
-    fakeCanvas.Print(Form("%s%s%d.%s]", AliQAv1::GetImageFileName(), GetMode(), fRunNumber, AliQAv1::GetImageFileFormat()), "ps"); 
 }
-
 //_____________________________________________________________________________
 Bool_t AliQAManager::DoIt(const AliQAv1::TASKINDEX_t taskIndex)
 {
@@ -323,7 +319,7 @@ Bool_t AliQAManager::DoIt(const AliQAv1::TASKINDEX_t taskIndex)
        } // event loop 
        // Save QA data for all detectors
 
-       rv = Finish(taskIndex) ;
+  EndOfCycle() ; 
        
        if ( taskIndex == AliQAv1::kRAWS ) 
                fRawReader->RewindEvents() ;
@@ -461,7 +457,7 @@ AliQADataMaker * AliQAManager::GetQADataMaker(const Int_t iDet)
       if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)
         qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ; 
 
-  } else if (iDet == AliQAv1::kGLOBAL) { //Global QA
+  } else if (iDet == AliQAv1::kGLOBAL && strcmp(GetMode(), AliQAv1::GetModeName(AliQAv1::kRECMODE)) == 0) { //Global QA
 
                qadm = new AliGlobalQADataMaker();
                qadm->SetName(AliQAv1::GetDetName(iDet));
@@ -472,7 +468,7 @@ AliQADataMaker * AliQAManager::GetQADataMaker(const Int_t iDet)
       if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)  
         qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ; 
 
-       }       else if (iDet == AliQAv1::kCORR && strcmp(GetMode(), "Rec") == 0 ) { //the data maker for correlations among detectors
+       }       else if (iDet == AliQAv1::kCORR && strcmp(GetMode(), AliQAv1::GetModeName(AliQAv1::kRECMODE)) == 0 ) { //the data maker for correlations among detectors
     qadm = new AliCorrQADataMakerRec(fQADataMaker) ; 
                qadm->SetName(AliQAv1::GetDetName(iDet));
                qadm->SetUniqueID(iDet);
@@ -482,12 +478,14 @@ AliQADataMaker * AliQAManager::GetQADataMaker(const Int_t iDet)
       if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)  
         qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ; 
 
-  } else if ( iDet < AliQAv1::kHLT ) {
-    
+  } else if ( iDet < AliQAv1::kGLOBAL ) {
+    TString  smode(GetMode()) ; 
+    if (smode.Contains(AliQAv1::GetModeName(AliQAv1::kQAMODE)))
+      smode = AliQAv1::GetModeName(AliQAv1::kRECMODE) ; 
     // load the QA data maker object
     TPluginManager* pluginManager = gROOT->GetPluginManager() ;
     TString detName = AliQAv1::GetDetName(iDet) ;
-    TString qadmName = "Ali" + detName + "QADataMaker" + GetMode() ;
+    TString qadmName = "Ali" + detName + "QADataMaker" + smode ;
     
     // first check if a plugin is defined for the quality assurance data maker
     TPluginHandler* pluginHandler = pluginManager->FindHandler("AliQADataMaker", detName) ;
@@ -495,9 +493,9 @@ AliQADataMaker * AliQAManager::GetQADataMaker(const Int_t iDet)
     if (!pluginHandler) {
       AliDebug(AliQAv1::GetQADebugLevel(), Form("defining plugin for %s", qadmName.Data())) ;
       TString libs = gSystem->GetLibraries() ;
-      TString temp(GetMode()) ;
+      TString temp(smode) ;
       temp.ToLower() ; 
-      if (libs.Contains("lib" + detName + GetMode() + ".so") || (gSystem->Load("lib" + detName + temp.Data() + ".so") >= 0)) {
+      if (libs.Contains("lib" + detName + smode + ".so") || (gSystem->Load("lib" + detName + temp.Data() + ".so") >= 0)) {
         pluginManager->AddHandler("AliQADataMaker", detName, qadmName, detName + "qadm", qadmName + "()") ;
       } else {
         pluginManager->AddHandler("AliQADataMaker", detName, qadmName, detName, qadmName + "()") ;
@@ -526,14 +524,12 @@ void  AliQAManager::EndOfCycle(TObjArray * detArray)
        // End of cycle QADataMakers 
        
   AliQAChecker::Instance()->SetRunNumber(fRunNumber) ; 
- if (fPrintImage) {
-    TCanvas fakeCanvas ; 
+  TCanvas fakeCanvas ; 
+
     fakeCanvas.Print(Form("%s%s%d.%s[", AliQAv1::GetImageFileName(), GetMode(), fRunNumber, AliQAv1::GetImageFileFormat()), "ps") ; 
-  }
        for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
                if (IsSelected(AliQAv1::GetDetName(iDet))) {
                        AliQADataMaker * qadm = GetQADataMaker(iDet) ;
-                       AliQACheckerBase * qac = AliQAChecker::Instance()->GetDetQAChecker(iDet) ;
                        if (!qadm) 
                                continue ;      
                        // skip non active detectors
@@ -542,17 +538,18 @@ void  AliQAManager::EndOfCycle(TObjArray * detArray)
                                if (!det || !det->IsActive())  
                                        continue ;
                        }
-      qac->SetPrintImage(fPrintImage) ;
-      
-      if (IsSaveData()) {
-        for (UInt_t taskIndex = 0; taskIndex < AliQAv1::kNTASKINDEX; taskIndex++) {
-          if ( fTasks.Contains(Form("%d", taskIndex)) ) 
-            qadm->EndOfCycle(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(taskIndex))) ;
-        }
+                       AliQACheckerBase * qac = AliQAChecker::Instance()->GetDetQAChecker(iDet) ;
+      if (qac) 
+        qac->SetPrintImage(fPrintImage) ;
+      for (UInt_t taskIndex = 0; taskIndex < AliQAv1::kNTASKINDEX; taskIndex++) {
+        if ( fTasks.Contains(Form("%d", taskIndex)) ) 
+          qadm->EndOfCycle(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(taskIndex))) ;
       }
                        qadm->Finish();
                }
        }
+  if (fPrintImage) 
+    fakeCanvas.Print(Form("%s%s%d.%s]", AliQAv1::GetImageFileName(), GetMode(), fRunNumber, AliQAv1::GetImageFileFormat()), "ps"); 
 }
 
 //_____________________________________________________________________________
@@ -561,29 +558,50 @@ void  AliQAManager::EndOfCycle(TString detectors)
        // End of cycle QADataMakers 
        
   AliQAChecker::Instance()->SetRunNumber(fRunNumber) ; 
-  if (fPrintImage) {
-    TCanvas fakeCanvas ; 
+  TCanvas fakeCanvas ; 
+  if (fPrintImage) 
     fakeCanvas.Print(Form("%s%s%d.%s[", AliQAv1::GetImageFileName(), GetMode(), fRunNumber, AliQAv1::GetImageFileFormat()), "ps") ; 
-  }
   for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
                if (IsSelected(AliQAv1::GetDetName(iDet))) {
                        AliQADataMaker * qadm = GetQADataMaker(iDet) ;
-      AliQACheckerBase * qac = AliQAChecker::Instance()->GetDetQAChecker(iDet) ;
                        if (!qadm) 
                                continue ;      
                        // skip non active detectors
       if (!detectors.Contains(AliQAv1::GetDetName(iDet))) 
         continue ;
-      qac->SetPrintImage(fPrintImage) ;
-      if (IsSaveData()) {
-        for (UInt_t taskIndex = 0; taskIndex < AliQAv1::kNTASKINDEX; taskIndex++) {
-          if ( fTasks.Contains(Form("%d", taskIndex)) ) 
-            qadm->EndOfCycle(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(taskIndex))) ;
-        }
+                       AliQACheckerBase * qac = AliQAChecker::Instance()->GetDetQAChecker(iDet) ;
+      if (qac) 
+        qac->SetPrintImage(fPrintImage) ;
+      for (UInt_t taskIndex = 0; taskIndex < AliQAv1::kNTASKINDEX; taskIndex++) {
+        if ( fTasks.Contains(Form("%d", taskIndex)) ) 
+          qadm->EndOfCycle(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(taskIndex))) ;
       }
                        qadm->Finish();
                }
        }
+  if (fPrintImage) 
+    fakeCanvas.Print(Form("%s%s%d.%s]", AliQAv1::GetImageFileName(), GetMode(), fRunNumber, AliQAv1::GetImageFileFormat()), "ps"); 
+}
+
+//_____________________________________________________________________________
+AliRecoParam::EventSpecie_t AliQAManager::GetEventSpecieFromESD() 
+{
+  AliRecoParam::EventSpecie_t runtype = AliRecoParam::kDefault ; 
+  if (!gSystem->AccessPathName("AliESDs.root")) { // AliESDs.root exists
+    TFile * esdFile = TFile::Open("AliESDs.root") ;
+    TTree * esdTree = static_cast<TTree *> (esdFile->Get("esdTree")) ; 
+    if ( !esdTree ) {
+      AliError("esdTree not found") ; 
+    } else {
+      AliESDEvent * esd    = new AliESDEvent() ;
+      esd->ReadFromTree(esdTree) ;
+      esdTree->GetEntry(0) ; 
+      runtype = AliRecoParam::Convert(esd->GetEventType()) ; 
+    }
+  } else {
+    AliError("AliESDs.root not found") ; 
+  }
+  return runtype ;
 }
 
 //_____________________________________________________________________________
@@ -591,7 +609,7 @@ void AliQAManager::Increment(const AliQAv1::TASKINDEX_t taskIndex)
 {
   // Increments the cycle counter for all QA Data Makers
   static AliQAv1::TASKINDEX_t currentTask = AliQAv1::kNTASKINDEX ; 
-  if (currentTask == taskIndex) 
+  if ( (currentTask == taskIndex) && taskIndex != AliQAv1::kNULLTASKINDEX )
     return ; 
   else 
     currentTask = taskIndex ; 
@@ -776,7 +794,7 @@ Bool_t AliQAManager::IsSelected(const Char_t * det)
        Bool_t rv = kFALSE;
        const TString detName(det) ;
   // always activates Correlation
-  if ( detName.Contains(AliQAv1::GetDetName(AliQAv1::kCORR))) {
+  if ( detName.Contains(AliQAv1::GetDetName(AliQAv1::kCORR)) || detName.Contains(AliQAv1::GetDetName(AliQAv1::kGLOBAL))) {
     rv = kTRUE ; 
   } else {
     // check if all detectors are selected
@@ -972,7 +990,7 @@ void AliQAManager::MergeCustom() const
                     if (  className.Contains("TH") || className.Contains("TProfile") ) {
                       TH1 * histIn = static_cast<TH1*> (key->ReadObj()) ; 
                       TH1 * histOu = static_cast<TH1*> (mergedDirectory->FindObjectAny(histIn->GetName())) ; 
-                      AliDebug(AliQAv1::GetQADebugLevel(), Form("%s %x %x\n", key->GetName(), histIn, histOu)) ; 
+                      AliDebug(AliQAv1::GetQADebugLevel(), Form("%s %p %p\n", key->GetName(), histIn, histOu)) ; 
                       mergedDirectory->cd() ; 
                       if ( ! histOu ) {
                         histIn->Write() ; 
@@ -1035,7 +1053,8 @@ Bool_t AliQAManager::MergeData(const Int_t runNumber, const char *fileName) cons
   for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
     Char_t * file = gSystem->Which(gSystem->WorkingDirectory(), Form("%s.%s.%d.root", AliQAv1::GetDetName(iDet), AliQAv1::GetQADataFileName(), runNumber)); 
     if (file) 
-      merger.AddFile(file) ; 
+      merger.AddFile(file);
+    delete[] file;
   }
   merger.Merge() ; 
        return kTRUE ; 
@@ -1092,7 +1111,8 @@ void AliQAManager::Reset(const Bool_t sameCycle)
        for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
                if (IsSelected(AliQAv1::GetDetName(iDet))) {
                        AliQADataMaker * qadm = GetQADataMaker(iDet);
-                       qadm->Reset();
+                       if (qadm) 
+        qadm->Reset();
                }
        } 
        if (fRawReaderDelete) { 
@@ -1107,14 +1127,33 @@ void AliQAManager::Reset(const Bool_t sameCycle)
        fNumberOfEvents = 999999 ;  
 }
 
+//_____________________________________________________________________________
+void AliQAManager::ResetDetectors(AliQAv1::TASKINDEX_t task, AliQAv1::DETECTORINDEX_t det)
+{
+    //calls ResetDetector of specified or all detectors
+  UInt_t iDet    = 0 ;
+  UInt_t iDetMax = fgkNDetectors ;    
+  if ( det != AliQAv1::kNULLDET ) {
+    iDet    = det ;
+    iDetMax = det+1 ;    
+  }
+  
+       for (iDet = 0; iDet < iDetMax ; iDet++) {
+               if (IsSelected(AliQAv1::GetDetName(iDet))) {
+                       AliQADataMaker * qadm = GetQADataMaker(iDet);
+                       qadm->ResetDetector(task);
+               }
+       }   
+}
+
 //_____________________________________________________________________________
 AliQAManager * AliQAManager::QAManager(AliQAv1::MODE_t mode, TMap *entryCache, Int_t run) 
 {
   // returns AliQAManager instance (singleton)
   
        if (!fgQAInstance) {
-    if ( (mode != AliQAv1::kSIMMODE) && (mode != AliQAv1::kRECMODE) ) {
-      AliErrorClass("You must specify kSIMMODE or kRECMODE") ; 
+    if ( (mode != AliQAv1::kSIMMODE) && (mode != AliQAv1::kRECMODE) && (mode != AliQAv1::kQAMODE) ) {
+      AliWarningClass("You must specify kSIMMODE or kRECMODE or kQAMODE") ; 
       return NULL ; 
     }
     fgQAInstance = new AliQAManager(mode) ;  
@@ -1243,7 +1282,6 @@ void AliQAManager::RunOneEvent(AliRawReader * rawReader)
        //Runs all the QA data Maker for Raws only and on one event only (event loop done by calling method)
   if ( ! rawReader ) 
     return ; 
-  AliCodeTimerAuto("",0) ;
   if (fTasks.Contains(Form("%d", AliQAv1::kRAWS))){
     for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
       if (!IsSelected(AliQAv1::GetDetName(iDet))) 
@@ -1254,23 +1292,20 @@ void AliQAManager::RunOneEvent(AliRawReader * rawReader)
       if ( qadm->IsCycleDone() ) {
         qadm->EndOfCycle() ;
       }
-      AliCodeTimerStart(Form("running RAW quality assurance data maker for %s", AliQAv1::GetDetName(iDet))); 
       qadm->SetEventSpecie(fEventSpecie) ;  
       if ( qadm->GetRecoParam() ) 
         if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)  
           qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ; 
                        qadm->Exec(AliQAv1::kRAWS, rawReader) ;
-      AliCodeTimerStop(Form("running RAW quality assurance data maker for %s", AliQAv1::GetDetName(iDet)));
                }
   }
 }
 
 //_____________________________________________________________________________
-void AliQAManager::RunOneEvent(AliESDEvent *& esd) 
+void AliQAManager::RunOneEvent(AliESDEvent *& esd, AliESDEvent *& hltesd
 {
        //Runs all the QA data Maker for ESDs only and on one event only (event loop done by calling method)
        
-  AliCodeTimerAuto("",0) ;
   if (fTasks.Contains(Form("%d", AliQAv1::kESDS))) {
     for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
       if (!IsSelected(AliQAv1::GetDetName(iDet))) 
@@ -1285,9 +1320,14 @@ void AliQAManager::RunOneEvent(AliESDEvent *& esd)
       if ( qadm->IsCycleDone() ) {
         qadm->EndOfCycle() ;
       }
-      AliCodeTimerStart(Form("running ESD quality assurance data maker for %s", AliQAv1::GetDetName(iDet)));
-                       qadm->Exec(AliQAv1::kESDS, esd) ;
-      AliCodeTimerStop(Form("running ESD quality assurance data maker for %s", AliQAv1::GetDetName(iDet)));
+      if (iDet == AliQAv1::kHLT) {
+        TObjArray esdarray;
+        esdarray.Add(esd); 
+        esdarray.Add(hltesd); 
+        qadm->Exec(AliQAv1::kESDS, &esdarray);
+      } else {
+        qadm->Exec(AliQAv1::kESDS, esd) ;        
+      }
                }
        }
 }
@@ -1298,7 +1338,6 @@ void AliQAManager::RunOneEventInOneDetector(Int_t det, TTree * tree)
        // Runs all the QA data Maker for ESDs only and on one event only (event loop done by calling method)
   
   TString test(tree->GetName()) ; 
-  AliCodeTimerAuto("",0) ;
   if (fTasks.Contains(Form("%d", AliQAv1::kRECPOINTS))) {
     if (IsSelected(AliQAv1::GetDetName(det))) {
       AliQADataMaker *qadm = GetQADataMaker(det);  
@@ -1313,12 +1352,10 @@ void AliQAManager::RunOneEventInOneDetector(Int_t det, TTree * tree)
         if ( qadm->IsCycleDone() ) {
           qadm->EndOfCycle() ;
         }
-        AliCodeTimerStart(Form("running RecPoints quality assurance data maker for %s", AliQAv1::GetDetName(det)));
         if (test.Contains("TreeD")) {
           qadm->Exec(AliQAv1::kDIGITSR, tree) ;
         } else  if (test.Contains("TreeR")) {
           qadm->Exec(AliQAv1::kRECPOINTS, tree) ;
-          AliCodeTimerStop(Form("running RecPoints quality assurance data maker for %s", AliQAv1::GetDetName(det)));
         }
       }
     }