]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliQAManager.cxx
added a protection before writing out the corr NTuple
[u/mrichter/AliRoot.git] / STEER / AliQAManager.cxx
index cb0e9e7c7c51a4ce3c88734d01f5d77a9936b733..e1d7a6b67741892a02575e7fa773467e347fcc0b 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);                                                //
 //                                                                           //
 ///////////////////////////////////////////////////////////////////////////////
 
+#include <TCanvas.h>
 #include <TKey.h>
 #include <TFile.h>
 #include <TFileMerger.h>
@@ -38,6 +39,7 @@
 #include <TROOT.h>
 #include <TString.h>
 #include <TSystem.h>
+#include <TStopwatch.h>
 
 #include "AliCDBManager.h"
 #include "AliCDBEntry.h"
@@ -53,6 +55,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" 
@@ -85,8 +89,10 @@ AliQAManager::AliQAManager() :
   fRawReader(NULL), 
   fRawReaderDelete(kTRUE), 
   fRunLoader(NULL), 
-  fTasks(""), 
-  fEventSpecie(AliRecoParam::kDefault)
+  fTasks(""),  
+  fEventSpecie(AliRecoParam::kDefault), 
+  fPrintImage(kTRUE), 
+  fSaveData(kTRUE) 
 {
        // default ctor
        fMaxEvents = fNumberOfEvents ; 
@@ -101,7 +107,7 @@ AliQAManager::AliQAManager() :
 }
 
 //_____________________________________________________________________________
-AliQAManager::AliQAManager(const Char_t * mode, const Char_t* gAliceFilename) :
+AliQAManager::AliQAManager(AliQAv1::MODE_t mode, const Char_t* gAliceFilename) :
   AliCDBManager(), 
   fCurrentEvent(0),  
        fCycleSame(kFALSE),
@@ -112,7 +118,7 @@ AliQAManager::AliQAManager(const Char_t * mode, const Char_t* gAliceFilename) :
        fGAliceFileName(gAliceFilename), 
        fFirstEvent(0),        
        fMaxEvents(0),   
-  fMode(mode), 
+  fMode(AliQAv1::GetModeName(mode)), 
        fNumberOfEvents(999999), 
   fRecoParam(),
        fRunNumber(0), 
@@ -120,7 +126,9 @@ AliQAManager::AliQAManager(const Char_t * mode, const Char_t* gAliceFilename) :
        fRawReaderDelete(kTRUE), 
        fRunLoader(NULL), 
   fTasks(""), 
-  fEventSpecie(AliRecoParam::kDefault)
+  fEventSpecie(AliRecoParam::kDefault), 
+  fPrintImage(kTRUE), 
+  fSaveData(kTRUE) 
 {
        // default ctor
        fMaxEvents = fNumberOfEvents ; 
@@ -153,8 +161,11 @@ AliQAManager::AliQAManager(const AliQAManager & qas) :
        fRawReader(NULL), 
        fRawReaderDelete(kTRUE), 
        fRunLoader(NULL), 
-  fTasks(qas.fTasks),
-  fEventSpecie(qas.fEventSpecie)
+  fTasks(qas.fTasks), 
+  fEventSpecie(qas.fEventSpecie), 
+  fPrintImage(qas.fPrintImage), 
+  fSaveData(qas.fSaveData) 
+
 {
        // cpy ctor
        for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
@@ -193,7 +204,6 @@ AliQAManager::~AliQAManager()
                fRawReader = NULL ;
        }
 }
-
 //_____________________________________________________________________________
 Bool_t AliQAManager::DoIt(const AliQAv1::TASKINDEX_t taskIndex)
 {
@@ -240,30 +250,47 @@ 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 ) {      
-              loader->LoadSDigits() ; 
-              data = loader->TreeS() ; 
-              if ( ! data ) {
-                AliWarning(Form(" SDigit Tree not found for  %s", AliQAv1::GetDetName(iDet))) ; 
-                break ; 
-              } 
+          {
+            
+            TString fileName(Form("%s.SDigits.root", AliQAv1::GetDetName(iDet))) ; 
+            if (gSystem->FindFile("./", fileName)) {
+              if( loader ) {      
+                loader->LoadSDigits() ; 
+                data = loader->TreeS() ; 
+                if ( ! data ) {
+                  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 ) {      
-              loader->LoadDigits() ; 
-              data = loader->TreeD() ; 
-              if ( ! data ) {
-                AliWarning(Form(" Digit Tree not found for  %s", AliQAv1::GetDetName(iDet))) ; 
-                break ; 
-              } 
-            }
-            qadm->Exec(taskIndex, data) ;
+              if( loader ) {      
+                loader->LoadDigits() ; 
+                data = loader->TreeD() ; 
+                if ( ! data ) {
+                  AliWarning(Form(" Digit Tree not found for  %s", AliQAv1::GetDetName(iDet))) ; 
+                  break ; 
+                } 
+                qadm->Exec(taskIndex, data) ;
+              }
+            break;
+            case AliQAv1::kDIGITSR :
+              if( loader ) {      
+                loader->LoadDigits() ; 
+                data = loader->TreeD() ; 
+                if ( ! data ) {
+                  AliWarning(Form(" Digit Tree not found for  %s", AliQAv1::GetDetName(iDet))) ; 
+                  break ; 
+                } 
+                qadm->Exec(taskIndex, data) ;
+              }
                                                break; 
                                                case AliQAv1::kRECPOINTS :
             if( loader ) {      
@@ -273,8 +300,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; 
@@ -288,10 +315,11 @@ 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) ;
+
+  EndOfCycle() ; 
        
        if ( taskIndex == AliQAv1::kRAWS ) 
                fRawReader->RewindEvents() ;
@@ -303,6 +331,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) ;
@@ -314,7 +345,7 @@ Bool_t AliQAManager::Finish(const AliQAv1::TASKINDEX_t taskIndex)
 }
 
 //_____________________________________________________________________________
-TObjArray * AliQAManager::GetFromOCDB(AliQAv1::DETECTORINDEX_t det, AliQAv1::TASKINDEX_t task, const char * year) const 
+TObjArray * AliQAManager::GetFromOCDB(AliQAv1::DETECTORINDEX_t det, AliQAv1::TASKINDEX_t task, const Char_t * year) const 
 {
        // Retrieve the list of QA data for a given detector and a given task 
        TObjArray * rv = NULL ;
@@ -332,18 +363,29 @@ 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 ; 
 }
 
+//_____________________________________________________________________________
+TCanvas ** AliQAManager::GetImage(Char_t * detName)
+{
+  // retrieves QA Image for the given detector
+  TCanvas ** rv = NULL ; 
+  Int_t detIndex = AliQAv1::GetDetIndex(detName) ; 
+  AliQACheckerBase * qac = AliQAChecker::Instance()->GetDetQAChecker(detIndex) ; 
+  rv = qac->GetImage() ;
+  return rv ; 
+}
+
 //_____________________________________________________________________________
 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) ;
@@ -381,13 +423,13 @@ AliLoader * AliQAManager::GetLoader(Int_t iDet)
 AliQAv1 * AliQAManager::GetQA(UInt_t run, UInt_t evt) 
 {
 // retrieves the QA object stored in a file named "Run{run}.Event{evt}_1.ESD.tag.root"  
-  char * fileName = Form("Run%d.Event%d_1.ESD.tag.root", run, evt) ; 
+  Char_t * fileName = Form("Run%d.Event%d_1.ESD.tag.root", run, evt) ; 
   TFile * tagFile = TFile::Open(fileName) ;
   if ( !tagFile ) {
     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() ; 
@@ -406,65 +448,73 @@ AliQADataMaker * AliQAManager::GetQADataMaker(const Int_t iDet)
 {
        // get the quality assurance data maker for a detector
        
-       if (fQADataMaker[iDet]) {
-    fQADataMaker[iDet]->SetEventSpecie(fEventSpecie) ; 
-               return fQADataMaker[iDet] ;
-  }
-       
-       AliQADataMaker * qadm = NULL ;
-       
-       if (iDet == AliQAv1::kGLOBAL) { //Global QA
+  AliQADataMaker * qadm =  fQADataMaker[iDet] ; 
+  
+       if (qadm) {
+    qadm->SetEventSpecie(fEventSpecie) ;  
+    if ( qadm->GetRecoParam() ) 
+      if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)
+        qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ; 
+
+  } else if (iDet == AliQAv1::kGLOBAL && strcmp(GetMode(), AliQAv1::GetModeName(AliQAv1::kRECMODE)) == 0) { //Global QA
+
                qadm = new AliGlobalQADataMaker();
                qadm->SetName(AliQAv1::GetDetName(iDet));
                qadm->SetUniqueID(iDet);
                fQADataMaker[iDet] = qadm;
-    qadm->SetEventSpecie(fEventSpecie) ; 
-               return qadm;
-       }
+    qadm->SetEventSpecie(fEventSpecie) ;  
+    if ( qadm->GetRecoParam() ) 
+      if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)  
+        qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ; 
 
-       if (iDet == AliQAv1::kCORR) { //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);
                fQADataMaker[iDet] = qadm;
-    qadm->SetEventSpecie(fEventSpecie) ; 
-               return qadm;
-  }
-
-       // load the QA data maker object
-       TPluginManager* pluginManager = gROOT->GetPluginManager() ;
-       TString detName = AliQAv1::GetDetName(iDet) ;
-       TString tmp(fMode) ; 
-       if (tmp.Contains("sim")) 
-               tmp.ReplaceAll("s", "S") ; 
-       else if (tmp.Contains("rec")) 
-               tmp.ReplaceAll("r", "R") ; 
-
-       TString qadmName = "Ali" + detName + "QADataMaker" + tmp ;
-
-       // 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) {
-               qadm->SetName(AliQAv1::GetDetName(iDet));
-               qadm->SetUniqueID(iDet);
-               fQADataMaker[iDet] = qadm ;
-    qadm->SetEventSpecie(fEventSpecie) ; 
-       }
+    qadm->SetEventSpecie(fEventSpecie) ;  
+    if ( qadm->GetRecoParam() ) 
+      if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)  
+        qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ; 
 
+  } 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" + smode ;
+    
+    // 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(smode) ;
+      temp.ToLower() ; 
+      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 + "()") ;
+      }
+      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 ;
 }
 
@@ -473,6 +523,10 @@ void  AliQAManager::EndOfCycle(TObjArray * detArray)
 {
        // End of cycle QADataMakers 
        
+  AliQAChecker::Instance()->SetRunNumber(fRunNumber) ; 
+  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) ;
@@ -484,13 +538,18 @@ void  AliQAManager::EndOfCycle(TObjArray * detArray)
                                if (!det || !det->IsActive())  
                                        continue ;
                        }
-                       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"); 
 }
 
 //_____________________________________________________________________________
@@ -498,7 +557,11 @@ void  AliQAManager::EndOfCycle(TString detectors)
 {
        // End of cycle QADataMakers 
        
-       for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
+  AliQAChecker::Instance()->SetRunNumber(fRunNumber) ; 
+  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) ;
                        if (!qadm) 
@@ -506,19 +569,50 @@ void  AliQAManager::EndOfCycle(TString detectors)
                        // skip non active detectors
       if (!detectors.Contains(AliQAv1::GetDetName(iDet))) 
         continue ;
-               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"); 
 }
 
 //_____________________________________________________________________________
-void AliQAManager::Increment()
+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 ;
+}
+
+//_____________________________________________________________________________
+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) && taskIndex != AliQAv1::kNULLTASKINDEX )
+    return ; 
+  else 
+    currentTask = taskIndex ; 
        for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
                if (IsSelected(AliQAv1::GetDetName(iDet))) {
                        AliQADataMaker * qadm = GetQADataMaker(iDet) ;
@@ -529,7 +623,7 @@ void AliQAManager::Increment()
 }
   
 //_____________________________________________________________________________
-Bool_t AliQAManager::InitQA(const AliQAv1::TASKINDEX_t taskIndex, const  char * input )
+Bool_t AliQAManager::InitQA(const AliQAv1::TASKINDEX_t taskIndex, const  Char_t * input )
 {
        // Initialize the event source and QA data makers
        
@@ -553,7 +647,7 @@ Bool_t AliQAManager::InitQA(const AliQAv1::TASKINDEX_t taskIndex, const  char *
                        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 ; 
@@ -594,6 +688,16 @@ Bool_t AliQAManager::InitQA(const AliQAv1::TASKINDEX_t taskIndex, const  char *
                AliGeomManager::LoadGeometry() ; 
        
        InitQADataMaker(fRunNumber, detArray) ; //, fCycleSame, kTRUE, detArray) ; 
+  if (fPrintImage) {
+    TCanvas fakeCanvas ; 
+    TStopwatch timer ; 
+    timer.Start() ; 
+    while (timer.CpuTime()<5) {
+      timer.Continue();
+      gSystem->ProcessEvents();
+    }
+    fakeCanvas.Print(Form("%s%s%d.%s[", AliQAv1::GetImageFileName(), GetMode(), fRunNumber, AliQAv1::GetImageFileFormat()), "ps") ;    
+  }    
        return kTRUE ; 
 }
 
@@ -601,6 +705,7 @@ Bool_t AliQAManager::InitQA(const AliQAv1::TASKINDEX_t taskIndex, const  char *
 void  AliQAManager::InitQADataMaker(UInt_t run, TObjArray * detArray) 
 {
        // Initializes The QADataMaker for all active detectors and for all active tasks 
+  fRunNumber = run ; 
        for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
                if (IsSelected(AliQAv1::GetDetName(iDet))) {
                        AliQADataMaker * qadm = GetQADataMaker(iDet) ;
@@ -681,7 +786,7 @@ Bool_t AliQAManager::InitRunLoader()
 }
 
 //_____________________________________________________________________________
-Bool_t AliQAManager::IsSelected(const char * det) 
+Bool_t AliQAManager::IsSelected(const Char_t * det) 
 {
   // check whether detName is contained in detectors
        // if yes, it is removed from detectors
@@ -689,7 +794,7 @@ Bool_t AliQAManager::IsSelected(const char * 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
@@ -707,19 +812,20 @@ Bool_t AliQAManager::IsSelected(const char * det)
 }
 
 //_____________________________________________________________________________
-Bool_t AliQAManager::Merge(Int_t runNumber) const
+Bool_t AliQAManager::Merge(Int_t runNumber, const char *fileName) const
 {
        // Merge data from all detectors from a given run in one single file 
-       // Merge the QA results from all the data chunks in one run 
+       // Merge the QA results from all the data chunks in one run
+  // The 'fileName' is name of the output file with merged QA data  
  if ( runNumber == -1)
    runNumber = fRunNumber ; 
- Bool_t rv = MergeData(runNumber) ; 
+ Bool_t rv = MergeData(runNumber,fileName) ; 
  //rv *= MergeResults(runNumber) ; // not needed for the time being
  return rv ; 
 }
        
 //______________________________________________________________________
-Bool_t AliQAManager::MergeXML(const char * collectionFile, const char * subFile, const char * outFile) 
+Bool_t AliQAManager::MergeXML(const Char_t * collectionFile, const Char_t * subFile, const Char_t * outFile) 
 {
   // merges files listed in a xml collection 
   // usage Merge(collection, outputFile))
@@ -738,15 +844,13 @@ Bool_t AliQAManager::MergeXML(const char * collectionFile, const char * subFile,
    return kFALSE ; 
  
   // Open the file collection 
-  printf("*** Create Collection       ***\n");
-  printf("***  Wk-Dir = |%s|             \n",gSystem->WorkingDirectory());
-  printf("***  Coll   = |%s|             \n",collectionFile);                  
+  AliInfoClass(Form("*** Create Collection       ***\n***  Wk-Dir = |%s|             \n***  Coll   = |%s|             \n",gSystem->WorkingDirectory(), collectionFile));               
   
   TGridCollection * collection = (TGridCollection*)gROOT->ProcessLine(Form("TAlienCollection::Open(\"%s\")",collectionFile));
   TGridResult* result = collection->GetGridResult("", 0, 0);
   
   Int_t index = 0  ;
-  const char * turl ;
+  const Char_t * turl ;
   TFileMerger merger(kFALSE) ; 
   if (!outFile) {
     TString tempo(collectionFile) ; 
@@ -759,7 +863,7 @@ Bool_t AliQAManager::MergeXML(const char * collectionFile, const char * subFile,
   merger.OutputFile(outFile) ; 
   
   while ( (turl = result->GetKey(index, "turl")) ) {
-    char * file ;
+    Char_t * file ;
     if ( subFile )
       file = Form("%s#%s", turl, subFile) ; 
     else 
@@ -802,7 +906,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 ; 
@@ -830,15 +934,15 @@ 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)) ; 
     // search all QA files for runNumber in the current directory
-    char * fileList[AliQAv1::kNDET] ;
+    Char_t * fileList[AliQAv1::kNDET] ;
     index = 0 ; 
     for (Int_t iDet = 0; iDet < AliQAv1::kNDET ; iDet++) {
-      char * file = gSystem->Which(gSystem->WorkingDirectory(), Form("%s.%s.%d.root", AliQAv1::GetDetName(iDet), AliQAv1::GetQADataFileName(), runNumber)); 
+      Char_t * file = gSystem->Which(gSystem->WorkingDirectory(), Form("%s.%s.%d.root", AliQAv1::GetDetName(iDet), AliQAv1::GetQADataFileName(), runNumber)); 
       if (file) 
         fileList[index++] = file ;
     }
@@ -881,12 +985,12 @@ 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())) ; 
-                      AliDebug(AliQAv1::GetQADebugLevel(), Form("%s %x %x\n", key->GetName(), histIn, histOu)) ; 
+                      TH1 * histIn = static_cast<TH1*> (key->ReadObj()) ; 
+                      TH1 * histOu = static_cast<TH1*> (mergedDirectory->FindObjectAny(histIn->GetName())) ; 
+                      AliDebug(AliQAv1::GetQADebugLevel(), Form("%s %p %p\n", key->GetName(), histIn, histOu)) ; 
                       mergedDirectory->cd() ; 
                       if ( ! histOu ) {
                         histIn->Write() ; 
@@ -902,11 +1006,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() ; 
@@ -938,17 +1042,19 @@ void AliQAManager::MergeCustom() const
 }
 
 //_____________________________________________________________________________
-Bool_t AliQAManager::MergeData(const Int_t runNumber) const
+Bool_t AliQAManager::MergeData(const Int_t runNumber, const char *fileName) const
 {
        // Merge QA data from all detectors for a given run in one single file 
   
-  TFileMerger merger ; 
-  TString outFileName = Form("Merged.%s.Data.root",AliQAv1::GetQADataFileName()) ;
+  TFileMerger merger(kFALSE) ; 
+  TString outFileName = fileName;
+  if (outFileName.IsNull()) outFileName.Form("Merged.%s.Data.root",AliQAv1::GetQADataFileName());
   merger.OutputFile(outFileName.Data()) ; 
   for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
-    char * file = gSystem->Which(gSystem->WorkingDirectory(), Form("%s.%s.%d.root", AliQAv1::GetDetName(iDet), AliQAv1::GetQADataFileName(), runNumber)); 
+    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 ; 
@@ -1005,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) { 
@@ -1021,11 +1128,34 @@ void AliQAManager::Reset(const Bool_t sameCycle)
 }
 
 //_____________________________________________________________________________
-AliQAManager * AliQAManager::QAManager(const Char_t * mode, TMap *entryCache, Int_t run) 
+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) && (mode != AliQAv1::kQAMODE) ) {
+      AliWarningClass("You must specify kSIMMODE or kRECMODE or kQAMODE") ; 
+      return NULL ; 
+    }
     fgQAInstance = new AliQAManager(mode) ;  
     if (!entryCache)
                  fgQAInstance->Init();
@@ -1036,7 +1166,14 @@ AliQAManager * AliQAManager::QAManager(const Char_t * mode, TMap *entryCache, In
 }
 
 //_____________________________________________________________________________
-TString AliQAManager::Run(const char * detectors, AliRawReader * rawReader, const Bool_t sameCycle) 
+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) 
 {
        //Runs all the QA data Maker for Raws only
        
@@ -1055,7 +1192,7 @@ TString AliQAManager::Run(const char * detectors, AliRawReader * rawReader, cons
        
        if (!fCycleSame) 
     if ( !InitQA(AliQAv1::kRAWS) ) 
-      return kFALSE ; 
+      return "" ; 
   fRawReaderDelete = kFALSE ; 
 
        DoIt(AliQAv1::kRAWS) ; 
@@ -1063,7 +1200,7 @@ TString AliQAManager::Run(const char * detectors, AliRawReader * rawReader, cons
 }
 
 //_____________________________________________________________________________
-TString AliQAManager::Run(const char * detectors, const char * fileName, const Bool_t sameCycle) 
+TString AliQAManager::Run(const Char_t * detectors, const Char_t * fileName, const Bool_t sameCycle) 
 {
        //Runs all the QA data Maker for Raws only
 
@@ -1090,14 +1227,14 @@ TString AliQAManager::Run(const char * detectors, const char * fileName, const B
        
        if (!fCycleSame) 
     if ( !InitQA(AliQAv1::kRAWS, fileName) ) 
-      return kFALSE ; 
+      return "" ; 
        
        DoIt(AliQAv1::kRAWS) ; 
        return  fDetectorsW ;
 }
 
 //_____________________________________________________________________________
-TString AliQAManager::Run(const char * detectors, const AliQAv1::TASKINDEX_t taskIndex, Bool_t const sameCycle, const  char * fileName ) 
+TString AliQAManager::Run(const Char_t * detectors, const AliQAv1::TASKINDEX_t taskIndex, Bool_t const sameCycle, const  Char_t * fileName ) 
 {
        // Runs all the QA data Maker for every detector
        
@@ -1121,26 +1258,22 @@ TString AliQAManager::Run(const char * detectors, const AliQAv1::TASKINDEX_t tas
                        }
                }
        }
-       
-
-       if ( taskIndex == AliQAv1::kNULLTASKINDEX) { 
+  if ( taskIndex == AliQAv1::kNULLTASKINDEX) { 
                for (UInt_t task = 0; task < AliQAv1::kNTASKINDEX; task++) {
                        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 ;
-
 }
 
 //_____________________________________________________________________________
@@ -1149,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("") ;
   if (fTasks.Contains(Form("%d", AliQAv1::kRAWS))){
     for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
       if (!IsSelected(AliQAv1::GetDetName(iDet))) 
@@ -1160,20 +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) ; 
+      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("") ;
   if (fTasks.Contains(Form("%d", AliQAv1::kESDS))) {
     for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
       if (!IsSelected(AliQAv1::GetDetName(iDet))) 
@@ -1181,12 +1313,21 @@ void AliQAManager::RunOneEvent(AliESDEvent *& esd)
       AliQADataMaker *qadm = GetQADataMaker(iDet);  
       if (!qadm) 
         continue;
+      qadm->SetEventSpecie(fEventSpecie) ;  
+      if ( qadm->GetRecoParam() ) 
+        if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)  
+          qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ; 
       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) ;        
+      }
                }
        }
 }
@@ -1195,24 +1336,34 @@ void AliQAManager::RunOneEvent(AliESDEvent *& esd)
 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)
-       AliCodeTimerAuto("") ;
+  
+  TString test(tree->GetName()) ; 
   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 ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)  
+            qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ; 
+          else
+            AliError(Form("%d defined by %s is not an event specie", qadm->GetRecoParam()->GetEventSpecie(), qadm->GetName())) ; 
+        }                    
         if ( qadm->IsCycleDone() ) {
           qadm->EndOfCycle() ;
         }
-        AliCodeTimerStart(Form("running RecPoints quality assurance data maker for %s", AliQAv1::GetDetName(det)));
-        qadm->Exec(AliQAv1::kRECPOINTS, tree) ;
-        AliCodeTimerStop(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) ;
+        }
       }
     }
   }
 }
 
 //_____________________________________________________________________________
-Bool_t AliQAManager::Save2OCDB(const Int_t runNumber, AliRecoParam::EventSpecie_t es, const char * year, const char * detectors) const
+Bool_t AliQAManager::Save2OCDB(const Int_t runNumber, AliRecoParam::EventSpecie_t es, const Char_t * year, const Char_t * detectors) const
 {
        // take the locasl QA data merge into a single file and save in OCDB 
        Bool_t rv = kTRUE ; 
@@ -1248,7 +1399,7 @@ Bool_t AliQAManager::Save2OCDB(const Int_t runNumber, AliRecoParam::EventSpecie_
 }
 
 //_____________________________________________________________________________
-Bool_t AliQAManager::SaveIt2OCDB(const Int_t runNumber, TFile * inputFile, const char * year, AliRecoParam::EventSpecie_t es) const
+Bool_t AliQAManager::SaveIt2OCDB(const Int_t runNumber, TFile * inputFile, const Char_t * year, AliRecoParam::EventSpecie_t es) const
 {
        // reads the TH1 from file and adds it to appropriate list before saving to OCDB
        Bool_t rv = kTRUE ;
@@ -1285,7 +1436,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())) ; 
@@ -1295,7 +1446,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())) ;
@@ -1305,7 +1456,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())) ;
@@ -1334,11 +1485,21 @@ Bool_t AliQAManager::SaveIt2OCDB(const Int_t runNumber, TFile * inputFile, const
        return rv ; 
 }      
 
+//_____________________________________________________________________________
+
+void AliQAManager::SetCheckerExternParam(AliQAv1::DETECTORINDEX_t detIndex, TList * parameterList) 
+{
+  // set the external parameters list for the detector checkers 
+  AliQACheckerBase * qac = AliQAChecker::Instance()->GetDetQAChecker(detIndex) ; 
+  qac->SetExternParamlist(parameterList) ; 
+  qac->PrintExternParam() ;  
+}
+
 //_____________________________________________________________________________
 void AliQAManager::SetEventSpecie(AliRecoParam::EventSpecie_t es) 
 {
   // set the current event specie and inform AliQAv1 that this event specie has been encountered
-  fEventSpecie = es ;
+  fEventSpecie = es ; 
   AliQAv1::Instance()->SetEventSpecie(es) ; 
 }
 
@@ -1359,3 +1520,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() ; 
+}