]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliQAManager.cxx
1.The QA data created on demand according to the event species at filling time. 2...
[u/mrichter/AliRoot.git] / STEER / AliQAManager.cxx
index 673205e86a11021670bc05d0018875e8a97a375d..c1d73b925934fec3f952b2f5ecabeda9f7acd9cf 100644 (file)
 // class for running the QA makers                                           //
 //                                                                           //
 //   AliQAManager qas;                                                //
-//   qas.Run(AliQA::kRAWS, rawROOTFileName);                                 //
-//   qas.Run(AliQA::kHITS);                                                  //
-//   qas.Run(AliQA::kSDIGITS);                                               //
-//   qas.Run(AliQA::kDIGITS);                                                //
-//   qas.Run(AliQA::kRECPOINTS);                                             //
-//   qas.Run(AliQA::kESDS);                                                  //
+//   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>
+#include <TGrid.h>
+#include <TGridCollection.h>
+#include <TGridResult.h>
 #include <TPluginManager.h>
 #include <TROOT.h>
 #include <TString.h>
@@ -49,7 +53,7 @@
 #include "AliHeader.h"
 #include "AliLog.h"
 #include "AliModule.h"
-#include "AliQA.h"
+#include "AliQAv1.h"
 #include "AliQADataMakerRec.h"
 #include "AliQADataMakerSim.h"
 #include "AliQAManager.h" 
@@ -82,19 +86,20 @@ AliQAManager::AliQAManager() :
   fRawReader(NULL), 
   fRawReaderDelete(kTRUE), 
   fRunLoader(NULL), 
-  fTasks(""), 
-  fEventSpecie(AliRecoParam::kDefault)
+  fTasks(""),  
+  fEventSpecie(AliRecoParam::kDefault), 
+  fPrintImage(kTRUE) 
 {
        // default ctor
        fMaxEvents = fNumberOfEvents ; 
        for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
-               if (IsSelected(AliQA::GetDetName(iDet))) {
+               if (IsSelected(AliQAv1::GetDetName(iDet))) {
                        fLoader[iDet]      = NULL ;
                        fQADataMaker[iDet] = NULL ;
                        fQACycles[iDet]    = 999999 ;
-      fQAWriteExpert[iDet] = kTRUE ;
                }
        }       
+  SetWriteExpert() ; 
 }
 
 //_____________________________________________________________________________
@@ -117,18 +122,23 @@ AliQAManager::AliQAManager(const Char_t * mode, const Char_t* gAliceFilename) :
        fRawReaderDelete(kTRUE), 
        fRunLoader(NULL), 
   fTasks(""), 
-  fEventSpecie(AliRecoParam::kDefault)
+  fEventSpecie(AliRecoParam::kDefault), 
+  fPrintImage(kTRUE) 
 {
        // default ctor
        fMaxEvents = fNumberOfEvents ; 
        for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
-               if (IsSelected(AliQA::GetDetName(iDet))) {
+               if (IsSelected(AliQAv1::GetDetName(iDet))) {
                        fLoader[iDet]      = NULL ;
                        fQADataMaker[iDet] = NULL ;
                        fQACycles[iDet]    = 999999 ;
-      fQAWriteExpert[iDet] = kTRUE ;
     }
   }
+  SetWriteExpert() ; 
+  if (fMode.Contains("sim")) 
+               fMode.ReplaceAll("s", "S") ; 
+  else if (fMode.Contains("rec")) 
+    fMode.ReplaceAll("r", "R") ; 
 }
 
 //_____________________________________________________________________________
@@ -150,8 +160,10 @@ 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) 
+
 {
        // cpy ctor
        for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
@@ -176,7 +188,7 @@ AliQAManager::~AliQAManager()
 {
        // dtor
        for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
-               if (IsSelected(AliQA::GetDetName(iDet))) {
+               if (IsSelected(AliQAv1::GetDetName(iDet))) {
                  fLoader[iDet] = NULL;
                  if (fQADataMaker[iDet]) {
                          (fQADataMaker[iDet])->Finish() ; 
@@ -189,10 +201,13 @@ AliQAManager::~AliQAManager()
                delete fRawReader ;
                fRawReader = NULL ;
        }
+  TCanvas fakeCanvas ; 
+  if (fPrintImage) 
+    fakeCanvas.Print(Form("%s%s%d.%s]", AliQAv1::GetImageFileName(), GetMode(), fRunNumber, AliQAv1::GetImageFileFormat())); 
 }
 
 //_____________________________________________________________________________
-Bool_t AliQAManager::DoIt(const AliQA::TASKINDEX_t taskIndex)
+Bool_t AliQAManager::DoIt(const AliQAv1::TASKINDEX_t taskIndex)
 {
        // Runs all the QA data Maker for every detector
                
@@ -202,11 +217,11 @@ Bool_t AliQAManager::DoIt(const AliQA::TASKINDEX_t taskIndex)
                fCurrentEvent++ ; 
                // Get the event
                if ( iEvent%10 == 0  ) 
-                       AliInfo(Form("processing event %d", iEvent));
-               if ( taskIndex == AliQA::kRAWS ) {
+                       AliDebug(AliQAv1::GetQADebugLevel(), Form("processing event %d", iEvent));
+               if ( taskIndex == AliQAv1::kRAWS ) {
                        if ( !fRawReader->NextEvent() )
                                break ;
-               } else if ( taskIndex == AliQA::kESDS ) {
+               } else if ( taskIndex == AliQAv1::kESDS ) {
                        if ( fESDTree->GetEntry(iEvent) == 0 )
                                break ;
                } else {
@@ -215,7 +230,7 @@ Bool_t AliQAManager::DoIt(const AliQA::TASKINDEX_t taskIndex)
                }
                // loop  over active loaders
                for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
-                       if (IsSelected(AliQA::GetDetName(iDet))) {
+                       if (IsSelected(AliQAv1::GetDetName(iDet))) {
                                AliQADataMaker * qadm = GetQADataMaker(iDet) ;
                                if (!qadm) continue; // This detector doesn't have any QA (for example, HLT)
                                if ( qadm->IsCycleDone() ) {
@@ -224,63 +239,74 @@ Bool_t AliQAManager::DoIt(const AliQA::TASKINDEX_t taskIndex)
                                TTree * data = NULL ; 
                                AliLoader* loader = GetLoader(qadm->GetUniqueID());
                                switch (taskIndex) {
-                                       case AliQA::kNULLTASKINDEX : 
+                                       case AliQAv1::kNULLTASKINDEX : 
                                                break ; 
-                                       case AliQA::kRAWS :
+                                       case AliQAv1::kRAWS :
                                                qadm->Exec(taskIndex, fRawReader) ; 
                                                break ; 
-                                       case AliQA::kHITS :
+                                       case AliQAv1::kHITS :
             if( loader ) {
               loader->LoadHits() ; 
               data = loader->TreeH() ; 
               if ( ! data ) {
-                AliWarning(Form(" Hit Tree not found for  %s", AliQA::GetDetName(iDet))) ; 
+                AliWarning(Form(" Hit Tree not found for  %s", AliQAv1::GetDetName(iDet))) ; 
                 break ; 
               } 
+              qadm->Exec(taskIndex, data) ;
             } 
-            qadm->Exec(taskIndex, data) ;
                                                break ;
-                                               case AliQA::kSDIGITS :
+                                               case AliQAv1::kSDIGITS :
             if( loader ) {      
               loader->LoadSDigits() ; 
               data = loader->TreeS() ; 
               if ( ! data ) {
-                AliWarning(Form(" SDigit Tree not found for  %s", AliQA::GetDetName(iDet))) ; 
+                AliWarning(Form(" SDigit Tree not found for  %s", AliQAv1::GetDetName(iDet))) ; 
                 break ; 
               } 
+              qadm->Exec(taskIndex, data) ; 
             }
-            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) ;
+                                               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) ;
+              }
+            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 AliQA::kRECPOINTS :
+                                               case AliQAv1::kRECPOINTS :
             if( loader ) {      
               loader->LoadRecPoints() ; 
               data = loader->TreeR() ; 
               if (!data) {
-                AliWarning(Form("RecPoints not found for %s", AliQA::GetDetName(iDet))) ; 
+                AliWarning(Form("RecPoints not found for %s", AliQAv1::GetDetName(iDet))) ; 
                 break ; 
               } 
+              qadm->Exec(taskIndex, data) ; 
             }
-            qadm->Exec(taskIndex, data) ; 
             break; 
-                                               case AliQA::kTRACKSEGMENTS :
+                                               case AliQAv1::kTRACKSEGMENTS :
                                                break; 
-                                               case AliQA::kRECPARTICLES :
+                                               case AliQAv1::kRECPARTICLES :
                                                break; 
-                                               case AliQA::kESDS :
+                                               case AliQAv1::kESDS :
                                                qadm->Exec(taskIndex, fESD) ;
                                                break; 
-                                               case AliQA::kNTASKINDEX :
+                                               case AliQAv1::kNTASKINDEX :
                                                break; 
                                } //task switch
                        }
@@ -290,18 +316,18 @@ Bool_t AliQAManager::DoIt(const AliQA::TASKINDEX_t taskIndex)
        // Save QA data for all detectors
        rv = Finish(taskIndex) ;
        
-       if ( taskIndex == AliQA::kRAWS ) 
+       if ( taskIndex == AliQAv1::kRAWS ) 
                fRawReader->RewindEvents() ;
 
        return rv ; 
 }
 
 //_____________________________________________________________________________
-Bool_t AliQAManager::Finish(const AliQA::TASKINDEX_t taskIndex) 
+Bool_t AliQAManager::Finish(const AliQAv1::TASKINDEX_t taskIndex) 
 {
        // write output to file for all detectors
        for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
-               if (IsSelected(AliQA::GetDetName(iDet))) {
+               if (IsSelected(AliQAv1::GetDetName(iDet))) {
                        AliQADataMaker * qadm = GetQADataMaker(iDet) ;
                        if (qadm) 
         qadm->EndOfCycle(taskIndex) ;
@@ -311,39 +337,50 @@ Bool_t AliQAManager::Finish(const AliQA::TASKINDEX_t taskIndex)
 }
 
 //_____________________________________________________________________________
-TObjArray * AliQAManager::GetFromOCDB(AliQA::DETECTORINDEX_t det, AliQA::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 ;
-       if ( !strlen(AliQA::GetQARefStorage()) ) { 
-               AliError("No storage defined, use AliQA::SetQARefStorage") ; 
+       if ( !strlen(AliQAv1::GetQARefStorage()) ) { 
+               AliError("No storage defined, use AliQAv1::SetQARefStorage") ; 
                return NULL ; 
        }       
        if ( ! IsDefaultStorageSet() ) {
-               TString tmp(AliQA::GetQARefDefaultStorage()) ; 
+               TString tmp(AliQAv1::GetQARefDefaultStorage()) ; 
                tmp.Append(year) ; 
                tmp.Append("/") ; 
                Instance()->SetDefaultStorage(tmp.Data()) ;             
-               Instance()->SetSpecificStorage(Form("%s/*", AliQA::GetQAName()), AliQA::GetQARefStorage()) ;
+               Instance()->SetSpecificStorage(Form("%s/*", AliQAv1::GetQAName()), AliQAv1::GetQARefStorage()) ;
        }
-       TString detOCDBDir(Form("%s/%s/%s", AliQA::GetQAName(), AliQA::GetDetName((Int_t)det), AliQA::GetRefOCDBDirName())) ; 
-       AliInfo(Form("Retrieving reference data from %s/%s for %s", AliQA::GetQARefStorage(), detOCDBDir.Data(), AliQA::GetTaskName(task).Data())) ; 
+       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(AliQA::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) ; 
+  AliQADataMaker * qadm = GetQADataMaker(detIndex) ; 
+  rv = qadm->GetImage() ;
+  return rv ; 
+}
+
 //_____________________________________________________________________________
 AliLoader * AliQAManager::GetLoader(Int_t iDet)
 {
        // get the loader for a detector
 
-       if ( !fRunLoader || iDet == AliQA::kCORR) 
+       if ( !fRunLoader || iDet == AliQAv1::kCORR) 
                return NULL ; 
        
-       TString detName = AliQA::GetDetName(iDet) ;
+       TString detName = AliQAv1::GetDetName(iDet) ;
     fLoader[iDet] = fRunLoader->GetLoader(detName + "Loader");
        if (fLoader[iDet]) 
                return fLoader[iDet] ;
@@ -357,7 +394,7 @@ AliLoader * AliQAManager::GetLoader(Int_t iDet)
        TPluginHandler* pluginHandler = pluginManager->FindHandler("AliLoader", detName) ;
        // if not, add a plugin for it
        if (!pluginHandler) {
-               AliDebug(1, Form("defining plugin for %s", loaderName.Data())) ;
+               AliDebug(AliQAv1::GetQADebugLevel(), Form("defining plugin for %s", loaderName.Data())) ;
                TString libs = gSystem->GetLibraries() ;
                if (libs.Contains("lib" + detName + "base.so") || (gSystem->Load("lib" + detName + "base.so") >= 0)) {
                        pluginManager->AddHandler("AliQADataMaker", detName, loaderName, detName + "loader", loaderName + "()") ;
@@ -375,16 +412,16 @@ AliLoader * AliQAManager::GetLoader(Int_t iDet)
 }
 
 //_____________________________________________________________________________
-AliQA * AliQAManager::GetQA(UInt_t run, UInt_t evt) 
+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() ; 
@@ -393,7 +430,7 @@ AliQA * AliQAManager::GetQA(UInt_t run, UInt_t evt)
   AliRunTag * tag = new AliRunTag ; 
   tagTree->SetBranchAddress("AliTAG", &tag) ; 
   tagTree->GetEntry(evt) ; 
-  AliQA * qa = AliQA::Instance(tag->GetQALength(), tag->GetQA(), tag->GetESLength(), tag->GetEventSpecies()) ; 
+  AliQAv1 * qa = AliQAv1::Instance(tag->GetQALength(), tag->GetQAArray(), tag->GetESLength(), tag->GetEventSpecies()) ; 
   tagFile->Close() ; 
   return qa ; 
 }
@@ -403,65 +440,69 @@ 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 == AliQA::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) { //Global QA
+
                qadm = new AliGlobalQADataMaker();
-               qadm->SetName(AliQA::GetDetName(iDet));
+               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 == AliQA::kCORR) { //the data maker for correlations among detectors
+       }       else if (iDet == AliQAv1::kCORR && strcmp(GetMode(), "Rec") == 0 ) { //the data maker for correlations among detectors
     qadm = new AliCorrQADataMakerRec(fQADataMaker) ; 
-               qadm->SetName(AliQA::GetDetName(iDet));
+               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 = 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) ; 
-       }
+    qadm->SetEventSpecie(fEventSpecie) ;  
+    if ( qadm->GetRecoParam() ) 
+      if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)  
+        qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ; 
 
+  } else {
+    
+    // load the QA data maker object
+    TPluginManager* pluginManager = gROOT->GetPluginManager() ;
+    TString detName = AliQAv1::GetDetName(iDet) ;
+    TString qadmName = "Ali" + detName + "QADataMaker" + GetMode() ;
+    
+    // first check if a plugin is defined for the quality assurance data maker
+    TPluginHandler* pluginHandler = pluginManager->FindHandler("AliQADataMaker", detName) ;
+    // if not, add a plugin for it
+    if (!pluginHandler) {
+      AliDebug(AliQAv1::GetQADebugLevel(), Form("defining plugin for %s", qadmName.Data())) ;
+      TString libs = gSystem->GetLibraries() ;
+      if (libs.Contains("lib" + detName + GetMode() + ".so") || (gSystem->Load("lib" + detName + GetMode() + ".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 ;
 }
 
@@ -470,20 +511,26 @@ void  AliQAManager::EndOfCycle(TObjArray * detArray)
 {
        // End of cycle QADataMakers 
        
+  if (fPrintImage) {
+    TCanvas fakeCanvas ; 
+    fakeCanvas.Print(Form("%s%s%d.%s[", AliQAv1::GetImageFileName(), GetMode(), fRunNumber, AliQAv1::GetImageFileFormat())) ; 
+  }
        for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
-               if (IsSelected(AliQA::GetDetName(iDet))) {
+               if (IsSelected(AliQAv1::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))) ;
+                               AliModule* det = static_cast<AliModule*>(detArray->FindObject(AliQAv1::GetDetName(iDet))) ;
                                if (!det || !det->IsActive())  
                                        continue ;
                        }
-                       for (UInt_t taskIndex = 0; taskIndex < AliQA::kNTASKINDEX; taskIndex++) {
+      qadm->SetPrintImage(fPrintImage) ;
+      
+                       for (UInt_t taskIndex = 0; taskIndex < AliQAv1::kNTASKINDEX; taskIndex++) {
                                if ( fTasks.Contains(Form("%d", taskIndex)) ) 
-                                       qadm->EndOfCycle(AliQA::GetTaskIndex(AliQA::GetTaskName(taskIndex))) ;
+                                       qadm->EndOfCycle(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(taskIndex))) ;
                        }
                        qadm->Finish();
                }
@@ -495,17 +542,22 @@ void  AliQAManager::EndOfCycle(TString detectors)
 {
        // End of cycle QADataMakers 
        
-       for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
-               if (IsSelected(AliQA::GetDetName(iDet))) {
+  if (fPrintImage) {
+    TCanvas fakeCanvas ; 
+    fakeCanvas.Print(Form("%s%s%d.%s[", AliQAv1::GetImageFileName(), GetMode(), fRunNumber, AliQAv1::GetImageFileFormat())) ; 
+  }
+  for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
+               if (IsSelected(AliQAv1::GetDetName(iDet))) {
                        AliQADataMaker * qadm = GetQADataMaker(iDet) ;
                        if (!qadm) 
                                continue ;      
                        // skip non active detectors
-      if (!detectors.Contains(AliQA::GetDetName(iDet))) 
+      if (!detectors.Contains(AliQAv1::GetDetName(iDet))) 
         continue ;
-               for (UInt_t taskIndex = 0; taskIndex < AliQA::kNTASKINDEX; taskIndex++) {
+      qadm->SetPrintImage(fPrintImage) ;
+               for (UInt_t taskIndex = 0; taskIndex < AliQAv1::kNTASKINDEX; taskIndex++) {
                                if ( fTasks.Contains(Form("%d", taskIndex)) ) 
-                                       qadm->EndOfCycle(AliQA::GetTaskIndex(AliQA::GetTaskName(taskIndex))) ;
+                                       qadm->EndOfCycle(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(taskIndex))) ;
                        }
                        qadm->Finish();
                }
@@ -517,7 +569,7 @@ void AliQAManager::Increment()
 {
   // Increments the cycle counter for all QA Data Makers
        for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
-               if (IsSelected(AliQA::GetDetName(iDet))) {
+               if (IsSelected(AliQAv1::GetDetName(iDet))) {
                        AliQADataMaker * qadm = GetQADataMaker(iDet) ;
                        if (qadm) 
         qadm->Increment() ;
@@ -526,13 +578,13 @@ void AliQAManager::Increment()
 }
   
 //_____________________________________________________________________________
-Bool_t AliQAManager::InitQA(const AliQA::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
        
        fTasks += Form("%d", taskIndex) ; 
 
-       if (taskIndex == AliQA::kRAWS) { 
+       if (taskIndex == AliQAv1::kRAWS) { 
                if (!fRawReader) {
                        fRawReader = AliRawReader::Create(input);
                }
@@ -546,11 +598,11 @@ Bool_t AliQAManager::InitQA(const AliQA::TASKINDEX_t taskIndex, const  char * in
                fNumberOfEvents = 999999 ;
                if ( fMaxEvents < 0 ) 
                        fMaxEvents = fNumberOfEvents ; 
-               } else if (taskIndex == AliQA::kESDS) {
-                       fTasks = AliQA::GetTaskName(AliQA::kESDS) ; 
+               } else if (taskIndex == AliQAv1::kESDS) {
+                       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 ; 
@@ -591,6 +643,10 @@ Bool_t AliQAManager::InitQA(const AliQA::TASKINDEX_t taskIndex, const  char * in
                AliGeomManager::LoadGeometry() ; 
        
        InitQADataMaker(fRunNumber, detArray) ; //, fCycleSame, kTRUE, detArray) ; 
+  if (fPrintImage) {
+    TCanvas fakeCanvas ; 
+    fakeCanvas.Print(Form("%s%s%d.%s[", AliQAv1::GetImageFileName(), GetMode(), fRunNumber, AliQAv1::GetImageFileFormat())) ;    
+  }    
        return kTRUE ; 
 }
 
@@ -598,29 +654,29 @@ Bool_t AliQAManager::InitQA(const AliQA::TASKINDEX_t taskIndex, const  char * in
 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(AliQA::GetDetName(iDet))) {
+               if (IsSelected(AliQAv1::GetDetName(iDet))) {
                        AliQADataMaker * qadm = GetQADataMaker(iDet) ;
                        if (!qadm) {
-                               AliError(Form("AliQADataMaker not found for %s", AliQA::GetDetName(iDet))) ; 
-                               fDetectorsW.ReplaceAll(AliQA::GetDetName(iDet), "") ; 
+                               AliError(Form("AliQADataMaker not found for %s", AliQAv1::GetDetName(iDet))) ; 
+                               fDetectorsW.ReplaceAll(AliQAv1::GetDetName(iDet), "") ; 
                        } else {
         if (fQAWriteExpert[iDet])
           qadm->SetWriteExpert() ; 
-                               AliDebug(1, Form("Data Maker found for %s", qadm->GetName())) ; 
+                               AliDebug(AliQAv1::GetQADebugLevel(), Form("Data Maker found for %s %d", qadm->GetName(), qadm->WriteExpert())) ; 
                                // skip non active detectors
                                if (detArray) {
-                                       AliModule* det = static_cast<AliModule*>(detArray->FindObject(AliQA::GetDetName(iDet))) ;
+                                       AliModule* det = static_cast<AliModule*>(detArray->FindObject(AliQAv1::GetDetName(iDet))) ;
                                        if (!det || !det->IsActive())  
                                                continue ;
                                }
-                               if (fQAWriteExpert[iDet]) qadm->SetWriteExpert() ; 
              // Set default reco params
         Bool_t sameCycle = kFALSE ; 
-                               for (UInt_t taskIndex = 0; taskIndex < AliQA::kNTASKINDEX; taskIndex++) {
+                               for (UInt_t taskIndex = 0; taskIndex < AliQAv1::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) ;
+                                               qadm->Init(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(taskIndex)), GetQACycles(qadm->GetUniqueID())) ;
+            qadm->StartOfCycle(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(taskIndex)), run,  sameCycle) ;
             sameCycle = kTRUE ;
                                        }
                                }
@@ -641,9 +697,9 @@ Bool_t AliQAManager::InitRunLoader()
                        // load all base libraries to get the loader classes
                        TString libs = gSystem->GetLibraries() ;
                        for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
-                               if (!IsSelected(AliQA::GetDetName(iDet))) 
+                               if (!IsSelected(AliQAv1::GetDetName(iDet))) 
                                        continue ; 
-                               TString detName = AliQA::GetDetName(iDet) ;
+                               TString detName = AliQAv1::GetDetName(iDet) ;
                                if (detName == "HLT") 
                                        continue;
                                if (libs.Contains("lib" + detName + "base.so")) 
@@ -679,7 +735,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
@@ -687,7 +743,7 @@ Bool_t AliQAManager::IsSelected(const char * det)
        Bool_t rv = kFALSE;
        const TString detName(det) ;
   // always activates Correlation
-  if ( detName.Contains(AliQA::GetDetName(AliQA::kCORR))) {
+  if ( detName.Contains(AliQAv1::GetDetName(AliQAv1::kCORR))) {
     rv = kTRUE ; 
   } else {
     // check if all detectors are selected
@@ -705,58 +761,249 @@ Bool_t AliQAManager::IsSelected(const char * det)
 }
 
 //_____________________________________________________________________________
-Bool_t AliQAManager::Merge(const Int_t runNumber) const
+Bool_t AliQAManager::Merge(Int_t runNumber, const char *fileName) 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) ;
+       // 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
+  // The 'fileName' is name of the output file with merged QA data  
+ if ( runNumber == -1)
+   runNumber = fRunNumber ; 
+ Bool_t rv = MergeData(runNumber,fileName) ; 
+ //rv *= MergeResults(runNumber) ; // not needed for the time being
  return rv ; 
 }
        
-       
+//______________________________________________________________________
+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))
+  //              collection: is a xml collection  
+  
+  Bool_t rv = kFALSE ; 
+  
+  if ( strstr(collectionFile, ".xml") == 0 ) {
+    AliError("Input collection file must be an \".xml\" file\n") ; 
+    return kFALSE ; 
+  }
+    
+ if ( !gGrid ) 
+   TGrid::Connect("alien://"); 
+ if ( !gGrid ) 
+   return kFALSE ; 
+  // Open the file collection 
+  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_t * turl ;
+  TFileMerger merger(kFALSE) ; 
+  if (!outFile) {
+    TString tempo(collectionFile) ; 
+    if ( subFile) 
+      tempo.ReplaceAll(".xml", subFile) ; 
+    else 
+      tempo.ReplaceAll(".xml", "_Merged.root") ; 
+    outFile = tempo.Data() ; 
+  }
+  merger.OutputFile(outFile) ; 
+  
+  while ( (turl = result->GetKey(index, "turl")) ) {
+    Char_t * file ;
+    if ( subFile )
+      file = Form("%s#%s", turl, subFile) ; 
+    else 
+      file = Form("%s", turl) ; 
+    
+    AliDebug(AliQAv1::GetQADebugLevel(), Form("%s\n", file)) ; 
+    merger.AddFile(file) ; 
+    index++ ;  
+  }
+  
+  if (index) 
+    merger.Merge() ; 
+  
+  AliDebug(AliQAv1::GetQADebugLevel(), Form("Files merged into %s\n", outFile)) ;
+  
+  rv = kFALSE;
+  return rv ;
+}
+
 //_____________________________________________________________________________
-Bool_t AliQAManager::MergeData(const Int_t runNumber) const
+void AliQAManager::MergeCustom() const
 {
-       // Merge all the cycles from all detectors in one single file per run
-       TString cmd ;
-       if (runNumber != -1) 
-               cmd = Form(".! ls *%s*.%d.root > tempo.txt", AliQA::GetQADataFileName(), runNumber) ; 
-       else 
-               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 index = 0 ; 
-       while ( 1 ) {
-               in >> file[index] ; 
-               if ( !in.good() ) 
-                       break ; 
-               AliInfo(Form("index = %d file = %s", index, (file[index]).Data())) ; 
-               index++ ;
-       }
-       
-       if ( index == 0 ) { 
-               AliError(Form("run number %d not found", runNumber)) ; 
-               return kFALSE ; 
-       }
+       // Custom Merge of QA data from all detectors for all runs in one single file 
+  // search all the run numbers
+  // search all the run numbers
+  gROOT->ProcessLine(".! ls *QA*.root > QAtempo.txt") ;
+  TString QAfile ; 
+  FILE * QAfiles = fopen("QAtempo.txt", "r") ; 
+  Int_t index = 0 ; 
+  TList srunList ; 
+  TIter nextRun(&srunList) ; 
+  TObjString * srun = NULL ; 
+  Int_t loRun = 999999999 ; 
+  Int_t hiRun = 0 ; 
+  while ( QAfile.Gets(QAfiles) ) {
+    Bool_t runExist = kFALSE ; 
+    TString srunNew(QAfile(QAfile.Index("QA.")+3, QAfile.Index(".root")-(QAfile.Index("QA.")+3))) ; 
+    Int_t cuRun = srunNew.Atoi() ;
+    if (cuRun < loRun) 
+      loRun = cuRun ; 
+    if (cuRun > hiRun)
+      hiRun = cuRun ; 
+    while ( (srun = static_cast<TObjString *> (nextRun())) ) {
+      if ( cuRun == (srun->String()).Atoi() ) {
+        runExist = kTRUE ; 
+        break ; 
+      } 
+    }
+    nextRun.Reset() ; 
+    if ( ! runExist ) 
+      srunList.Add(new TObjString(srunNew.Data()));
+  }
+  nextRun.Reset() ;    
+  Int_t runNumber = 0 ; 
+  TFile mergedFile(Form("Merged.%s.Data.root", AliQAv1::GetQADataFileName()), "RECREATE") ; 
+  TH1I * hisRun = new TH1I("hLMR", "List of merged runs", hiRun-loRun+10, loRun, hiRun+10) ; 
+  // create the structure into the merged file
+  for (Int_t iDet = 0; iDet < AliQAv1::kNDET ; iDet++) {
+    TDirectory * detDir = mergedFile.mkdir(AliQAv1::GetDetName(iDet)) ; 
+    for (Int_t taskIndex = 0; taskIndex < AliQAv1::kNTASKINDEX; taskIndex++) {
+      detDir->cd() ; 
+      TDirectory * taskDir = gDirectory->mkdir(AliQAv1::GetTaskName(taskIndex)) ; 
+      for (Int_t es = 0 ; es < AliRecoParam::kNSpecies ; es++) {
+        taskDir->cd() ; 
+        TDirectory * esDir = gDirectory->mkdir(AliRecoParam::GetEventSpecieName(es)) ;
+        esDir->cd() ; 
+        gDirectory->mkdir(AliQAv1::GetExpert()) ; 
+      }
+    }
+  }
+  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_t * fileList[AliQAv1::kNDET] ;
+    index = 0 ; 
+    for (Int_t iDet = 0; iDet < AliQAv1::kNDET ; iDet++) {
+      Char_t * file = gSystem->Which(gSystem->WorkingDirectory(), Form("%s.%s.%d.root", AliQAv1::GetDetName(iDet), AliQAv1::GetQADataFileName(), runNumber)); 
+      if (file) 
+        fileList[index++] = file ;
+    }
+    if ( index == 0 ) {
+      AliError("No QA data file found\n") ; 
+      return ; 
+    }
+    for ( Int_t i = 0 ; i < index ; i++) {
+      TFile * inFile = TFile::Open(fileList[i]) ;  
+      TList * listOfKeys =inFile->GetListOfKeys() ; 
+      TIter nextkey(listOfKeys) ; 
+      TObject * obj1 ; 
+      TString dirName("") ; 
+      while ( (obj1 = nextkey()) ) {
+        TDirectory * directoryDet = inFile->GetDirectory(obj1->GetName()) ; 
+        if ( directoryDet ) {
+          AliDebug(AliQAv1::GetQADebugLevel(), Form("%s dir = %s", inFile->GetName(), directoryDet->GetName())) ; 
+          dirName += Form("%s/", directoryDet->GetName() ) ; 
+          directoryDet->cd() ;
+          TList * listOfTasks = directoryDet->GetListOfKeys() ; 
+          TIter nextTask(listOfTasks) ; 
+          TObject * obj2 ; 
+          while ( (obj2 = nextTask()) ) {
+            TDirectory * directoryTask = directoryDet->GetDirectory(obj2->GetName()) ; 
+            if ( directoryTask ) {
+              dirName += Form("%s", obj2->GetName()) ; 
+              AliDebug(AliQAv1::GetQADebugLevel(), Form("%s", dirName.Data())) ; 
+              directoryTask->cd() ; 
+              TList * listOfEventSpecie = directoryTask->GetListOfKeys() ; 
+              TIter nextEventSpecie(listOfEventSpecie) ; 
+              TObject * obj3 ; 
+              while ( (obj3 = nextEventSpecie()) ) {
+                TDirectory * directoryEventSpecie = directoryTask->GetDirectory(obj3->GetName()) ; 
+                if ( directoryEventSpecie ) {
+                  dirName += Form("/%s/", obj3->GetName()) ; 
+                  AliDebug(AliQAv1::GetQADebugLevel(), Form("%s\n", dirName.Data())) ; 
+                  directoryEventSpecie->cd() ; 
+                  // histograms are here
+                  TDirectory * mergedDirectory = mergedFile.GetDirectory(dirName.Data()) ;
+                  TList * listOfData = directoryEventSpecie->GetListOfKeys() ; 
+                  TIter nextData(listOfData) ; 
+                  TKey * key ; 
+                  while ( (key = static_cast<TKey *>(nextData())) ) {
+                    TString className(key->GetClassName()) ; 
+                    if (  className.Contains("TH") || className.Contains("TProfile") ) {
+                      TH1 * histIn = static_cast<TH1*> (key->ReadObj()) ; 
+                      TH1 * histOu = static_cast<TH1*> (mergedDirectory->FindObjectAny(histIn->GetName())) ; 
+                      AliDebug(AliQAv1::GetQADebugLevel(), Form("%s %x %x\n", key->GetName(), histIn, histOu)) ; 
+                      mergedDirectory->cd() ; 
+                      if ( ! histOu ) {
+                        histIn->Write() ; 
+                      } else {
+                        histOu->Add(histIn) ; 
+                        histOu->Write(histOu->GetName(), kOverwrite) ; 
+                      }
+                    }
+                    else if ( className.Contains("TDirectoryFile") ) {
+                      TDirectory * dirExpert = directoryEventSpecie->GetDirectory(key->GetName()) ; 
+                      dirExpert->cd() ; 
+                      TDirectory * mergedDirectoryExpert = mergedDirectory->GetDirectory(dirExpert->GetName()) ; 
+                      TList * listOfExpertData = dirExpert->GetListOfKeys() ; 
+                      TIter nextExpertData(listOfExpertData) ; 
+                      TKey * keykey ; 
+                      while ( (keykey = static_cast<TKey *>(nextExpertData())) ) {
+                        TString classNameExpert(keykey->GetClassName()) ; 
+                        if (classNameExpert.Contains("TH")) {
+                          TH1 * histInExpert = static_cast<TH1*> (keykey->ReadObj()) ; 
+                          TH1 * histOuExpert = static_cast<TH1*> (mergedDirectory->FindObjectAny(histInExpert->GetName())) ; 
+                          mergedDirectoryExpert->cd() ; 
+                          if ( ! histOuExpert ) {
+                            histInExpert->Write() ; 
+                          } else {
+                            histOuExpert->Add(histInExpert) ; 
+                            histOuExpert->Write(histOuExpert->GetName(), kOverwrite) ; 
+                          }
+                        }
+                      }
+                    } else {
+                      AliError(Form("No merge done for this object %s in %s", key->GetName(), dirName.Data())) ; 
+                    }
+                  }
+                  dirName.ReplaceAll(Form("/%s/",obj3->GetName()), "") ; 
+                }
+              }
+              dirName.ReplaceAll(obj2->GetName(), "") ; 
+            }
+          }
+        }
+      }
+      inFile->Close() ; 
+    }
+  }
+  mergedFile.cd() ;
+  hisRun->Write() ; 
+  mergedFile.Close() ; 
+  srunList.Delete() ;   
+}
 
-  TFileMerger merger ; 
-  TString outFileName ;
-  if (runNumber != -1) 
-    outFileName = Form("Merged.%s.Data.%d.root",AliQA::GetQADataFileName(),runNumber); 
-  else 
-    outFileName = Form("Merged.%s.Data.root",AliQA::GetQADataFileName()); 
+//_____________________________________________________________________________
+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(kFALSE) ; 
+  TString outFileName = fileName;
+  if (outFileName.IsNull()) outFileName.Form("Merged.%s.Data.root",AliQAv1::GetQADataFileName());
   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) ; 
-    }
-       }
+  for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
+    Char_t * file = gSystem->Which(gSystem->WorkingDirectory(), Form("%s.%s.%d.root", AliQAv1::GetDetName(iDet), AliQAv1::GetQADataFileName(), runNumber)); 
+    if (file) 
+      merger.AddFile(file) ; 
+  }
   merger.Merge() ; 
        return kTRUE ; 
 }
@@ -765,8 +1012,9 @@ Bool_t AliQAManager::MergeData(const Int_t runNumber) const
 Bool_t AliQAManager::MergeResults(const Int_t runNumber) const
 {
        // Merge the QA result from all the data chunks in a run 
+  // to be revised whwn it will be used (see MergeData)
        TString cmd ;
-       cmd = Form(".! ls %s*.root > tempo.txt", AliQA::GetQADataFileName()) ; 
+       cmd = Form(".! ls %s*.root > tempo.txt", AliQAv1::GetQADataFileName()) ; 
        gROOT->ProcessLine(cmd.Data()) ;
        ifstream in("tempo.txt") ; 
        const Int_t chunkMax = 100 ;  
@@ -778,7 +1026,7 @@ Bool_t AliQAManager::MergeResults(const Int_t runNumber) const
                in >> fileList[index] ; 
                if ( !in.good() ) 
                        break ; 
-               AliInfo(Form("index = %d file = %s", index, (fileList[index].Data()))) ; 
+               AliDebug(AliQAv1::GetQADebugLevel(), Form("index = %d file = %s", index, (fileList[index].Data()))) ; 
                index++ ;
        }
        
@@ -790,9 +1038,9 @@ Bool_t AliQAManager::MergeResults(const Int_t runNumber) const
        TFileMerger merger ; 
   TString outFileName ;
   if (runNumber != -1) 
-    outFileName = Form("Merged.%s.Result.%d.root",AliQA::GetQADataFileName(),runNumber); 
+    outFileName = Form("Merged.%s.Result.%d.root",AliQAv1::GetQADataFileName(),runNumber); 
   else 
-    outFileName = Form("Merged.%s.Result.root",AliQA::GetQADataFileName()); 
+    outFileName = Form("Merged.%s.Result.root",AliQAv1::GetQADataFileName()); 
        merger.OutputFile(outFileName.Data()) ; 
        for (Int_t ifile = 0 ; ifile < index ; ifile++) {
                TString file = fileList[ifile] ; 
@@ -809,7 +1057,7 @@ void AliQAManager::Reset(const Bool_t sameCycle)
        // Reset the default data members
 
        for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
-               if (IsSelected(AliQA::GetDetName(iDet))) {
+               if (IsSelected(AliQAv1::GetDetName(iDet))) {
                        AliQADataMaker * qadm = GetQADataMaker(iDet);
                        qadm->Reset();
                }
@@ -832,6 +1080,8 @@ AliQAManager * AliQAManager::QAManager(const Char_t * mode, TMap *entryCache, In
   // returns AliQAManager instance (singleton)
   
        if (!fgQAInstance) {
+    if ( (strcmp(mode, "sim") != 0) && (strcmp(mode, "rec") != 0) )
+      AliFatalClass("You must specify sim or rec") ; 
     fgQAInstance = new AliQAManager(mode) ;  
     if (!entryCache)
                  fgQAInstance->Init();
@@ -842,7 +1092,7 @@ AliQAManager * AliQAManager::QAManager(const Char_t * mode, TMap *entryCache, In
 }
 
 //_____________________________________________________________________________
-TString AliQAManager::Run(const char * detectors, AliRawReader * rawReader, const Bool_t sameCycle) 
+TString AliQAManager::Run(const Char_t * detectors, AliRawReader * rawReader, const Bool_t sameCycle) 
 {
        //Runs all the QA data Maker for Raws only
        
@@ -860,16 +1110,16 @@ TString AliQAManager::Run(const char * detectors, AliRawReader * rawReader, cons
        }       
        
        if (!fCycleSame) 
-    if ( !InitQA(AliQA::kRAWS) ) 
+    if ( !InitQA(AliQAv1::kRAWS) ) 
       return kFALSE ; 
   fRawReaderDelete = kFALSE ; 
 
-       DoIt(AliQA::kRAWS) ; 
+       DoIt(AliQAv1::kRAWS) ; 
        return  fDetectorsW ;
 }
 
 //_____________________________________________________________________________
-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
 
@@ -895,15 +1145,15 @@ TString AliQAManager::Run(const char * detectors, const char * fileName, const B
        }
        
        if (!fCycleSame) 
-    if ( !InitQA(AliQA::kRAWS, fileName) ) 
+    if ( !InitQA(AliQAv1::kRAWS, fileName) ) 
       return kFALSE ; 
        
-       DoIt(AliQA::kRAWS) ; 
+       DoIt(AliQAv1::kRAWS) ; 
        return  fDetectorsW ;
 }
 
 //_____________________________________________________________________________
-TString AliQAManager::Run(const char * detectors, const AliQA::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
        
@@ -920,22 +1170,20 @@ TString AliQAManager::Run(const char * detectors, const AliQA::TASKINDEX_t taskI
                        rl->CdGAFile() ; 
                        rl->LoadgAlice() ;
                        if ( ! rl->GetAliRun() ) {
-                               AliInfo("AliRun not found in galice.root") ;
+                               AliDebug(AliQAv1::GetQADebugLevel(), "AliRun not found in galice.root") ;
                        } else {
                                rl->LoadHeader() ;
                                man->SetRun(rl->GetHeader()->GetRun()) ;
                        }
                }
        }
-       
-
-       if ( taskIndex == AliQA::kNULLTASKINDEX) { 
-               for (UInt_t task = 0; task < AliQA::kNTASKINDEX; task++) {
+  if ( taskIndex == AliQAv1::kNULLTASKINDEX) { 
+               for (UInt_t task = 0; task < AliQAv1::kNTASKINDEX; task++) {
                        if ( fTasks.Contains(Form("%d", task)) ) {
         if (!fCycleSame)
-          if ( !InitQA(AliQA::GetTaskIndex(AliQA::GetTaskName(task)), fileName) ) 
+          if ( !InitQA(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(task)), fileName) ) 
             return kFALSE ;
-        DoIt(AliQA::GetTaskIndex(AliQA::GetTaskName(task))) ;
+        DoIt(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(task))) ;
                        }
                }
        } else {
@@ -944,9 +1192,7 @@ TString AliQAManager::Run(const char * detectors, const AliQA::TASKINDEX_t taskI
         return kFALSE ; 
       DoIt(taskIndex) ; 
   }            
-       
        return fDetectorsW ;
-
 }
 
 //_____________________________________________________________________________
@@ -956,9 +1202,9 @@ void AliQAManager::RunOneEvent(AliRawReader * rawReader)
   if ( ! rawReader ) 
     return ; 
        AliCodeTimerAuto("") ;
-  if (fTasks.Contains(Form("%d", AliQA::kRAWS))){
+  if (fTasks.Contains(Form("%d", AliQAv1::kRAWS))){
     for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
-      if (!IsSelected(AliQA::GetDetName(iDet))) 
+      if (!IsSelected(AliQAv1::GetDetName(iDet))) 
         continue;
       AliQADataMaker *qadm = GetQADataMaker(iDet);  
       if (!qadm) 
@@ -966,10 +1212,13 @@ void AliQAManager::RunOneEvent(AliRawReader * rawReader)
       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)));
+      AliCodeTimerStart(Form("running RAW quality assurance data maker for %s", AliQAv1::GetDetName(iDet))); 
+      qadm->SetEventSpecie(fEventSpecie) ;  
+      if ( qadm->GetRecoParam() ) 
+        if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)  
+          qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ; 
+                       qadm->Exec(AliQAv1::kRAWS, rawReader) ;
+      AliCodeTimerStop(Form("running RAW quality assurance data maker for %s", AliQAv1::GetDetName(iDet)));
                }
   }
 }
@@ -980,19 +1229,23 @@ void AliQAManager::RunOneEvent(AliESDEvent *& esd)
        //Runs all the QA data Maker for ESDs only and on one event only (event loop done by calling method)
        
   AliCodeTimerAuto("") ;
-  if (fTasks.Contains(Form("%d", AliQA::kESDS))) {
+  if (fTasks.Contains(Form("%d", AliQAv1::kESDS))) {
     for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
-      if (!IsSelected(AliQA::GetDetName(iDet))) 
+      if (!IsSelected(AliQAv1::GetDetName(iDet))) 
         continue;
       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", AliQA::GetDetName(iDet)));
-                       qadm->Exec(AliQA::kESDS, esd) ;
-      AliCodeTimerStop(Form("running ESD quality assurance data maker for %s", AliQA::GetDetName(iDet)));
+      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)));
                }
        }
 }
@@ -1001,34 +1254,44 @@ 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)
+  
+  TString test(tree->GetName()) ; 
        AliCodeTimerAuto("") ;
-  if (fTasks.Contains(Form("%d", AliQA::kRECPOINTS))) {
-    if (IsSelected(AliQA::GetDetName(det))) {
+  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()) ;         
         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)));
+        AliCodeTimerStart(Form("running RecPoints quality assurance data maker for %s", AliQAv1::GetDetName(det)));
+        if (test.Contains("TreeD")) {
+          qadm->Exec(AliQAv1::kDIGITSR, tree) ;
+        } else  if (test.Contains("TreeR")) {
+          qadm->Exec(AliQAv1::kRECPOINTS, tree) ;
+          AliCodeTimerStop(Form("running RecPoints quality assurance data maker for %s", AliQAv1::GetDetName(det)));
+        }
       }
     }
   }
 }
 
 //_____________________________________________________________________________
-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 ; 
-       TString tmp(AliQA::GetQARefStorage()) ; 
+       TString tmp(AliQAv1::GetQARefStorage()) ; 
        if ( tmp.IsNull() ) { 
-               AliError("No storage defined, use AliQA::SetQARefStorage") ; 
+               AliError("No storage defined, use AliQAv1::SetQARefStorage") ; 
                return kFALSE ; 
        }
-       if ( !(tmp.Contains(AliQA::GetLabLocalOCDB()) || tmp.Contains(AliQA::GetLabAliEnOCDB())) ) {
-               AliError(Form("%s is a wrong storage, use %s or %s", AliQA::GetQARefStorage(), AliQA::GetLabLocalOCDB().Data(), AliQA::GetLabAliEnOCDB().Data())) ; 
+       if ( !(tmp.Contains(AliQAv1::GetLabLocalOCDB()) || tmp.Contains(AliQAv1::GetLabAliEnOCDB())) ) {
+               AliError(Form("%s is a wrong storage, use %s or %s", AliQAv1::GetQARefStorage(), AliQAv1::GetLabLocalOCDB().Data(), AliQAv1::GetLabAliEnOCDB().Data())) ; 
                return kFALSE ; 
        }
        TString sdet(detectors) ; 
@@ -1038,13 +1301,13 @@ Bool_t AliQAManager::Save2OCDB(const Int_t runNumber, AliRecoParam::EventSpecie_
                rv = Merge(runNumber) ; 
                if ( ! rv )
                        return kFALSE ; 
-               TString inputFileName(Form("Merged.%s.Data.%d.root", AliQA::GetQADataFileName(), runNumber)) ; 
+               TString inputFileName(Form("Merged.%s.Data.%d.root", AliQAv1::GetQADataFileName(), runNumber)) ; 
                inputFile = TFile::Open(inputFileName.Data()) ; 
                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.root", AliQA::GetDetName(index), AliQA::GetQADataFileName(), runNumber)) ; 
+               for (Int_t index = 0; index < AliQAv1::kNDET; index++) {
+                       if (sdet.Contains(AliQAv1::GetDetName(index))) {
+                               TString inputFileName(Form("%s.%s.%d.root", AliQAv1::GetDetName(index), AliQAv1::GetQADataFileName(), runNumber)) ; 
                                inputFile = TFile::Open(inputFileName.Data()) ;                         
                                rv *= SaveIt2OCDB(runNumber, inputFile, year, es) ; 
                        }
@@ -1054,80 +1317,80 @@ 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 ;
-       AliInfo(Form("Saving TH1s in %s to %s", inputFile->GetName(), AliQA::GetQARefStorage())) ; 
+       AliDebug(AliQAv1::GetQADebugLevel(), Form("Saving TH1s in %s to %s", inputFile->GetName(), AliQAv1::GetQARefStorage())) ; 
        if ( ! IsDefaultStorageSet() ) {
-               TString tmp( AliQA::GetQARefStorage() ) ; 
-               if ( tmp.Contains(AliQA::GetLabLocalOCDB()) ) 
-                       Instance()->SetDefaultStorage(AliQA::GetQARefStorage()) ;
+               TString tmp( AliQAv1::GetQARefStorage() ) ; 
+               if ( tmp.Contains(AliQAv1::GetLabLocalOCDB()) ) 
+                       Instance()->SetDefaultStorage(AliQAv1::GetQARefStorage()) ;
                else {
-                       TString tmp1(AliQA::GetQARefDefaultStorage()) ; 
+                       TString tmp1(AliQAv1::GetQARefDefaultStorage()) ; 
                        tmp1.Append(year) ; 
                        tmp1.Append("?user=alidaq") ; 
                        Instance()->SetDefaultStorage(tmp1.Data()) ; 
                }
        }
-       Instance()->SetSpecificStorage("*", AliQA::GetQARefStorage()) ; 
+       Instance()->SetSpecificStorage("*", AliQAv1::GetQARefStorage()) ; 
        if(GetRun() < 0) 
                Instance()->SetRun(runNumber);
 
        AliCDBMetaData mdr ;
        mdr.SetResponsible("yves schutz");
 
-       for ( Int_t detIndex = 0 ; detIndex < AliQA::kNDET ; detIndex++) {
-               TDirectory * detDir = inputFile->GetDirectory(AliQA::GetDetName(detIndex)) ; 
+       for ( Int_t detIndex = 0 ; detIndex < AliQAv1::kNDET ; detIndex++) {
+               TDirectory * detDir = inputFile->GetDirectory(AliQAv1::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())) ; 
+                       AliDebug(AliQAv1::GetQADebugLevel(), Form("Entering %s", detDir->GetName())) ;
+      AliQAv1::SetQARefDataDirName(es) ;
+                       TString detOCDBDir(Form("%s/%s/%s", AliQAv1::GetDetName(detIndex), AliQAv1::GetRefOCDBDirName(), AliQAv1::GetRefDataDirName())) ; 
                        AliCDBId idr(detOCDBDir.Data(), runNumber, AliCDBRunRange::Infinity())  ;
                        TList * listDetQAD = new TList() ;
-                       TString listName(Form("%s QA data Reference", AliQA::GetDetName(detIndex))) ; 
-                       mdr.SetComment(Form("%s QA stuff", AliQA::GetDetName(detIndex)));
+                       TString listName(Form("%s QA data Reference", AliQAv1::GetDetName(detIndex))) ; 
+                       mdr.SetComment(Form("%s QA stuff", AliQAv1::GetDetName(detIndex)));
                        listDetQAD->SetName(listName) ; 
                        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)) ; 
-                               AliInfo(Form("Saving %s", esDir->GetName())) ; 
+                               AliDebug(AliQAv1::GetQADebugLevel(), Form("Saving %s", esDir->GetName())) ; 
                                TObjArray * listTaskQAD = new TObjArray(100) ; 
                                listTaskQAD->SetName(Form("%s/%s", taskKey->GetName(), AliRecoParam::GetEventSpecieName(es))) ;
                                listDetQAD->Add(listTaskQAD) ; 
                                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())) ;
                                        } else {
-            if ( AliQA::GetExpert() == histKey->GetName() ) {
+            if ( AliQAv1::GetExpert() == histKey->GetName() ) {
               TDirectory * expertDir   = esDir->GetDirectory(histKey->GetName()) ; 
               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())) ;
                 } else {
-                  AliInfo(Form("Adding %s", expertHistKey->GetName())) ;
+                  AliDebug(AliQAv1::GetQADebugLevel(), Form("Adding %s", expertHistKey->GetName())) ;
                   if ( expertOdata->IsA()->InheritsFrom("TH1") ) {
-                    AliInfo(Form("Adding %s", expertHistKey->GetName())) ;
+                    AliDebug(AliQAv1::GetQADebugLevel(), Form("Adding %s", expertHistKey->GetName())) ;
                     TH1 * hExpertdata = static_cast<TH1*>(expertOdata) ; 
                     listTaskQAD->Add(hExpertdata) ; 
                   }                  
                 }                
               }
             }
-                                               AliInfo(Form("Adding %s", histKey->GetName())) ;
+                                               AliDebug(AliQAv1::GetQADebugLevel(), Form("Adding %s", histKey->GetName())) ;
                                                if ( odata->IsA()->InheritsFrom("TH1") ) {
-                                                       AliInfo(Form("Adding %s", histKey->GetName())) ;
+                                                       AliDebug(AliQAv1::GetQADebugLevel(), Form("Adding %s", histKey->GetName())) ;
                                                        TH1 * hdata = static_cast<TH1*>(odata) ; 
                                                        listTaskQAD->Add(hdata) ; 
                                                }
@@ -1143,9 +1406,9 @@ Bool_t AliQAManager::SaveIt2OCDB(const Int_t runNumber, TFile * inputFile, const
 //_____________________________________________________________________________
 void AliQAManager::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) ; 
+  // set the current event specie and inform AliQAv1 that this event specie has been encountered
+  fEventSpecie = es ; 
+  AliQAv1::Instance()->SetEventSpecie(es) ; 
 }
 
 //_____________________________________________________________________________
@@ -1156,4 +1419,24 @@ void AliQAManager::SetRecoParam(const Int_t det, const AliDetectorRecoParam *par
   GetQADataMaker(det)->SetRecoParam(par) ; 
 }
 
+//_____________________________________________________________________________
+void AliQAManager::SetWriteExpert()
+{
+  // enable the writing of QA expert data
+  for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
+       if (IsSelected(AliQAv1::GetDetName(iDet))) 
+      fQAWriteExpert[iDet] = kTRUE ;
+  }
+}  
+
+//_____________________________________________________________________________
+void AliQAManager::Destroy() {
+// delete AliQAManager instance and
+// all associated objects
+
+  if (fgQAInstance) {
+    delete fgQAInstance ;
+    fgQAInstance = NULL ;
+  }
+}