]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliQAManager.cxx
Bug fix in copy constructor and assignement operator (Matthias + me)
[u/mrichter/AliRoot.git] / STEER / AliQAManager.cxx
index 7920f4e12dc771be1603c0da8367d1e3a7c87258..55b6785ab194037519fd55adaf5f496d2605c64a 100644 (file)
 //                                                                           //
 // class for running the QA makers                                           //
 //                                                                           //
-//   AliQAManager qas;                                                //
-//   qas.Run(AliQAv1::kRAWS, rawROOTFileName);                                 //
-//   qas.Run(AliQAv1::kHITS);                                                  //
-//   qas.Run(AliQAv1::kSDIGITS);                                               //
-//   qas.Run(AliQAv1::kDIGITS);                                                //
-//   qas.Run(AliQAv1::kRECPOINTS);                                             //
-//   qas.Run(AliQAv1::kESDS);                                                  //
+//   AliQAManager qas;                                                       //
+//   qas.Run(AliQAv1::kRAWS, rawROOTFileName);                               //
+//   qas.Run(AliQAv1::kHITS);                                                //
+//   qas.Run(AliQAv1::kSDIGITS);                                             //
+//   qas.Run(AliQAv1::kDIGITS);                                              //
+//   qas.Run(AliQAv1::kRECPOINTS);                                           //
+//   qas.Run(AliQAv1::kESDS);                                                //
 //                                                                           //
 ///////////////////////////////////////////////////////////////////////////////
 
@@ -54,6 +54,8 @@
 #include "AliLog.h"
 #include "AliModule.h"
 #include "AliQAv1.h"
+#include "AliQAChecker.h"
+#include "AliQACheckerBase.h"
 #include "AliQADataMakerRec.h"
 #include "AliQADataMakerSim.h"
 #include "AliQAManager.h" 
@@ -88,7 +90,8 @@ AliQAManager::AliQAManager() :
   fRunLoader(NULL), 
   fTasks(""),  
   fEventSpecie(AliRecoParam::kDefault), 
-  fPrintImage(kTRUE) 
+  fPrintImage(kTRUE), 
+  fSaveData(kTRUE) 
 {
        // default ctor
        fMaxEvents = fNumberOfEvents ; 
@@ -103,7 +106,7 @@ AliQAManager::AliQAManager() :
 }
 
 //_____________________________________________________________________________
-AliQAManager::AliQAManager(Char_t * mode, const Char_t* gAliceFilename) :
+AliQAManager::AliQAManager(AliQAv1::MODE_t mode, const Char_t* gAliceFilename) :
   AliCDBManager(), 
   fCurrentEvent(0),  
        fCycleSame(kFALSE),
@@ -114,7 +117,7 @@ AliQAManager::AliQAManager(Char_t * mode, const Char_t* gAliceFilename) :
        fGAliceFileName(gAliceFilename), 
        fFirstEvent(0),        
        fMaxEvents(0),   
-  fMode(mode), 
+  fMode(AliQAv1::GetModeName(mode)), 
        fNumberOfEvents(999999), 
   fRecoParam(),
        fRunNumber(0), 
@@ -123,7 +126,8 @@ AliQAManager::AliQAManager(Char_t * mode, const Char_t* gAliceFilename) :
        fRunLoader(NULL), 
   fTasks(""), 
   fEventSpecie(AliRecoParam::kDefault), 
-  fPrintImage(kTRUE) 
+  fPrintImage(kTRUE), 
+  fSaveData(kTRUE) 
 {
        // default ctor
        fMaxEvents = fNumberOfEvents ; 
@@ -135,10 +139,6 @@ AliQAManager::AliQAManager(Char_t * mode, const Char_t* gAliceFilename) :
     }
   }
   SetWriteExpert() ; 
-  if (fMode.Contains("sim")) 
-               fMode.ReplaceAll("s", "S") ; 
-  else if (fMode.Contains("rec")) 
-    fMode.ReplaceAll("r", "R") ; 
 }
 
 //_____________________________________________________________________________
@@ -162,7 +162,8 @@ AliQAManager::AliQAManager(const AliQAManager & qas) :
        fRunLoader(NULL), 
   fTasks(qas.fTasks), 
   fEventSpecie(qas.fEventSpecie), 
-  fPrintImage(qas.fPrintImage) 
+  fPrintImage(qas.fPrintImage), 
+  fSaveData(qas.fSaveData) 
 
 {
        // cpy ctor
@@ -252,8 +253,8 @@ Bool_t AliQAManager::DoIt(const AliQAv1::TASKINDEX_t taskIndex)
                 AliWarning(Form(" Hit Tree not found for  %s", AliQAv1::GetDetName(iDet))) ; 
                 break ; 
               } 
+              qadm->Exec(taskIndex, data) ;
             } 
-            qadm->Exec(taskIndex, data) ;
                                                break ;
                                                case AliQAv1::kSDIGITS :
             if( loader ) {      
@@ -263,8 +264,8 @@ Bool_t AliQAManager::DoIt(const AliQAv1::TASKINDEX_t taskIndex)
                 AliWarning(Form(" SDigit Tree not found for  %s", AliQAv1::GetDetName(iDet))) ; 
                 break ; 
               } 
+              qadm->Exec(taskIndex, data) ; 
             }
-            qadm->Exec(taskIndex, data) ; 
                                                break; 
                                                case AliQAv1::kDIGITS :
               if( loader ) {      
@@ -274,7 +275,9 @@ Bool_t AliQAManager::DoIt(const AliQAv1::TASKINDEX_t taskIndex)
                   AliWarning(Form(" Digit Tree not found for  %s", AliQAv1::GetDetName(iDet))) ; 
                   break ; 
                 } 
+                qadm->Exec(taskIndex, data) ;
               }
+            break;
             case AliQAv1::kDIGITSR :
               if( loader ) {      
                 loader->LoadDigits() ; 
@@ -283,8 +286,8 @@ Bool_t AliQAManager::DoIt(const AliQAv1::TASKINDEX_t taskIndex)
                   AliWarning(Form(" Digit Tree not found for  %s", AliQAv1::GetDetName(iDet))) ; 
                   break ; 
                 } 
+                qadm->Exec(taskIndex, data) ;
               }
-            qadm->Exec(taskIndex, data) ;
                                                break; 
                                                case AliQAv1::kRECPOINTS :
             if( loader ) {      
@@ -294,8 +297,8 @@ Bool_t AliQAManager::DoIt(const AliQAv1::TASKINDEX_t taskIndex)
                 AliWarning(Form("RecPoints not found for %s", AliQAv1::GetDetName(iDet))) ; 
                 break ; 
               } 
+              qadm->Exec(taskIndex, data) ; 
             }
-            qadm->Exec(taskIndex, data) ; 
             break; 
                                                case AliQAv1::kTRACKSEGMENTS :
                                                break; 
@@ -309,9 +312,10 @@ Bool_t AliQAManager::DoIt(const AliQAv1::TASKINDEX_t taskIndex)
                                } //task switch
                        }
                } // detector loop
-    Increment() ; 
+    Increment(taskIndex) ; 
        } // event loop 
        // Save QA data for all detectors
+
        rv = Finish(taskIndex) ;
        
        if ( taskIndex == AliQAv1::kRAWS ) 
@@ -324,6 +328,9 @@ Bool_t AliQAManager::DoIt(const AliQAv1::TASKINDEX_t taskIndex)
 Bool_t AliQAManager::Finish(const AliQAv1::TASKINDEX_t taskIndex) 
 {
        // write output to file for all detectors
+  
+  AliQAChecker::Instance()->SetRunNumber(fRunNumber) ; 
+
        for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
                if (IsSelected(AliQAv1::GetDetName(iDet))) {
                        AliQADataMaker * qadm = GetQADataMaker(iDet) ;
@@ -353,9 +360,9 @@ TObjArray * AliQAManager::GetFromOCDB(AliQAv1::DETECTORINDEX_t det, AliQAv1::TAS
        TString detOCDBDir(Form("%s/%s/%s", AliQAv1::GetQAName(), AliQAv1::GetDetName((Int_t)det), AliQAv1::GetRefOCDBDirName())) ; 
      AliDebug(AliQAv1::GetQADebugLevel(), Form("Retrieving reference data from %s/%s for %s", AliQAv1::GetQARefStorage(), detOCDBDir.Data(), AliQAv1::GetTaskName(task).Data())) ; 
        AliCDBEntry* entry = QAManager()->Get(detOCDBDir.Data(), 0) ; //FIXME 0 --> Run Number
-       TList * listDetQAD = dynamic_cast<TList *>(entry->GetObject()) ;
+       TList * listDetQAD = static_cast<TList *>(entry->GetObject()) ;
        if ( listDetQAD ) 
-               rv = dynamic_cast<TObjArray *>(listDetQAD->FindObject(AliQAv1::GetTaskName(task))) ; 
+               rv = static_cast<TObjArray *>(listDetQAD->FindObject(AliQAv1::GetTaskName(task))) ; 
        return rv ; 
 }
 
@@ -365,8 +372,8 @@ TCanvas ** AliQAManager::GetImage(Char_t * detName)
   // retrieves QA Image for the given detector
   TCanvas ** rv = NULL ; 
   Int_t detIndex = AliQAv1::GetDetIndex(detName) ; 
-  AliQADataMaker * qadm = GetQADataMaker(detIndex) ; 
-  rv = qadm->GetImage() ;
+  AliQACheckerBase * qac = AliQAChecker::Instance()->GetDetQAChecker(detIndex) ; 
+  rv = qac->GetImage() ;
   return rv ; 
 }
 
@@ -375,7 +382,7 @@ AliLoader * AliQAManager::GetLoader(Int_t iDet)
 {
        // get the loader for a detector
 
-       if ( !fRunLoader || iDet == AliQAv1::kCORR) 
+       if ( !fRunLoader || iDet == AliQAv1::kCORR || iDet == AliQAv1::kGLOBAL 
                return NULL ; 
        
        TString detName = AliQAv1::GetDetName(iDet) ;
@@ -419,7 +426,7 @@ AliQAv1 * AliQAManager::GetQA(UInt_t run, UInt_t evt)
     AliError(Form("File %s not found", fileName)) ;
     return NULL ; 
   }
-  TTree * tagTree = dynamic_cast<TTree *>(tagFile->Get("T")) ; 
+  TTree * tagTree = static_cast<TTree *>(tagFile->Get("T")) ; 
   if ( !tagTree ) {
     AliError(Form("Tree T not found in %s", fileName)) ; 
     tagFile->Close() ; 
@@ -438,30 +445,18 @@ AliQADataMaker * AliQAManager::GetQADataMaker(const Int_t iDet)
 {
        // get the quality assurance data maker for a detector
        
-       if (fQADataMaker[iDet]) {
-    fQADataMaker[iDet]->SetEventSpecie(fEventSpecie) ;  
-    if ( fQADataMaker[iDet]->GetRecoParam() ) 
-      if ( AliRecoParam::Convert(fQADataMaker[iDet]->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)
-        fQADataMaker[iDet]->SetEventSpecie(fQADataMaker[iDet]->GetRecoParam()->GetEventSpecie()) ; 
-               return fQADataMaker[iDet] ;
-  }
-       
-       AliQADataMaker * qadm = NULL ;
-       
-       if (iDet == AliQAv1::kGLOBAL) { //Global QA
-               qadm = new AliGlobalQADataMaker();
-               qadm->SetName(AliQAv1::GetDetName(iDet));
-               qadm->SetUniqueID(iDet);
-               fQADataMaker[iDet] = qadm;
+  AliQADataMaker * qadm =  fQADataMaker[iDet] ; 
+  
+       if (qadm) {
     qadm->SetEventSpecie(fEventSpecie) ;  
     if ( qadm->GetRecoParam() ) 
-      if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)  
+      if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)
         qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ; 
-               return qadm;
-       }
 
-       if (iDet == AliQAv1::kCORR) { //the data maker for correlations among detectors
-    qadm = new AliCorrQADataMakerRec(fQADataMaker) ; 
+  } else if (iDet == AliQAv1::kGLOBAL) { //Global QA
+
+               qadm = new AliGlobalQADataMaker();
                qadm->SetName(AliQAv1::GetDetName(iDet));
                qadm->SetUniqueID(iDet);
                fQADataMaker[iDet] = qadm;
@@ -469,40 +464,52 @@ AliQADataMaker * AliQAManager::GetQADataMaker(const Int_t iDet)
     if ( qadm->GetRecoParam() ) 
       if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)  
         qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ; 
-               return qadm;
-  }
-
-       // load the QA data maker object
-       TPluginManager* pluginManager = gROOT->GetPluginManager() ;
-       TString detName = AliQAv1::GetDetName(iDet) ;
-       TString qadmName = "Ali" + detName + "QADataMaker" + fMode ;
 
-       // first check if a plugin is defined for the quality assurance data maker
-       TPluginHandler* pluginHandler = pluginManager->FindHandler("AliQADataMaker", detName) ;
-       // if not, add a plugin for it
-       if (!pluginHandler) {
-               AliDebug(AliQAv1::GetQADebugLevel(), Form("defining plugin for %s", qadmName.Data())) ;
-               TString libs = gSystem->GetLibraries() ;
-               if (libs.Contains("lib" + detName + fMode + ".so") || (gSystem->Load("lib" + detName + fMode + ".so") >= 0)) {
-                       pluginManager->AddHandler("AliQADataMaker", detName, qadmName, detName + "qadm", qadmName + "()") ;
-               } else {
-                       pluginManager->AddHandler("AliQADataMaker", detName, qadmName, detName, qadmName + "()") ;
-               }
-               pluginHandler = pluginManager->FindHandler("AliQADataMaker", detName) ;
-       }
-       if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
-               qadm = (AliQADataMaker *) pluginHandler->ExecPlugin(0) ;
-       }
-       if (qadm) {
+       }       else if (iDet == AliQAv1::kCORR && strcmp(GetMode(), "Rec") == 0 ) { //the data maker for correlations among detectors
+    qadm = new AliCorrQADataMakerRec(fQADataMaker) ; 
                qadm->SetName(AliQAv1::GetDetName(iDet));
                qadm->SetUniqueID(iDet);
-               fQADataMaker[iDet] = qadm ;
+               fQADataMaker[iDet] = qadm;
     qadm->SetEventSpecie(fEventSpecie) ;  
     if ( qadm->GetRecoParam() ) 
       if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)  
         qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ; 
-       }
 
+  } else if ( iDet < AliQAv1::kHLT ) {
+    
+    // load the QA data maker object
+    TPluginManager* pluginManager = gROOT->GetPluginManager() ;
+    TString detName = AliQAv1::GetDetName(iDet) ;
+    TString qadmName = "Ali" + detName + "QADataMaker" + GetMode() ;
+    
+    // first check if a plugin is defined for the quality assurance data maker
+    TPluginHandler* pluginHandler = pluginManager->FindHandler("AliQADataMaker", detName) ;
+    // if not, add a plugin for it
+    if (!pluginHandler) {
+      AliDebug(AliQAv1::GetQADebugLevel(), Form("defining plugin for %s", qadmName.Data())) ;
+      TString libs = gSystem->GetLibraries() ;
+      TString temp(GetMode()) ;
+      temp.ToLower() ; 
+      if (libs.Contains("lib" + detName + GetMode() + ".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 + "()") ;
+      }
+      pluginHandler = pluginManager->FindHandler("AliQADataMaker", detName) ;
+    }
+    if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
+      qadm = (AliQADataMaker *) pluginHandler->ExecPlugin(0) ;
+    }
+    if (qadm) {
+      qadm->SetName(AliQAv1::GetDetName(iDet));
+      qadm->SetUniqueID(iDet);
+      fQADataMaker[iDet] = qadm ;
+      qadm->SetEventSpecie(fEventSpecie) ;  
+      if ( qadm->GetRecoParam() ) 
+        if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)  
+          qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ; 
+    }
+  }
   return qadm ;
 }
 
@@ -511,13 +518,15 @@ void  AliQAManager::EndOfCycle(TObjArray * detArray)
 {
        // End of cycle QADataMakers 
        
-  if (fPrintImage) {
+  AliQAChecker::Instance()->SetRunNumber(fRunNumber) ; 
+ if (fPrintImage) {
     TCanvas fakeCanvas ; 
     fakeCanvas.Print(Form("%s%s%d.%s[", AliQAv1::GetImageFileName(), GetMode(), fRunNumber, AliQAv1::GetImageFileFormat())) ; 
   }
        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
@@ -526,11 +535,14 @@ void  AliQAManager::EndOfCycle(TObjArray * detArray)
                                if (!det || !det->IsActive())  
                                        continue ;
                        }
-      qadm->SetPrintImage(fPrintImage) ;
-                       for (UInt_t taskIndex = 0; taskIndex < AliQAv1::kNTASKINDEX; taskIndex++) {
-                               if ( fTasks.Contains(Form("%d", taskIndex)) ) 
-                                       qadm->EndOfCycle(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(taskIndex))) ;
-                       }
+      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))) ;
+        }
+      }
                        qadm->Finish();
                }
        }
@@ -541,6 +553,7 @@ void  AliQAManager::EndOfCycle(TString detectors)
 {
        // End of cycle QADataMakers 
        
+  AliQAChecker::Instance()->SetRunNumber(fRunNumber) ; 
   if (fPrintImage) {
     TCanvas fakeCanvas ; 
     fakeCanvas.Print(Form("%s%s%d.%s[", AliQAv1::GetImageFileName(), GetMode(), fRunNumber, AliQAv1::GetImageFileFormat())) ; 
@@ -548,25 +561,33 @@ void  AliQAManager::EndOfCycle(TString detectors)
   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 ;
-      qadm->SetPrintImage(fPrintImage) ;
-               for (UInt_t taskIndex = 0; taskIndex < AliQAv1::kNTASKINDEX; taskIndex++) {
-                               if ( fTasks.Contains(Form("%d", taskIndex)) ) 
-                                       qadm->EndOfCycle(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(taskIndex))) ;
-                       }
+      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))) ;
+        }
+      }
                        qadm->Finish();
                }
        }
 }
 
 //_____________________________________________________________________________
-void AliQAManager::Increment()
+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) 
+    return ; 
+  else 
+    currentTask = taskIndex ; 
        for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
                if (IsSelected(AliQAv1::GetDetName(iDet))) {
                        AliQADataMaker * qadm = GetQADataMaker(iDet) ;
@@ -601,7 +622,7 @@ Bool_t AliQAManager::InitQA(const AliQAv1::TASKINDEX_t taskIndex, const  Char_t
                        fTasks = AliQAv1::GetTaskName(AliQAv1::kESDS) ; 
       if (!gSystem->AccessPathName("AliESDs.root")) { // AliESDs.root exists
         TFile * esdFile = TFile::Open("AliESDs.root") ;
-        fESDTree = dynamic_cast<TTree *> (esdFile->Get("esdTree")) ; 
+        fESDTree = static_cast<TTree *> (esdFile->Get("esdTree")) ; 
         if ( !fESDTree ) {
           AliError("esdTree not found") ; 
           return kFALSE ; 
@@ -854,7 +875,7 @@ void AliQAManager::MergeCustom() const
       loRun = cuRun ; 
     if (cuRun > hiRun)
       hiRun = cuRun ; 
-    while ( (srun = dynamic_cast<TObjString *> (nextRun())) ) {
+    while ( (srun = static_cast<TObjString *> (nextRun())) ) {
       if ( cuRun == (srun->String()).Atoi() ) {
         runExist = kTRUE ; 
         break ; 
@@ -882,7 +903,7 @@ void AliQAManager::MergeCustom() const
       }
     }
   }
-  while ( (srun = dynamic_cast<TObjString *> (nextRun())) ) {
+  while ( (srun = static_cast<TObjString *> (nextRun())) ) {
     runNumber = (srun->String()).Atoi() ; 
     hisRun->Fill(runNumber) ; 
     AliDebug(AliQAv1::GetQADebugLevel(), Form("Merging run number %d", runNumber)) ; 
@@ -933,11 +954,11 @@ void AliQAManager::MergeCustom() const
                   TList * listOfData = directoryEventSpecie->GetListOfKeys() ; 
                   TIter nextData(listOfData) ; 
                   TKey * key ; 
-                  while ( (key = dynamic_cast<TKey *>(nextData())) ) {
+                  while ( (key = static_cast<TKey *>(nextData())) ) {
                     TString className(key->GetClassName()) ; 
                     if (  className.Contains("TH") || className.Contains("TProfile") ) {
-                      TH1 * histIn = dynamic_cast<TH1*> (key->ReadObj()) ; 
-                      TH1 * histOu = dynamic_cast<TH1*> (mergedDirectory->FindObjectAny(histIn->GetName())) ; 
+                      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)) ; 
                       mergedDirectory->cd() ; 
                       if ( ! histOu ) {
@@ -954,11 +975,11 @@ void AliQAManager::MergeCustom() const
                       TList * listOfExpertData = dirExpert->GetListOfKeys() ; 
                       TIter nextExpertData(listOfExpertData) ; 
                       TKey * keykey ; 
-                      while ( (keykey = dynamic_cast<TKey *>(nextExpertData())) ) {
+                      while ( (keykey = static_cast<TKey *>(nextExpertData())) ) {
                         TString classNameExpert(keykey->GetClassName()) ; 
                         if (classNameExpert.Contains("TH")) {
-                          TH1 * histInExpert = dynamic_cast<TH1*> (keykey->ReadObj()) ; 
-                          TH1 * histOuExpert = dynamic_cast<TH1*> (mergedDirectory->FindObjectAny(histInExpert->GetName())) ; 
+                          TH1 * histInExpert = static_cast<TH1*> (keykey->ReadObj()) ; 
+                          TH1 * histOuExpert = static_cast<TH1*> (mergedDirectory->FindObjectAny(histInExpert->GetName())) ; 
                           mergedDirectoryExpert->cd() ; 
                           if ( ! histOuExpert ) {
                             histInExpert->Write() ; 
@@ -1074,13 +1095,15 @@ void AliQAManager::Reset(const Bool_t sameCycle)
 }
 
 //_____________________________________________________________________________
-AliQAManager * AliQAManager::QAManager(Char_t * mode, TMap *entryCache, Int_t run) 
+AliQAManager * AliQAManager::QAManager(AliQAv1::MODE_t mode, TMap *entryCache, Int_t run) 
 {
   // returns AliQAManager instance (singleton)
   
        if (!fgQAInstance) {
-    if ( (strcmp(mode, "sim") != 0) && (strcmp(mode, "rec") != 0) )
-      AliFatalClass("You must specify sim or rec") ; 
+    if ( (mode != AliQAv1::kSIMMODE) && (mode != AliQAv1::kRECMODE) ) {
+      AliErrorClass("You must specify kSIMMODE or kRECMODE") ; 
+      return NULL ; 
+    }
     fgQAInstance = new AliQAManager(mode) ;  
     if (!entryCache)
                  fgQAInstance->Init();
@@ -1090,6 +1113,13 @@ AliQAManager * AliQAManager::QAManager(Char_t * mode, TMap *entryCache, Int_t ru
        return fgQAInstance;
 }
 
+//_____________________________________________________________________________
+AliQAManager * AliQAManager::QAManager(AliQAv1::TASKINDEX_t task) 
+{
+  // returns AliQAManager instance (singleton)
+  return QAManager(AliQAv1::Mode(task)) ; 
+}
+
 //_____________________________________________________________________________
 TString AliQAManager::Run(const Char_t * detectors, AliRawReader * rawReader, const Bool_t sameCycle) 
 {
@@ -1110,7 +1140,7 @@ TString AliQAManager::Run(const Char_t * detectors, AliRawReader * rawReader, co
        
        if (!fCycleSame) 
     if ( !InitQA(AliQAv1::kRAWS) ) 
-      return kFALSE ; 
+      return "" ; 
   fRawReaderDelete = kFALSE ; 
 
        DoIt(AliQAv1::kRAWS) ; 
@@ -1145,7 +1175,7 @@ TString AliQAManager::Run(const Char_t * detectors, const Char_t * fileName, con
        
        if (!fCycleSame) 
     if ( !InitQA(AliQAv1::kRAWS, fileName) ) 
-      return kFALSE ; 
+      return "" ; 
        
        DoIt(AliQAv1::kRAWS) ; 
        return  fDetectorsW ;
@@ -1181,14 +1211,14 @@ TString AliQAManager::Run(const Char_t * detectors, const AliQAv1::TASKINDEX_t t
                        if ( fTasks.Contains(Form("%d", task)) ) {
         if (!fCycleSame)
           if ( !InitQA(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(task)), fileName) ) 
-            return kFALSE ;
+            return "" ;
         DoIt(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(task))) ;
                        }
                }
        } else {
     if (! fCycleSame )
       if ( !InitQA(taskIndex, fileName) ) 
-        return kFALSE ; 
+        return "" ; 
       DoIt(taskIndex) ; 
   }            
        return fDetectorsW ;
@@ -1200,7 +1230,7 @@ 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("") ;
+  AliCodeTimerAuto("",0) ;
   if (fTasks.Contains(Form("%d", AliQAv1::kRAWS))){
     for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
       if (!IsSelected(AliQAv1::GetDetName(iDet))) 
@@ -1227,7 +1257,7 @@ void AliQAManager::RunOneEvent(AliESDEvent *& esd)
 {
        //Runs all the QA data Maker for ESDs only and on one event only (event loop done by calling method)
        
-  AliCodeTimerAuto("") ;
+  AliCodeTimerAuto("",0) ;
   if (fTasks.Contains(Form("%d", AliQAv1::kESDS))) {
     for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
       if (!IsSelected(AliQAv1::GetDetName(iDet))) 
@@ -1255,22 +1285,24 @@ 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("") ;
+  AliCodeTimerAuto("",0) ;
   if (fTasks.Contains(Form("%d", AliQAv1::kRECPOINTS))) {
     if (IsSelected(AliQAv1::GetDetName(det))) {
       AliQADataMaker *qadm = GetQADataMaker(det);  
       if (qadm) { 
         qadm->SetEventSpecie(fEventSpecie) ;  
-        if ( qadm->GetRecoParam() ) 
+        if ( qadm->GetRecoParam() ) {
           if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)  
-            qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ;         
+            qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ; 
+          else
+            AliFatal(Form("%d is not an event specie", qadm->GetRecoParam()->GetEventSpecie())) ; 
+        }                    
         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) ;
-          AliCodeTimerStop(Form("running Digits quality assurance data maker for %s", AliQAv1::GetDetName(det)));
         } else  if (test.Contains("TreeR")) {
           qadm->Exec(AliQAv1::kRECPOINTS, tree) ;
           AliCodeTimerStop(Form("running RecPoints quality assurance data maker for %s", AliQAv1::GetDetName(det)));
@@ -1354,7 +1386,7 @@ Bool_t AliQAManager::SaveIt2OCDB(const Int_t runNumber, TFile * inputFile, const
                        TList * taskList = detDir->GetListOfKeys() ; 
                        TIter nextTask(taskList) ; 
                        TKey * taskKey ; 
-                       while ( (taskKey = dynamic_cast<TKey*>(nextTask())) ) {
+                       while ( (taskKey = static_cast<TKey*>(nextTask())) ) {
                                TDirectory * taskDir = detDir->GetDirectory(taskKey->GetName()) ; 
         TDirectory * esDir   = taskDir->GetDirectory(AliRecoParam::GetEventSpecieName(es)) ; 
                                AliDebug(AliQAv1::GetQADebugLevel(), Form("Saving %s", esDir->GetName())) ; 
@@ -1364,7 +1396,7 @@ Bool_t AliQAManager::SaveIt2OCDB(const Int_t runNumber, TFile * inputFile, const
                                TList * histList = esDir->GetListOfKeys() ; 
                                TIter nextHist(histList) ; 
                                TKey * histKey ; 
-                               while ( (histKey = dynamic_cast<TKey*>(nextHist())) ) {
+                               while ( (histKey = static_cast<TKey*>(nextHist())) ) {
                                        TObject * odata = esDir->Get(histKey->GetName()) ; 
                                        if ( !odata ) {
                                                AliError(Form("%s in %s/%s returns a NULL pointer !!", histKey->GetName(), detDir->GetName(), taskDir->GetName())) ;
@@ -1374,7 +1406,7 @@ Bool_t AliQAManager::SaveIt2OCDB(const Int_t runNumber, TFile * inputFile, const
               TList * expertHistList = expertDir->GetListOfKeys() ; 
               TIter nextExpertHist(expertHistList) ; 
               TKey * expertHistKey ; 
-              while ( (expertHistKey = dynamic_cast<TKey*>(nextExpertHist())) ) {
+              while ( (expertHistKey = static_cast<TKey*>(nextExpertHist())) ) {
                 TObject * expertOdata = expertDir->Get(expertHistKey->GetName()) ; 
                 if ( !expertOdata ) {
                   AliError(Form("%s in %s/%s/Expert returns a NULL pointer !!", expertHistKey->GetName(), detDir->GetName(), taskDir->GetName())) ;
@@ -1428,3 +1460,22 @@ void AliQAManager::SetWriteExpert()
       fQAWriteExpert[iDet] = kTRUE ;
   }
 }  
+
+//_____________________________________________________________________________
+void AliQAManager::Destroy() {
+  // delete AliQAManager instance and
+  // all associated objects
+
+  if (fgQAInstance) {
+    delete fgQAInstance ;
+    fgQAInstance = NULL ;
+  }
+}
+
+//_____________________________________________________________________________
+void AliQAManager::ShowQA() {
+  // Show the result of the QA checking
+  // for all detectors 
+       for ( Int_t detIndex = 0 ; detIndex < AliQAv1::kNDET ; detIndex++) 
+    AliQAv1::Instance(AliQAv1::GetDetIndex(AliQAv1::GetDetName(detIndex)))->Show() ; 
+}