]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/STEER/AliReconstruction.cxx
Implement comparison of sim and rec CDB's, by default for the TPC/RecoParam only
[u/mrichter/AliRoot.git] / STEER / STEER / AliReconstruction.cxx
index 13ae831ae7b388f37b7c21ad1ce0f4ea0e70dfc1..453687716252a18bb86dd7bbfd72049162a77ea6 100644 (file)
@@ -13,7 +13,7 @@
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/* $Id$ */
+/* $Id: AliReconstruction.cxx 63911 2013-08-19 16:46:41Z hristov $ */
 
 ///////////////////////////////////////////////////////////////////////////////
 //                                                                           //
 #include <sys/resource.h>
 ClassImp(AliReconstruction)
 
+using std::endl;
+
 //_____________________________________________________________________________
 const char* AliReconstruction::fgkStopEvFName = "_stopEvent_";
-const char* AliReconstruction::fgkDetectorName[AliReconstruction::kNDetectors] = {"ITS", "TPC", "TRD", "TOF", "PHOS", "HMPID", "EMCAL", "MUON", "FMD", "ZDC", "PMD", "T0", "VZERO", "ACORDE"
-// #ifdef MFT_UPGRADE
-//                                                                                   , "MFT"
-// #endif 
-                                                                                  , "MFT"    // AU
-                                                                                 , "HLT"
-};
+const char* AliReconstruction::fgkDetectorName[AliReconstruction::kNDetectors] = {"ITS", "TPC", "TRD",
+"TOF", "PHOS", 
+"HMPID", "EMCAL", "MUON", "FMD", "ZDC", "PMD", "T0", "VZERO", "ACORDE","AD","FIT","MFT", "HLT"};
 
 //_____________________________________________________________________________
 AliReconstruction::AliReconstruction(const char* gAliceFilename) :
   TSelector(),
   fRunVertexFinder(kTRUE),
   fRunVertexFinderTracks(kTRUE),
-  fRunHLTTracking(kFALSE),
   fRunMuonTracking(kFALSE),
+  fRunMFTTrackingMU(kFALSE),
   fRunV0Finder(kTRUE),
   fRunCascadeFinder(kTRUE),
   fRunMultFinder(kTRUE),
   fStopOnError(kTRUE),
+  fStopOnMissingTriggerFile(kTRUE),
   fWriteAlignmentData(kFALSE),
   fWriteESDfriend(kFALSE),
   fFillTriggerESD(kTRUE),
@@ -286,6 +285,7 @@ AliReconstruction::AliReconstruction(const char* gAliceFilename) :
   fCDBUri(),
   fQARefUri(),
   fSpecCDBUri(), 
+  fCheckRecoCDBvsSimuCDB(),
   fInitCDBCalled(kFALSE),
   fCDBSnapshotMode(kFALSE),
   fSetRunNumberFromDataCalled(kFALSE),
@@ -298,6 +298,8 @@ AliReconstruction::AliReconstruction(const char* gAliceFilename) :
   fWriteQAExpertData(kTRUE), 
   fRunPlaneEff(kFALSE),
 
+  fESDpid(NULL),
+
   fesd(NULL),
   fhltesd(NULL),
   fesdf(NULL),
@@ -315,6 +317,12 @@ AliReconstruction::AliReconstruction(const char* gAliceFilename) :
   fSspecie(0),
   fNhighPt(0),
   fShighPt(0),
+  //
+  fTreeBuffSize(30000000),
+  fMemCountESD(0),
+  fMemCountESDF(0),
+  fMemCountESDHLT(0),
+  //
   fUpgradeModule(""),
   fAnalysisMacro(),
   fAnalysis(0),
@@ -338,7 +346,9 @@ AliReconstruction::AliReconstruction(const char* gAliceFilename) :
     fQAWriteExpert[iDet] = kFALSE ; 
   }
   fBeamInt[0][0]=fBeamInt[0][1]=fBeamInt[1][0]=fBeamInt[1][1] = -1;
-
+  //
+  AddCheckRecoCDBvsSimuCDB("TPC/Calib/RecoParam"); // check for similarity in the sim and rec
+  //
   AliPID pid;
 }
 
@@ -347,12 +357,13 @@ AliReconstruction::AliReconstruction(const AliReconstruction& rec) :
   TSelector(),
   fRunVertexFinder(rec.fRunVertexFinder),
   fRunVertexFinderTracks(rec.fRunVertexFinderTracks),
-  fRunHLTTracking(rec.fRunHLTTracking),
   fRunMuonTracking(rec.fRunMuonTracking),
+  fRunMFTTrackingMU(rec.fRunMFTTrackingMU),
   fRunV0Finder(rec.fRunV0Finder),
   fRunCascadeFinder(rec.fRunCascadeFinder),
   fRunMultFinder(rec.fRunMultFinder),
   fStopOnError(rec.fStopOnError),
+  fStopOnMissingTriggerFile(rec.fStopOnMissingTriggerFile),
   fWriteAlignmentData(rec.fWriteAlignmentData),
   fWriteESDfriend(rec.fWriteESDfriend),
   fFillTriggerESD(rec.fFillTriggerESD),
@@ -411,6 +422,7 @@ AliReconstruction::AliReconstruction(const AliReconstruction& rec) :
   fCDBUri(rec.fCDBUri),
   fQARefUri(rec.fQARefUri),
   fSpecCDBUri(), 
+  fCheckRecoCDBvsSimuCDB(),
   fInitCDBCalled(rec.fInitCDBCalled),
   fCDBSnapshotMode(rec.fCDBSnapshotMode),
   fSetRunNumberFromDataCalled(rec.fSetRunNumberFromDataCalled),
@@ -423,6 +435,8 @@ AliReconstruction::AliReconstruction(const AliReconstruction& rec) :
   fWriteQAExpertData(rec.fWriteQAExpertData), 
   fRunPlaneEff(rec.fRunPlaneEff),
 
+  fESDpid(NULL),
+
   fesd(NULL),
   fhltesd(NULL),
   fesdf(NULL),
@@ -440,6 +454,12 @@ AliReconstruction::AliReconstruction(const AliReconstruction& rec) :
   fSspecie(0),
   fNhighPt(0),
   fShighPt(0),
+  //
+  fTreeBuffSize(rec.fTreeBuffSize),
+  fMemCountESD(0),
+  fMemCountESDF(0),
+  fMemCountESDHLT(0),
+  //
   fUpgradeModule(""),
   fAnalysisMacro(rec.fAnalysisMacro),
   fAnalysis(0),
@@ -470,6 +490,10 @@ AliReconstruction::AliReconstruction(const AliReconstruction& rec) :
     if (rec.fSpecCDBUri[i]) fSpecCDBUri.Add(rec.fSpecCDBUri[i]->Clone());
   }
 
+  for (Int_t i = 0; i < rec.fCheckRecoCDBvsSimuCDB.GetEntriesFast(); i++) {
+    if (rec.fCheckRecoCDBvsSimuCDB[i]) fCheckRecoCDBvsSimuCDB.AddLast(rec.fCheckRecoCDBvsSimuCDB[i]->Clone());
+  }
+
   for (int i=2;i--;) for (int j=2;j--;) fBeamInt[i][j] = rec.fBeamInt[i][j];
 
 }
@@ -488,12 +512,13 @@ AliReconstruction& AliReconstruction::operator = (const AliReconstruction& rec)
 
   fRunVertexFinder       = rec.fRunVertexFinder;
   fRunVertexFinderTracks = rec.fRunVertexFinderTracks;
-  fRunHLTTracking        = rec.fRunHLTTracking;
   fRunMuonTracking       = rec.fRunMuonTracking;
+  fRunMFTTrackingMU      = rec.fRunMFTTrackingMU;
   fRunV0Finder           = rec.fRunV0Finder;
   fRunCascadeFinder      = rec.fRunCascadeFinder;
   fRunMultFinder         = rec.fRunMultFinder;
   fStopOnError           = rec.fStopOnError;
+  fStopOnMissingTriggerFile = rec.fStopOnMissingTriggerFile;
   fWriteAlignmentData    = rec.fWriteAlignmentData;
   fWriteESDfriend        = rec.fWriteESDfriend;
   fFillTriggerESD        = rec.fFillTriggerESD;
@@ -584,6 +609,12 @@ AliReconstruction& AliReconstruction::operator = (const AliReconstruction& rec)
   fCDBUri        = "";
   fQARefUri      = rec.fQARefUri;
   fSpecCDBUri.Delete();
+  fCheckRecoCDBvsSimuCDB.Delete();
+  //
+  for (Int_t i = 0; i < rec.fCheckRecoCDBvsSimuCDB.GetEntriesFast(); i++) {
+    if (rec.fCheckRecoCDBvsSimuCDB[i]) fCheckRecoCDBvsSimuCDB.AddLast(rec.fCheckRecoCDBvsSimuCDB[i]->Clone());
+  }
+  //
   fInitCDBCalled               = rec.fInitCDBCalled;
   fCDBSnapshotMode             = rec.fCDBSnapshotMode;
   fSetRunNumberFromDataCalled  = rec.fSetRunNumberFromDataCalled;
@@ -596,6 +627,7 @@ AliReconstruction& AliReconstruction::operator = (const AliReconstruction& rec)
   fWriteQAExpertData           = rec.fWriteQAExpertData;
   fRunPlaneEff                 = rec.fRunPlaneEff;
   for (int i=2;i--;) for (int j=2;j--;) fBeamInt[i][j] = rec.fBeamInt[i][j];
+  fESDpid  = NULL;
   fesd     = NULL;
   fhltesd  = NULL;
   fesdf    = NULL;
@@ -613,6 +645,12 @@ AliReconstruction& AliReconstruction::operator = (const AliReconstruction& rec)
   fSspecie = 0;
   fNhighPt = 0;
   fShighPt = 0;
+  //
+  fTreeBuffSize = rec.fTreeBuffSize;
+  fMemCountESD = 0;
+  fMemCountESDF = 0;
+  fMemCountESDHLT = 0;
+  //
   fUpgradeModule="";
   fAnalysisMacro = rec.fAnalysisMacro;
   fAnalysis = 0;
@@ -642,7 +680,7 @@ AliReconstruction::~AliReconstruction()
     delete fAlignObjArray;
   }
   fSpecCDBUri.Delete();
-
+  fCheckRecoCDBvsSimuCDB.Delete();
   AliCodeTimer::Instance()->Print();
 }
 
@@ -659,6 +697,8 @@ void AliReconstruction::InitQA()
 
 
   AliQAManager * qam = AliQAManager::QAManager(AliQAv1::kRECMODE) ; 
+  qam->SetSaveData(kTRUE); 
+  qam->SetCycleLength(AliQAv1::kITS, 5) ; 
   if (fWriteQAExpertData)
     qam->SetWriteExpert() ; 
  
@@ -685,7 +725,9 @@ void AliReconstruction::InitQA()
   }
   
   if (fRunQA) {
-  qam->SetActiveDetectors(fQADetectors) ; 
+  qam->SetActiveDetectors(fQADetectors) ;
+  qam->SetActiveOnlineDetectors(fRunInfo->GetActiveDetectors());
+    
   for (Int_t det = 0 ; det < AliQAv1::kNDET ; det++) {
     qam->SetCycleLength(AliQAv1::DETECTORINDEX_t(det), fQACycles[det]) ;  
     qam->SetWriteExpert(AliQAv1::DETECTORINDEX_t(det)) ;
@@ -801,6 +843,7 @@ void AliReconstruction::SetQARefDefaultStorage(const char* uri) {
   AliQAv1::SetQARefStorage(fQARefUri.Data()) ;
   
 }
+
 //_____________________________________________________________________________
 void AliReconstruction::SetSpecificStorage(const char* calibType, const char* uri) {
 // Store a detector-specific CDB storage location
@@ -843,6 +886,48 @@ void AliReconstruction::SetSpecificStorage(const char* calibType, const char* ur
 
 }
 
+//_____________________________________________________________________________
+void AliReconstruction::AddCheckRecoCDBvsSimuCDB(const char* cdbpath,const char* comment) 
+{
+  // require the cdb item to be the same in the rec as in the sim
+  // Activate it later within the Run() method
+  TString newent = cdbpath;
+  if (newent.IsNull()) return;
+  TIter nextit(&fCheckRecoCDBvsSimuCDB);
+  TNamed* cdbent=0;
+  while ((cdbent=(TNamed*)nextit())) {
+    TString str = cdbent->GetName();
+    if (str==newent) {
+      AliInfo(Form("%s is already in the list to check",cdbpath));
+      return;
+    }
+  }
+  fCheckRecoCDBvsSimuCDB.AddLast(new TNamed(cdbpath,comment));
+  //
+}
+
+//_____________________________________________________________________________
+void AliReconstruction::RemCheckRecoCDBvsSimuCDB(const char* cdbpath) 
+{
+  // require the cdb item to be the same in the rec as in the sim
+  // Activate it later within the Run() method
+  TString newent = cdbpath;
+  if (newent.IsNull()) return;
+  TIter nextit(&fCheckRecoCDBvsSimuCDB);
+  TNamed* cdbent=0;
+  while ((cdbent=(TNamed*)nextit())) {
+    TString str = cdbent->GetName();
+    if (str==newent) {
+      AliInfo(Form("Removing %s from the list to check",cdbpath));
+      delete fCheckRecoCDBvsSimuCDB.Remove(cdbent);
+      fCheckRecoCDBvsSimuCDB.Compress();
+      return;
+    }
+  }
+  AliInfo(Form("%s is not in the list to check",cdbpath));
+  //
+}
+
 //_____________________________________________________________________________
 Bool_t AliReconstruction::SetRunNumberFromData()
 {
@@ -1119,6 +1204,7 @@ Bool_t AliReconstruction::InitGRP() {
     fRunTracking = MatchDetectorList(fRunTracking,detMask);
     fFillESD = MatchDetectorList(fFillESD,detMask);
     fQADetectors = MatchDetectorList(fQADetectors,detMask);
+    AliInfo(Form("fQADetectors=%s",fQADetectors.Data()));
     fDeleteRecPoints = MatchDetectorList(fDeleteRecPoints,detMask);
     fDeleteDigits    = MatchDetectorList(fDeleteDigits,detMask);
     fLoadCDB.Form("%s %s %s %s",
@@ -1270,6 +1356,7 @@ Bool_t AliReconstruction::LoadCDB()
   // in the trigger or that are needed in order to put correct
   // information in ESD
   AliCDBManager::Instance()->GetAll("TRIGGER/*/*");
+  AliCDBManager::Instance()->GetAll("HLT/*/*");
 
   return kTRUE;
 }
@@ -1430,6 +1517,7 @@ Bool_t AliReconstruction::Run(const char* input)
         Abort("ProcessEvent",TSelector::kAbortFile);
         return kFALSE;
       }
+      CleanProcessedEvent();
       iEvent++;
     }
     if (!iEvent) AliWarning("No events passed trigger selection");
@@ -1522,7 +1610,7 @@ void AliReconstruction::Begin(TTree *)
   }
 
   // Import ideal TGeo geometry and apply misalignment
-  if (!gGeoManager) {
+  if (!AliGeomManager::GetGeometry()) {
     TString geom(gSystem->DirName(fGAliceFileName));
     geom += "/geometry.root";
     AliGeomManager::LoadGeometry(geom.Data());
@@ -1556,7 +1644,10 @@ void AliReconstruction::Begin(TTree *)
     Abort("MisalignGeometry", TSelector::kAbortProcess);
     return;
   }
-  AliCDBManager::Instance()->UnloadFromCache("GRP/Geometry/Data");
+
+  const TMap* cdbCache = AliCDBManager::Instance()->GetEntryCache();
+  if(cdbCache->Contains("GRP/Geometry/Data"))
+         AliCDBManager::Instance()->UnloadFromCache("GRP/Geometry/Data");
   if(!toCDBSnapshot) AliCDBManager::Instance()->UnloadFromCache("*/Align/*");
   AliSysInfo::AddStamp("MisalignGeom");
 
@@ -1565,7 +1656,9 @@ void AliReconstruction::Begin(TTree *)
     return;
   }
   AliSysInfo::AddStamp("InitGRP");
-  if(!toCDBSnapshot) AliCDBManager::Instance()->UnloadFromCache("GRP/Calib/CosmicTriggers");
+  if(!toCDBSnapshot)
+      if(cdbCache->Contains("GRP/Calib/CosmicTriggers"))
+         AliCDBManager::Instance()->UnloadFromCache("GRP/Calib/CosmicTriggers");
 
   if(!fCDBSnapshotMode || toCDBSnapshot){
       if (!LoadCDB()) {
@@ -1603,7 +1696,8 @@ void AliReconstruction::Begin(TTree *)
   {
       AliCDBManager::Instance()->DumpToSnapshotFile(snapshotFileOut.Data(),kFALSE);
       AliCDBManager::Instance()->UnloadFromCache("*/Align/*");
-      AliCDBManager::Instance()->UnloadFromCache("GRP/Calib/CosmicTriggers");
+      if(cdbCache->Contains("GRP/Calib/CosmicTriggers"))
+         AliCDBManager::Instance()->UnloadFromCache("GRP/Calib/CosmicTriggers");
   }
 
   if (fInput && gProof) {
@@ -1713,6 +1807,8 @@ void AliReconstruction::SlaveBegin(TTree*)
   }
   AliSysInfo::AddStamp("LoadLoader");
  
+  CheckRecoCDBvsSimuCDB();
+
   ftVertexer = new AliVertexerTracks(AliTracker::GetBz());
 
   // get trackers
@@ -1770,6 +1866,10 @@ void AliReconstruction::SlaveBegin(TTree*)
   // ESD layout template in CDB
   AliCDBManager* man = AliCDBManager::Instance();
   AliCDBEntry* hltESDConfig = man->Get("HLT/Calib/esdLayout");
+  if(!hltESDConfig){
+      AliError(Form("Error getting \"HLT/Calib/esdLayout\""));
+      return;
+  }
   AliESDEvent* pESDLayout=dynamic_cast<AliESDEvent*>(hltESDConfig->GetObject());
   if (pESDLayout) {
       // init all internal variables from the list of objects
@@ -1789,6 +1889,9 @@ void AliReconstruction::SlaveBegin(TTree*)
   gSystem->GetProcInfo(&procInfo);
   AliInfo(Form("Current memory usage %ld %ld", procInfo.fMemResident, procInfo.fMemVirtual));
   
+  // PID
+  fESDpid = new AliESDpid();
+
   //QA
   //Initialize the QA and start of cycle 
   if (fRunQA || fRunGlobalQA) 
@@ -1878,8 +1981,6 @@ Bool_t AliReconstruction::ProcessEvent(Int_t iEvent)
 
   AliCodeTimerAuto("",0);
 
-  AliESDpid pid;
-
   AliSysInfo::AddStamp(Form("StartEv_%d",iEvent), 0,0,iEvent);
 
   if (iEvent >= fRunLoader->GetNumberOfEvents()) {
@@ -1924,7 +2025,7 @@ Bool_t AliReconstruction::ProcessEvent(Int_t iEvent)
       if (reconstructor && fRecoParam.GetDetRecoParamArray(iDet)) {
         const AliDetectorRecoParam *par = fRecoParam.GetDetRecoParam(iDet);
         reconstructor->SetRecoParam(par);
-       reconstructor->GetPidSettings(&pid);
+       reconstructor->GetPidSettings(fESDpid);
        reconstructor->SetEventInfo(&fEventInfo);
         if (fRunQA) {
           AliQAManager::QAManager()->SetEventInfo(&fEventInfo) ;
@@ -1949,29 +2050,15 @@ Bool_t AliReconstruction::ProcessEvent(Int_t iEvent)
     AliQAManager::QAManager()->RunOneEvent(fRawReader) ;  
     AliSysInfo::AddStamp(Form("RawQA_%d",iEvent), 0,0,iEvent);
   }
-    // local single event reconstruction
-    if (!fRunLocalReconstruction.IsNull()) {
-      TString detectors=fRunLocalReconstruction;
-      // run HLT event reconstruction first
-      // ;-( IsSelected changes the string
-      if (IsSelected("HLT", detectors) &&
-         !RunLocalEventReconstruction("HLT")) {
-       if (fStopOnError) {CleanUp(); return kFALSE;}
-      }
-      detectors=fRunLocalReconstruction;
-      detectors.ReplaceAll("HLT", "");
-      if (!RunLocalEventReconstruction(detectors)) {
-        if (fStopOnError) {
-          CleanUp(); 
-          return kFALSE;
-        }
-      }
-    }
 
-  
     // fill Event header information from the RawEventHeader
     if (fRawReader){FillRawEventHeaderESD(fesd);}
     if (fRawReader){FillRawEventHeaderESD(fhltesd);}
+    if (fRawReader){
+      // Store DAQ detector pattern and attributes
+      fesd->SetDAQDetectorPattern(fRawReader->GetDetectorPattern()[0]);
+      fesd->SetDAQAttributes(fRawReader->GetAttributes()[2]);
+    }
 
     fesd->SetRunNumber(fRunLoader->GetHeader()->GetRun());
     fhltesd->SetRunNumber(fRunLoader->GetHeader()->GetRun());
@@ -2023,6 +2110,43 @@ Bool_t AliReconstruction::ProcessEvent(Int_t iEvent)
       fhltesd->SetUniformBMap(fld->IsUniform());
       fhltesd->SetBInfoStored();
     }
+
+    //
+    // run full HLT reconstruction first
+    //
+    {
+      TString detectors=fRunLocalReconstruction;
+      if (IsSelected("HLT", detectors) &&
+         !RunLocalEventReconstruction("HLT")) {
+       if (fStopOnError) {CleanUp(); return kFALSE;}
+      }
+      detectors=fFillESD;
+      // run HLT on hltesd
+      if (IsSelected("HLT", detectors) &&
+         !FillESD(fhltesd, "HLT")) {
+       if (fStopOnError) {CleanUp(); return kFALSE;}
+      }
+    }
+
+    // local single event reconstruction
+    if (!fRunLocalReconstruction.IsNull()) {
+      TString detectors=fRunLocalReconstruction;
+      // the logic for selection and correct sequence of reconstruction relies on the
+      // full list of detectors. Keyword 'ALL' should have been replaced at this point.
+      if (detectors.Contains("ALL")) {
+       AliFatal("Keyword 'ALL' needs to be replaced by the full list of detectors in "
+                "fRunLocalReconstruction. This should have been done by the framework");
+      }
+      detectors.ReplaceAll("HLT", "");
+      if (!RunLocalEventReconstruction(detectors)) {
+        if (fStopOnError) {
+          CleanUp(); 
+          return kFALSE;
+        }
+      }
+    }
+
+  
     //
     // Set most probable pt, for B=0 tracking
     // Get the global reco-params. They are atposition 16 inside the array of detectors in fRecoParam
@@ -2060,9 +2184,23 @@ Bool_t AliReconstruction::ProcessEvent(Int_t iEvent)
       AliSysInfo::AddStamp(Form("TrackingMUON_%d",iEvent), 0,0,iEvent);      
     }
 
+    //---------------- AU From here...
+
+    // MFT tracking of MUON tracks
+    if (!fRunTracking.IsNull()) {
+      if (fRunMFTTrackingMU && fRunMuonTracking) {
+       if (!RunMFTTrackingMU(fesd)) {
+         if (fStopOnError) {CleanUp(); return kFALSE;}
+       }
+      }
+      AliSysInfo::AddStamp(Form("TrackingMFT_MUON_%d",iEvent), 0,0,iEvent);      
+    }
+
+    //---------------- ...to here
+
     // barrel tracking
     if (!fRunTracking.IsNull()) {
-      if (!RunTracking(fesd,pid)) {
+      if (!RunTracking(fesd,*fESDpid)) {
        if (fStopOnError) {CleanUp(); return kFALSE;}
       }
     }
@@ -2070,27 +2208,18 @@ Bool_t AliReconstruction::ProcessEvent(Int_t iEvent)
     // fill ESD
     if (!fFillESD.IsNull()) {
       TString detectors=fFillESD;
-      // run HLT first and on hltesd
-      // ;-( IsSelected changes the string
-      if (IsSelected("HLT", detectors) &&
-         !FillESD(fhltesd, "HLT")) {
-       if (fStopOnError) {CleanUp(); return kFALSE;}
-      }
-      detectors=fFillESD;
-      // Temporary fix to avoid problems with HLT that overwrites the offline ESDs
+      // the logic for selection and correct sequence of reconstruction relies on the
+      // full list of detectors. Keyword 'ALL' should have been replaced at this point.
       if (detectors.Contains("ALL")) {
-       detectors="";
-       for (Int_t idet=0; idet<kNDetectors; ++idet){
-         detectors += fgkDetectorName[idet];
-         detectors += " ";
-       }
+       AliFatal("Keyword 'ALL' needs to be replaced by the full list of detectors in "
+                "fFillESD. This should have been done by the framework");
       }
+      // remove HLT as this has been executed at the beginning of the event reconstruction
       detectors.ReplaceAll("HLT", "");
       if (!FillESD(fesd, detectors)) {
        if (fStopOnError) {CleanUp(); return kFALSE;}
       }
     }
-    
 
     ffile->cd();
 
@@ -2115,7 +2244,7 @@ Bool_t AliReconstruction::ProcessEvent(Int_t iEvent)
       ok = kFALSE;
       if (tpcTrack)
        ok = AliTracker::
-         PropagateTrackToBxByBz(tpcTrack,kRadius,track->GetMass(),kMaxStep,kFALSE);
+         PropagateTrackToBxByBz(tpcTrack,kRadius,track->GetMassForTracking(),kMaxStep,kFALSE);
 
       if (ok) {
        Int_t n=trkArray.GetEntriesFast();
@@ -2127,7 +2256,7 @@ Bool_t AliReconstruction::ProcessEvent(Int_t iEvent)
       if (track->IsOn(AliESDtrack::kITSrefit)) continue;
 
       AliTracker::
-         PropagateTrackToBxByBz(track,kRadius,track->GetMass(),kMaxStep,kFALSE);
+         PropagateTrackToBxByBz(track,kRadius,track->GetMassForTracking(),kMaxStep,kFALSE);
       Double_t x[3]; track->GetXYZ(x);
       Double_t b[3]; AliTracker::GetBxByBz(x,b);
       track->RelateToVertexBxByBz(fesd->GetPrimaryVertexSPD(), b, kVeryBig);
@@ -2252,10 +2381,10 @@ Bool_t AliReconstruction::ProcessEvent(Int_t iEvent)
 
     // AdC+FN
     if (fReconstructor[3])
-      GetReconstructor(3)->FillEventTimeWithTOF(fesd,&pid);
+      GetReconstructor(3)->FillEventTimeWithTOF(fesd,fESDpid);
 
     // combined PID
-    pid.MakePID(fesd);
+    //    fESDpid->MakePID(fesd);
 
     if (fFillTriggerESD) {
       if (!FillTriggerESD(fesd)) {
@@ -2326,7 +2455,16 @@ Bool_t AliReconstruction::ProcessEvent(Int_t iEvent)
   
   }
   //
-  ftree->Fill();
+  Long64_t nbf;
+  nbf = ftree->Fill();
+  if (fTreeBuffSize>0 && ftree->GetAutoFlush()<0 && (fMemCountESD += nbf)>fTreeBuffSize ) { // default limit is still not reached
+    nbf = ftree->GetZipBytes();
+    if (nbf>0) nbf = -nbf;
+    else       nbf = ftree->GetEntries();
+    ftree->SetAutoFlush(nbf);
+    AliInfo(Form("Calling ftree->SetAutoFlush(%lld) | W:%lld T:%lld Z:%lld",
+                nbf,fMemCountESD,ftree->GetTotBytes(),ftree->GetZipBytes()));        
+  }
   AliSysInfo::AddStamp(Form("ESDFill_%d",iEvent), 0,0,iEvent);     
   //
   if (fWriteESDfriend) {
@@ -2340,11 +2478,24 @@ Bool_t AliReconstruction::ProcessEvent(Int_t iEvent)
     ftree->AutoSave("SaveSelf");
     if (fWriteESDfriend) ftreeF->AutoSave("SaveSelf");
   }
-    // write HLT ESD
-    fhlttree->Fill();
+  // write HLT ESD
+  
+  nbf = fhlttree->Fill();
+  if (fTreeBuffSize>0 && fhlttree->GetAutoFlush()<0 && (fMemCountESDHLT += nbf)>fTreeBuffSize ) { // default limit is still not reached
+    nbf = fhlttree->GetZipBytes();
+    if (nbf>0) nbf = -nbf;
+    else       nbf = fhlttree->GetEntries();
+    fhlttree->SetAutoFlush(nbf);
+    AliInfo(Form("Calling fhlttree->SetAutoFlush(%lld) | W:%lld T:%lld Z:%lld",
+                nbf,fMemCountESDHLT,fhlttree->GetTotBytes(),fhlttree->GetZipBytes()));        
+  }
+    
+    
+  return kTRUE;
+}
 
-    // call AliEVE
-    if (fRunAliEVE) RunAliEVE();
+void AliReconstruction::CleanProcessedEvent()
+{
     //
     fesd->Reset();
     fhltesd->Reset();
@@ -2352,20 +2503,13 @@ Bool_t AliReconstruction::ProcessEvent(Int_t iEvent)
       fesdf->~AliESDfriend();
       new (fesdf) AliESDfriend(); // Reset...
     }
+
+    for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
+      if (fReconstructor[iDet]) fReconstructor[iDet]->FinishEvent();
+    }
  
-    gSystem->GetProcInfo(&procInfo);
-    Long_t dMres=(procInfo.fMemResident-oldMres)/1024;
-    Long_t dMvir=(procInfo.fMemVirtual-oldMvir)/1024;
-    Float_t dCPU=procInfo.fCpuUser+procInfo.fCpuSys-oldCPU;
-    aveDMres+=(dMres-aveDMres)/(iEvent-fFirstEvent+1);
-    aveDMvir+=(dMvir-aveDMvir)/(iEvent-fFirstEvent+1);
-    aveDCPU+=(dCPU-aveDCPU)/(iEvent-fFirstEvent+1);
-    AliInfo(Form("======================= End Event %d: Res %ld(%3ld <%3ld>) Vir %ld(%3ld <%3ld>) CPU %5.2f <%5.2f> ===================",
-                iEvent, procInfo.fMemResident/1024, dMres, aveDMres, procInfo.fMemVirtual/1024, dMvir, aveDMvir, dCPU, aveDCPU));
-    oldMres=procInfo.fMemResident;
-    oldMvir=procInfo.fMemVirtual;
-    oldCPU=procInfo.fCpuUser+procInfo.fCpuSys;
-  
+    AliInfo("======================= End Event ===================");
+    
     fEventInfo.Reset();
     for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
       if (fReconstructor[iDet]) {
@@ -2381,7 +2525,7 @@ Bool_t AliReconstruction::ProcessEvent(Int_t iEvent)
   DeleteRecPoints(fDeleteRecPoints);
   DeleteDigits(fDeleteDigits);
   //
-  return kTRUE;
+
 }
 
 //_____________________________________________________________________________
@@ -2437,13 +2581,25 @@ void AliReconstruction::SlaveTerminate()
 
    // Add the AliRoot version that created this file
    TString sVersion("aliroot ");
-   sVersion += ALIROOT_SVN_BRANCH;
+   sVersion += ALIROOT_BRANCH;
    sVersion += ":";
-   sVersion += ALIROOT_SVN_REVISION;
+   sVersion += ALIROOT_REVISION;
    sVersion += "; root ";
+#ifdef ROOT_SVN_BRANCH
    sVersion += ROOT_SVN_BRANCH;
+#elif defined(ROOT_GIT_BRANCH)
+   sVersion += ROOT_GIT_BRANCH;
+#else
+   sVersion += "?";
+#endif
    sVersion += ":";
+#ifdef ROOT_SVN_REVSION
    sVersion += ROOT_SVN_REVISION;
+#elif defined(ROOT_GIT_COMMIT)
+   sVersion += ROOT_GIT_COMMIT;
+#else 
+   sVersion += "?";
+#endif
    sVersion += "; metadata ";
    sVersion += getenv("PRODUCTION_METADATA");
                    
@@ -2550,7 +2706,7 @@ Bool_t AliReconstruction::RunLocalEventReconstruction(const TString& detectors)
   // execute HLT reconstruction first since other detector reconstruction
   // might depend on HLT data
   // key 'HLT' is removed from detStr by IsSelected
-  if (!IsSelected("HLT", detStr)) {
+  if (IsSelected("HLT", detStr)) {
     AliReconstructor* reconstructor = GetReconstructor(kNDetectors-1);
     if (reconstructor) {
       // there is no AliLoader for HLT, see
@@ -2796,9 +2952,9 @@ Bool_t AliReconstruction::RunMultFinder(AliESDEvent*& esd)
 }
 
 //_____________________________________________________________________________
-Bool_t AliReconstruction::RunHLTTracking(AliESDEvent*& esd)
+Bool_t AliReconstruction::RunMuonTracking(AliESDEvent*& esd)
 {
-// run the HLT barrel tracking
+// run the muon spectrometer tracking
 
   AliCodeTimerAuto("",0)
 
@@ -2806,55 +2962,48 @@ Bool_t AliReconstruction::RunHLTTracking(AliESDEvent*& esd)
     AliError("Missing runLoader!");
     return kFALSE;
   }
+  Int_t iDet =  GetDetIndex("MUON"); // for MUON
 
-  AliInfo("running HLT tracking");
-
-  // Get a pointer to the HLT reconstructor
-  AliReconstructor *reconstructor = GetReconstructor(kNDetectors-1);
+  // Get a pointer to the MUON reconstructor
+  AliReconstructor *reconstructor = GetReconstructor(iDet);
   if (!reconstructor) return kFALSE;
 
-  // TPC + ITS
-  for (Int_t iDet = 1; iDet >= 0; iDet--) {
-    TString detName = fgkDetectorName[iDet];
-    AliDebug(1, Form("%s HLT tracking", detName.Data()));
-    reconstructor->SetOption(detName.Data());
-    AliTracker *tracker = reconstructor->CreateTracker();
-    if (!tracker) {
-      AliWarning(Form("couldn't create a HLT tracker for %s", detName.Data()));
-      if (fStopOnError) return kFALSE;
-      continue;
-    }
-    Double_t vtxPos[3];
-    Double_t vtxErr[3]={0.005,0.005,0.010};
-    const AliESDVertex *vertex = esd->GetVertex();
-    vertex->GetXYZ(vtxPos);
-    tracker->SetVertex(vtxPos,vtxErr);
-    if(iDet != 1) {
-      fLoader[iDet]->LoadRecPoints("read");
-      TTree* tree = fLoader[iDet]->TreeR();
-      if (!tree) {
-       AliError(Form("Can't get the %s cluster tree", detName.Data()));
-       return kFALSE;
-      }
-      tracker->LoadClusters(tree);
-    }
-    if (tracker->Clusters2Tracks(esd) != 0) {
-      AliError(Form("HLT %s Clusters2Tracks failed", fgkDetectorName[iDet]));
-      return kFALSE;
-    }
-    if(iDet != 1) {
-      tracker->UnloadClusters();
-    }
-    delete tracker;
+  
+  TString detName = fgkDetectorName[iDet];
+  AliDebug(1, Form("%s tracking", detName.Data()));
+  AliTracker *tracker =  reconstructor->CreateTracker();
+  if (!tracker) {
+    AliWarning(Form("couldn't create a tracker for %s", detName.Data()));
+    return kFALSE;
   }
+     
+  // read RecPoints
+  fLoader[iDet]->LoadRecPoints("read");  
+
+  tracker->LoadClusters(fLoader[iDet]->TreeR());
+  
+  Int_t rv = tracker->Clusters2Tracks(esd);
+  
+  fLoader[iDet]->UnloadRecPoints();
 
+  tracker->UnloadClusters();
+  
+  if ( rv )
+  {
+    AliError(Form("%s Clusters2Tracks failed", fgkDetectorName[iDet]));
+    return kFALSE;
+  }
+  
   return kTRUE;
 }
 
+
 //_____________________________________________________________________________
-Bool_t AliReconstruction::RunMuonTracking(AliESDEvent*& esd)
-{
-// run the muon spectrometer tracking
+Bool_t AliReconstruction::RunMFTTrackingMU(AliESDEvent*& esd) {
+
+  // AU
+
+  // run the global muon tracking: matching the MUON tracks with the MFT clusters
 
   AliCodeTimerAuto("",0)
 
@@ -2862,18 +3011,17 @@ Bool_t AliReconstruction::RunMuonTracking(AliESDEvent*& esd)
     AliError("Missing runLoader!");
     return kFALSE;
   }
-  Int_t iDet =  GetDetIndex("MUON"); // for MUON
+  Int_t iDet = GetDetIndex("MFT"); // for MFT
 
-  // Get a pointer to the MUON reconstructor
+  // Get a pointer to the MFT reconstructor
   AliReconstructor *reconstructor = GetReconstructor(iDet);
   if (!reconstructor) return kFALSE;
-
   
   TString detName = fgkDetectorName[iDet];
-  AliDebug(1, Form("%s tracking", detName.Data()));
-  AliTracker *tracker =  reconstructor->CreateTracker();
+  AliDebug(1, Form("%s tracking for muon tracks", detName.Data()));
+  AliTracker *tracker = reconstructor->CreateTracker();
   if (!tracker) {
-    AliWarning(Form("couldn't create a tracker for %s", detName.Data()));
+    AliWarning(Form("couldn't create a Muon tracker for %s", detName.Data()));
     return kFALSE;
   }
      
@@ -2888,15 +3036,14 @@ Bool_t AliReconstruction::RunMuonTracking(AliESDEvent*& esd)
 
   tracker->UnloadClusters();
   
-  if ( rv )
-  {
+  if (rv) {
     AliError(Form("%s Clusters2Tracks failed", fgkDetectorName[iDet]));
     return kFALSE;
   }
   
   return kTRUE;
-}
 
+}
 
 //_____________________________________________________________________________
 Bool_t AliReconstruction::RunTracking(AliESDEvent*& esd,AliESDpid &PID)
@@ -2942,7 +3089,7 @@ Bool_t AliReconstruction::RunTracking(AliESDEvent*& esd,AliESDpid &PID)
     fTracker[iDet]->LoadClusters(tree);
     AliSysInfo::AddStamp(Form("TLoadCluster%s_%d",fgkDetectorName[iDet],eventNr), iDet,2, eventNr);
     // run tracking
-    if (fTracker[iDet]->Clusters2Tracks(esd) != 0) {
+    if (fTracker[iDet]->Clusters2TracksHLT(esd, fhltesd) != 0) {
       AliError(Form("%s Clusters2Tracks failed", fgkDetectorName[iDet]));
       return kFALSE;
     }
@@ -2950,7 +3097,7 @@ Bool_t AliReconstruction::RunTracking(AliESDEvent*& esd,AliESDpid &PID)
     // preliminary PID in TPC needed by the ITS tracker
     if (iDet == 1) {
       GetReconstructor(1)->FillESD((TTree*)NULL, (TTree*)NULL, esd);
-      PID.MakePID(esd,kTRUE);
+      PID.MakePIDForTracking(esd);
       AliSysInfo::AddStamp(Form("MakePID0%s_%d",fgkDetectorName[iDet],eventNr), iDet,4,eventNr);
     } 
   }
@@ -3005,7 +3152,7 @@ Bool_t AliReconstruction::RunTracking(AliESDEvent*& esd,AliESDpid &PID)
     if (iDet == 1) {
       //GetReconstructor(1)->FillESD((TTree*)NULL, (TTree*)NULL, esd);
       //AliESDpid::MakePID(esd);
-      PID.MakePID(esd,kTRUE);
+      PID.MakePIDForTracking(esd);
       AliSysInfo::AddStamp(Form("MakePID1%s_%d",fgkDetectorName[iDet],eventNr), iDet,4,eventNr);
     }
 
@@ -3288,7 +3435,6 @@ Bool_t AliReconstruction::InitRunLoader()
     TString libs = gSystem->GetLibraries();
     for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
       TString detName = fgkDetectorName[iDet];
-      if (detName == "HLT") continue;
       if (libs.Contains("lib" + detName + "base.so")) continue;
       gSystem->Load("lib" + detName + "base.so");
     }
@@ -3387,6 +3533,7 @@ AliReconstructor* AliReconstruction::GetReconstructor(Int_t iDet)
     TObject* obj = fOptions.FindObject(detName.Data());
     if (obj) reconstructor->SetOption(obj->GetTitle());
     reconstructor->SetRunInfo(fRunInfo);
+    reconstructor->SetHLTESD(fhltesd);
     reconstructor->Init();
     fReconstructor[iDet] = reconstructor;
   }
@@ -3493,14 +3640,14 @@ Bool_t AliReconstruction::CreateTrackers(const TString& detectors)
     AliReconstructor* reconstructor = GetReconstructor(iDet);
     if (!reconstructor) continue;
     TString detName = fgkDetectorName[iDet];
-    if (detName == "HLT") {
-      fRunHLTTracking = kTRUE;
-      continue;
-    }
     if (detName == "MUON") {
       fRunMuonTracking = kTRUE;
       continue;
     }
+    if (detName == "MFT") {           // AU    
+      fRunMFTTrackingMU = kTRUE;      // AU
+      continue;                              // AU
+    }                                 // AU
 
     fTracker[iDet] = reconstructor->CreateTracker();
     if (!fTracker[iDet] && (iDet < 7)) {
@@ -3517,7 +3664,6 @@ Bool_t AliReconstruction::CreateTrackers(const TString& detectors)
 void AliReconstruction::CleanUp()
 {
 // delete trackers and the run loader and close and delete the file
-/*
   for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
     delete fReconstructor[iDet];
     fReconstructor[iDet] = NULL;
@@ -3525,7 +3671,6 @@ void AliReconstruction::CleanUp()
     delete fTracker[iDet];
     fTracker[iDet] = NULL;
   }
-*/
 
   delete fRunInfo;
   fRunInfo = NULL;
@@ -3543,6 +3688,9 @@ void AliReconstruction::CleanUp()
   delete fParentRawReader;
   fParentRawReader=NULL;
 
+  delete fESDpid;
+  fESDpid = NULL;
+
   if (ffile) {
     ffile->Close();
     delete ffile;
@@ -3987,6 +4135,7 @@ Bool_t AliReconstruction::GetEventInfo()
       fEventInfo.SetTriggerCluster(AliDAQ::ListOfTriggeredDetectors(aCTP->GetClusterMask()));
     }
     else {
+      if (fStopOnMissingTriggerFile) AliFatal("No trigger can be loaded! Stopping reconstruction!");
       AliWarning("No trigger can be loaded! The trigger information will not be used!");
       return kFALSE;
     }
@@ -4000,6 +4149,9 @@ Bool_t AliReconstruction::GetEventInfo()
   }
 
   // Load trigger aliases and declare the trigger classes included in aliases
+  //PH Why do we do it in each event and not only once in the beginning of the chunk??
+  //PH Temporary fix for #99725: AliReconstruction::GetEventInfo bug
+  fDeclTriggerClasses.Clear();
   AliCDBEntry * entry = AliCDBManager::Instance()->Get("GRP/CTP/Aliases");
   if (entry) {
     THashList * lst = dynamic_cast<THashList*>(entry->GetObject());
@@ -4377,7 +4529,16 @@ void AliReconstruction::WriteESDfriend() {
     fesdf->SetSkipBit(kTRUE);
   }
   //
-  ftreeF->Fill();
+  Long64_t nbf = ftreeF->Fill();
+  if (fTreeBuffSize>0 && ftreeF->GetAutoFlush()<0 && (fMemCountESDF += nbf)>fTreeBuffSize ) { // default limit is still not reached
+    nbf = ftreeF->GetZipBytes();
+    if (nbf>0) nbf = -nbf;
+    else       nbf = ftreeF->GetEntries();
+    ftreeF->SetAutoFlush(nbf);
+    AliInfo(Form("Calling ftreeF->SetAutoFlush(%lld) | W:%lld T:%lld Z:%lld",
+                nbf,fMemCountESDF,ftreeF->GetTotBytes(),ftreeF->GetZipBytes()));        
+  }
+  
 }
 
 //_________________________________________________________________
@@ -4390,6 +4551,7 @@ void AliReconstruction::DeleteDigits(const TString& detectors)
   AliInfo(Form("Deleting Digits: %s",detectors.Data()));
 
   for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
+    if(!IsSelected(fgkDetectorName[iDet], detStr)) continue;
     unlink(Form("%s.Digits.root",fgkDetectorName[iDet]));
   }
   AliSysInfo::AddStamp(Form("DelDigits_%d",iEvent), 0,0,iEvent);
@@ -4406,6 +4568,7 @@ void AliReconstruction::DeleteRecPoints(const TString& detectors)
   AliInfo(Form("Deleting Recpoints: %s",detectors.Data()));
   //
   for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
+    if(!IsSelected(fgkDetectorName[iDet], detStr)) continue;
     unlink(Form("%s.RecPoints.root",fgkDetectorName[iDet]));
   }
   AliSysInfo::AddStamp(Form("DelRecPoints_%d",iEvent), 0,0,iEvent);
@@ -4470,9 +4633,159 @@ Bool_t AliReconstruction::HasEnoughResources(int ev)
     //
     unlink(Form("%s",fgkStopEvFName));
     ofstream outfile(fgkStopEvFName);
-    outfile << ev << endl;
+    outfile << ev << std::endl;
     outfile.close();
     fStopped = kTRUE;
   }
   return res;
 }
+
+Bool_t AliReconstruction::HasNextEventAfter(Int_t eventId)
+{
+        return ( (eventId < fRunLoader->GetNumberOfEvents()) ||
+          (fRawReader && fRawReader->NextEvent()) );
+}
+
+//_________________________________________________________________
+void AliReconstruction::CheckRecoCDBvsSimuCDB()
+{
+  // if some CDB entries must be the same in the simulation
+  // and reconstruction, check here
+  int nent = fCheckRecoCDBvsSimuCDB.GetEntriesFast();
+  AliInfo(Form("Check %d entries for matching between sim and rec",nent));
+  //
+  // get simulation CDB
+  fRunLoader->CdGAFile();
+  TMap*  cdbMapSim  = (TMap*)gDirectory->Get("cdbMap");
+  TList* cdbListSim = (TList*)gDirectory->Get("cdbList");
+  if (!(cdbMapSim && cdbListSim)) {
+    AliInfo(Form("No CDBMap/List found in %s, nothing to check",fGAliceFileName.Data()));
+    return;
+  }
+  // read the requested objects to make sure they will appear in the reco list
+  for (Int_t i=0;i<nent;i++) {
+    TNamed* cdbent = (TNamed*) fCheckRecoCDBvsSimuCDB[i];
+    if (!cdbent) continue;
+    AliCDBManager::Instance()->Get(cdbent->GetName());
+  }
+  // get default path for simulation
+  TPair* pair;
+  TObjString* stro;
+  pair = (TPair*)cdbMapSim->FindObject("default");
+  if (!pair) {AliFatal("Did not find default storage used for simulations"); return;}
+  TString defSimStore = ((TObjString*)pair->Value())->GetString();
+  RectifyCDBurl(defSimStore);
+  //
+  // get reconstruction CDB
+  const TMap *cdbMapRec = AliCDBManager::Instance()->GetStorageMap();   
+  const TList *cdbListRec = AliCDBManager::Instance()->GetRetrievedIds();       
+  //
+  // get default path for reconstruction
+  pair = (TPair*)cdbMapRec->FindObject("default");
+  if (!pair) {AliFatal("Did not find default storage used for reconstruction"); return;}
+  TString defRecStore = ((TObjString*)pair->Value())->GetString();
+  RectifyCDBurl(defRecStore);
+  //
+  for (Int_t i=0;i<nent;i++) {
+    TNamed* cdbent = (TNamed*) fCheckRecoCDBvsSimuCDB[i];
+    if (!cdbent) continue;
+    //
+    AliInfo(Form("#%d Checking %s",i,cdbent->GetName()));
+    //
+    // check in the simuCDB special params
+    pair = (TPair*)cdbMapSim->FindObject(cdbent->GetName());
+    TString idSimD = "";
+    TString idSimS = "";
+    if (pair) { // specific path is used
+      idSimS = ((TObjString*)pair->Value())->GetString();
+      RectifyCDBurl(idSimS);
+    }
+    else { // check in default storage list
+      TIter nextSim(cdbListSim);
+      while ((stro=(TObjString*)nextSim())) {
+       if (stro->GetString().Contains(cdbent->GetName())) {
+         idSimD = stro->GetString();
+         break;
+       }
+      }
+    }
+    //
+    // check in the recoCDB special params
+    pair = (TPair*)cdbMapRec->FindObject(cdbent->GetName());
+    TString idRecD = "";
+    TString idRecS = "";
+    if (pair) {  // specific path is used
+      idRecS = ((TObjString*)pair->Value())->GetString();
+      RectifyCDBurl(idRecS);
+    }
+    else { // check in default storage list
+      TIter nextRec(cdbListRec);
+      while ((stro=(TObjString*)nextRec())) {
+       if (stro->GetString().Contains(cdbent->GetName())) {
+         idRecD = stro->GetString();
+         break;
+       }
+      }
+    }
+    //-----------------------------
+    Bool_t ok = kTRUE;
+    if (!idSimD.IsNull()) {  // simulation used object from default storage
+      AliInfo(Form("Simulation used default storage %s\nentry %s",defSimStore.Data(),idSimD.Data()));
+      if (!idRecD.IsNull()) { // reco also
+       AliInfo(Form("Reconstruction used default storage %s\nentry %s",defRecStore.Data(),idRecD.Data()));
+       if ( (idSimD!=idRecD) || (defSimStore!=defRecStore) ) ok = kFALSE;
+      }
+      else if (!idRecS.IsNull()) { // reco used specific storage, strict check of version is not possible
+       AliInfo(Form("Reconstruction used specific storage %s",idRecS.Data()));
+       if (defSimStore!=idRecS) ok = kFALSE;
+      }
+      else {
+       AliInfo("Did not find object used in reconstruction");
+       ok = kFALSE;
+      }
+    }
+    else if (!idSimS.IsNull()) { // simulation used object from specific storage
+      AliInfo(Form("Simulation used specific storage %s",idSimS.Data()));
+      if (!idRecS.IsNull()) { // reco also     
+       AliInfo(Form("Reconstruction used specific storage %s",idRecS.Data()));
+       if (idSimS!=idRecS) ok = kFALSE;
+      }
+      else if (!idRecD.IsNull()) {
+       AliInfo(Form("Reconstruction used default storage %s\nentry",idRecD.Data()));
+       if (idSimS!=defRecStore) ok = kFALSE;
+      }
+      else {
+       AliInfo("Did not find object used in reconstruction");
+       ok = kFALSE;
+      }      
+    }
+    else {
+      AliInfo("Did not find object used in simulation");
+      ok = kFALSE;      
+    }
+    if (!ok) AliFatal("Different objects were used in sim and rec");
+  }
+  //
+}
+
+//_________________________________________________________
+void AliReconstruction::RectifyCDBurl(TString& url)
+{
+  // TBD RS
+  // remove everything but the url
+  TString sbs;
+  if (!(sbs=url("\\?User=[^?]*")).IsNull())                url.ReplaceAll(sbs,"");
+  if (!(sbs=url("\\?DBFolder=[^?]*")).IsNull())            url.ReplaceAll("?DB","");
+  if (!(sbs=url("\\?SE=[^?]*")).IsNull())                  url.ReplaceAll(sbs,"");
+  if (!(sbs=url("\\?CacheFolder=[^?]*")).IsNull())         url.ReplaceAll(sbs,"");
+  if (!(sbs=url("\\?OperateDisconnected=[^?]*")).IsNull()) url.ReplaceAll(sbs,"");
+  if (!(sbs=url("\\?CacheSize=[^?]*")).IsNull())           url.ReplaceAll(sbs,"");  
+  if (!(sbs=url("\\?CleanupInterval=[^?]*")).IsNull())     url.ReplaceAll(sbs,"");  
+  Bool_t slash=kFALSE,space=kFALSE;
+  while ( (slash=url.EndsWith("/")) || (space=url.EndsWith(" ")) ) {
+    if (slash) url = url.Strip(TString::kTrailing,'/');
+    if (space) url = url.Strip(TString::kTrailing,' ');
+  }
+  //url.ToLower();
+  //
+}