]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliQADataMakerSteer.cxx
Base class (AliMisaligner); each detector will provide its derived class,
[u/mrichter/AliRoot.git] / STEER / AliQADataMakerSteer.cxx
index a9f867bc54deeff90b629bbb7670cab2a9ebead9..fce56b43213efe753911f5a98341fc8cfd9fe6a6 100644 (file)
 #include "AliCDBEntry.h"
 #include "AliCDBId.h"
 #include "AliCDBMetaData.h"
+#include "AliCodeTimer.h"
+#include "AliCorrQADataMakerRec.h"
+#include "AliDetectorRecoParam.h"
 #include "AliESDEvent.h"
+#include "AliGeomManager.h"
+#include "AliGlobalQADataMaker.h"
 #include "AliHeader.h"
 #include "AliLog.h"
 #include "AliModule.h"
 #include "AliRawReaderRoot.h"
 #include "AliRun.h"
 #include "AliRunLoader.h"
+#include "AliRunTag.h"
 
 ClassImp(AliQADataMakerSteer) 
 
 //_____________________________________________________________________________
-AliQADataMakerSteer::AliQADataMakerSteer(const char* gAliceFilename, const char * name, const char * title) :
+AliQADataMakerSteer::AliQADataMakerSteer(const Char_t * mode, const Char_t* gAliceFilename, const Char_t * name, const Char_t * title) :
        TNamed(name, title), 
        fCurrentEvent(0),  
        fCycleSame(kFALSE),
@@ -65,17 +71,18 @@ AliQADataMakerSteer::AliQADataMakerSteer(const char* gAliceFilename, const char
        fDetectorsW("ALL"), 
        fESD(NULL), 
        fESDTree(NULL),
-       fFirst(kTRUE),  
        fGAliceFileName(gAliceFilename), 
        fFirstEvent(0),        
-       fMaxEvents(0),        
+       fMaxEvents(0),   
+  fMode(mode), 
        fNumberOfEvents(999999), 
-    fRunNumber(0), 
+  fRecoParam(),
+       fRunNumber(0), 
        fRawReader(NULL), 
        fRawReaderDelete(kTRUE), 
-       fRunLoader(NULL),
-       fQADataMakers()
-
+       fRunLoader(NULL), 
+  fTasks(""), 
+  fEventSpecie(AliRecoParam::kDefault)
 {
        // default ctor
        fMaxEvents = fNumberOfEvents ; 
@@ -84,6 +91,7 @@ AliQADataMakerSteer::AliQADataMakerSteer(const char* gAliceFilename, const char
                        fLoader[iDet]      = NULL ;
                        fQADataMaker[iDet] = NULL ;
                        fQACycles[iDet]    = 999999 ;
+      fQAWriteExpert[iDet] = kTRUE ;
                }
        }       
 }
@@ -97,22 +105,25 @@ AliQADataMakerSteer::AliQADataMakerSteer(const AliQADataMakerSteer & qas) :
        fDetectorsW(qas.fDetectorsW), 
        fESD(NULL), 
        fESDTree(NULL), 
-       fFirst(qas.fFirst),  
        fGAliceFileName(qas.fGAliceFileName), 
        fFirstEvent(qas.fFirstEvent),        
-       fMaxEvents(qas.fMaxEvents),        
+       fMaxEvents(qas.fMaxEvents),    
+       fMode(qas.fMode), 
        fNumberOfEvents(qas.fNumberOfEvents), 
-    fRunNumber(qas.fRunNumber), 
+       fRecoParam(),           
+       fRunNumber(qas.fRunNumber), 
        fRawReader(NULL), 
        fRawReaderDelete(kTRUE), 
-       fRunLoader(NULL),
-       fQADataMakers()
+       fRunLoader(NULL), 
+  fTasks(qas.fTasks),
+  fEventSpecie(qas.fEventSpecie)
 {
        // cpy ctor
        for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
-               fLoader[iDet]      = qas.fLoader[iDet] ;
-               fQADataMaker[iDet] = qas.fQADataMaker[iDet] ;
-               fQACycles[iDet]    = qas.fQACycles[iDet] ;      
+               fLoader[iDet]         = qas.fLoader[iDet] ;
+               fQADataMaker[iDet]    = qas.fQADataMaker[iDet] ;
+               fQACycles[iDet]       = qas.fQACycles[iDet] ;   
+    fQAWriteExpert[iDet] = qas.fQAWriteExpert[iDet] ;
        }
 }
 
@@ -129,26 +140,24 @@ AliQADataMakerSteer & AliQADataMakerSteer::operator = (const AliQADataMakerSteer
 AliQADataMakerSteer::~AliQADataMakerSteer() 
 {
        // dtor
-  for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
-         if (IsSelected(AliQA::GetDetName(iDet))) {
+       for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
+               if (IsSelected(AliQA::GetDetName(iDet))) {
                  fLoader[iDet] = NULL;
                  if (fQADataMaker[iDet]) {
                          (fQADataMaker[iDet])->Finish() ; 
-                         delete fQADataMaker[iDet] ;
-                         fQADataMaker[iDet] = NULL ;
+                               delete fQADataMaker[iDet] ;
                  }
-         }
-  }
-
-  if (fRawReaderDelete) { 
-       fRunLoader = NULL ;
-       delete fRawReader ;
-       fRawReader = NULL ;
-  }
+               }
+       }
+       if (fRawReaderDelete) { 
+               fRunLoader = NULL ;
+               delete fRawReader ;
+               fRawReader = NULL ;
+       }
 }
 
 //_____________________________________________________________________________
-Bool_t AliQADataMakerSteer::DoIt(const AliQA::TASKINDEX_t taskIndex, const char * mode)
+Bool_t AliQADataMakerSteer::DoIt(const AliQA::TASKINDEX_t taskIndex)
 {
        // Runs all the QA data Maker for every detector
                
@@ -170,82 +179,99 @@ Bool_t AliQADataMakerSteer::DoIt(const AliQA::TASKINDEX_t taskIndex, const char
                                break ;
                }
                // loop  over active loaders
-               for (Int_t i = 0; i < fQADataMakers.GetEntriesFast() ; i++) {
-                       AliQADataMaker * qadm = static_cast<AliQADataMaker *>(fQADataMakers.At(i)) ;
-                       if ( qadm->IsCycleDone() ) {
-                               qadm->EndOfCycle(AliQA::kRAWS) ;
-                               qadm->StartOfCycle(AliQA::kRAWS) ;
+               for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
+                       if (IsSelected(AliQA::GetDetName(iDet))) {
+                               AliQADataMaker * qadm = GetQADataMaker(iDet) ;
+                               if (!qadm) continue; // This detector doesn't have any QA (for example, HLT)
+                               if ( qadm->IsCycleDone() ) {
+          qadm->EndOfCycle(taskIndex) ;
+                               }
+                               TTree * data = NULL ; 
+                               AliLoader* loader = GetLoader(qadm->GetUniqueID());
+                               switch (taskIndex) {
+                                       case AliQA::kNULLTASKINDEX : 
+                                               break ; 
+                                       case AliQA::kRAWS :
+                                               qadm->Exec(taskIndex, fRawReader) ; 
+                                               break ; 
+                                       case AliQA::kHITS :
+            if( loader ) {
+              loader->LoadHits() ; 
+              data = loader->TreeH() ; 
+              if ( ! data ) {
+                AliWarning(Form(" Hit Tree not found for  %s", AliQA::GetDetName(iDet))) ; 
+                break ; 
+              } 
+            } 
+            qadm->Exec(taskIndex, data) ;
+                                               break ;
+                                               case AliQA::kSDIGITS :
+            if( loader ) {      
+              loader->LoadSDigits() ; 
+              data = loader->TreeS() ; 
+              if ( ! data ) {
+                AliWarning(Form(" SDigit Tree not found for  %s", AliQA::GetDetName(iDet))) ; 
+                break ; 
+              } 
+            }
+            qadm->Exec(taskIndex, data) ; 
+                                               break; 
+                                               case AliQA::kDIGITS :
+            if( loader ) {      
+              loader->LoadDigits() ; 
+              data = loader->TreeD() ; 
+              if ( ! data ) {
+                AliWarning(Form(" Digit Tree not found for  %s", AliQA::GetDetName(iDet))) ; 
+                break ; 
+              } 
+            }
+            qadm->Exec(taskIndex, data) ;
+                                               break; 
+                                               case AliQA::kRECPOINTS :
+            if( loader ) {      
+              loader->LoadRecPoints() ; 
+              data = loader->TreeR() ; 
+              if (!data) {
+                AliWarning(Form("RecPoints not found for %s", AliQA::GetDetName(iDet))) ; 
+                break ; 
+              } 
+            }
+            qadm->Exec(taskIndex, data) ; 
+            break; 
+                                               case AliQA::kTRACKSEGMENTS :
+                                               break; 
+                                               case AliQA::kRECPARTICLES :
+                                               break; 
+                                               case AliQA::kESDS :
+                                               qadm->Exec(taskIndex, fESD) ;
+                                               break; 
+                                               case AliQA::kNTASKINDEX :
+                                               break; 
+                               } //task switch
                        }
-                       TTree * data ; 
-                       Int_t iDet = qadm->GetUniqueID();
-                       AliLoader* loader = GetLoader(iDet);
-                       switch (taskIndex) {
-                               case AliQA::kRAWS :
-                                       qadm->Exec(taskIndex, fRawReader) ; 
-                                       break ; 
-                               case AliQA::kHITS :
-                                       loader->LoadHits() ; 
-                                       data = loader->TreeH() ; 
-                                       if ( ! data ) {
-                                               AliWarning(Form(" Hit Tree not found for  %s", AliQA::GetDetName(iDet))) ; 
-                                       } else {
-                                               qadm->Exec(taskIndex, data) ;
-                                       } 
-                                       break ;
-                                       case AliQA::kSDIGITS :
-                                       loader->LoadSDigits() ; 
-                                       data = loader->TreeS() ; 
-                                       if ( ! data ) {
-                                               AliWarning(Form(" SDigit Tree not found for  %s", AliQA::GetDetName(iDet))) ; 
-                                       } else {
-                                               qadm->Exec(taskIndex, data) ; 
-                                       }
-                                       break; 
-                                       case AliQA::kDIGITS :
-                                       loader->LoadDigits() ; 
-                                       data = loader->TreeD() ; 
-                                       if ( ! data ) {
-                                               AliWarning(Form(" Digit Tree not found for  %s", AliQA::GetDetName(iDet))) ; 
-                                       } else {
-                                               qadm->Exec(taskIndex, data) ;
-                                       }
-                                       break; 
-                                       case AliQA::kRECPOINTS :
-                                       loader->LoadRecPoints() ; 
-                                       data = loader->TreeR() ; 
-                                       if (!data) {
-                                               AliWarning(Form("RecPoints not found for %s", AliQA::GetDetName(iDet))) ; 
-                                       } else {
-                                               qadm->Exec(taskIndex, data) ; 
-                                       }
-                                       break; 
-                                       case AliQA::kTRACKSEGMENTS :
-                                       break; 
-                                       case AliQA::kRECPARTICLES :
-                                       break; 
-                                       case AliQA::kESDS :
-                                       qadm->Exec(taskIndex, fESD) ;
-                                       break; 
-                                       case AliQA::kNTASKINDEX :
-                                       break; 
-                       } //task switch
-                       //qadm->Increment() ; 
                } // detector loop
+    Increment() ; 
        } // event loop 
-//     // Save QA data for all detectors
-       rv = Finish(taskIndex, mode) ;
+       // Save QA data for all detectors
+       rv = Finish(taskIndex) ;
+       
+       if ( taskIndex == AliQA::kRAWS ) 
+               fRawReader->RewindEvents() ;
 
        return rv ; 
 }
 
 //_____________________________________________________________________________
-Bool_t AliQADataMakerSteer::Finish(const AliQA::TASKINDEX_t taskIndex, const char * /*mode*/
+Bool_t AliQADataMakerSteer::Finish(const AliQA::TASKINDEX_t taskIndex) 
 {
        // write output to file for all detectors
-       for (Int_t i = 0; i < fQADataMakers.GetEntriesFast() ; i++) {
-               AliQADataMaker * qadm = static_cast<AliQADataMaker *>(fQADataMakers.At(i));
-               qadm->EndOfCycle(taskIndex) ; 
-       }    
+       for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
+               if (IsSelected(AliQA::GetDetName(iDet))) {
+                       AliQADataMaker * qadm = GetQADataMaker(iDet) ;
+                       if (qadm) 
+        qadm->EndOfCycle(taskIndex) ;
+               }
+       }
        return kTRUE ; 
 }
 
@@ -254,8 +280,7 @@ TObjArray * AliQADataMakerSteer::GetFromOCDB(AliQA::DETECTORINDEX_t det, AliQA::
 {
        // Retrieve the list of QA data for a given detector and a given task 
        TObjArray * rv = NULL ;
-       TString tmp(AliQA::GetQARefStorage()) ; 
-       if ( tmp.IsNull() ) { 
+       if ( !strlen(AliQA::GetQARefStorage()) ) { 
                AliError("No storage defined, use AliQA::SetQARefStorage") ; 
                return NULL ; 
        }       
@@ -281,7 +306,7 @@ AliLoader * AliQADataMakerSteer::GetLoader(Int_t iDet)
 {
        // get the loader for a detector
 
-       if ( !fRunLoader ) 
+       if ( !fRunLoader || iDet == AliQA::kCORR
                return NULL ; 
        
        TString detName = AliQA::GetDetName(iDet) ;
@@ -316,58 +341,168 @@ AliLoader * AliQADataMakerSteer::GetLoader(Int_t iDet)
 }
 
 //_____________________________________________________________________________
-AliQADataMaker * AliQADataMakerSteer::GetQADataMaker(const Int_t iDet, const char * mode )
+AliQA * AliQADataMakerSteer::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) ; 
+  TFile * tagFile = TFile::Open(fileName) ;
+  if ( !tagFile ) {
+    AliError(Form("File %s not found", fileName)) ;
+    return NULL ; 
+  }
+  TTree * tagTree = dynamic_cast<TTree *>(tagFile->Get("T")) ; 
+  if ( !tagTree ) {
+    AliError(Form("Tree T not found in %s", fileName)) ; 
+    tagFile->Close() ; 
+    return NULL ; 
+  }
+  AliRunTag * tag = new AliRunTag ; 
+  tagTree->SetBranchAddress("AliTAG", &tag) ; 
+  tagTree->GetEntry(evt) ; 
+  AliQA * qa = AliQA::Instance(tag->GetQALength(), tag->GetQA(), tag->GetESLength(), tag->GetEventSpecies()) ; 
+  tagFile->Close() ; 
+  return qa ; 
+}
+
+//_____________________________________________________________________________
+AliQADataMaker * AliQADataMakerSteer::GetQADataMaker(const Int_t iDet) 
 {
        // get the quality assurance data maker for a detector
        
-       if (fQADataMaker[iDet]) 
+       if (fQADataMaker[iDet]) {
+    fQADataMaker[iDet]->SetEventSpecie(fEventSpecie) ; 
                return fQADataMaker[iDet] ;
+  }
        
        AliQADataMaker * qadm = NULL ;
        
-       if (fFirst) {
-               // load the QA data maker object
-               TPluginManager* pluginManager = gROOT->GetPluginManager() ;
-               TString detName = AliQA::GetDetName(iDet) ;
-               TString tmp(mode) ; 
-               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(1, Form("defining plugin for %s", qadmName.Data())) ;
-                       TString libs = gSystem->GetLibraries() ;
-                       if (libs.Contains("lib" + detName + mode + ".so") || (gSystem->Load("lib" + detName + mode + ".so") >= 0)) {
-                               pluginManager->AddHandler("AliQADataMaker", detName, qadmName, detName + "qadm", qadmName + "()") ;
-                       } else {
-                               pluginManager->AddHandler("AliQADataMaker", detName, qadmName, detName, qadmName + "()") ;
+       if (iDet == AliQA::kGLOBAL) { //Global QA
+               qadm = new AliGlobalQADataMaker();
+               qadm->SetName(AliQA::GetDetName(iDet));
+               qadm->SetUniqueID(iDet);
+               fQADataMaker[iDet] = qadm;
+    qadm->SetEventSpecie(fEventSpecie) ; 
+               return qadm;
+       }
+
+       if (iDet == AliQA::kCORR) { //the data maker for correlations among detectors
+    qadm = new AliCorrQADataMakerRec(fQADataMaker) ; 
+               qadm->SetName(AliQA::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 = AliQA::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(1, 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(AliQA::GetDetName(iDet));
+               qadm->SetUniqueID(iDet);
+               fQADataMaker[iDet] = qadm ;
+    qadm->SetEventSpecie(fEventSpecie) ; 
+       }
+
+  return qadm ;
+}
+
+//_____________________________________________________________________________
+void  AliQADataMakerSteer::EndOfCycle(TObjArray * detArray) 
+{
+       // End of cycle QADataMakers 
+       
+       for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
+               if (IsSelected(AliQA::GetDetName(iDet))) {
+                       AliQADataMaker * qadm = GetQADataMaker(iDet) ;
+                       if (!qadm) 
+                               continue ;      
+                       // skip non active detectors
+                       if (detArray) {
+                               AliModule* det = static_cast<AliModule*>(detArray->FindObject(AliQA::GetDetName(iDet))) ;
+                               if (!det || !det->IsActive())  
+                                       continue ;
+                       }
+                       for (UInt_t taskIndex = 0; taskIndex < AliQA::kNTASKINDEX; taskIndex++) {
+                               if ( fTasks.Contains(Form("%d", taskIndex)) ) 
+                                       qadm->EndOfCycle(AliQA::GetTaskIndex(AliQA::GetTaskName(taskIndex))) ;
                        }
-                       pluginHandler = pluginManager->FindHandler("AliQADataMaker", detName) ;
+                       qadm->Finish();
                }
-               if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
-                       qadm = (AliQADataMaker *) pluginHandler->ExecPlugin(0) ;
+       }
+}
+
+//_____________________________________________________________________________
+void  AliQADataMakerSteer::EndOfCycle(TString detectors) 
+{
+       // End of cycle QADataMakers 
+       
+       for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
+               if (IsSelected(AliQA::GetDetName(iDet))) {
+                       AliQADataMaker * qadm = GetQADataMaker(iDet) ;
+                       if (!qadm) 
+                               continue ;      
+                       // skip non active detectors
+      if (!detectors.Contains(AliQA::GetDetName(iDet))) 
+        continue ;
+               for (UInt_t taskIndex = 0; taskIndex < AliQA::kNTASKINDEX; taskIndex++) {
+                               if ( fTasks.Contains(Form("%d", taskIndex)) ) 
+                                       qadm->EndOfCycle(AliQA::GetTaskIndex(AliQA::GetTaskName(taskIndex))) ;
+                       }
+                       qadm->Finish();
                }
-               if (qadm) 
-                       fQADataMaker[iDet] = qadm ;
        }
-       return qadm ;
 }
 
 //_____________________________________________________________________________
-Bool_t AliQADataMakerSteer::Init(const AliQA::TASKINDEX_t taskIndex, const char * mode, const  char * input )
+void AliQADataMakerSteer::Increment()
+{
+  // Increments the cycle counter for all QA Data Makers
+       for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
+               if (IsSelected(AliQA::GetDetName(iDet))) {
+                       AliQADataMaker * qadm = GetQADataMaker(iDet) ;
+                       if (qadm) 
+        qadm->Increment() ;
+    }
+  }
+}
+  
+//_____________________________________________________________________________
+Bool_t AliQADataMakerSteer::Init(const AliQA::TASKINDEX_t taskIndex, const  char * input )
 {
        // Initialize the event source and QA data makers
        
+       fTasks += Form("%d", taskIndex) ; 
+
        if (taskIndex == AliQA::kRAWS) { 
                if (!fRawReader) {
                        fRawReader = AliRawReader::Create(input);
                }
-           if ( ! fRawReader ) 
+               if ( ! fRawReader ) 
                        return kFALSE ; 
                fRawReaderDelete = kTRUE ; 
                fRawReader->NextEvent() ; 
@@ -378,52 +513,66 @@ Bool_t AliQADataMakerSteer::Init(const AliQA::TASKINDEX_t taskIndex, const char
                if ( fMaxEvents < 0 ) 
                        fMaxEvents = fNumberOfEvents ; 
                } else if (taskIndex == AliQA::kESDS) {
-               if (!gSystem->AccessPathName("AliESDs.root")) { // AliESDs.root exists
-                       TFile * esdFile = TFile::Open("AliESDs.root") ;
-                       fESDTree = dynamic_cast<TTree *> (esdFile->Get("esdTree")) ; 
-                       if ( !fESDTree ) {
-                               AliError("esdTree not found") ; 
-                               return kFALSE ; 
-                       } else {
-                               fESD     = new AliESDEvent() ;
-                               fESD->ReadFromTree(fESDTree) ;
-                               fESDTree->GetEntry(0) ; 
-                               fRunNumber = fESD->GetRunNumber() ; 
-                               fNumberOfEvents = fESDTree->GetEntries() ;
-                               if ( fMaxEvents < 0 ) 
-                                       fMaxEvents = fNumberOfEvents ; 
-                       }
-               } else {
-                       AliError("AliESDs.root not found") ; 
-                       return kFALSE ; 
-               }                       
-               } else {
-               if ( !InitRunLoader() ) { 
-                       AliWarning("No Run Loader not found") ; 
-               } else {
-                       fNumberOfEvents = fRunLoader->GetNumberOfEvents() ;
-                       if ( fMaxEvents < 0 ) 
-                               fMaxEvents = fNumberOfEvents ; 
+                       fTasks = AliQA::GetTaskName(AliQA::kESDS) ; 
+      if (!gSystem->AccessPathName("AliESDs.root")) { // AliESDs.root exists
+        TFile * esdFile = TFile::Open("AliESDs.root") ;
+        fESDTree = dynamic_cast<TTree *> (esdFile->Get("esdTree")) ; 
+        if ( !fESDTree ) {
+          AliError("esdTree not found") ; 
+          return kFALSE ; 
+        } else {
+          fESD     = new AliESDEvent() ;
+          fESD->ReadFromTree(fESDTree) ;
+          fESDTree->GetEntry(0) ; 
+          fRunNumber = fESD->GetRunNumber() ; 
+          fNumberOfEvents = fESDTree->GetEntries() ;
+          if ( fMaxEvents < 0 ) 
+            fMaxEvents = fNumberOfEvents ; 
+        }
+      } else {
+        AliError("AliESDs.root not found") ; 
+        return kFALSE ; 
+      }                        
+    } else {
+      if ( !InitRunLoader() ) { 
+        AliWarning("No Run Loader not found") ; 
+      } else {
+        fNumberOfEvents = fRunLoader->GetNumberOfEvents() ;
+        if ( fMaxEvents < 0 ) 
+          fMaxEvents = fNumberOfEvents ; 
+      }
+    }
 
-               }
-       }
-
-       // Get Detectors 
-       TObjArray* detArray = NULL ; 
+  // Get Detectors 
+  TObjArray* detArray = NULL ; 
        if (fRunLoader) // check if RunLoader exists 
                if ( fRunLoader->GetAliRun() ) { // check if AliRun exists in gAlice.root
                        detArray = fRunLoader->GetAliRun()->Detectors() ;
                        fRunNumber = fRunLoader->GetHeader()->GetRun() ; 
                }
-       // Build array of QA data makers for all detectors
-       fQADataMakers.Clear();
+
+       // Initialize all QA data makers for all detectors
+       fRunNumber = AliCDBManager::Instance()->GetRun() ; 
+       if ( !  AliGeomManager::GetGeometry() ) 
+               AliGeomManager::LoadGeometry() ; 
+       
+       InitQADataMaker(fRunNumber, detArray) ; //, fCycleSame, kTRUE, detArray) ; 
+       return kTRUE ; 
+}
+
+//_____________________________________________________________________________
+void  AliQADataMakerSteer::InitQADataMaker(UInt_t run, TObjArray * detArray) 
+{
+       // Initializes The QADataMaker for all active detectors and for all active tasks 
        for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
                if (IsSelected(AliQA::GetDetName(iDet))) {
-                       AliQADataMaker * qadm = GetQADataMaker(iDet, mode) ;
+                       AliQADataMaker * qadm = GetQADataMaker(iDet) ;
                        if (!qadm) {
                                AliError(Form("AliQADataMaker not found for %s", AliQA::GetDetName(iDet))) ; 
                                fDetectorsW.ReplaceAll(AliQA::GetDetName(iDet), "") ; 
                        } else {
+        if (fQAWriteExpert[iDet])
+          qadm->SetWriteExpert() ; 
                                AliDebug(1, Form("Data Maker found for %s", qadm->GetName())) ; 
                                // skip non active detectors
                                if (detArray) {
@@ -431,22 +580,22 @@ Bool_t AliQADataMakerSteer::Init(const AliQA::TASKINDEX_t taskIndex, const char
                                        if (!det || !det->IsActive())  
                                                continue ;
                                }
-                               qadm->SetName(AliQA::GetDetName(iDet));
-                               qadm->SetUniqueID(iDet);
-                               fQADataMakers.Add(qadm);
+                               if (fQAWriteExpert[iDet]) qadm->SetWriteExpert() ; 
+             // Set default reco params
+        Bool_t sameCycle = kFALSE ; 
+                               for (UInt_t taskIndex = 0; taskIndex < AliQA::kNTASKINDEX; taskIndex++) {
+                                       if ( fTasks.Contains(Form("%d", taskIndex)) ) {
+                                               qadm->Init(AliQA::GetTaskIndex(AliQA::GetTaskName(taskIndex)), GetQACycles(qadm->GetUniqueID())) ;
+            qadm->StartOfCycle(AliQA::GetTaskIndex(AliQA::GetTaskName(taskIndex)), run,  sameCycle) ;
+            sameCycle = kTRUE ;
+                                       }
+                               }
                        }
                }
-       } 
-       // Initialize all QA data makers for all detectors
-       for (Int_t i = 0; i < fQADataMakers.GetEntriesFast() ; i++) {
-               AliQADataMaker * qadm = static_cast<AliQADataMaker *>(fQADataMakers.At(i));
-               qadm->Init(taskIndex, fRunNumber, GetQACycles(qadm->GetUniqueID())) ;
-               qadm->StartOfCycle(taskIndex, fCycleSame) ;
-       } 
-       fFirst = kFALSE ;
-       return kTRUE ; 
+       }
 }
 
+
 //_____________________________________________________________________________
 Bool_t AliQADataMakerSteer::InitRunLoader()
 {
@@ -503,43 +652,48 @@ Bool_t AliQADataMakerSteer::IsSelected(const char * det)
        
        Bool_t rv = kFALSE;
        const TString detName(det) ;
-       // check if all detectors are selected
-       if (fDetectors.Contains("ALL")) {
-               fDetectors = "ALL";
-               rv = kTRUE;
-       } else if ((fDetectors.CompareTo(detName) == 0) ||
-                          fDetectors.BeginsWith(detName+" ") ||
-                          fDetectors.EndsWith(" "+detName) ||
-                          fDetectors.Contains(" "+detName+" ")) {
-               //              fDetectors.ReplaceAll(detName, "");
-               rv = kTRUE;
-       }
-       
-       // clean up the detectors string
-       //      while (fDetectors.Contains("  ")) 
-       //              fDetectors.ReplaceAll("  ", " ");
-       //      while (fDetectors.BeginsWith(" ")) 
-       //              fDetectors.Remove(0, 1);
-       //      while (fDetectors.EndsWith(" ")) 
-       //              fDetectors.Remove(fDetectors.Length()-1, 1);
-       
+  // always activates Correlation
+  if ( detName.Contains(AliQA::GetDetName(AliQA::kCORR))) {
+    rv = kTRUE ; 
+  } else {
+    // check if all detectors are selected
+    if (fDetectors.Contains("ALL")) {
+      fDetectors = "ALL";
+      rv = kTRUE;
+    } else if ((fDetectors.CompareTo(detName) == 0) ||
+               fDetectors.BeginsWith(detName+" ") ||
+               fDetectors.EndsWith(" "+detName) ||
+               fDetectors.Contains(" "+detName+" ")) {
+      rv = kTRUE;
+    }
+  }
        return rv ;
 }
 
 //_____________________________________________________________________________
 Bool_t AliQADataMakerSteer::Merge(const Int_t runNumber) const
+{
+       // Merge data from all the cycles from all detectors in one single file per run
+       // Merge the QA results from all the data chunks in one run 
+ Bool_t rv = MergeData(runNumber) ; 
+ rv *= MergeResults(runNumber) ;
+ return rv ; 
+}
+       
+       
+//_____________________________________________________________________________
+Bool_t AliQADataMakerSteer::MergeData(const Int_t runNumber) const
 {
        // Merge all the cycles from all detectors in one single file per run
        TString cmd ;
-       if ( runNumber == -1 )
-               cmd = Form(".! ls *%s*.*.*.root > tempo.txt", AliQA::GetQADataFileName()) ; 
+       if (runNumber == -1) 
+               cmd = Form(".! ls *%s*.%d.root > tempo.txt", AliQA::GetQADataFileName(), runNumber) ; 
        else 
-               cmd = Form(".! ls *%s*.%d.*.root > tempo.txt", AliQA::GetQADataFileName(), runNumber) ; 
+               cmd = Form(".! ls *%s*.*.root > tempo.txt", AliQA::GetQADataFileName()) ; 
        gROOT->ProcessLine(cmd.Data()) ;
        ifstream in("tempo.txt") ; 
        const Int_t runMax = 10 ;  
        TString file[AliQA::kNDET*runMax] ;
-       Int_t run[AliQA::kNDET*runMax] = {-1} ;
        
        Int_t index = 0 ; 
        while ( 1 ) {
@@ -554,42 +708,56 @@ Bool_t AliQADataMakerSteer::Merge(const Int_t runNumber) const
                AliError(Form("run number %d not found", runNumber)) ; 
                return kFALSE ; 
        }
+
+  TFileMerger merger ; 
+  TString outFileName(Form("Merged.%s.Data.%d.root",AliQA::GetQADataFileName(),runNumber)); 
+  merger.OutputFile(outFileName.Data()) ; 
+  for (Int_t ifile = 0 ; ifile < index-1 ; ifile++) {
+    TString pattern(Form("%s.%d.", AliQA::GetQADataFileName(), runNumber)); 
+    TString tmp(file[ifile]) ; 
+    if (tmp.Contains(pattern)) {
+      merger.AddFile(tmp) ; 
+    }
+       }
+  merger.Merge() ; 
+       return kTRUE ; 
+}
+
+//_____________________________________________________________________________
+Bool_t AliQADataMakerSteer::MergeResults(const Int_t runNumber) const
+{
+       // Merge the QA result from all the data chunks in a run 
+       TString cmd ;
+       cmd = Form(".! ls %s*.root > tempo.txt", AliQA::GetQADataFileName()) ; 
+       gROOT->ProcessLine(cmd.Data()) ;
+       ifstream in("tempo.txt") ; 
+       const Int_t chunkMax = 100 ;  
+       TString fileList[chunkMax] ;
        
-       Int_t runIndex    = 0 ;  
-       Int_t runIndexMax = 0 ; 
-       TString stmp(Form(".%s.", AliQA::GetQADataFileName())) ; 
-       for (Int_t ifile = 0 ; ifile < index ; ifile++) {
-               TString tmp(file[ifile]) ; 
-               tmp.ReplaceAll(".root", "") ; 
-               TString det = tmp(0, tmp.Index(".")) ; 
-               tmp.Remove(0, tmp.Index(stmp)+4) ; 
-               TString ttmp = tmp(0, tmp.Index(".")) ; 
-               Int_t newRun = ttmp.Atoi() ;
-               for (Int_t irun = 0; irun <= runIndexMax; irun++) {
-                       if (newRun == run[irun]) 
-                               break ; 
-                       run[runIndex] = newRun ; 
-                       runIndex++ ; 
-               }
-               runIndexMax = runIndex ; 
-               ttmp = tmp(tmp.Index(".")+1, tmp.Length()) ; 
-               Int_t cycle = ttmp.Atoi() ;  
-               AliDebug(1, Form("%s : det = %s run = %d cycle = %d \n", file[ifile].Data(), det.Data(), newRun, cycle)) ; 
+       Int_t index = 0 ; 
+       while ( 1 ) {
+               TString file ; 
+               in >> fileList[index] ; 
+               if ( !in.good() ) 
+                       break ; 
+               AliInfo(Form("index = %d file = %s", index, (fileList[index].Data()))) ; 
+               index++ ;
        }
-       for (Int_t irun = 0 ; irun < runIndexMax ; irun++) {
-               TFileMerger merger ; 
-               TString outFileName(Form("Merged.%s.%d.root",AliQA::GetQADataFileName(),run[irun]));            
-               merger.OutputFile(outFileName.Data()) ; 
-               for (Int_t ifile = 0 ; ifile < index-1 ; ifile++) {
-                       TString pattern(Form("%s.%d.", AliQA::GetQADataFileName(), run[irun])) ; 
-                       TString tmp(file[ifile]) ; 
-                       if (tmp.Contains(pattern)) {
-                               merger.AddFile(tmp) ; 
-                       }
-               }
-               merger.Merge() ; 
+       
+       if ( index == 0 ) { 
+               AliError("No QA Result File found") ; 
+               return kFALSE ; 
        }
        
+       TFileMerger merger ; 
+       TString outFileName(Form("Merged.%s.Result.%d.root", AliQA::GetQADataFileName(), runNumber));           
+       merger.OutputFile(outFileName.Data()) ; 
+       for (Int_t ifile = 0 ; ifile < index ; ifile++) {
+               TString file = fileList[ifile] ; 
+               merger.AddFile(file) ; 
+       }
+       merger.Merge() ; 
+       
        return kTRUE ; 
 }
 
@@ -598,9 +766,11 @@ void AliQADataMakerSteer::Reset(const Bool_t sameCycle)
 {
        // Reset the default data members
 
-       for (Int_t i = 0; i < fQADataMakers.GetEntriesFast() ; i++) {
-               AliQADataMaker * qadm = static_cast<AliQADataMaker *>(fQADataMakers.At(i));
-               qadm->Reset(sameCycle);
+       for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
+               if (IsSelected(AliQA::GetDetName(iDet))) {
+                       AliQADataMaker * qadm = GetQADataMaker(iDet);
+                       qadm->Reset();
+               }
        } 
        if (fRawReaderDelete) { 
                delete fRawReader ;
@@ -610,7 +780,7 @@ void AliQADataMakerSteer::Reset(const Bool_t sameCycle)
        fCycleSame      = sameCycle ; 
        fESD            = NULL ; 
        fESDTree        = NULL ; 
-       fFirst          = kTRUE ;   
+       //fFirst          = kTRUE ;   
        fNumberOfEvents = 999999 ;  
 }
 
@@ -625,22 +795,19 @@ TString AliQADataMakerSteer::Run(const char * detectors, AliRawReader * rawReade
        fDetectorsW      = detectors ;  
        
        AliCDBManager* man = AliCDBManager::Instance() ; 
-       if ( ! man->GetLock() ) { 
-               man->SetDefaultStorage(AliQA::GetQARefStorage()) ; 
-               man->SetSpecificStorage("*", AliQA::GetQARefStorage()) ;
-       }
-       
+
        if ( man->GetRun() == -1 ) {// check if run number not set previously and set it from raw data
                rawReader->NextEvent() ; 
                man->SetRun(fRawReader->GetRunNumber()) ;
                rawReader->RewindEvents() ;
        }       
        
-       if ( !Init(AliQA::kRAWS, "rec") ) 
-               return kFALSE ; 
-       fRawReaderDelete = kFALSE ; 
+       if (!fCycleSame) 
+    if ( !Init(AliQA::kRAWS) ) 
+      return kFALSE ; 
+  fRawReaderDelete = kFALSE ; 
 
-       DoIt(AliQA::kRAWS, "rec") ; 
+       DoIt(AliQA::kRAWS) ; 
        return  fDetectorsW ;
 }
 
@@ -670,10 +837,11 @@ TString AliQADataMakerSteer::Run(const char * detectors, const char * fileName,
                }
        }
        
-       if ( !Init(AliQA::kRAWS, "rec", fileName) ) 
-               return kFALSE ; 
+       if (!fCycleSame) 
+    if ( !Init(AliQA::kRAWS, fileName) ) 
+      return kFALSE ; 
        
-       DoIt(AliQA::kRAWS, "rec") ; 
+       DoIt(AliQA::kRAWS) ; 
        return  fDetectorsW ;
 }
 
@@ -686,16 +854,6 @@ TString AliQADataMakerSteer::Run(const char * detectors, const AliQA::TASKINDEX_
        fDetectors       = detectors ; 
        fDetectorsW      = detectors ;          
        
-       TString mode ; 
-       if ( (taskIndex == AliQA::kHITS) || (taskIndex == AliQA::kSDIGITS) || (taskIndex == AliQA::kDIGITS) ) 
-               mode = "sim" ; 
-       else if ( (taskIndex == AliQA::kRAWS) || (taskIndex == AliQA::kRECPOINTS) || (taskIndex == AliQA::kESDS) )
-               mode = "rec" ; 
-       else {
-               AliError(Form("%s not implemented", AliQA::GetTaskName(taskIndex).Data())) ; 
-               return "" ;
-       }
-
        AliCDBManager* man = AliCDBManager::Instance() ;        
        if ( man->GetRun() == -1 ) { // check if run number not set previously and set it from AliRun
                AliRunLoader * rl = AliRunLoader::Open("galice.root") ;
@@ -705,7 +863,7 @@ TString AliQADataMakerSteer::Run(const char * detectors, const AliQA::TASKINDEX_
                        rl->CdGAFile() ; 
                        rl->LoadgAlice() ;
                        if ( ! rl->GetAliRun() ) {
-                               AliFatal("AliRun not found in galice.root") ;
+                               AliInfo("AliRun not found in galice.root") ;
                        } else {
                                rl->LoadHeader() ;
                                man->SetRun(rl->GetHeader()->GetRun()) ;
@@ -713,17 +871,97 @@ TString AliQADataMakerSteer::Run(const char * detectors, const AliQA::TASKINDEX_
                }
        }
        
-       if ( !Init(taskIndex, mode.Data(), fileName) ) 
-               return kFALSE ; 
 
-       DoIt(taskIndex, mode.Data()) ;
+       if ( taskIndex == AliQA::kNULLTASKINDEX) { 
+               for (UInt_t task = 0; task < AliQA::kNTASKINDEX; task++) {
+                       if ( fTasks.Contains(Form("%d", task)) ) {
+        if (!fCycleSame)
+          if ( !Init(AliQA::GetTaskIndex(AliQA::GetTaskName(task)), fileName) ) 
+            return kFALSE ;
+        DoIt(AliQA::GetTaskIndex(AliQA::GetTaskName(task))) ;
+                       }
+               }
+       } else {
+    if (! fCycleSame )
+      if ( !Init(taskIndex, fileName) ) 
+        return kFALSE ; 
+      DoIt(taskIndex) ; 
+  }            
        
        return fDetectorsW ;
 
 }
 
 //_____________________________________________________________________________
-Bool_t AliQADataMakerSteer::Save2OCDB(const Int_t runNumber, const char * year, const Int_t cycleNumber, const char * detectors) const
+void AliQADataMakerSteer::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", AliQA::kRAWS))){
+    for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
+      if (!IsSelected(AliQA::GetDetName(iDet))) 
+        continue;
+      AliQADataMaker *qadm = GetQADataMaker(iDet);  
+      if (!qadm) 
+        continue;
+      if ( qadm->IsCycleDone() ) {
+        qadm->EndOfCycle() ;
+      }
+      AliCodeTimerStart(Form("running RAW quality assurance data maker for %s", AliQA::GetDetName(iDet))); 
+      qadm->SetEventSpecie(fEventSpecie) ; 
+                       qadm->Exec(AliQA::kRAWS, rawReader) ;
+      AliCodeTimerStop(Form("running RAW quality assurance data maker for %s", AliQA::GetDetName(iDet)));
+               }
+  }
+}
+
+//_____________________________________________________________________________
+void AliQADataMakerSteer::RunOneEvent(AliESDEvent *& esd) 
+{
+       //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", AliQA::kESDS))) {
+    for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
+      if (!IsSelected(AliQA::GetDetName(iDet))) 
+        continue;
+      AliQADataMaker *qadm = GetQADataMaker(iDet);  
+      if (!qadm) 
+        continue;
+      if ( qadm->IsCycleDone() ) {
+        qadm->EndOfCycle() ;
+      }
+      AliCodeTimerStart(Form("running ESD quality assurance data maker for %s", AliQA::GetDetName(iDet)));
+                       qadm->Exec(AliQA::kESDS, esd) ;
+      AliCodeTimerStop(Form("running ESD quality assurance data maker for %s", AliQA::GetDetName(iDet)));
+               }
+       }
+}
+
+//_____________________________________________________________________________
+void AliQADataMakerSteer::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("") ;
+  if (fTasks.Contains(Form("%d", AliQA::kRECPOINTS))) {
+    if (IsSelected(AliQA::GetDetName(det))) {
+      AliQADataMaker *qadm = GetQADataMaker(det);  
+      if (qadm) { 
+        if ( qadm->IsCycleDone() ) {
+          qadm->EndOfCycle() ;
+        }
+        AliCodeTimerStart(Form("running RecPoints quality assurance data maker for %s", AliQA::GetDetName(det)));
+        qadm->Exec(AliQA::kRECPOINTS, tree) ;
+        AliCodeTimerStop(Form("running RecPoints quality assurance data maker for %s", AliQA::GetDetName(det)));
+      }
+    }
+  }
+}
+
+//_____________________________________________________________________________
+Bool_t AliQADataMakerSteer::Save2OCDB(const Int_t runNumber, AliRecoParam::EventSpecie_t es, const char * year, const char * detectors) const
 {
        // take the locasl QA data merge into a single file and save in OCDB 
        Bool_t rv = kTRUE ; 
@@ -743,15 +981,15 @@ Bool_t AliQADataMakerSteer::Save2OCDB(const Int_t runNumber, const char * year,
                rv = Merge(runNumber) ; 
                if ( ! rv )
                        return kFALSE ; 
-               TString inputFileName(Form("Merged.%s.%d.root", AliQA::GetQADataFileName(), runNumber)) ; 
+               TString inputFileName(Form("Merged.%s.Data.%d.root", AliQA::GetQADataFileName(), runNumber)) ; 
                inputFile = TFile::Open(inputFileName.Data()) ; 
-               rv = SaveIt2OCDB(runNumber, inputFile, year) ; 
+               rv = SaveIt2OCDB(runNumber, inputFile, year, es) ; 
        } else {
                for (Int_t index = 0; index < AliQA::kNDET; index++) {
                        if (sdet.Contains(AliQA::GetDetName(index))) {
-                               TString inputFileName(Form("%s.%s.%d.%d.root", AliQA::GetDetName(index), AliQA::GetQADataFileName(), runNumber, cycleNumber)) ; 
+                               TString inputFileName(Form("%s.%s.%d.root", AliQA::GetDetName(index), AliQA::GetQADataFileName(), runNumber)) ; 
                                inputFile = TFile::Open(inputFileName.Data()) ;                         
-                               rv *= SaveIt2OCDB(runNumber, inputFile, year) ; 
+                               rv *= SaveIt2OCDB(runNumber, inputFile, year, es) ; 
                        }
                }
        }
@@ -759,7 +997,7 @@ Bool_t AliQADataMakerSteer::Save2OCDB(const Int_t runNumber, const char * year,
 }
 
 //_____________________________________________________________________________
-Bool_t AliQADataMakerSteer::SaveIt2OCDB(const Int_t runNumber, TFile * inputFile, const char * year) const
+Bool_t AliQADataMakerSteer::SaveIt2OCDB(const Int_t runNumber, TFile * inputFile, const char * 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 ;
@@ -770,10 +1008,10 @@ Bool_t AliQADataMakerSteer::SaveIt2OCDB(const Int_t runNumber, TFile * inputFile
                if ( tmp.Contains(AliQA::GetLabLocalOCDB()) ) 
                        man->SetDefaultStorage(AliQA::GetQARefStorage()) ;
                else {
-                       TString tmp(AliQA::GetQARefDefaultStorage()) ; 
-                       tmp.Append(year) ; 
-                       tmp.Append("?user=alidaq") ; 
-                       man->SetDefaultStorage(tmp.Data()) ; 
+                       TString tmp1(AliQA::GetQARefDefaultStorage()) ; 
+                       tmp1.Append(year) ; 
+                       tmp1.Append("?user=alidaq") ; 
+                       man->SetDefaultStorage(tmp1.Data()) ; 
                }
        }
        man->SetSpecificStorage("*", AliQA::GetQARefStorage()) ; 
@@ -787,29 +1025,50 @@ Bool_t AliQADataMakerSteer::SaveIt2OCDB(const Int_t runNumber, TFile * inputFile
                TDirectory * detDir = inputFile->GetDirectory(AliQA::GetDetName(detIndex)) ; 
                if ( detDir ) {
                        AliInfo(Form("Entering %s", detDir->GetName())) ;
+      AliQA::SetQARefDataDirName(es) ;
                        TString detOCDBDir(Form("%s/%s/%s", AliQA::GetDetName(detIndex), AliQA::GetRefOCDBDirName(), AliQA::GetRefDataDirName())) ; 
                        AliCDBId idr(detOCDBDir.Data(), runNumber, AliCDBRunRange::Infinity())  ;
                        TList * listDetQAD = new TList() ;
                        TString listName(Form("%s QA data Reference", AliQA::GetDetName(detIndex))) ; 
-                       mdr.SetComment("HMPID QA stuff");
+                       mdr.SetComment(Form("%s QA stuff", AliQA::GetDetName(detIndex)));
                        listDetQAD->SetName(listName) ; 
                        TList * taskList = detDir->GetListOfKeys() ; 
                        TIter nextTask(taskList) ; 
                        TKey * taskKey ; 
                        while ( (taskKey = dynamic_cast<TKey*>(nextTask())) ) {
                                TDirectory * taskDir = detDir->GetDirectory(taskKey->GetName()) ; 
-                               AliInfo(Form("Saving %s", taskDir->GetName())) ; 
+        TDirectory * esDir   = taskDir->GetDirectory(AliRecoParam::GetEventSpecieName(es)) ; 
+                               AliInfo(Form("Saving %s", esDir->GetName())) ; 
                                TObjArray * listTaskQAD = new TObjArray(100) ; 
-                               listTaskQAD->SetName(taskKey->GetName()) ;
+                               listTaskQAD->SetName(Form("%s/%s", taskKey->GetName(), AliRecoParam::GetEventSpecieName(es))) ;
                                listDetQAD->Add(listTaskQAD) ; 
-                               TList * histList = taskDir->GetListOfKeys() ; 
+                               TList * histList = esDir->GetListOfKeys() ; 
                                TIter nextHist(histList) ; 
                                TKey * histKey ; 
                                while ( (histKey = dynamic_cast<TKey*>(nextHist())) ) {
-                                       TObject * odata = taskDir->Get(histKey->GetName()) ; 
+                                       TObject * odata = esDir->Get(histKey->GetName()) ; 
                                        if ( !odata ) {
                                                AliError(Form("%s in %s/%s returns a NULL pointer !!", histKey->GetName(), detDir->GetName(), taskDir->GetName())) ;
                                        } else {
+            if ( AliQA::GetExpert() == histKey->GetName() ) {
+              TDirectory * expertDir   = esDir->GetDirectory(histKey->GetName()) ; 
+              TList * expertHistList = expertDir->GetListOfKeys() ; 
+              TIter nextExpertHist(expertHistList) ; 
+              TKey * expertHistKey ; 
+              while ( (expertHistKey = dynamic_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())) ;
+                } else {
+                  AliInfo(Form("Adding %s", expertHistKey->GetName())) ;
+                  if ( expertOdata->IsA()->InheritsFrom("TH1") ) {
+                    AliInfo(Form("Adding %s", expertHistKey->GetName())) ;
+                    TH1 * hExpertdata = static_cast<TH1*>(expertOdata) ; 
+                    listTaskQAD->Add(hExpertdata) ; 
+                  }                  
+                }                
+              }
+            }
                                                AliInfo(Form("Adding %s", histKey->GetName())) ;
                                                if ( odata->IsA()->InheritsFrom("TH1") ) {
                                                        AliInfo(Form("Adding %s", histKey->GetName())) ;
@@ -825,3 +1084,20 @@ Bool_t AliQADataMakerSteer::SaveIt2OCDB(const Int_t runNumber, TFile * inputFile
        return rv ; 
 }      
 
+//_____________________________________________________________________________
+void AliQADataMakerSteer::SetEventSpecie(AliRecoParam::EventSpecie_t es) 
+{
+  // set the current event specie and inform AliQA that this event specie has been encountered
+  fEventSpecie = es ;
+  AliQA::Instance()->SetEventSpecie(es) ; 
+}
+
+//_____________________________________________________________________________
+void AliQADataMakerSteer::SetRecoParam(const Int_t det, const AliDetectorRecoParam *par) 
+{
+  // Set custom reconstruction parameters for a given detector
+  // Single set of parameters for all the events
+  GetQADataMaker(det)->SetRecoParam(par) ; 
+}
+
+