]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliQAManager.cxx
Changes in QA to be able to process separately different triggers (Ruben)
[u/mrichter/AliRoot.git] / STEER / AliQAManager.cxx
index d8b2f10e7a8bbd92056ca81823751c7102514409..1d944674ac71c68d0e118144755964705ed5f425 100644 (file)
@@ -94,15 +94,15 @@ AliQAManager::AliQAManager() :
   fPrintImage(kTRUE), 
   fSaveData(kTRUE) 
 {
-       // default ctor
-       fMaxEvents = fNumberOfEvents ; 
-       for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
-               if (IsSelected(AliQAv1::GetDetName(iDet))) {
-                       fLoader[iDet]      = NULL ;
-                       fQADataMaker[iDet] = NULL ;
-                       fQACycles[iDet]    = 999999 ;
-               }
-       }       
+  // default ctor
+  fMaxEvents = fNumberOfEvents ; 
+  for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
+    if (IsSelected(AliQAv1::GetDetName(iDet))) {
+      fLoader[iDet]      = NULL ;
+      fQADataMaker[iDet] = NULL ;
+      fQACycles[iDet]    = 999999 ;
+    }
+  }    
   SetWriteExpert() ; 
 }
 
@@ -110,33 +110,33 @@ AliQAManager::AliQAManager() :
 AliQAManager::AliQAManager(AliQAv1::MODE_t mode, const Char_t* gAliceFilename) :
   AliCDBManager(), 
   fCurrentEvent(0),  
-       fCycleSame(kFALSE),
-       fDetectors("ALL"), 
-       fDetectorsW("ALL"), 
-       fESD(NULL), 
-       fESDTree(NULL),
-       fGAliceFileName(gAliceFilename), 
-       fFirstEvent(0),        
-       fMaxEvents(0),   
+  fCycleSame(kFALSE),
+  fDetectors("ALL"), 
+  fDetectorsW("ALL"), 
+  fESD(NULL), 
+  fESDTree(NULL),
+  fGAliceFileName(gAliceFilename), 
+  fFirstEvent(0),        
+  fMaxEvents(0),   
   fMode(AliQAv1::GetModeName(mode)), 
-       fNumberOfEvents(999999), 
+  fNumberOfEvents(999999), 
   fRecoParam(),
-       fRunNumber(0), 
-       fRawReader(NULL), 
-       fRawReaderDelete(kTRUE), 
-       fRunLoader(NULL), 
+  fRunNumber(0), 
+  fRawReader(NULL), 
+  fRawReaderDelete(kTRUE), 
+  fRunLoader(NULL), 
   fTasks(""), 
   fEventSpecie(AliRecoParam::kDefault), 
   fPrintImage(kTRUE), 
   fSaveData(kTRUE) 
 {
-       // default ctor
-       fMaxEvents = fNumberOfEvents ; 
-       for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
-               if (IsSelected(AliQAv1::GetDetName(iDet))) {
-                       fLoader[iDet]      = NULL ;
-                       fQADataMaker[iDet] = NULL ;
-                       fQACycles[iDet]    = 999999 ;
+  // default ctor
+  fMaxEvents = fNumberOfEvents ; 
+  for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
+    if (IsSelected(AliQAv1::GetDetName(iDet))) {
+      fLoader[iDet]      = NULL ;
+      fQADataMaker[iDet] = NULL ;
+      fQACycles[iDet]    = 999999 ;
     }
   }
   SetWriteExpert() ; 
@@ -145,33 +145,33 @@ AliQAManager::AliQAManager(AliQAv1::MODE_t mode, const Char_t* gAliceFilename) :
 //_____________________________________________________________________________
 AliQAManager::AliQAManager(const AliQAManager & qas) : 
   AliCDBManager(), 
-       fCurrentEvent(qas.fCurrentEvent),  
-       fCycleSame(kFALSE),
-       fDetectors(qas.fDetectors), 
-       fDetectorsW(qas.fDetectorsW), 
-       fESD(NULL), 
-       fESDTree(NULL), 
-       fGAliceFileName(qas.fGAliceFileName), 
-       fFirstEvent(qas.fFirstEvent),        
-       fMaxEvents(qas.fMaxEvents),    
-       fMode(qas.fMode), 
-       fNumberOfEvents(qas.fNumberOfEvents), 
-       fRecoParam(),           
-       fRunNumber(qas.fRunNumber), 
-       fRawReader(NULL), 
-       fRawReaderDelete(kTRUE), 
-       fRunLoader(NULL), 
+  fCurrentEvent(qas.fCurrentEvent),  
+  fCycleSame(kFALSE),
+  fDetectors(qas.fDetectors), 
+  fDetectorsW(qas.fDetectorsW), 
+  fESD(NULL), 
+  fESDTree(NULL), 
+  fGAliceFileName(qas.fGAliceFileName), 
+  fFirstEvent(qas.fFirstEvent),        
+  fMaxEvents(qas.fMaxEvents),    
+  fMode(qas.fMode), 
+  fNumberOfEvents(qas.fNumberOfEvents), 
+  fRecoParam(),                
+  fRunNumber(qas.fRunNumber), 
+  fRawReader(NULL), 
+  fRawReaderDelete(kTRUE), 
+  fRunLoader(NULL), 
   fTasks(qas.fTasks), 
   fEventSpecie(qas.fEventSpecie), 
   fPrintImage(qas.fPrintImage), 
   fSaveData(qas.fSaveData) 
 
 {
-       // 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] ;   
+  // 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] ;      
     fQAWriteExpert[iDet] = qas.fQAWriteExpert[iDet] ;
   }
 }
@@ -179,7 +179,7 @@ AliQAManager::AliQAManager(const AliQAManager & qas) :
 //_____________________________________________________________________________
 AliQAManager & AliQAManager::operator = (const AliQAManager & qas) 
 {
-       // assignment operator
+  // assignment operator
   this->~AliQAManager() ;
   new(this) AliQAManager(qas) ;
   return *this ;
@@ -188,72 +188,72 @@ AliQAManager & AliQAManager::operator = (const AliQAManager & qas)
 //_____________________________________________________________________________
 AliQAManager::~AliQAManager() 
 {
-       // dtor
-       for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
-               if (IsSelected(AliQAv1::GetDetName(iDet))) {
-                 fLoader[iDet] = NULL;
-                 if (fQADataMaker[iDet]) {
-                         (fQADataMaker[iDet])->Finish() ; 
-                               delete fQADataMaker[iDet] ;
-                 }
-               }
-       }
-       if (fRawReaderDelete) { 
-               fRunLoader = NULL ;
-               delete fRawReader ;
-               fRawReader = NULL ;
-       }
+  // dtor
+  for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
+    if (IsSelected(AliQAv1::GetDetName(iDet))) {
+      fLoader[iDet] = NULL;
+      if (fQADataMaker[iDet]) {
+       (fQADataMaker[iDet])->Finish() ; 
+       delete fQADataMaker[iDet] ;
+      }
+    }
+  }
+  if (fRawReaderDelete) { 
+    fRunLoader = NULL ;
+    delete fRawReader ;
+    fRawReader = NULL ;
+  }
 }
 //_____________________________________________________________________________
 Bool_t AliQAManager::DoIt(const AliQAv1::TASKINDEX_t taskIndex)
 {
-       // Runs all the QA data Maker for every detector
+  // Runs all the QA data Maker for every detector
                
-       Bool_t rv = kFALSE ;
-    // Fill QA data in event loop 
-       for (UInt_t iEvent = fFirstEvent ; iEvent < (UInt_t)fMaxEvents ; iEvent++) {
-               fCurrentEvent++ ; 
-               // Get the event
-               if ( iEvent%10 == 0  ) 
-                       AliDebug(AliQAv1::GetQADebugLevel(), Form("processing event %d", iEvent));
-               if ( taskIndex == AliQAv1::kRAWS ) {
-                       if ( !fRawReader->NextEvent() )
-                               break ;
-               } else if ( taskIndex == AliQAv1::kESDS ) {
-                       if ( fESDTree->GetEntry(iEvent) == 0 )
-                               break ;
-               } else {
-                       if ( fRunLoader->GetEvent(iEvent) != 0 )
-                               break ;
-               }
-               // loop  over active loaders
-               for (UInt_t iDet = 0; iDet < fgkNDetectors ; 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() ) {
+  Bool_t rv = kFALSE ;
+  // Fill QA data in event loop 
+  for (UInt_t iEvent = fFirstEvent ; iEvent < (UInt_t)fMaxEvents ; iEvent++) {
+    fCurrentEvent++ ; 
+    // Get the event
+    if ( iEvent%10 == 0  ) 
+      AliDebug(AliQAv1::GetQADebugLevel(), Form("processing event %d", iEvent));
+    if ( taskIndex == AliQAv1::kRAWS ) {
+      if ( !fRawReader->NextEvent() )
+       break ;
+    } else if ( taskIndex == AliQAv1::kESDS ) {
+      if ( fESDTree->GetEntry(iEvent) == 0 )
+       break ;
+    } else {
+      if ( fRunLoader->GetEvent(iEvent) != 0 )
+       break ;
+    }
+    // loop  over active loaders
+    for (UInt_t iDet = 0; iDet < fgkNDetectors ; 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() ) {
           qadm->EndOfCycle(taskIndex) ;
-                               }
-                               TTree * data = NULL ; 
-                               AliLoader* loader = GetLoader(qadm->GetUniqueID());
-                               switch (taskIndex) {
-                                       case AliQAv1::kNULLTASKINDEX : 
-                                               break ; 
-                                       case AliQAv1::kRAWS :
-                                               qadm->Exec(taskIndex, fRawReader) ; 
-                                               break ; 
-                                       case AliQAv1::kHITS :
-            if( loader ) {
-              loader->LoadHits() ; 
-              data = loader->TreeH() ; 
-              if ( ! data ) {
-                AliWarning(Form(" Hit Tree not found for  %s", AliQAv1::GetDetName(iDet))) ; 
-                break ; 
-              
-              qadm->Exec(taskIndex, data) ;
-            
-                                               break ;
-                                               case AliQAv1::kSDIGITS :
+       }
+       TTree * data = NULL ; 
+       AliLoader* loader = GetLoader(qadm->GetUniqueID());
+       switch (taskIndex) {
+       case AliQAv1::kNULLTASKINDEX : 
+         break ; 
+       case AliQAv1::kRAWS :
+         qadm->Exec(taskIndex, fRawReader) ; 
+         break ; 
+       case AliQAv1::kHITS :
+         if( loader ) {
+           loader->LoadHits() ; 
+           data = loader->TreeH() ; 
+           if ( ! data ) {
+             AliWarning(Form(" Hit Tree not found for  %s", AliQAv1::GetDetName(iDet))) ; 
+             break ; 
+           } 
+           qadm->Exec(taskIndex, data) ;
+         } 
+         break ;
+       case AliQAv1::kSDIGITS :
           {
             
             TString fileName(Form("%s.SDigits.root", AliQAv1::GetDetName(iDet))) ; 
@@ -269,104 +269,104 @@ Bool_t AliQAManager::DoIt(const AliQAv1::TASKINDEX_t taskIndex)
               }
             }
           }
-                                               break; 
-                                               case AliQAv1::kDIGITS :
-              if( loader ) {      
-                loader->LoadDigits() ; 
-                data = loader->TreeD() ; 
-                if ( ! data ) {
-                  AliWarning(Form(" Digit Tree not found for  %s", AliQAv1::GetDetName(iDet))) ; 
-                  break ; 
-                
-                qadm->Exec(taskIndex, data) ;
-              }
-            break;
-            case AliQAv1::kDIGITSR :
-              if( loader ) {      
-                loader->LoadDigits() ; 
-                data = loader->TreeD() ; 
-                if ( ! data ) {
-                  AliWarning(Form(" Digit Tree not found for  %s", AliQAv1::GetDetName(iDet))) ; 
-                  break ; 
-                
-                qadm->Exec(taskIndex, data) ;
-              }
-                                               break; 
-                                               case AliQAv1::kRECPOINTS :
-            if( loader ) {      
-              loader->LoadRecPoints() ; 
-              data = loader->TreeR() ; 
-              if (!data) {
-                AliWarning(Form("RecPoints not found for %s", AliQAv1::GetDetName(iDet))) ; 
-                break ; 
-              
-              qadm->Exec(taskIndex, data) ; 
-            }
-            break; 
-                                               case AliQAv1::kTRACKSEGMENTS :
-                                               break; 
-                                               case AliQAv1::kRECPARTICLES :
-                                               break; 
-                                               case AliQAv1::kESDS :
-                                               qadm->Exec(taskIndex, fESD) ;
-                                               break; 
-                                               case AliQAv1::kNTASKINDEX :
-                                               break; 
-                               } //task switch
-                       }
-               } // detector loop
+         break; 
+       case AliQAv1::kDIGITS :
+         if( loader ) {      
+           loader->LoadDigits() ; 
+           data = loader->TreeD() ; 
+           if ( ! data ) {
+             AliWarning(Form(" Digit Tree not found for  %s", AliQAv1::GetDetName(iDet))) ; 
+             break ; 
+           } 
+           qadm->Exec(taskIndex, data) ;
+         }
+         break;
+       case AliQAv1::kDIGITSR :
+         if( loader ) {      
+           loader->LoadDigits() ; 
+           data = loader->TreeD() ; 
+           if ( ! data ) {
+             AliWarning(Form(" Digit Tree not found for  %s", AliQAv1::GetDetName(iDet))) ; 
+             break ; 
+           } 
+           qadm->Exec(taskIndex, data) ;
+         }
+         break; 
+       case AliQAv1::kRECPOINTS :
+         if( loader ) {      
+           loader->LoadRecPoints() ; 
+           data = loader->TreeR() ; 
+           if (!data) {
+             AliWarning(Form("RecPoints not found for %s", AliQAv1::GetDetName(iDet))) ; 
+             break ; 
+           } 
+           qadm->Exec(taskIndex, data) ; 
+         }
+         break; 
+       case AliQAv1::kTRACKSEGMENTS :
+         break; 
+       case AliQAv1::kRECPARTICLES :
+         break; 
+       case AliQAv1::kESDS :
+         qadm->Exec(taskIndex, fESD) ;
+         break; 
+       case AliQAv1::kNTASKINDEX :
+         break; 
+       } //task switch
+      }
+    } // detector loop
     Increment(taskIndex) ; 
-       } // event loop 
-       // Save QA data for all detectors
+  } // event loop      
+  // Save QA data for all detectors
 
   EndOfCycle() ; 
        
-       if ( taskIndex == AliQAv1::kRAWS ) 
-               fRawReader->RewindEvents() ;
+  if ( taskIndex == AliQAv1::kRAWS ) 
+    fRawReader->RewindEvents() ;
 
-       return rv ; 
+  return rv ; 
 }
 
 //_____________________________________________________________________________
 Bool_t AliQAManager::Finish(const AliQAv1::TASKINDEX_t taskIndex) 
 {
-       // write output to file for all detectors
+  // write output to file for all detectors
   
   AliQAChecker::Instance()->SetRunNumber(fRunNumber) ; 
 
-       for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
-               if (IsSelected(AliQAv1::GetDetName(iDet))) {
-                       AliQADataMaker * qadm = GetQADataMaker(iDet) ;
-                       if (qadm) 
+  for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
+    if (IsSelected(AliQAv1::GetDetName(iDet))) {
+      AliQADataMaker * qadm = GetQADataMaker(iDet) ;
+      if (qadm) 
         qadm->EndOfCycle(taskIndex) ;
-               }
-       }
-       return kTRUE ; 
+    }
+  }
+  return kTRUE ; 
 }
 
 //_____________________________________________________________________________
 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(AliQAv1::GetQARefStorage()) ) { 
-               AliError("No storage defined, use AliQAv1::SetQARefStorage") ; 
-               return NULL ; 
-       }       
-       if ( ! IsDefaultStorageSet() ) {
-               TString tmp(AliQAv1::GetQARefDefaultStorage()) ; 
-               tmp.Append(year) ; 
-               tmp.Append("/") ; 
-               Instance()->SetDefaultStorage(tmp.Data()) ;             
-               Instance()->SetSpecificStorage(Form("%s/*", AliQAv1::GetQAName()), AliQAv1::GetQARefStorage()) ;
-       }
-       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 = static_cast<TList *>(entry->GetObject()) ;
-       if ( listDetQAD ) 
-               rv = static_cast<TObjArray *>(listDetQAD->FindObject(AliQAv1::GetTaskName(task))) ; 
-       return rv ; 
+  // Retrieve the list of QA data for a given detector and a given task 
+  TObjArray * rv = NULL ;
+  if ( !strlen(AliQAv1::GetQARefStorage()) ) { 
+    AliError("No storage defined, use AliQAv1::SetQARefStorage") ; 
+    return NULL ; 
+  }    
+  if ( ! IsDefaultStorageSet() ) {
+    TString tmp(AliQAv1::GetQARefDefaultStorage()) ; 
+    tmp.Append(year) ; 
+    tmp.Append("/") ; 
+    Instance()->SetDefaultStorage(tmp.Data()) ;                
+    Instance()->SetSpecificStorage(Form("%s/*", AliQAv1::GetQAName()), AliQAv1::GetQARefStorage()) ;
+  }
+  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 = static_cast<TList *>(entry->GetObject()) ;
+  if ( listDetQAD ) 
+    rv = static_cast<TObjArray *>(listDetQAD->FindObject(AliQAv1::GetTaskName(task))) ; 
+  return rv ; 
 }
 
 //_____________________________________________________________________________
@@ -375,54 +375,56 @@ TCanvas ** AliQAManager::GetImage(Char_t * detName)
   // retrieves QA Image for the given detector
   TCanvas ** rv = NULL ; 
   Int_t detIndex = AliQAv1::GetDetIndex(detName) ; 
-  AliQACheckerBase * qac = AliQAChecker::Instance()->GetDetQAChecker(detIndex) ; 
-  rv = qac->GetImage() ;
+  if ( detIndex != AliQAv1::kNULLDET) {
+    AliQACheckerBase * qac = AliQAChecker::Instance()->GetDetQAChecker(detIndex) ; 
+    rv = qac->GetImage() ;
+  }
   return rv ; 
 }
 
 //_____________________________________________________________________________
 AliLoader * AliQAManager::GetLoader(Int_t iDet)
 {
-       // get the loader for a detector
+  // get the loader for a detector
 
-       if ( !fRunLoader || iDet == AliQAv1::kCORR || iDet == AliQAv1::kGLOBAL ) 
-               return NULL ; 
+  if ( !fRunLoader || iDet == AliQAv1::kCORR || iDet == AliQAv1::kGLOBAL ) 
+    return NULL ; 
        
-       TString detName = AliQAv1::GetDetName(iDet) ;
-    fLoader[iDet] = fRunLoader->GetLoader(detName + "Loader");
-       if (fLoader[iDet]) 
-               return fLoader[iDet] ;
+  TString detName = AliQAv1::GetDetName(iDet) ;
+  fLoader[iDet] = fRunLoader->GetLoader(detName + "Loader");
+  if (fLoader[iDet]) 
+    return fLoader[iDet] ;
        
-       // load the QA data maker object
-       TPluginManager* pluginManager = gROOT->GetPluginManager() ;
-       TString loaderName = "Ali" + detName + "Loader" ;
-
-       AliLoader * loader = NULL ;
-       // first check if a plugin is defined for the quality assurance data maker
-       TPluginHandler* pluginHandler = pluginManager->FindHandler("AliLoader", detName) ;
-       // if not, add a plugin for it
-       if (!pluginHandler) {
-               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 + "()") ;
-               } else {
-                       pluginManager->AddHandler("AliLoader", detName, loaderName, detName, loaderName + "()") ;
-               }
-               pluginHandler = pluginManager->FindHandler("AliLoader", detName) ;
-       }
-       if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
-               loader = (AliLoader *) pluginHandler->ExecPlugin(0) ;
-       }
-       if (loader) 
-               fLoader[iDet] = loader ;
-       return loader ;
+  // load the QA data maker object
+  TPluginManager* pluginManager = gROOT->GetPluginManager() ;
+  TString loaderName = "Ali" + detName + "Loader" ;
+
+  AliLoader * loader = NULL ;
+  // first check if a plugin is defined for the quality assurance data maker
+  TPluginHandler* pluginHandler = pluginManager->FindHandler("AliLoader", detName) ;
+  // if not, add a plugin for it
+  if (!pluginHandler) {
+    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 + "()") ;
+    } else {
+      pluginManager->AddHandler("AliLoader", detName, loaderName, detName, loaderName + "()") ;
+    }
+    pluginHandler = pluginManager->FindHandler("AliLoader", detName) ;
+  }
+  if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
+    loader = (AliLoader *) pluginHandler->ExecPlugin(0) ;
+  }
+  if (loader) 
+    fLoader[iDet] = loader ;
+  return loader ;
 }
 
 //_____________________________________________________________________________
 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"  
+  // retrieves the QA object stored in a file named "Run{run}.Event{evt}_1.ESD.tag.root"  
   Char_t * fileName = Form("Run%d.Event%d_1.ESD.tag.root", run, evt) ; 
   TFile * tagFile = TFile::Open(fileName) ;
   if ( !tagFile ) {
@@ -446,11 +448,11 @@ AliQAv1 * AliQAManager::GetQA(UInt_t run, UInt_t evt)
 //_____________________________________________________________________________
 AliQADataMaker * AliQAManager::GetQADataMaker(const Int_t iDet) 
 {
-       // get the quality assurance data maker for a detector
+  // get the quality assurance data maker for a detector
        
   AliQADataMaker * qadm =  fQADataMaker[iDet] ; 
   
-       if (qadm) {
+  if (qadm) {
  
     qadm->SetEventSpecie(fEventSpecie) ;  
     if ( qadm->GetRecoParam() ) 
@@ -459,20 +461,20 @@ AliQADataMaker * AliQAManager::GetQADataMaker(const Int_t iDet)
 
   } else if (iDet == AliQAv1::kGLOBAL && strcmp(GetMode(), AliQAv1::GetModeName(AliQAv1::kRECMODE)) == 0) { //Global QA
 
-               qadm = new AliGlobalQADataMaker();
-               qadm->SetName(AliQAv1::GetDetName(iDet));
-               qadm->SetUniqueID(iDet);
-               fQADataMaker[iDet] = qadm;
+    qadm = new AliGlobalQADataMaker();
+    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()) ; 
 
-       }       else if (iDet == AliQAv1::kCORR && strcmp(GetMode(), AliQAv1::GetModeName(AliQAv1::kRECMODE)) == 0 ) { //the data maker for correlations among detectors
+  }    else if (iDet == AliQAv1::kCORR && strcmp(GetMode(), AliQAv1::GetModeName(AliQAv1::kRECMODE)) == 0 ) { //the data maker for correlations among detectors
     qadm = new AliCorrQADataMakerRec(fQADataMaker) ; 
-               qadm->SetName(AliQAv1::GetDetName(iDet));
-               qadm->SetUniqueID(iDet);
-               fQADataMaker[iDet] = 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)  
@@ -521,33 +523,33 @@ AliQADataMaker * AliQAManager::GetQADataMaker(const Int_t iDet)
 //_____________________________________________________________________________
 void  AliQAManager::EndOfCycle(TObjArray * detArray) 
 {
-       // End of cycle QADataMakers 
+  // End of cycle QADataMakers 
        
   AliQAChecker::Instance()->SetRunNumber(fRunNumber) ; 
   TCanvas fakeCanvas ; 
 
-    fakeCanvas.Print(Form("%s%s%d.%s[", AliQAv1::GetImageFileName(), GetMode(), fRunNumber, AliQAv1::GetImageFileFormat()), "ps") ; 
-       for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
-               if (IsSelected(AliQAv1::GetDetName(iDet))) {
-                       AliQADataMaker * qadm = GetQADataMaker(iDet) ;
-                       if (!qadm) 
-                               continue ;      
-                       // skip non active detectors
-                       if (detArray) {
-                               AliModule* det = static_cast<AliModule*>(detArray->FindObject(AliQAv1::GetDetName(iDet))) ;
-                               if (!det || !det->IsActive())  
-                                       continue ;
-                       }
-                       AliQACheckerBase * qac = AliQAChecker::Instance()->GetDetQAChecker(iDet) ;
+  fakeCanvas.Print(Form("%s%s%d.%s[", AliQAv1::GetImageFileName(), GetMode(), fRunNumber, AliQAv1::GetImageFileFormat()), "ps") ; 
+  for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
+    if (IsSelected(AliQAv1::GetDetName(iDet))) {
+      AliQADataMaker * qadm = GetQADataMaker(iDet) ;
+      if (!qadm) 
+       continue ;      
+      // skip non active detectors
+      if (detArray) {
+       AliModule* det = static_cast<AliModule*>(detArray->FindObject(AliQAv1::GetDetName(iDet))) ;
+       if (!det || !det->IsActive())  
+         continue ;
+      }
+      AliQACheckerBase * qac = AliQAChecker::Instance()->GetDetQAChecker(iDet) ;
       if (qac) 
         qac->SetPrintImage(fPrintImage) ;
       for (UInt_t taskIndex = 0; taskIndex < AliQAv1::kNTASKINDEX; taskIndex++) {
         if ( fTasks.Contains(Form("%d", taskIndex)) ) 
           qadm->EndOfCycle(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(taskIndex))) ;
       }
-                       qadm->Finish();
-               }
-       }
+      qadm->Finish();
+    }
+  }
   if (fPrintImage) 
     fakeCanvas.Print(Form("%s%s%d.%s]", AliQAv1::GetImageFileName(), GetMode(), fRunNumber, AliQAv1::GetImageFileFormat()), "ps"); 
 }
@@ -555,30 +557,30 @@ void  AliQAManager::EndOfCycle(TObjArray * detArray)
 //_____________________________________________________________________________
 void  AliQAManager::EndOfCycle(TString detectors) 
 {
-       // End of cycle QADataMakers 
-       
+  // End of cycle QADataMakers 
+  
   AliQAChecker::Instance()->SetRunNumber(fRunNumber) ; 
   TCanvas fakeCanvas ; 
   if (fPrintImage) 
     fakeCanvas.Print(Form("%s%s%d.%s[", AliQAv1::GetImageFileName(), GetMode(), fRunNumber, AliQAv1::GetImageFileFormat()), "ps") ; 
   for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
-               if (IsSelected(AliQAv1::GetDetName(iDet))) {
-                       AliQADataMaker * qadm = GetQADataMaker(iDet) ;
-                       if (!qadm) 
-                               continue ;      
-                       // skip non active detectors
+    if (IsSelected(AliQAv1::GetDetName(iDet))) {
+      AliQADataMaker * qadm = GetQADataMaker(iDet) ;
+      if (!qadm) 
+       continue ;      
+      // skip non active detectors
       if (!detectors.Contains(AliQAv1::GetDetName(iDet))) 
         continue ;
-                       AliQACheckerBase * qac = AliQAChecker::Instance()->GetDetQAChecker(iDet) ;
+      AliQACheckerBase * qac = AliQAChecker::Instance()->GetDetQAChecker(iDet) ;
       if (qac) 
         qac->SetPrintImage(fPrintImage) ;
       for (UInt_t taskIndex = 0; taskIndex < AliQAv1::kNTASKINDEX; taskIndex++) {
         if ( fTasks.Contains(Form("%d", taskIndex)) ) 
           qadm->EndOfCycle(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(taskIndex))) ;
       }
-                       qadm->Finish();
-               }
-       }
+      qadm->Finish();
+    }
+  }
   if (fPrintImage) 
     fakeCanvas.Print(Form("%s%s%d.%s]", AliQAv1::GetImageFileName(), GetMode(), fRunNumber, AliQAv1::GetImageFileFormat()), "ps"); 
 }
@@ -596,7 +598,7 @@ AliRecoParam::EventSpecie_t AliQAManager::GetEventSpecieFromESD()
       AliESDEvent * esd    = new AliESDEvent() ;
       esd->ReadFromTree(esdTree) ;
       esdTree->GetEntry(0) ; 
-      runtype = AliRecoParam::ConvertIndex(esd->GetEventType()) ; 
+      runtype = AliRecoParam::Convert(esd->GetEventType()) ; 
     }
   } else {
     AliError("AliESDs.root not found") ; 
@@ -609,14 +611,14 @@ void AliQAManager::Increment(const AliQAv1::TASKINDEX_t taskIndex)
 {
   // Increments the cycle counter for all QA Data Makers
   static AliQAv1::TASKINDEX_t currentTask = AliQAv1::kNTASKINDEX ; 
-  if (currentTask == taskIndex) 
+  if ( (currentTask == taskIndex) && taskIndex != AliQAv1::kNULLTASKINDEX )
     return ; 
   else 
     currentTask = taskIndex ; 
-       for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
-               if (IsSelected(AliQAv1::GetDetName(iDet))) {
-                       AliQADataMaker * qadm = GetQADataMaker(iDet) ;
-                       if (qadm) 
+  for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
+    if (IsSelected(AliQAv1::GetDetName(iDet))) {
+      AliQADataMaker * qadm = GetQADataMaker(iDet) ;
+      if (qadm) 
         qadm->Increment() ;
     }
   }
@@ -625,69 +627,69 @@ void AliQAManager::Increment(const AliQAv1::TASKINDEX_t taskIndex)
 //_____________________________________________________________________________
 Bool_t AliQAManager::InitQA(const AliQAv1::TASKINDEX_t taskIndex, const  Char_t * input )
 {
-       // Initialize the event source and QA data makers
+  // Initialize the event source and QA data makers
        
-       fTasks += Form("%d", taskIndex) ; 
-
-       if (taskIndex == AliQAv1::kRAWS) { 
-               if (!fRawReader) {
-                       fRawReader = AliRawReader::Create(input);
-               }
-               if ( ! fRawReader ) 
-                       return kFALSE ; 
-               fRawReaderDelete = kTRUE ; 
-               fRawReader->NextEvent() ; 
-               fRunNumber = fRawReader->GetRunNumber() ; 
-               SetRun(fRunNumber) ; 
-               fRawReader->RewindEvents();
-               fNumberOfEvents = 999999 ;
-               if ( fMaxEvents < 0 ) 
-                       fMaxEvents = fNumberOfEvents ; 
-               } 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 = static_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") ; 
+  fTasks += Form("%d", taskIndex) ; 
+
+  if (taskIndex == AliQAv1::kRAWS) { 
+    if (!fRawReader) {
+      fRawReader = AliRawReader::Create(input);
+    }
+    if ( ! fRawReader ) 
+      return kFALSE ; 
+    fRawReaderDelete = kTRUE ; 
+    fRawReader->NextEvent() ; 
+    fRunNumber = fRawReader->GetRunNumber() ; 
+    SetRun(fRunNumber) ; 
+    fRawReader->RewindEvents();
+    fNumberOfEvents = 999999 ;
+    if ( fMaxEvents < 0 ) 
+      fMaxEvents = fNumberOfEvents ; 
+  } 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 = static_cast<TTree *> (esdFile->Get("esdTree")) ; 
+      if ( !fESDTree ) {
+       AliError("esdTree not found") ; 
+       return kFALSE ; 
       } else {
-        fNumberOfEvents = fRunLoader->GetNumberOfEvents() ;
-        if ( fMaxEvents < 0 ) 
-          fMaxEvents = fNumberOfEvents ; 
+       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 ; 
-       if (fRunLoader) // check if RunLoader exists 
-               if ( fRunLoader->GetAliRun() ) { // check if AliRun exists in gAlice.root
-                       detArray = fRunLoader->GetAliRun()->Detectors() ;
-                       fRunNumber = fRunLoader->GetHeader()->GetRun() ; 
-               }
-
-       // Initialize all QA data makers for all detectors
-       fRunNumber = AliCDBManager::Instance()->GetRun() ; 
-       if ( !  AliGeomManager::GetGeometry() ) 
-               AliGeomManager::LoadGeometry() ; 
+  if (fRunLoader) // check if RunLoader exists 
+    if ( fRunLoader->GetAliRun() ) { // check if AliRun exists in gAlice.root
+      detArray = fRunLoader->GetAliRun()->Detectors() ;
+      fRunNumber = fRunLoader->GetHeader()->GetRun() ; 
+    }
+
+  // Initialize all QA data makers for all detectors
+  fRunNumber = AliCDBManager::Instance()->GetRun() ; 
+  if ( !  AliGeomManager::GetGeometry() ) 
+    AliGeomManager::LoadGeometry() ; 
        
-       InitQADataMaker(fRunNumber, detArray) ; //, fCycleSame, kTRUE, detArray) ; 
+  InitQADataMaker(fRunNumber, detArray) ; //, fCycleSame, kTRUE, detArray) ; 
   if (fPrintImage) {
     TCanvas fakeCanvas ; 
     TStopwatch timer ; 
@@ -698,105 +700,105 @@ Bool_t AliQAManager::InitQA(const AliQAv1::TASKINDEX_t taskIndex, const  Char_t
     }
     fakeCanvas.Print(Form("%s%s%d.%s[", AliQAv1::GetImageFileName(), GetMode(), fRunNumber, AliQAv1::GetImageFileFormat()), "ps") ;    
   }    
-       return kTRUE ; 
+  return kTRUE ; 
 }
 
 //_____________________________________________________________________________
 void  AliQAManager::InitQADataMaker(UInt_t run, TObjArray * detArray) 
 {
-       // Initializes The QADataMaker for all active detectors and for all active tasks 
+  // Initializes The QADataMaker for all active detectors and for all active tasks 
   fRunNumber = run ; 
-       for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
-               if (IsSelected(AliQAv1::GetDetName(iDet))) {
-                       AliQADataMaker * qadm = GetQADataMaker(iDet) ;
-                       if (!qadm) {
-                               AliError(Form("AliQADataMaker not found for %s", AliQAv1::GetDetName(iDet))) ; 
-                               fDetectorsW.ReplaceAll(AliQAv1::GetDetName(iDet), "") ; 
-                       } else {
+  for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
+    if (IsSelected(AliQAv1::GetDetName(iDet))) {
+      AliQADataMaker * qadm = GetQADataMaker(iDet) ;
+      if (!qadm) {
+       AliError(Form("AliQADataMaker not found for %s", AliQAv1::GetDetName(iDet))) ; 
+       fDetectorsW.ReplaceAll(AliQAv1::GetDetName(iDet), "") ; 
+      } else {
         if (fQAWriteExpert[iDet])
           qadm->SetWriteExpert() ; 
-                               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(AliQAv1::GetDetName(iDet))) ;
-                                       if (!det || !det->IsActive())  
-                                               continue ;
-                               }
-             // Set default reco params
+       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(AliQAv1::GetDetName(iDet))) ;
+         if (!det || !det->IsActive())  
+           continue ;
+       }
+       // Set default reco params
         Bool_t sameCycle = kFALSE ; 
-                               for (UInt_t taskIndex = 0; taskIndex < AliQAv1::kNTASKINDEX; taskIndex++) {
-                                       if ( fTasks.Contains(Form("%d", taskIndex)) ) {
-                                               qadm->Init(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(taskIndex)), GetQACycles(qadm->GetUniqueID())) ;
+       for (UInt_t taskIndex = 0; taskIndex < AliQAv1::kNTASKINDEX; taskIndex++) {
+         if ( fTasks.Contains(Form("%d", taskIndex)) ) {
+           qadm->Init(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(taskIndex)), GetQACycles(qadm->GetUniqueID())) ;
             qadm->StartOfCycle(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(taskIndex)), run,  sameCycle) ;
             sameCycle = kTRUE ;
-                                       }
-                               }
-                       }
-               }
+         }
        }
+      }
+    }
+  }
 }
 
 
 //_____________________________________________________________________________
 Bool_t AliQAManager::InitRunLoader()
 {
-       // get or create the run loader
-       if (fRunLoader) {
-               fCycleSame = kTRUE ; 
-       } else {
-               if (!gSystem->AccessPathName(fGAliceFileName.Data())) { // galice.root exists
-                       // load all base libraries to get the loader classes
-                       TString libs = gSystem->GetLibraries() ;
-                       for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
-                               if (!IsSelected(AliQAv1::GetDetName(iDet))) 
-                                       continue ; 
-                               TString detName = AliQAv1::GetDetName(iDet) ;
-                               if (detName == "HLT") 
-                                       continue;
-                               if (libs.Contains("lib" + detName + "base.so")) 
-                                       continue;
-                               gSystem->Load("lib" + detName + "base.so");
-                       }
-                       fRunLoader = AliRunLoader::Open(fGAliceFileName.Data());
-                       if (!fRunLoader) {
-                               AliError(Form("no run loader found in file %s", fGAliceFileName.Data()));
-                               return kFALSE;
-                       }
-                       fRunLoader->CdGAFile();
-                       if (fRunLoader->LoadgAlice() == 0) {
-                               gAlice = fRunLoader->GetAliRun();
-                       }
-
-                       if (!gAlice) {
-                               AliError(Form("no gAlice object found in file %s", fGAliceFileName.Data()));
-                               return kFALSE;
-                       }
-
-               } else {               // galice.root does not exist
-                       AliError(Form("the file %s does not exist", fGAliceFileName.Data()));
-                       return kFALSE;
-               }
-       }
+  // get or create the run loader
+  if (fRunLoader) {
+    fCycleSame = kTRUE ; 
+  } else {
+    if (!gSystem->AccessPathName(fGAliceFileName.Data())) { // galice.root exists
+      // load all base libraries to get the loader classes
+      TString libs = gSystem->GetLibraries() ;
+      for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
+       if (!IsSelected(AliQAv1::GetDetName(iDet))) 
+         continue ; 
+       TString detName = AliQAv1::GetDetName(iDet) ;
+       if (detName == "HLT") 
+         continue;
+       if (libs.Contains("lib" + detName + "base.so")) 
+         continue;
+       gSystem->Load("lib" + detName + "base.so");
+      }
+      fRunLoader = AliRunLoader::Open(fGAliceFileName.Data());
+      if (!fRunLoader) {
+       AliError(Form("no run loader found in file %s", fGAliceFileName.Data()));
+       return kFALSE;
+      }
+      fRunLoader->CdGAFile();
+      if (fRunLoader->LoadgAlice() == 0) {
+       gAlice = fRunLoader->GetAliRun();
+      }
 
-       if (!fRunNumber) { 
-               fRunLoader->LoadHeader();
-               fRunNumber = fRunLoader->GetHeader()->GetRun() ; 
-       }
-       return kTRUE;
+      if (!gAlice) {
+       AliError(Form("no gAlice object found in file %s", fGAliceFileName.Data()));
+       return kFALSE;
+      }
+
+    } else {               // galice.root does not exist
+      AliError(Form("the file %s does not exist", fGAliceFileName.Data()));
+      return kFALSE;
+    }
+  }
+
+  if (!fRunNumber) { 
+    fRunLoader->LoadHeader();
+    fRunNumber = fRunLoader->GetHeader()->GetRun() ; 
+  }
+  return kTRUE;
 }
 
 //_____________________________________________________________________________
 Bool_t AliQAManager::IsSelected(const Char_t * det) 
 {
   // check whether detName is contained in detectors
-       // if yes, it is removed from detectors
+  // if yes, it is removed from detectors
        
-       Bool_t rv = kFALSE;
-       const TString detName(det) ;
+  Bool_t rv = kFALSE;
+  const TString detName(det) ;
   // always activates Correlation
-  if ( detName.Contains(AliQAv1::GetDetName(AliQAv1::kCORR)) || detName.Contains(AliQAv1::GetDetName(AliQAv1::kGLOBAL))) {
-    rv = kTRUE ; 
-  } else {
+//  if ( detName.Contains(AliQAv1::GetDetName(AliQAv1::kCORR)) || detName.Contains(AliQAv1::GetDetName(AliQAv1::kGLOBAL))) {
+//    rv = kTRUE ; 
+//  } else {
     // check if all detectors are selected
     if (fDetectors.Contains("ALL")) {
       fDetectors = "ALL";
@@ -807,21 +809,21 @@ Bool_t AliQAManager::IsSelected(const Char_t * det)
                fDetectors.Contains(" "+detName+" ")) {
       rv = kTRUE;
     }
-  }
-       return rv ;
+//  }
+  return rv ;
 }
 
 //_____________________________________________________________________________
 Bool_t AliQAManager::Merge(Int_t runNumber, const char *fileName) const
 {
-       // Merge data from all detectors from a given run in one single file 
-       // Merge the QA results from all the data chunks in one run
+  // Merge 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 ; 
 if ( runNumber == -1)
+    runNumber = fRunNumber ; 
 Bool_t rv = MergeData(runNumber,fileName) ; 
 //rv *= MergeResults(runNumber) ; // not needed for the time being
 return rv ; 
 }
        
 //______________________________________________________________________
@@ -838,10 +840,10 @@ Bool_t AliQAManager::MergeXML(const Char_t * collectionFile, const Char_t * subF
     return kFALSE ; 
   }
     
- if ( !gGrid ) 
-   TGrid::Connect("alien://"); 
- if ( !gGrid ) 
-   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));               
@@ -886,7 +888,7 @@ Bool_t AliQAManager::MergeXML(const Char_t * collectionFile, const Char_t * subF
 //_____________________________________________________________________________
 void AliQAManager::MergeCustom() const
 {
-       // Custom Merge of QA data from all detectors for all runs in one single file 
+  // 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") ;
@@ -990,7 +992,7 @@ void AliQAManager::MergeCustom() const
                     if (  className.Contains("TH") || className.Contains("TProfile") ) {
                       TH1 * histIn = static_cast<TH1*> (key->ReadObj()) ; 
                       TH1 * histOu = static_cast<TH1*> (mergedDirectory->FindObjectAny(histIn->GetName())) ; 
-                      AliDebug(AliQAv1::GetQADebugLevel(), Form("%s %x %x\n", key->GetName(), histIn, histOu)) ; 
+                      AliDebug(AliQAv1::GetQADebugLevel(), Form("%s %p %p\n", key->GetName(), histIn, histOu)) ; 
                       mergedDirectory->cd() ; 
                       if ( ! histOu ) {
                         histIn->Write() ; 
@@ -1044,7 +1046,7 @@ void AliQAManager::MergeCustom() const
 //_____________________________________________________________________________
 Bool_t AliQAManager::MergeData(const Int_t runNumber, const char *fileName) const
 {
-       // Merge QA data from all detectors for a given run in one single file 
+  // Merge QA data from all detectors for a given run in one single file 
   
   TFileMerger merger(kFALSE) ; 
   TString outFileName = fileName;
@@ -1057,80 +1059,80 @@ Bool_t AliQAManager::MergeData(const Int_t runNumber, const char *fileName) cons
     delete[] file;
   }
   merger.Merge() ; 
-       return kTRUE ; 
+  return kTRUE ; 
 }
 
 //_____________________________________________________________________________
 Bool_t AliQAManager::MergeResults(const Int_t runNumber) const
 {
-       // Merge the QA result from all the data chunks in a run 
+  // 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", AliQAv1::GetQADataFileName()) ; 
-       gROOT->ProcessLine(cmd.Data()) ;
-       ifstream in("tempo.txt") ; 
-       const Int_t chunkMax = 100 ;  
-       TString fileList[chunkMax] ;
+  TString cmd ;
+  cmd = Form(".! ls %s*.root > tempo.txt", AliQAv1::GetQADataFileName()) ; 
+  gROOT->ProcessLine(cmd.Data()) ;
+  ifstream in("tempo.txt") ; 
+  const Int_t chunkMax = 100 ;  
+  TString fileList[chunkMax] ;
        
-       Int_t index = 0 ; 
-       while ( 1 ) {
-               TString file ; 
-               in >> fileList[index] ; 
-               if ( !in.good() ) 
-                       break ; 
-               AliDebug(AliQAv1::GetQADebugLevel(), Form("index = %d file = %s", index, (fileList[index].Data()))) ; 
-               index++ ;
-       }
+  Int_t index = 0 ; 
+  while ( 1 ) {
+    TString file ; 
+    in >> fileList[index] ; 
+    if ( !in.good() ) 
+      break ; 
+    AliDebug(AliQAv1::GetQADebugLevel(), Form("index = %d file = %s", index, (fileList[index].Data()))) ; 
+    index++ ;
+  }
        
-       if ( index == 0 ) { 
-               AliError("No QA Result File found") ; 
-               return kFALSE ; 
-       }
+  if ( index == 0 ) { 
+    AliError("No QA Result File found") ; 
+    return kFALSE ; 
+  }
        
-       TFileMerger merger ; 
+  TFileMerger merger ; 
   TString outFileName ;
   if (runNumber != -1) 
     outFileName = Form("Merged.%s.Result.%d.root",AliQAv1::GetQADataFileName(),runNumber); 
   else 
     outFileName = Form("Merged.%s.Result.root",AliQAv1::GetQADataFileName()); 
-       merger.OutputFile(outFileName.Data()) ; 
-       for (Int_t ifile = 0 ; ifile < index ; ifile++) {
-               TString file = fileList[ifile] ; 
-               merger.AddFile(file) ; 
-       }
-       merger.Merge() ; 
+  merger.OutputFile(outFileName.Data()) ; 
+  for (Int_t ifile = 0 ; ifile < index ; ifile++) {
+    TString file = fileList[ifile] ; 
+    merger.AddFile(file) ; 
+  }
+  merger.Merge() ; 
        
-       return kTRUE ; 
+  return kTRUE ; 
 }
 
 //_____________________________________________________________________________
 void AliQAManager::Reset(const Bool_t sameCycle)
 {
-       // Reset the default data members
+  // Reset the default data members
 
-       for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
-               if (IsSelected(AliQAv1::GetDetName(iDet))) {
-                       AliQADataMaker * qadm = GetQADataMaker(iDet);
-                       if (qadm) 
+  for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
+    if (IsSelected(AliQAv1::GetDetName(iDet))) {
+      AliQADataMaker * qadm = GetQADataMaker(iDet);
+      if (qadm) 
         qadm->Reset();
-               }
-       
-       if (fRawReaderDelete) { 
-               delete fRawReader ;
-               fRawReader      = NULL ;
-       }
+    }
+  } 
+  if (fRawReaderDelete) { 
+    delete fRawReader ;
+    fRawReader      = NULL ;
+  }
 
-       fCycleSame      = sameCycle ; 
-       fESD            = NULL ; 
-       fESDTree        = NULL ; 
-       //fFirst          = kTRUE ;   
-       fNumberOfEvents = 999999 ;  
+  fCycleSame      = sameCycle ; 
+  fESD            = NULL ; 
+  fESDTree        = NULL ; 
+  //fFirst          = kTRUE ;   
+  fNumberOfEvents = 999999 ;  
 }
 
 //_____________________________________________________________________________
 void AliQAManager::ResetDetectors(AliQAv1::TASKINDEX_t task, AliQAv1::DETECTORINDEX_t det)
 {
-    //calls ResetDetector of specified or all detectors
+  //calls ResetDetector of specified or all detectors
   UInt_t iDet    = 0 ;
   UInt_t iDetMax = fgkNDetectors ;    
   if ( det != AliQAv1::kNULLDET ) {
@@ -1138,12 +1140,12 @@ void AliQAManager::ResetDetectors(AliQAv1::TASKINDEX_t task, AliQAv1::DETECTORIN
     iDetMax = det+1 ;    
   }
   
-       for (iDet = 0; iDet < iDetMax ; iDet++) {
-               if (IsSelected(AliQAv1::GetDetName(iDet))) {
-                       AliQADataMaker * qadm = GetQADataMaker(iDet);
-                       qadm->ResetDetector(task);
-               }
-       }   
+  for (iDet = 0; iDet < iDetMax ; iDet++) {
+    if (IsSelected(AliQAv1::GetDetName(iDet))) {
+      AliQADataMaker * qadm = GetQADataMaker(iDet);
+      qadm->ResetDetector(task);
+    }
+  }   
 }
 
 //_____________________________________________________________________________
@@ -1151,18 +1153,18 @@ AliQAManager * AliQAManager::QAManager(AliQAv1::MODE_t mode, TMap *entryCache, I
 {
   // returns AliQAManager instance (singleton)
   
-       if (!fgQAInstance) {
+  if (!fgQAInstance) {
     if ( (mode != AliQAv1::kSIMMODE) && (mode != AliQAv1::kRECMODE) && (mode != AliQAv1::kQAMODE) ) {
       AliWarningClass("You must specify kSIMMODE or kRECMODE or kQAMODE") ; 
       return NULL ; 
     }
     fgQAInstance = new AliQAManager(mode) ;  
     if (!entryCache)
-                 fgQAInstance->Init();
-               else
-                 fgQAInstance->InitFromCache(entryCache,run);
+      fgQAInstance->Init();
+    else
+      fgQAInstance->InitFromCache(entryCache,run);
   }
-       return fgQAInstance;
+  return fgQAInstance;
 }
 
 //_____________________________________________________________________________
@@ -1175,111 +1177,111 @@ AliQAManager * AliQAManager::QAManager(AliQAv1::TASKINDEX_t task)
 //_____________________________________________________________________________
 TString AliQAManager::Run(const Char_t * detectors, AliRawReader * rawReader, const Bool_t sameCycle) 
 {
-       //Runs all the QA data Maker for Raws only
+  //Runs all the QA data Maker for Raws only
        
-       fCycleSame       = sameCycle ;
-       fRawReader       = rawReader ;
-       fDetectors       = detectors ; 
-       fDetectorsW      = detectors ;  
+  fCycleSame       = sameCycle ;
+  fRawReader       = rawReader ;
+  fDetectors       = detectors ; 
+  fDetectorsW      = detectors ;       
        
-       AliCDBManager* man = AliCDBManager::Instance() ; 
+  AliCDBManager* man = AliCDBManager::Instance() ; 
 
-       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 ( 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 (!fCycleSame) 
+  if (!fCycleSame) 
     if ( !InitQA(AliQAv1::kRAWS) ) 
       return "" ; 
   fRawReaderDelete = kFALSE ; 
 
-       DoIt(AliQAv1::kRAWS) ; 
-       return  fDetectorsW ;
+  DoIt(AliQAv1::kRAWS) ; 
+  return       fDetectorsW ;
 }
 
 //_____________________________________________________________________________
 TString AliQAManager::Run(const Char_t * detectors, const Char_t * fileName, const Bool_t sameCycle) 
 {
-       //Runs all the QA data Maker for Raws only
+  //Runs all the QA data Maker for Raws only
 
-       fCycleSame       = sameCycle ;
-       fDetectors       = detectors ; 
-       fDetectorsW      = detectors ;  
+  fCycleSame       = sameCycle ;
+  fDetectors       = detectors ; 
+  fDetectorsW      = detectors ;       
        
-       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") ;
-               if ( ! rl ) {
-                       AliFatal("galice.root file not found in current directory") ; 
-               } else {
-                       rl->CdGAFile() ; 
-                       rl->LoadgAlice() ;
-                       if ( ! rl->GetAliRun() ) {
-                               AliFatal("AliRun not found in galice.root") ;
-                       } else {
-                               rl->LoadHeader() ;
-                               man->SetRun(rl->GetHeader()->GetRun());
-                       }
-               }
-       }
+  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") ;
+    if ( ! rl ) {
+      AliFatal("galice.root file not found in current directory") ; 
+    } else {
+      rl->CdGAFile() ; 
+      rl->LoadgAlice() ;
+      if ( ! rl->GetAliRun() ) {
+       AliFatal("AliRun not found in galice.root") ;
+      } else {
+       rl->LoadHeader() ;
+       man->SetRun(rl->GetHeader()->GetRun());
+      }
+    }
+  }
        
-       if (!fCycleSame) 
+  if (!fCycleSame) 
     if ( !InitQA(AliQAv1::kRAWS, fileName) ) 
       return "" ; 
        
-       DoIt(AliQAv1::kRAWS) ; 
-       return  fDetectorsW ;
+  DoIt(AliQAv1::kRAWS) ; 
+  return       fDetectorsW ;
 }
 
 //_____________________________________________________________________________
 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
+  // Runs all the QA data Maker for every detector
        
-       fCycleSame       = sameCycle ;
-       fDetectors       = detectors ; 
-       fDetectorsW      = detectors ;          
+  fCycleSame       = sameCycle ;
+  fDetectors       = detectors ; 
+  fDetectorsW      = detectors ;               
        
-       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") ;
-               if ( ! rl ) {
-                       AliFatal("galice.root file not found in current directory") ; 
-               } else {
-                       rl->CdGAFile() ; 
-                       rl->LoadgAlice() ;
-                       if ( ! rl->GetAliRun() ) {
-                               AliDebug(AliQAv1::GetQADebugLevel(), "AliRun not found in galice.root") ;
-                       } else {
-                               rl->LoadHeader() ;
-                               man->SetRun(rl->GetHeader()->GetRun()) ;
-                       }
-               }
-       }
+  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") ;
+    if ( ! rl ) {
+      AliFatal("galice.root file not found in current directory") ; 
+    } else {
+      rl->CdGAFile() ; 
+      rl->LoadgAlice() ;
+      if ( ! rl->GetAliRun() ) {
+       AliDebug(AliQAv1::GetQADebugLevel(), "AliRun not found in galice.root") ;
+      } else {
+       rl->LoadHeader() ;
+       man->SetRun(rl->GetHeader()->GetRun()) ;
+      }
+    }
+  }
   if ( taskIndex == AliQAv1::kNULLTASKINDEX) { 
-               for (UInt_t task = 0; task < AliQAv1::kNTASKINDEX; task++) {
-                       if ( fTasks.Contains(Form("%d", task)) ) {
+    for (UInt_t task = 0; task < AliQAv1::kNTASKINDEX; task++) {
+      if ( fTasks.Contains(Form("%d", task)) ) {
         if (!fCycleSame)
           if ( !InitQA(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(task)), fileName) ) 
             return "" ;
         DoIt(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(task))) ;
-                       }
-               }
-       } else {
+      }
+    }
+  } else {
     if (! fCycleSame )
       if ( !InitQA(taskIndex, fileName) ) 
         return "" ; 
-      DoIt(taskIndex) ; 
+    DoIt(taskIndex) ; 
   }            
-       return fDetectorsW ;
+  return fDetectorsW ;
 }
 
 //_____________________________________________________________________________
 void AliQAManager::RunOneEvent(AliRawReader * rawReader) 
 {
-       //Runs all the QA data Maker for Raws only and on one event only (event loop done by calling method)
+  //Runs all the QA data Maker for Raws only and on one event only (event loop done by calling method)
   if ( ! rawReader ) 
     return ; 
   if (fTasks.Contains(Form("%d", AliQAv1::kRAWS))){
@@ -1294,17 +1296,17 @@ void AliQAManager::RunOneEvent(AliRawReader * rawReader)
       }
       qadm->SetEventSpecie(fEventSpecie) ;  
       if ( qadm->GetRecoParam() ) 
-        if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)  
+       if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault) 
           qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ; 
-                       qadm->Exec(AliQAv1::kRAWS, rawReader) ;
-               }
+      qadm->Exec(AliQAv1::kRAWS, rawReader) ;
+    }
   }
 }
 
 //_____________________________________________________________________________
 void AliQAManager::RunOneEvent(AliESDEvent *& esd, AliESDEvent *& hltesd) 
 {
-       //Runs all the QA data Maker for ESDs only and on one event only (event loop done by calling method)
+  //Runs all the QA data Maker for ESDs only and on one event only (event loop done by calling method)
        
   if (fTasks.Contains(Form("%d", AliQAv1::kESDS))) {
     for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
@@ -1315,7 +1317,7 @@ void AliQAManager::RunOneEvent(AliESDEvent *& esd, AliESDEvent *& hltesd)
         continue;
       qadm->SetEventSpecie(fEventSpecie) ;  
       if ( qadm->GetRecoParam() ) 
-        if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)  
+       if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)  
           qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ; 
       if ( qadm->IsCycleDone() ) {
         qadm->EndOfCycle() ;
@@ -1328,14 +1330,14 @@ void AliQAManager::RunOneEvent(AliESDEvent *& esd, AliESDEvent *& hltesd)
       } else {
         qadm->Exec(AliQAv1::kESDS, 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)
+  // Runs all the QA data Maker for ESDs only and on one event only (event loop done by calling method)
   
   TString test(tree->GetName()) ; 
   if (fTasks.Contains(Form("%d", AliQAv1::kRECPOINTS))) {
@@ -1365,92 +1367,92 @@ void AliQAManager::RunOneEventInOneDetector(Int_t det, TTree * tree)
 //_____________________________________________________________________________
 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(AliQAv1::GetQARefStorage()) ; 
-       if ( tmp.IsNull() ) { 
-               AliError("No storage defined, use AliQAv1::SetQARefStorage") ; 
-               return kFALSE ; 
-       }
-       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) ; 
-       sdet.ToUpper() ;
-       TFile * inputFile ; 
-       if ( sdet.Contains("ALL") ) {
-               rv = Merge(runNumber) ; 
-               if ( ! rv )
-                       return kFALSE ; 
-               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 < 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) ; 
-                       }
-               }
-       }
-       return rv ; 
+  // take the locasl QA data merge into a single file and save in OCDB 
+  Bool_t rv = kTRUE ; 
+  TString tmp(AliQAv1::GetQARefStorage()) ; 
+  if ( tmp.IsNull() ) { 
+    AliError("No storage defined, use AliQAv1::SetQARefStorage") ; 
+    return kFALSE ; 
+  }
+  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) ; 
+  sdet.ToUpper() ;
+  TFile * inputFile ; 
+  if ( sdet.Contains("ALL") ) {
+    rv = Merge(runNumber) ; 
+    if ( ! rv )
+      return kFALSE ; 
+    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 < 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) ; 
+      }
+    }
+  }
+  return rv ; 
 }
 
 //_____________________________________________________________________________
 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 ;
-       AliDebug(AliQAv1::GetQADebugLevel(), Form("Saving TH1s in %s to %s", inputFile->GetName(), AliQAv1::GetQARefStorage())) ; 
-       if ( ! IsDefaultStorageSet() ) {
-               TString tmp( AliQAv1::GetQARefStorage() ) ; 
-               if ( tmp.Contains(AliQAv1::GetLabLocalOCDB()) ) 
-                       Instance()->SetDefaultStorage(AliQAv1::GetQARefStorage()) ;
-               else {
-                       TString tmp1(AliQAv1::GetQARefDefaultStorage()) ; 
-                       tmp1.Append(year) ; 
-                       tmp1.Append("?user=alidaq") ; 
-                       Instance()->SetDefaultStorage(tmp1.Data()) ; 
-               }
-       }
-       Instance()->SetSpecificStorage("*", AliQAv1::GetQARefStorage()) ; 
-       if(GetRun() < 0) 
-               Instance()->SetRun(runNumber);
+  // reads the TH1 from file and adds it to appropriate list before saving to OCDB
+  Bool_t rv = kTRUE ;
+  AliDebug(AliQAv1::GetQADebugLevel(), Form("Saving TH1s in %s to %s", inputFile->GetName(), AliQAv1::GetQARefStorage())) ; 
+  if ( ! IsDefaultStorageSet() ) {
+    TString tmp( AliQAv1::GetQARefStorage() ) ; 
+    if ( tmp.Contains(AliQAv1::GetLabLocalOCDB()) ) 
+      Instance()->SetDefaultStorage(AliQAv1::GetQARefStorage()) ;
+    else {
+      TString tmp1(AliQAv1::GetQARefDefaultStorage()) ; 
+      tmp1.Append(year) ; 
+      tmp1.Append("?user=alidaq") ; 
+      Instance()->SetDefaultStorage(tmp1.Data()) ; 
+    }
+  }
+  Instance()->SetSpecificStorage("*", AliQAv1::GetQARefStorage()) ; 
+  if(GetRun() < 0) 
+    Instance()->SetRun(runNumber);
 
-       AliCDBMetaData mdr ;
-       mdr.SetResponsible("yves schutz");
+  AliCDBMetaData mdr ;
+  mdr.SetResponsible("yves schutz");
 
-       for ( Int_t detIndex = 0 ; detIndex < AliQAv1::kNDET ; detIndex++) {
-               TDirectory * detDir = inputFile->GetDirectory(AliQAv1::GetDetName(detIndex)) ; 
-               if ( detDir ) {
-                       AliDebug(AliQAv1::GetQADebugLevel(), Form("Entering %s", detDir->GetName())) ;
+  for ( Int_t detIndex = 0 ; detIndex < AliQAv1::kNDET ; detIndex++) {
+    TDirectory * detDir = inputFile->GetDirectory(AliQAv1::GetDetName(detIndex)) ; 
+    if ( detDir ) {
+      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", 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 = static_cast<TKey*>(nextTask())) ) {
-                               TDirectory * taskDir = detDir->GetDirectory(taskKey->GetName()) ; 
+      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", 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 = static_cast<TKey*>(nextTask())) ) {
+       TDirectory * taskDir = detDir->GetDirectory(taskKey->GetName()) ; 
         TDirectory * esDir   = taskDir->GetDirectory(AliRecoParam::GetEventSpecieName(es)) ; 
-                               AliDebug(AliQAv1::GetQADebugLevel(), Form("Saving %s", esDir->GetName())) ; 
-                               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 = 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 {
+       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 = 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 ( AliQAv1::GetExpert() == histKey->GetName() ) {
               TDirectory * expertDir   = esDir->GetDirectory(histKey->GetName()) ; 
               TList * expertHistList = expertDir->GetListOfKeys() ; 
@@ -1470,19 +1472,19 @@ Bool_t AliQAManager::SaveIt2OCDB(const Int_t runNumber, TFile * inputFile, const
                 }                
               }
             }
-                                               AliDebug(AliQAv1::GetQADebugLevel(), Form("Adding %s", histKey->GetName())) ;
-                                               if ( odata->IsA()->InheritsFrom("TH1") ) {
-                                                       AliDebug(AliQAv1::GetQADebugLevel(), Form("Adding %s", histKey->GetName())) ;
-                                                       TH1 * hdata = static_cast<TH1*>(odata) ; 
-                                                       listTaskQAD->Add(hdata) ; 
-                                               }
-                                       }
-                               }
-                       }
-                       Instance()->Put(listDetQAD, idr, &mdr) ;
-               }
+           AliDebug(AliQAv1::GetQADebugLevel(), Form("Adding %s", histKey->GetName())) ;
+           if ( odata->IsA()->InheritsFrom("TH1") ) {
+             AliDebug(AliQAv1::GetQADebugLevel(), Form("Adding %s", histKey->GetName())) ;
+             TH1 * hdata = static_cast<TH1*>(odata) ; 
+             listTaskQAD->Add(hdata) ; 
+           }
+         }
        }
-       return rv ; 
+      }
+      Instance()->Put(listDetQAD, idr, &mdr) ;
+    }
+  }
+  return rv ; 
 }      
 
 //_____________________________________________________________________________
@@ -1516,7 +1518,7 @@ void AliQAManager::SetWriteExpert()
 {
   // enable the writing of QA expert data
   for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
-       if (IsSelected(AliQAv1::GetDetName(iDet))) 
+    if (IsSelected(AliQAv1::GetDetName(iDet))) 
       fQAWriteExpert[iDet] = kTRUE ;
   }
 }  
@@ -1536,6 +1538,7 @@ void AliQAManager::Destroy() {
 void AliQAManager::ShowQA() {
   // Show the result of the QA checking
   // for all detectors 
-       for ( Int_t detIndex = 0 ; detIndex < AliQAv1::kNDET ; detIndex++) 
-    AliQAv1::Instance(AliQAv1::GetDetIndex(AliQAv1::GetDetName(detIndex)))->Show() ; 
+  for ( Int_t detIndex = 0 ; detIndex < AliQAv1::kNDET ; detIndex++) 
+    if ( IsSelected(AliQAv1::GetDetName(detIndex)) ) 
+      AliQAv1::Instance(AliQAv1::GetDetIndex(AliQAv1::GetDetName(detIndex)))->Show() ; 
 }