]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/STEER/AliReconstruction.cxx
Setting of aliases to rawReader done only once. Base decision on cosmic or calib...
[u/mrichter/AliRoot.git] / STEER / STEER / AliReconstruction.cxx
index 48b4ea029b5e4287862c03256144a1ce2330813e..a488e55d3dcad54c6036e24e22f22914a39a72fa 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 <TMessage.h>
 #include <TUrl.h>
 #include <TRandom.h>
+#include <THashList.h>
 
 #include "AliAlignObj.h"
 #include "AliAnalysisManager.h"
 #include "AliLHCData.h"
 #include "ARVersion.h"
 #include <RVersion.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/resource.h>
 ClassImp(AliReconstruction)
 
+using std::endl;
+
 //_____________________________________________________________________________
-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::fgkStopEvFName = "_stopEvent_";
+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),
@@ -234,9 +238,13 @@ AliReconstruction::AliReconstruction(const char* gAliceFilename) :
   fDmax(50.),
   fZmax(50.),
 
+  fCosmicAlias("kCosmic"),
+  fLaserAlias("kCalibLaser"),
   fRunLocalReconstruction("ALL"),
   fRunTracking("ALL"),
   fFillESD("ALL"),
+  fDeleteRecPoints(""),
+  fDeleteDigits(""),
   fLoadCDB(""),
   fUseTrackingErrorsForAlignment(""),
   fGAliceFileName(gAliceFilename),
@@ -272,7 +280,8 @@ AliReconstruction::AliReconstruction(const char* gAliceFilename) :
   fDiamondProfileSPD(NULL),
   fDiamondProfile(NULL),
   fDiamondProfileTPC(NULL),
-  fListOfCosmicTriggers(NULL),
+  fListOfCosmicTriggers(NULL), //RS for BWD comp.
+  fAlias2Trigger(NULL),
   
   fGRPData(NULL),
 
@@ -280,9 +289,9 @@ AliReconstruction::AliReconstruction(const char* gAliceFilename) :
   fCDBUri(),
   fQARefUri(),
   fSpecCDBUri(), 
+  fCheckRecoCDBvsSimuCDB(),
   fInitCDBCalled(kFALSE),
-  fFromCDBSnapshot(kFALSE),
-  fSnapshotFileName(""),
+  fCDBSnapshotMode(kFALSE),
   fSetRunNumberFromDataCalled(kFALSE),
   fQADetectors("ALL"), 
   fQATasks("ALL"), 
@@ -293,6 +302,8 @@ AliReconstruction::AliReconstruction(const char* gAliceFilename) :
   fWriteQAExpertData(kTRUE), 
   fRunPlaneEff(kFALSE),
 
+  fESDpid(NULL),
+
   fesd(NULL),
   fhltesd(NULL),
   fesdf(NULL),
@@ -310,14 +321,23 @@ AliReconstruction::AliReconstruction(const char* gAliceFilename) :
   fSspecie(0),
   fNhighPt(0),
   fShighPt(0),
+  //
+  fTreeBuffSize(30000000),
+  fMemCountESD(0),
+  fMemCountESDF(0),
+  fMemCountESDHLT(0),
+  //
   fUpgradeModule(""),
   fAnalysisMacro(),
   fAnalysis(0),
   fRecoHandler(0),
-  fDeclTriggerClasses("")
+  fDeclTriggerClasses(""),
+  fStopped(kFALSE),
+  fMaxRSS(0),
+  fMaxVMEM(0)
 {
 // create reconstruction object with default parameters
-  gGeoManager = NULL;
+  AliGeomManager::Destroy();
   
   for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
     fReconstructor[iDet] = NULL;
@@ -330,7 +350,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;
 }
 
@@ -339,12 +361,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),
@@ -355,9 +378,13 @@ AliReconstruction::AliReconstruction(const AliReconstruction& rec) :
   fDmax(rec.fDmax),
   fZmax(rec.fZmax),
 
+  fCosmicAlias(rec.fCosmicAlias),
+  fLaserAlias(rec.fLaserAlias),
   fRunLocalReconstruction(rec.fRunLocalReconstruction),
   fRunTracking(rec.fRunTracking),
   fFillESD(rec.fFillESD),
+  fDeleteRecPoints(""),
+  fDeleteDigits(""),
   fLoadCDB(rec.fLoadCDB),
   fUseTrackingErrorsForAlignment(rec.fUseTrackingErrorsForAlignment),
   fGAliceFileName(rec.fGAliceFileName),
@@ -393,7 +420,8 @@ AliReconstruction::AliReconstruction(const AliReconstruction& rec) :
   fDiamondProfileSPD(rec.fDiamondProfileSPD),
   fDiamondProfile(rec.fDiamondProfile),
   fDiamondProfileTPC(rec.fDiamondProfileTPC),
-  fListOfCosmicTriggers(NULL),
+  fListOfCosmicTriggers(NULL), //RS for BWD comp.
+  fAlias2Trigger(NULL),
   
   fGRPData(NULL),
 
@@ -401,9 +429,9 @@ AliReconstruction::AliReconstruction(const AliReconstruction& rec) :
   fCDBUri(rec.fCDBUri),
   fQARefUri(rec.fQARefUri),
   fSpecCDBUri(), 
+  fCheckRecoCDBvsSimuCDB(),
   fInitCDBCalled(rec.fInitCDBCalled),
-  fFromCDBSnapshot(rec.fFromCDBSnapshot),
-  fSnapshotFileName(rec.fSnapshotFileName),
+  fCDBSnapshotMode(rec.fCDBSnapshotMode),
   fSetRunNumberFromDataCalled(rec.fSetRunNumberFromDataCalled),
   fQADetectors(rec.fQADetectors), 
   fQATasks(rec.fQATasks), 
@@ -414,6 +442,8 @@ AliReconstruction::AliReconstruction(const AliReconstruction& rec) :
   fWriteQAExpertData(rec.fWriteQAExpertData), 
   fRunPlaneEff(rec.fRunPlaneEff),
 
+  fESDpid(NULL),
+
   fesd(NULL),
   fhltesd(NULL),
   fesdf(NULL),
@@ -431,11 +461,20 @@ 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),
   fRecoHandler(0),
-  fDeclTriggerClasses(rec.fDeclTriggerClasses)
+  fDeclTriggerClasses(rec.fDeclTriggerClasses),
+  fStopped(kFALSE),
+  fMaxRSS(0),
+  fMaxVMEM(0)
 {
 // copy constructor
 
@@ -458,6 +497,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];
 
 }
@@ -476,12 +519,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;
@@ -492,9 +536,14 @@ AliReconstruction& AliReconstruction::operator = (const AliReconstruction& rec)
   fDmax      = rec.fDmax;
   fZmax      = rec.fZmax;
 
+  fCosmicAlias                   = rec.fCosmicAlias;
+  fLaserAlias                    = rec.fLaserAlias;
+
   fRunLocalReconstruction        = rec.fRunLocalReconstruction;
   fRunTracking                   = rec.fRunTracking;
   fFillESD                       = rec.fFillESD;
+  fDeleteRecPoints               = rec.fDeleteRecPoints;
+  fDeleteDigits                  = rec.fDeleteDigits;
   fLoadCDB                       = rec.fLoadCDB;
   fUseTrackingErrorsForAlignment = rec.fUseTrackingErrorsForAlignment;
   fGAliceFileName                = rec.fGAliceFileName;
@@ -560,6 +609,9 @@ AliReconstruction& AliReconstruction::operator = (const AliReconstruction& rec)
 
   delete fListOfCosmicTriggers; fListOfCosmicTriggers = NULL;
   if (rec.fListOfCosmicTriggers) fListOfCosmicTriggers = (THashTable*)((rec.fListOfCosmicTriggers)->Clone());
+  //
+  delete fAlias2Trigger; fAlias2Trigger = NULL;
+  if (rec.fAlias2Trigger) fAlias2Trigger = (THashList*)((rec.fAlias2Trigger)->Clone());
 
   delete fGRPData; fGRPData = NULL;
   //  if (rec.fGRPData) fGRPData = (TMap*)((rec.fGRPData)->Clone());
@@ -570,9 +622,14 @@ 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;
-  fFromCDBSnapshot             = rec.fFromCDBSnapshot;
-  fSnapshotFileName            = rec.fSnapshotFileName;
+  fCDBSnapshotMode             = rec.fCDBSnapshotMode;
   fSetRunNumberFromDataCalled  = rec.fSetRunNumberFromDataCalled;
   fQADetectors                 = rec.fQADetectors;
   fQATasks                     = rec.fQATasks; 
@@ -583,6 +640,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;
@@ -600,6 +658,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;
@@ -619,6 +683,10 @@ AliReconstruction::~AliReconstruction()
     fListOfCosmicTriggers->Delete();
     delete fListOfCosmicTriggers;
   }
+  if (fAlias2Trigger) {
+    fAlias2Trigger->Delete();
+    delete fAlias2Trigger;
+  }
   delete fGRPData;
   delete fRunScalers;
   delete fCTPTimeParams;
@@ -629,7 +697,7 @@ AliReconstruction::~AliReconstruction()
     delete fAlignObjArray;
   }
   fSpecCDBUri.Delete();
-
+  fCheckRecoCDBvsSimuCDB.Delete();
   AliCodeTimer::Instance()->Print();
 }
 
@@ -646,6 +714,8 @@ void AliReconstruction::InitQA()
 
 
   AliQAManager * qam = AliQAManager::QAManager(AliQAv1::kRECMODE) ; 
+  qam->SetSaveData(kTRUE); 
+  qam->SetCycleLength(AliQAv1::kITS, 5) ; 
   if (fWriteQAExpertData)
     qam->SetWriteExpert() ; 
  
@@ -672,7 +742,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)) ;
@@ -764,6 +836,13 @@ void AliReconstruction::InitCDB()
   AliSysInfo::AddStamp("InitCDB");
 }
 
+//_____________________________________________________________________________
+void AliReconstruction::SetCDBSnapshotMode(const char* snapshotFileName) {
+    if (!AliCDBManager::Instance()->SetSnapshotMode(snapshotFileName))
+      AliFatal("Setting CDB snapshot mode failed.");
+    fCDBSnapshotMode = kTRUE;
+}
+
 //_____________________________________________________________________________
 void AliReconstruction::SetDefaultStorage(const char* uri) {
 // Store the desired default CDB storage location
@@ -782,6 +861,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
@@ -824,6 +904,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()
 {
@@ -843,6 +965,7 @@ Bool_t AliReconstruction::SetRunNumberFromData()
        AliWarning("Run number is taken from raw-event header! Ignoring settings in AliCDBManager!");
       } 
       man->SetRun(fRawReader->GetRunNumber());
+      GetEventInfo();
       fRawReader->RewindEvents();
     }
     else {
@@ -930,7 +1053,6 @@ Bool_t AliReconstruction::MisalignGeometry(const TString& detectors)
     if(AliGeomManager::GetNalignable("GRP") != 0)
       loadAlObjsListOfDets.Prepend("GRP "); //add alignment objects for non-sensitive modules
     AliGeomManager::ApplyAlignObjsFromCDB(loadAlObjsListOfDets.Data());
-    AliCDBManager::Instance()->UnloadFromCache("*/Align/*");
   }else{
     // Check if the array with alignment objects was
     // provided by the user. If yes, apply the objects
@@ -1100,6 +1222,9 @@ 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",
                  fRunLocalReconstruction.Data(),
                  fRunTracking.Data(),
@@ -1211,17 +1336,6 @@ Bool_t AliReconstruction::InitGRP() {
      AliError("No TPC diamond profile found in OCDB!");
   }
 
-  entry = AliCDBManager::Instance()->Get("GRP/Calib/CosmicTriggers");
-  if (entry) {
-    fListOfCosmicTriggers = dynamic_cast<THashTable*>(entry->GetObject());
-    entry->SetOwner(0);
-    AliCDBManager::Instance()->UnloadFromCache("GRP/Calib/CosmicTriggers");
-  }
-
-  if (!fListOfCosmicTriggers) {
-    AliWarning("Can not get list of cosmic triggers from OCDB! Cosmic event specie will be effectively disabled!");
-  }
-
   return kTRUE;
 } 
 
@@ -1250,6 +1364,18 @@ 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/*/*");
+
+  AliCDBEntry* entry = AliCDBManager::Instance()->Get("GRP/Calib/CosmicTriggers");
+  if (entry) {
+    fListOfCosmicTriggers = dynamic_cast<THashTable*>(entry->GetObject());
+    entry->SetOwner(0);
+  }
+  //
+  if (!fListOfCosmicTriggers) {
+    AliWarning("Can not get list of cosmic triggers from OCDB! Cosmic event specie will rely on aliases if defined");
+  }
+
 
   return kTRUE;
 }
@@ -1403,12 +1529,17 @@ Bool_t AliReconstruction::Run(const char* input)
     Int_t iEvent = 0;
     while ((iEvent < fRunLoader->GetNumberOfEvents()) ||
           (fRawReader && fRawReader->NextEvent())) {
+      //
+      // check if process has enough resources 
+      if (!HasEnoughResources(iEvent)) break;
       if (!ProcessEvent(iEvent)) {
         Abort("ProcessEvent",TSelector::kAbortFile);
         return kFALSE;
       }
+      CleanProcessedEvent();
       iEvent++;
     }
+    if (!iEvent) AliWarning("No events passed trigger selection");
     SlaveTerminate();
     if (GetAbort() != TSelector::kContinue) return kFALSE;
     Terminate();
@@ -1477,7 +1608,9 @@ void AliReconstruction::InitRun(const char* input)
   // Set CDB lock: from now on it is forbidden to reset the run number
   // or the default storage or to activate any further storage!
   SetCDBLock();
-  
+  //
+  ProcessTriggerAliases();
+  //  
 }
 
 //_____________________________________________________________________________
@@ -1498,7 +1631,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());
@@ -1515,19 +1648,47 @@ void AliReconstruction::Begin(TTree *)
     AliSysInfo::AddStamp("CheckGeom");
   }
 
-  if(fFromCDBSnapshot){
-      AliDebug(2,"Initializing from a CDB snapshot");
-      if(!AliCDBManager::Instance()->InitFromSnapshot(fSnapshotFileName.Data())){
-         Abort("InitFromSnapshot", TSelector::kAbortProcess);
-         return;
+  Bool_t toCDBSnapshot=kFALSE;
+  TString snapshotFileOut(""); // we could use fSnapshotFileName if we are not interested
+  // in reading from and writing to a snapshot file at the same time
+  if(TString(getenv("OCDB_SNAPSHOT_CREATE")) == TString("kTRUE")){
+      toCDBSnapshot=kTRUE;
+      //fFromCDBSnapshot=kFALSE;
+      TString snapshotFile(getenv("OCDB_SNAPSHOT_FILENAME"));
+      if(!(snapshotFile.IsNull() || snapshotFile.IsWhitespace()))
+         snapshotFileOut = snapshotFile;
+      else
+         snapshotFileOut="OCDB.root";
+  }
+
+  TString detStr(fLoadAlignData);
+  if (!toCDBSnapshot) {
+    if (!MisalignGeometry(fLoadAlignData)) {
+      Abort("MisalignGeometry", TSelector::kAbortProcess);
+      return;
+    }
+  } else {
+    // when creating the snapshot, load the CDB alignment objects without applying them to the geometry
+    for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
+      if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
+      if (!strcmp(fgkDetectorName[iDet],"HLT")) continue;
+      if (AliGeomManager::GetNalignable(fgkDetectorName[iDet]) != 0)
+      {
+        TString detAlignPath = fgkDetectorName[iDet];
+        detAlignPath += "/Align/Data";
+        AliCDBManager::Instance()->Get(detAlignPath);
       }
+    } // end loop over detectors
+    if(AliGeomManager::GetNalignable("GRP") != 0)
+      AliCDBManager::Instance()->Get("GRP/Align/Data");
   }
 
-  if (!MisalignGeometry(fLoadAlignData)) {
-    Abort("MisalignGeometry", TSelector::kAbortProcess);
-    return;
+  const TMap* cdbCache = AliCDBManager::Instance()->GetEntryCache();
+  if(!toCDBSnapshot) {
+    if(cdbCache->Contains("GRP/Geometry/Data"))
+      AliCDBManager::Instance()->UnloadFromCache("GRP/Geometry/Data");
+    AliCDBManager::Instance()->UnloadFromCache("*/Align/*");
   }
-  AliCDBManager::Instance()->UnloadFromCache("GRP/Geometry/Data");
   AliSysInfo::AddStamp("MisalignGeom");
 
   if (!InitGRP()) {
@@ -1535,13 +1696,16 @@ void AliReconstruction::Begin(TTree *)
     return;
   }
   AliSysInfo::AddStamp("InitGRP");
+  if(!toCDBSnapshot)
+      if(cdbCache->Contains("GRP/Calib/CosmicTriggers"))
+         AliCDBManager::Instance()->UnloadFromCache("GRP/Calib/CosmicTriggers");
 
-  if(!fFromCDBSnapshot){
+  if(!fCDBSnapshotMode || toCDBSnapshot){
       if (!LoadCDB()) {
          Abort("LoadCDB", TSelector::kAbortProcess);
          return;
       }
-      AliSysInfo::AddStamp("LoadCDB");
+      AliSysInfo::AddStamp("LoadCDB"); 
   }
 
   if (!LoadTriggerScalersCDB()) {
@@ -1568,6 +1732,12 @@ void AliReconstruction::Begin(TTree *)
   }
   AliSysInfo::AddStamp("InitRecoParams");
 
+  if(toCDBSnapshot)
+  {
+      AliCDBManager::Instance()->DumpToSnapshotFile(snapshotFileOut.Data(),kFALSE);
+      exit(0);
+  }
+
   if (fInput && gProof) {
     if (reco) *reco = *this;
 
@@ -1675,6 +1845,8 @@ void AliReconstruction::SlaveBegin(TTree*)
   }
   AliSysInfo::AddStamp("LoadLoader");
  
+  CheckRecoCDBvsSimuCDB();
+
   ftVertexer = new AliVertexerTracks(AliTracker::GetBz());
 
   // get trackers
@@ -1731,22 +1903,21 @@ void AliReconstruction::SlaveBegin(TTree*)
   // order to create all branches. Initialization is done from an
   // ESD layout template in CDB
   AliCDBManager* man = AliCDBManager::Instance();
-  AliCDBPath hltESDConfigPath("HLT/ConfigHLT/esdLayout");
-  AliCDBEntry* hltESDConfig=NULL;
-  if (man->GetId(hltESDConfigPath)!=NULL &&
-      (hltESDConfig=man->Get(hltESDConfigPath))!=NULL) {
-    AliESDEvent* pESDLayout=dynamic_cast<AliESDEvent*>(hltESDConfig->GetObject());
-    if (pESDLayout) {
+  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
       pESDLayout->GetStdContent();
 
       // copy content and create non-std objects
       *fhltesd=*pESDLayout;
       fhltesd->Reset();
-    } else {
-      AliError(Form("error setting hltEsd layout from %s: invalid object type",
-                   hltESDConfigPath.GetPath().Data()));
-    }
+  } else {
+      AliError(Form("error setting hltEsd layout from \"HLT/Calib/esdLayout\": invalid object type"));
   }
 
   fhltesd->WriteToTree(fhlttree);
@@ -1756,6 +1927,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) 
@@ -1778,7 +1952,7 @@ void AliReconstruction::SlaveBegin(TTree*)
     }
     // Set the event and other data pointers
     fRecoHandler = new AliRecoInputHandler();
-    fRecoHandler->Init(ftree, "LOCAL");
+//    fRecoHandler->Init(ftree, "LOCAL");
     fRecoHandler->SetEvent(fesd);
     fRecoHandler->SetESDfriend(fesdf);
     fRecoHandler->SetHLTEvent(fhltesd);
@@ -1787,6 +1961,7 @@ void AliReconstruction::SlaveBegin(TTree*)
     // Enter external loop mode
     fAnalysis->SetExternalLoop(kTRUE);
     // Initialize analysis
+    fAnalysis->SlaveBegin(ftree);
     fAnalysis->StartAnalysis("local", (TTree*)0);
     // Connect ESD tree with the input container
     fAnalysis->GetCommonInputContainer()->SetData(ftree);
@@ -1805,12 +1980,16 @@ Bool_t AliReconstruction::Process(Long64_t entry)
   AliRawVEvent *event = NULL;
   currTree->SetBranchAddress("rawevent",&event);
   currTree->GetEntry(entry);
-  fRawReader = new AliRawReaderRoot(event);
+  fRawReader = new AliRawReaderRoot(event,entry);
+  // check if process has enough resources 
+  if (!HasEnoughResources(entry)) return kFALSE;
   fStatus = ProcessEvent(fRunLoader->GetNumberOfEvents());
   delete fRawReader;
   fRawReader = NULL;
   delete event;
 
+  if (!fStatus) Abort("ProcessEvent",TSelector::kAbortFile);  
+  CleanProcessedEvent();
   return fStatus;
 }
 
@@ -1842,7 +2021,7 @@ Bool_t AliReconstruction::ProcessEvent(Int_t iEvent)
 
   AliCodeTimerAuto("",0);
 
-  AliESDpid pid;
+  AliSysInfo::AddStamp(Form("StartEv_%d",iEvent), 0,0,iEvent);
 
   if (iEvent >= fRunLoader->GetNumberOfEvents()) {
     fRunLoader->SetEventNumber(iEvent);
@@ -1874,7 +2053,9 @@ Bool_t AliReconstruction::ProcessEvent(Int_t iEvent)
     oldCPU=procInfo.fCpuUser+procInfo.fCpuSys;
   }
   AliInfo(Form("================================= Processing event %d of type %-10s ==================================", iEvent,fRecoParam.PrintEventSpecie()));
+  fEventInfo.Print();
 
+  AliSysInfo::AddStamp(Form("StartReco_%d",iEvent), 0,0,iEvent);
   // Set the reco-params
   {
     TString detStr = fLoadCDB;
@@ -1884,7 +2065,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) ;
@@ -1907,30 +2088,17 @@ Bool_t AliReconstruction::ProcessEvent(Int_t iEvent)
   if (fRunQA && IsInTasks(AliQAv1::kRAWS)) {
     AliQAManager::QAManager()->SetEventSpecie(fRecoParam.GetEventSpecie()) ;
     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());
@@ -1961,22 +2129,64 @@ Bool_t AliReconstruction::ProcessEvent(Int_t iEvent)
        esdRunH->SetMeanIntensity(ib,it, fBeamInt[ib][it]); 
       }
     //
+    fesd->SetBeamEnergy(fGRPData->GetBeamEnergy());
+    fesd->SetBeamType(fGRPData->GetBeamType().Data());
+    fesd->SetBeamParticle(fGRPData->GetSingleBeamType(0).Atoi(),0);
+    fesd->SetBeamParticle(fGRPData->GetSingleBeamType(1).Atoi(),1);
+    fhltesd->SetBeamEnergy(fGRPData->GetBeamEnergy());
+    fhltesd->SetBeamType(fGRPData->GetBeamType().Data());
+    fhltesd->SetBeamParticle(fGRPData->GetSingleBeamType(0).Atoi(),0);
+    fhltesd->SetBeamParticle(fGRPData->GetSingleBeamType(1).Atoi(),1);
+    //
     AliMagF* fld = (AliMagF*)TGeoGlobalMagField::Instance()->GetField();
     if (fld) { // set info needed for field initialization
       fesd->SetCurrentL3(fld->GetCurrentSol());
       fesd->SetCurrentDip(fld->GetCurrentDip());
-      fesd->SetBeamEnergy(fld->GetBeamEnergy());
-      fesd->SetBeamType(fld->GetBeamTypeText());
       fesd->SetUniformBMap(fld->IsUniform());
       fesd->SetBInfoStored();
       //
       fhltesd->SetCurrentL3(fld->GetCurrentSol());
       fhltesd->SetCurrentDip(fld->GetCurrentDip());
-      fhltesd->SetBeamEnergy(fld->GetBeamEnergy());
-      fhltesd->SetBeamType(fld->GetBeamTypeText());
       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
@@ -1986,11 +2196,14 @@ Bool_t AliReconstruction::ProcessEvent(Int_t iEvent)
     // Fill raw-data error log into the ESD
     if (fRawReader) FillRawDataErrorLog(iEvent,fesd);
 
+    AliSysInfo::AddStamp(Form("FillHeadErrs_%d",iEvent), 0,0,iEvent);
+
     // vertex finder
     if (fRunVertexFinder) {
       if (!RunVertexFinder(fesd)) {
        if (fStopOnError) {CleanUp(); return kFALSE;}
       }
+      AliSysInfo::AddStamp(Form("VtxFinder_%d",iEvent), 0,0,iEvent);
     }
 
     // For Plane Efficiency: run the SPD trackleter
@@ -1998,6 +2211,7 @@ Bool_t AliReconstruction::ProcessEvent(Int_t iEvent)
       if (!RunSPDTrackleting(fesd)) {
         if (fStopOnError) {CleanUp(); return kFALSE;}
       }
+      AliSysInfo::AddStamp(Form("TrackletEff_%d",iEvent), 0,0,iEvent);
     }
 
     // Muon tracking
@@ -2007,11 +2221,26 @@ Bool_t AliReconstruction::ProcessEvent(Int_t iEvent)
          if (fStopOnError) {CleanUp(); return kFALSE;}
        }
       }
+      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;}
       }
     }
@@ -2019,27 +2248,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();
 
@@ -2050,7 +2270,7 @@ Bool_t AliReconstruction::ProcessEvent(Int_t iEvent)
     const Double_t kRadius  = 2.8; //something less than the beam pipe radius
 
     TObjArray trkArray;
-    UShort_t *selectedIdx=new UShort_t[ntracks];
+    UShort_t selectedIdx[ntracks];
 
     for (Int_t itrack=0; itrack<ntracks; itrack++){
       const Double_t kMaxStep = 1;   //max step over the material
@@ -2064,7 +2284,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();
@@ -2076,13 +2296,13 @@ 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);
 
     }
-
+    AliSysInfo::AddStamp(Form("RelToSPDVtx_%d",iEvent), 0,0,iEvent);      
     //
     // Improve the reconstructed primary vertex position using the tracks
     //
@@ -2135,6 +2355,7 @@ Bool_t AliReconstruction::ProcessEvent(Int_t iEvent)
           }
          delete pvtx; pvtx=NULL;
        }
+       AliSysInfo::AddStamp(Form("VtxTrk_%d",iEvent), 0,0,iEvent);      
 
        // TPC-only primary vertex
        ftVertexer->SetTPCMode();
@@ -2163,10 +2384,10 @@ Bool_t AliReconstruction::ProcessEvent(Int_t iEvent)
           }
          delete pvtx; pvtx=NULL;
        }
+       AliSysInfo::AddStamp(Form("VtxTPC_%d",iEvent), 0,0,iEvent);      
 
     }
-    delete[] selectedIdx;
-
+    
     if(fDiamondProfile && fDiamondProfile->GetXRes()<kRadius) fesd->SetDiamond(fDiamondProfile);
     else fesd->SetDiamond(fDiamondProfileSPD);
 
@@ -2176,12 +2397,12 @@ Bool_t AliReconstruction::ProcessEvent(Int_t iEvent)
        // get cuts for V0vertexer from AliGRPRecoParam
        if (grpRecoParam) {
         Int_t nCutsV0vertexer = grpRecoParam->GetVertexerV0NCuts();
-        Double_t *cutsV0vertexer = new Double_t[nCutsV0vertexer];
+        Double_t cutsV0vertexer[nCutsV0vertexer];
         grpRecoParam->GetVertexerV0Cuts(cutsV0vertexer);
         vtxer.SetCuts(cutsV0vertexer);
-        delete [] cutsV0vertexer; cutsV0vertexer = NULL; 
        }
        vtxer.Tracks2V0vertices(fesd);
+       AliSysInfo::AddStamp(Form("V0Finder_%d",iEvent), 0,0,iEvent); 
 
        if (fRunCascadeFinder) {
           // Cascade finding
@@ -2189,21 +2410,21 @@ Bool_t AliReconstruction::ProcessEvent(Int_t iEvent)
          // get cuts for CascadeVertexer from AliGRPRecoParam
          if (grpRecoParam) {
            Int_t nCutsCascadeVertexer = grpRecoParam->GetVertexerCascadeNCuts();
-           Double_t *cutsCascadeVertexer = new Double_t[nCutsCascadeVertexer];
+           Double_t cutsCascadeVertexer[nCutsCascadeVertexer];
            grpRecoParam->GetVertexerCascadeCuts(cutsCascadeVertexer);
            cvtxer.SetCuts(cutsCascadeVertexer);
-           delete [] cutsCascadeVertexer; cutsCascadeVertexer = NULL; 
          }
           cvtxer.V0sTracks2CascadeVertices(fesd);
+         AliSysInfo::AddStamp(Form("CascadeFinder_%d",iEvent), 0,0,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)) {
@@ -2215,8 +2436,15 @@ Bool_t AliReconstruction::ProcessEvent(Int_t iEvent)
        if (fStopOnError) {CleanUp(); return kFALSE;}
     }
 
+    AliSysInfo::AddStamp(Form("FillVaria_%d",iEvent), 0,0,iEvent); 
+
     // write ESD
-    if (fCleanESD) CleanESD(fesd);
+    UInt_t specie = fesd->GetEventSpecie();
+    Bool_t keepAll = (specie==AliRecoParam::kCosmic || specie==AliRecoParam::kCalib);
+    if (fCleanESD && (!keepAll) ) {
+      CleanESD(fesd);
+      AliSysInfo::AddStamp(Form("CleanESD_%d",iEvent), 0,0,iEvent); 
+    }
     // 
     // RS run updated trackleter: since we want to mark the clusters used by tracks and also mark the 
     // tracks interpreted as primary, this step should be done in the very end, when full 
@@ -2226,11 +2454,13 @@ Bool_t AliReconstruction::ProcessEvent(Int_t iEvent)
       if (!RunMultFinder(fesd)) {
        if (fStopOnError) {CleanUp(); return kFALSE;}
       }
+      AliSysInfo::AddStamp(Form("MultFinder_%d",iEvent), 0,0,iEvent); 
     }
 
   if (fRunQA && IsInTasks(AliQAv1::kESDS)) {
     AliQAManager::QAManager()->SetEventSpecie(fRecoParam.GetEventSpecie()) ;
     AliQAManager::QAManager()->RunOneEvent(fesd, fhltesd) ; 
+    AliSysInfo::AddStamp(Form("RunQA_%d",iEvent), 0,0,iEvent); 
   }
   if (fRunGlobalQA) {
     AliQADataMaker *qadm = AliQAManager::QAManager()->GetQADataMaker(AliQAv1::kGLOBAL);
@@ -2238,6 +2468,7 @@ Bool_t AliReconstruction::ProcessEvent(Int_t iEvent)
       qadm->SetEventSpecie(fRecoParam.GetEventSpecie()) ;
     if (qadm && IsInTasks(AliQAv1::kESDS))
       qadm->Exec(AliQAv1::kESDS, fesd);
+    AliSysInfo::AddStamp(Form("RunGlobQA_%d",iEvent), 0,0,iEvent);     
   }
 
   // copy HLT decision from HLTesd to esd
@@ -2255,34 +2486,50 @@ Bool_t AliReconstruction::ProcessEvent(Int_t iEvent)
     fRecoHandler->BeginEvent(iEvent);
     fAnalysis->ExecAnalysis();
     fRecoHandler->FinishEvent();
+    AliSysInfo::AddStamp(Form("Analysis_%d",iEvent), 0,0,iEvent);     
   }  
   //
-    if (fWriteESDfriend) 
-      fesd->GetESDfriend(fesdf);
-
-    ftree->Fill();
-    if (fWriteESDfriend) {
-      WriteESDfriend();
-    }
-    // Auto-save the ESD tree in case of prompt reco @P2
-    if (fRawReader && fRawReader->UseAutoSaveESD()) {
-      ftree->AutoSave("SaveSelf");
-      if (fWriteESDfriend) ftreeF->AutoSave("SaveSelf");
-    }
-
-    // write HLT ESD
-    fhlttree->Fill();
-
-    // call AliEVE
-    if (fRunAliEVE) RunAliEVE();
-    //
-    fesd->Reset();
-    fhltesd->Reset();
-    if (fWriteESDfriend) {
-      fesdf->~AliESDfriend();
-      new (fesdf) AliESDfriend(); // Reset...
-    }
+  if (fWriteESDfriend) {
+    fesd->GetESDfriend(fesdf);
+    AliSysInfo::AddStamp(Form("CreateFriend_%d",iEvent), 0,0,iEvent);     
+  
+  }
+  //
+  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) {
+    WriteESDfriend();
+    AliSysInfo::AddStamp(Form("WriteFriend_%d",iEvent), 0,0,iEvent);     
+  }
+  //
+  //
+  // Auto-save the ESD tree in case of prompt reco @P2
+  if (fRawReader && fRawReader->UseAutoSaveESD()) {
+    ftree->AutoSave("SaveSelf");
+    if (fWriteESDfriend) ftreeF->AutoSave("SaveSelf");
+  }
+  // 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()));        
+  }
+    
     gSystem->GetProcInfo(&procInfo);
     Long_t dMres=(procInfo.fMemResident-oldMres)/1024;
     Long_t dMvir=(procInfo.fMemVirtual-oldMvir)/1024;
@@ -2291,12 +2538,32 @@ Bool_t AliReconstruction::ProcessEvent(Int_t iEvent)
     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));
+                iEvent, procInfo.fMemResident/1024, dMres, aveDMres, procInfo.fMemVirtual/1024, dMvir, aveDMvir, dCPU, aveDCPU));
     oldMres=procInfo.fMemResident;
     oldMvir=procInfo.fMemVirtual;
     oldCPU=procInfo.fCpuUser+procInfo.fCpuSys;
   
-    fEventInfo.Reset();
+    
+  return kTRUE;
+}
+
+void AliReconstruction::CleanProcessedEvent()
+{
+    //
+    fesd->Reset();
+    fhltesd->Reset();
+    if (fWriteESDfriend) {
+      fesdf->~AliESDfriend();
+      new (fesdf) AliESDfriend(); // Reset...
+    }
+
+    for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
+      if (fReconstructor[iDet]) fReconstructor[iDet]->FinishEvent();
+    }
+    AliInfo("======================= End Event ===================");
+    
+
     for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
       if (fReconstructor[iDet]) {
        fReconstructor[iDet]->SetRecoParam(NULL);
@@ -2308,7 +2575,10 @@ Bool_t AliReconstruction::ProcessEvent(Int_t iEvent)
   if (fRunQA || fRunGlobalQA) 
     AliQAManager::QAManager()->Increment() ; 
 
-    return kTRUE;
+  DeleteRecPoints(fDeleteRecPoints);
+  DeleteDigits(fDeleteDigits);
+  //
+
 }
 
 //_____________________________________________________________________________
@@ -2364,15 +2634,27 @@ 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 += gSystem->Getenv("PRODUCTION_METADATA");
+   sVersion += getenv("PRODUCTION_METADATA");
                    
 
    TNamed * alirootVersion = new TNamed("alirootVersion",sVersion.Data());
@@ -2477,7 +2759,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
@@ -2493,6 +2775,7 @@ Bool_t AliReconstruction::RunLocalEventReconstruction(const TString& detectors)
         reconstructor->Reconstruct(dummy, NULL);
       }
     }
+    AliSysInfo::AddStamp(Form("LRecHLT_%d",eventNr), -1,1,eventNr);
   }
 
   AliInfo(Form("kNDetectors = %d",kNDetectors));
@@ -2722,9 +3005,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)
 
@@ -2732,55 +3015,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)
 
@@ -2788,18 +3064,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;
   }
      
@@ -2814,15 +3089,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)
@@ -2868,16 +3142,17 @@ 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;
     }
+    AliSysInfo::AddStamp(Form("Tracking0%s_%d",fgkDetectorName[iDet],eventNr), iDet,3,eventNr);
     // 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);
     } 
-    AliSysInfo::AddStamp(Form("Tracking0%s_%d",fgkDetectorName[iDet],eventNr), iDet,3,eventNr);
   }
 
   // pass 2: ALL backwards
@@ -2913,11 +3188,13 @@ Bool_t AliReconstruction::RunTracking(AliESDEvent*& esd,AliESDpid &PID)
            if (qadm) qadm->InitRecPointsForTracker() ; 
          }
        }
+       //      AliSysInfo::AddStamp(Form("QAInitResid%s_%d",fgkDetectorName[iDet],eventNr), iDet,0, eventNr);
       }
     if (fTracker[iDet]->PropagateBack(esd) != 0) {
       AliError(Form("%s backward propagation failed", fgkDetectorName[iDet]));
       //      return kFALSE;
     }
+    AliSysInfo::AddStamp(Form("Tracking1%s_%d",fgkDetectorName[iDet],eventNr), iDet,3, eventNr);
 
     // unload clusters
     if (iDet > 3) {     // all except ITS, TPC, TRD and TOF
@@ -2928,9 +3205,10 @@ 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);
     }
-    AliSysInfo::AddStamp(Form("Tracking1%s_%d",fgkDetectorName[iDet],eventNr), iDet,3, eventNr);
+
   }
   //stop filling residuals for the "outer" detectors
   if (fRunGlobalQA) AliTracker::SetFillResiduals(fRecoParam.GetEventSpecie(), kFALSE);     
@@ -2970,9 +3248,11 @@ Bool_t AliReconstruction::RunTracking(AliESDEvent*& esd,AliESDpid &PID)
 
   // write space-points to the ESD in case alignment data output
   // is switched on
-  if (fWriteAlignmentData)
+  if (fWriteAlignmentData) {
     WriteAlignmentData(esd);
-
+    AliSysInfo::AddStamp(Form("WrtAlignData_%d",eventNr), 0,0, eventNr);
+  }
+  
   for (Int_t iDet = 3; iDet >= 0; iDet--) {
     if (!fTracker[iDet]) continue;
     // unload clusters
@@ -3087,6 +3367,9 @@ Bool_t AliReconstruction::FillTriggerESD(AliESDEvent*& esd)
       if (esd->GetTriggerMask() != input.GetClassMask())
        AliError(Form("Invalid trigger pattern found in CTP raw-data: %llx %llx",
                      input.GetClassMask(),esd->GetTriggerMask()));
+      if (esd->GetTriggerMaskNext50() != input.GetClassMaskNext50())
+       AliError(Form("Invalid trigger pattern found in CTP raw-data Next50: %llx %llx",
+                     input.GetClassMaskNext50(),esd->GetTriggerMaskNext50()));
       if (esd->GetOrbitNumber() != input.GetOrbitID())
        AliError(Form("Invalid orbit id found in CTP raw-data: %x %x",
                      input.GetOrbitID(),esd->GetOrbitNumber()));
@@ -3098,15 +3381,16 @@ Bool_t AliReconstruction::FillTriggerESD(AliESDEvent*& esd)
       esdheader->SetL1TriggerInputs(input.GetL1Inputs());
       esdheader->SetL2TriggerInputs(input.GetL2Inputs());
       // IR
-      UInt_t orbit=input.GetOrbitID();
-       for(Int_t i=0 ; i<input.GetNIRs() ; i++ )
-          if(TMath::Abs(Int_t(orbit-(input.GetIR(i))->GetOrbit()))<=1){
-            esdheader->AddTriggerIR(input.GetIR(i));
-         }
+      //      UInt_t orbit=input.GetOrbitID();
+      for(Int_t i=0 ; i<input.GetNIRs() ; i++ ) {
+       esdheader->AddTriggerIR(input.GetIR(i));
+      }
        AliCentralTrigger* rlCTP = fRunLoader->GetTrigger();
-       rlCTP->SetL0TriggerInputs(input.GetL0Inputs());
-       rlCTP->SetL1TriggerInputs(input.GetL1Inputs());
-       rlCTP->SetL2TriggerInputs(input.GetL2Inputs());
+       if (rlCTP) {
+        rlCTP->SetL0TriggerInputs(input.GetL0Inputs());
+        rlCTP->SetL1TriggerInputs(input.GetL1Inputs());
+        rlCTP->SetL2TriggerInputs(input.GetL2Inputs());
+       }
     }
     if (fIsNewRunLoader) fRunLoader->TreeCT()->Fill();
   }
@@ -3127,6 +3411,12 @@ Bool_t AliReconstruction::FillTriggerScalers(AliESDEvent*& esd)
           if(scalesd)esdheader->SetTriggerScalersRecord(scalesd);
         }
      }
+     for(Int_t i=0;i<50;i++){
+          if((1ull<<i) & esd->GetTriggerMaskNext50()){
+          AliTriggerScalersESD* scalesd = fRunScalers->GetScalersForEventClass( timestamp, i+51);
+          if(scalesd)esdheader->SetTriggerScalersRecord(scalesd);
+        }
+     }
      const AliTriggerScalersRecordESD* scalrecEvent = fRunScalers->GetScalersDeltaForEvent( timestamp);
      const AliTriggerScalersRecordESD* scalrecRun = fRunScalers->GetScalersDeltaForRun();
      if (scalrecEvent) esdheader->SetTriggerScalersDeltaEvent(scalrecEvent);
@@ -3207,9 +3497,8 @@ 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");
+      gSystem->Load("lib" + detName + "base");
     }
     fRunLoader = AliRunLoader::Open(fGAliceFileName.Data());
     if (!fRunLoader) {
@@ -3282,7 +3571,7 @@ AliReconstructor* AliReconstruction::GetReconstructor(Int_t iDet)
     AliDebug(1, Form("defining plugin for %s", recName.Data()));
     TString libs = gSystem->GetLibraries();
     if (libs.Contains("lib" + detName + "base.so") ||
-       (gSystem->Load("lib" + detName + "base.so") >= 0)) {
+       (gSystem->Load("lib" + detName + "base") >= 0)) {
       pluginManager->AddHandler("AliReconstructor", detName, 
                                recName, detName + "rec", recName + "()");
     } else {
@@ -3306,6 +3595,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;
   }
@@ -3412,14 +3702,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)) {
@@ -3436,15 +3726,14 @@ 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++) {
+    if (fReconstructor[iDet]) fReconstructor[iDet]->SetRecoParam(NULL);
     delete fReconstructor[iDet];
     fReconstructor[iDet] = NULL;
     fLoader[iDet] = NULL;
     delete fTracker[iDet];
     fTracker[iDet] = NULL;
   }
-*/
 
   delete fRunInfo;
   fRunInfo = NULL;
@@ -3462,6 +3751,9 @@ void AliReconstruction::CleanUp()
   delete fParentRawReader;
   fParentRawReader=NULL;
 
+  delete fESDpid;
+  fESDpid = NULL;
+
   if (ffile) {
     ffile->Close();
     delete ffile;
@@ -3693,7 +3985,7 @@ Bool_t AliReconstruction::InitAliEVE()
   // The return flag shows whenever the
   // AliEVE initialization was successful or not.
 
-  TString macroStr(gSystem->Getenv("ALIEVE_ONLINE_MACRO"));
+  TString macroStr(getenv("ALIEVE_ONLINE_MACRO"));
 
   if (macroStr.IsNull())
     macroStr.Form("%s/EVE/macros/alieve_online.C",gSystem->ExpandPathName("$ALICE_ROOT"));
@@ -3864,13 +4156,16 @@ Bool_t AliReconstruction::GetEventInfo()
   // Fill the event info object
   // ...
   AliCodeTimerAuto("",0)
-
+  
   AliCentralTrigger *aCTP = NULL;
+  fEventInfo.Reset();
   if (fRawReader) {
     fEventInfo.SetEventType(fRawReader->GetType());
 
     ULong64_t mask = fRawReader->GetClassMask();
+    ULong64_t maskNext50 = fRawReader->GetClassMaskNext50();
     fEventInfo.SetTriggerMask(mask);
+    fEventInfo.SetTriggerMaskNext50(maskNext50);
     UInt_t clmask = fRawReader->GetDetectorPattern()[0];
     fEventInfo.SetTriggerCluster(AliDAQ::ListOfTriggeredDetectors(clmask));
 
@@ -3884,9 +4179,13 @@ Bool_t AliReconstruction::GetEventInfo()
     aCTP->SetClassMask(mask);
     aCTP->SetClusterMask(clmask);
 
-    AliCentralTrigger* rlCTP = fRunLoader->GetTrigger();
-    rlCTP->SetClassMask(mask);
-    rlCTP->SetClusterMask(clmask);
+    if (fRunLoader) {
+      AliCentralTrigger* rlCTP = fRunLoader->GetTrigger();
+      if (rlCTP) {
+       rlCTP->SetClassMask(mask);
+       rlCTP->SetClusterMask(clmask);
+      }
+    }
   }
   else {
     fEventInfo.SetEventType(AliRawEventHeaderBase::kPhysicsEvent);
@@ -3894,6 +4193,7 @@ Bool_t AliReconstruction::GetEventInfo()
     if (fRunLoader && (!fRunLoader->LoadTrigger())) {
       aCTP = fRunLoader->GetTrigger();
       fEventInfo.SetTriggerMask(aCTP->GetClassMask());
+      fEventInfo.SetTriggerMaskNext50(aCTP->GetClassMaskNext50());
       // get inputs from actp - just get
       AliESDHeader* esdheader = fesd->GetHeader();
       esdheader->SetL0TriggerInputs(aCTP->GetL0TriggerInputs());
@@ -3902,6 +4202,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;
     }
@@ -3913,37 +4214,42 @@ Bool_t AliReconstruction::GetEventInfo()
     if (fRawReader) delete aCTP;
     return kFALSE;
   }
-
   UChar_t clustmask = 0;
   TString trclasses;
   ULong64_t trmask = fEventInfo.GetTriggerMask();
+  ULong64_t trmaskNext50 = fEventInfo.GetTriggerMaskNext50();
   const TObjArray& classesArray = config->GetClasses();
   Int_t nclasses = classesArray.GetEntriesFast();
   for( Int_t iclass=0; iclass < nclasses; iclass++ ) {
     AliTriggerClass* trclass = (AliTriggerClass*)classesArray.At(iclass);
     if (trclass && trclass->GetMask()>0) {
       Int_t trindex = TMath::Nint(TMath::Log2(trclass->GetMask()));
-      fesd->SetTriggerClass(trclass->GetName(),trindex);
-      if (fRawReader) fRawReader->LoadTriggerClass(trclass->GetName(),trindex);
+      if (fesd) fesd->SetTriggerClass(trclass->GetName(),trindex);
       if (trmask & (1ull << trindex)) {
        trclasses += " ";
        trclasses += trclass->GetName();
        trclasses += " ";
        clustmask |= trclass->GetCluster()->GetClusterMask();
+       if (TriggerMatches2Alias(trclass->GetName(),fCosmicAlias)) fEventInfo.SetCosmicTrigger(kTRUE);
+       else if (TriggerMatches2Alias(trclass->GetName(),fLaserAlias))  fEventInfo.SetCalibLaserTrigger(kTRUE);
+       else fEventInfo.SetBeamTrigger(kTRUE);
       }
     }
-  }
-  fEventInfo.SetTriggerClasses(trclasses);
-  // Now put the declared trigger classes (not present in the run)
-  // to 0/false in the event selection
-  if (!fDeclTriggerClasses.IsNull()) {
-    TObjArray *tokens = fDeclTriggerClasses.Tokenize(" ");
-    Int_t ntokens = tokens->GetEntriesFast();
-    for (Int_t itoken = 0; itoken < ntokens; ++itoken) {
-      if (fRawReader) fRawReader->LoadTriggerClass((((TObjString*)tokens->At(itoken))->String()).Data(),-1);
+    if (trclass && trclass->GetMaskNext50()>0) {
+      Int_t trindex = TMath::Nint(TMath::Log2(trclass->GetMaskNext50()))+50;
+      if (fesd) fesd->SetTriggerClass(trclass->GetName(),trindex);
+      if (trmaskNext50 & (1ull << (trindex-50))) {
+       trclasses += " ";
+       trclasses += trclass->GetName();
+       trclasses += " ";
+       clustmask |= trclass->GetCluster()->GetClusterMask();
+       if (TriggerMatches2Alias(trclass->GetName(),fCosmicAlias)) fEventInfo.SetCosmicTrigger(kTRUE);
+       else if (TriggerMatches2Alias(trclass->GetName(),fLaserAlias))  fEventInfo.SetCalibLaserTrigger(kTRUE);
+       else fEventInfo.SetBeamTrigger(kTRUE);
+      }
     }
-    delete tokens;
   }
+  fEventInfo.SetTriggerClasses(trclasses);
 
   // Write names of active trigger inputs in ESD Header
   const TObjArray& inputsArray = config->GetInputs(); 
@@ -3952,17 +4258,23 @@ Bool_t AliReconstruction::GetEventInfo()
     AliTriggerInput* trginput = (AliTriggerInput*)inputsArray.At(iinput);
     if (trginput && trginput->GetMask()>0) {
       Int_t inputIndex = (Int_t)TMath::Nint(TMath::Log2(trginput->GetMask()));
-      AliESDHeader* headeresd = fesd->GetHeader();
-      Int_t trglevel = (Int_t)trginput->GetLevel();
-      if (trglevel == 0) headeresd->SetActiveTriggerInputs(trginput->GetInputName(), inputIndex);
-      if (trglevel == 1) headeresd->SetActiveTriggerInputs(trginput->GetInputName(), inputIndex+24);
-      if (trglevel == 2) headeresd->SetActiveTriggerInputs(trginput->GetInputName(), inputIndex+48);
+      AliESDHeader* headeresd = 0x0;
+      if (fesd) headeresd = fesd->GetHeader();
+      if (headeresd) {
+       Int_t trglevel = (Int_t)trginput->GetLevel();
+       if (trglevel == 0) headeresd->SetActiveTriggerInputs(trginput->GetInputName(), inputIndex);
+       if (trglevel == 1) headeresd->SetActiveTriggerInputs(trginput->GetInputName(), inputIndex+24);
+       if (trglevel == 2) headeresd->SetActiveTriggerInputs(trginput->GetInputName(), inputIndex+48);
+      }
     }
   }
 
   // Set the information in ESD
-  fesd->SetTriggerMask(trmask);
-  fesd->SetTriggerCluster(clustmask);
+  if (fesd) {
+    fesd->SetTriggerMask(trmask);
+    fesd->SetTriggerMaskNext50(trmaskNext50);
+    fesd->SetTriggerCluster(clustmask);
+  }
 
   if (!aCTP->CheckTriggeredDetectors()) {
     if (fRawReader) delete aCTP;
@@ -3973,6 +4285,8 @@ Bool_t AliReconstruction::GetEventInfo()
 
   // We have to fill also the HLT decision here!!
   // ...
+  // check if event has cosmic or laser alias
+  
 
   return kTRUE;
 }
@@ -4061,7 +4375,7 @@ void AliReconstruction::Abort(const char *method, EAbort what)
   else if (fAbort == kAbortFile)
     mess = "AbortFile";
 
-  Info(mess, whyMess.Data());
+  Info(mess.Data(), "%s", whyMess.Data());
 }
 
 //______________________________________________________________________________
@@ -4263,6 +4577,357 @@ void AliReconstruction::WriteESDfriend() {
     new (fesdf) AliESDfriend(); // Reset...
     fesdf->SetSkipBit(kTRUE);
   }
+  //
+  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()));        
+  }
+  
+}
+
+//_________________________________________________________________
+void AliReconstruction::DeleteDigits(const TString& detectors)
+{
+  // delete requested digit files produced at current event
+  static int iEvent = 0;
+  if (detectors.IsNull()) return;
+  TString detStr = 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);
+  iEvent++;
+}
+
+//_________________________________________________________________
+void AliReconstruction::DeleteRecPoints(const TString& detectors)
+{
+  // delete requested recpoint files produced at current event
+  static int iEvent = 0;
+  if (detectors.IsNull()) return;
+  TString detStr = 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);
+  iEvent++;
+}
+
+//_________________________________________________________________
+void AliReconstruction::SetStopOnResourcesExcess(Int_t vRSS,Int_t vVMEM)
+{
+  // require checking the resources left and stopping on excess
+  // if 0  : no check is done
+  // if >0 : stop reconstruction if exceeds this value
+  // if <0 : use as margin to system limits
+  //
+  const int kKB2MB = 1024;
+  const int kInfMem = 9999999;
+  //
+  struct rlimit r;
+  int pgSize = getpagesize();
+  //
+  if (vRSS>0) {
+    fMaxRSS = vRSS;
+    AliInfo(Form("Setting max. RSS usage to user value %d MB",fMaxRSS));
+  }
+  else if (vRSS<0) {
+    getrlimit(RLIMIT_RSS,&r);
+    fMaxRSS = r.rlim_max==RLIM_INFINITY ? kInfMem : int(r.rlim_max*pgSize/kKB2MB/kKB2MB) + vRSS;
+    AliInfo(Form("Setting max. RSS usage to system hard limit %d%s MB (%d margin)",fMaxRSS,r.rlim_max==RLIM_INFINITY ? "(inf)":"",-vRSS));
+  }
+  else {AliInfo("No check on RSS memory usage will be applied");}
+  //
+  if (vVMEM>0) {
+    fMaxVMEM = vVMEM;
+    AliInfo(Form("Setting max. VMEM usage to user value %d MB",fMaxVMEM));
+  }
+  else if (vVMEM<0) {
+    getrlimit(RLIMIT_AS,&r);
+    fMaxVMEM = r.rlim_max==RLIM_INFINITY ? kInfMem : int(r.rlim_max*pgSize/kKB2MB/kKB2MB) + vVMEM;
+    AliInfo(Form("Setting max. VMEM usage to system hard limit %d%s MB (%d margin)",fMaxVMEM,r.rlim_max==RLIM_INFINITY ? "(inf)":"",-vVMEM));
+  }
+  else {AliInfo("No check on RSS memory usage will be applied");}
+  //  
+}
+
+//_________________________________________________________________
+Bool_t AliReconstruction::HasEnoughResources(int ev)
+{
+  // check if process consumed more than allowed resources
+  const int kKB2MB = 1024;
+  Bool_t res = kTRUE;
+  if (!fMaxRSS && !fMaxVMEM) return res;
+  //
+  ProcInfo_t procInfo;
+  gSystem->GetProcInfo(&procInfo);
+  if (procInfo.fMemResident/kKB2MB > fMaxRSS)  res = kFALSE;
+  if (procInfo.fMemVirtual/kKB2MB  > fMaxVMEM) res = kFALSE;  
+  //
+  if (!res) {
+    AliInfo(Form("Job exceeded allowed limits: RSS:%d (%d) VMEM:%d (%d), will stop",
+                int(procInfo.fMemResident/kKB2MB),fMaxRSS,
+                int(procInfo.fMemVirtual/kKB2MB) ,fMaxVMEM));
+    //
+    unlink(Form("%s",fgkStopEvFName));
+    ofstream outfile(fgkStopEvFName);
+    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()));
+    //
+    // find cdbID used for sim
+    TString idSim="",storSim="";
+    TIter nextSim(cdbListSim);
+    while ((stro=(TObjString*)nextSim())) {
+      if (stro->GetString().Contains(cdbent->GetName())) {
+       idSim = stro->GetString();
+       break;
+      }
+    }    
+    // find the storage used for sim
+    // check in the simuCDB special paths
+    pair = (TPair*)cdbMapSim->FindObject(cdbent->GetName());
+    if (pair) { // specific path is used
+      storSim = ((TObjString*)pair->Value())->GetString();
+      RectifyCDBurl(storSim);
+    }
+    else storSim = defSimStore;  // default storage list is used
+    //
+    if (!idSim.IsNull()) AliInfo(Form("Sim. used %s from %s",idSim.Data(), storSim.Data()));
+    else                 AliInfo("Sim. did not use this object");
+    //
+    // find cdbID used for rec
+    TString idRec="",storRec="";
+    TIter nextRec(cdbListRec);
+    AliCDBId* id=0;
+    while ((id=(AliCDBId*)nextRec())) {
+      idRec = id->ToString();
+      if (idRec.Contains(cdbent->GetName())) break;
+      idRec="";
+    }
+    //
+    // find storage used for the rec
+    pair = (TPair*)cdbMapRec->FindObject(cdbent->GetName());
+    if (pair) {  // specific path is used
+      storRec = ((TObjString*)pair->Value())->GetString();
+      RectifyCDBurl(storRec);
+    }
+    else storRec = defRecStore; // default storage list is used
+    //
+    if (!idRec.IsNull()) AliInfo(Form("Rec. used %s from %s",idRec.Data(), storRec.Data()));
+    else                 AliInfo("Rec. did not use this object");
+    //
+    if (!idSim.IsNull() && !idRec.IsNull() && ((idSim!=idRec) || (storSim!=storRec)) ) 
+      AliFatal("Different objects were used in sim and rec");
+  }
   
-  ftreeF->Fill();
+}
+
+//_________________________________________________________
+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();
+  //
+}
+
+//_________________________________________________________
+void AliReconstruction::ProcessTriggerAliases()
+{
+  // load trigger aliases, attach them to the reader
+  //
+  fDeclTriggerClasses.Clear();
+  AliCentralTrigger *aCTP = NULL;
+  if (fRawReader) {
+    aCTP = new AliCentralTrigger();
+    TString configstr("");
+    if (!aCTP->LoadConfiguration(configstr)) { // Load CTP config from OCDB
+      AliError("No trigger configuration found in OCDB! The trigger configuration information will not be used!");
+      delete aCTP;
+      return;
+    }
+  }
+  else if (fRunLoader && (!fRunLoader->LoadTrigger())) {
+    aCTP = fRunLoader->GetTrigger();
+  }
+  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;
+  }
+  //  
+  AliTriggerConfiguration *config = aCTP->GetConfiguration();
+  if (!config) {
+    AliError("No trigger configuration has been found! The trigger configuration information will not be used!");
+    if (fRawReader) delete aCTP;
+    return;
+  }
+  //
+  // here we have list of active triggers
+  const TObjArray& classesArray = config->GetClasses();
+  Int_t nclasses = classesArray.GetEntriesFast();
+  // 
+  fAlias2Trigger = new THashList();
+  //
+  AliCDBEntry * entry = AliCDBManager::Instance()->Get("GRP/CTP/Aliases");
+  if (entry) {
+    THashList * lst = dynamic_cast<THashList*>(entry->GetObject());
+    if (lst) {
+      lst->Sort(kSortDescending); // to avoid problems with substrungs
+      if (fRawReader) fRawReader->LoadTriggerAlias(lst);
+      // Now declare all the triggers present in the aliases
+      TIter iter(lst);
+      TNamed *nmd = 0;
+      while((nmd = dynamic_cast<TNamed*>(iter.Next()))) { // account aliases of this trigger >>
+       fDeclTriggerClasses += " ";
+       fDeclTriggerClasses += nmd->GetName();
+       //
+       if (!classesArray.FindObject(nmd->GetName())) continue;
+       TString aliasList(nmd->GetTitle());
+       TObjArray* arrAliases = aliasList.Tokenize(',');
+       Int_t nAliases = arrAliases->GetEntries();
+       // Loop on aliases for the current trigger
+       for(Int_t i=0; i<nAliases; i++){
+         TObjString *alias = (TObjString*) arrAliases->At(i);
+         // Find the current alias in the hash list. If it is not there, add TNamed entry
+         TNamed * inlist = (TNamed*)fAlias2Trigger->FindObject((alias->GetString()).Data());
+         if (!inlist) {
+           inlist = new TNamed((alias->GetString()).Data(),Form(" %s ",nmd->GetName()));
+           fAlias2Trigger->Add(inlist);
+         }
+         else {
+           TString tt(inlist->GetTitle());
+           tt += "||";
+           tt += Form(" %s ",nmd->GetName());
+           inlist->SetTitle(tt.Data());
+         }
+       }
+       delete arrAliases;
+      }  // account aliases of this trigger <<
+    }
+    else AliError("Cannot cast the object with trigger aliases to THashList!");
+  }
+  else AliError("No OCDB ebtry for the trigger aliases!");
+  //
+  AliInfo("Aliases defined:");
+  fAlias2Trigger->Print();
+  //
+  if (fRawReader) {
+    // active classes mentioned in the alias will be converted to their masks
+    for( Int_t iclass=0; iclass < nclasses; iclass++ ) {
+      AliTriggerClass* trclass = (AliTriggerClass*)classesArray.At(iclass);
+      if (trclass && trclass->GetMask()>0) {
+       Int_t trindex = TMath::Nint(TMath::Log2(trclass->GetMask()));
+       fRawReader->LoadTriggerClass(trclass->GetName(),trindex);
+      }
+      if (trclass && trclass->GetMaskNext50()>0) {
+       Int_t trindex = TMath::Nint(TMath::Log2(trclass->GetMaskNext50()))+50;
+       fRawReader->LoadTriggerClass(trclass->GetName(),trindex);
+      }
+    }
+    //
+    // nullify all remaining triggers mentioned in the alias
+    if (!fDeclTriggerClasses.IsNull()) {
+      TObjArray *tokens = fDeclTriggerClasses.Tokenize(" ");
+      Int_t ntokens = tokens->GetEntriesFast();
+      for (Int_t itoken = 0; itoken < ntokens; ++itoken) {
+       fRawReader->LoadTriggerClass((((TObjString*)tokens->At(itoken))->String()).Data(),-1);
+      }
+      delete tokens;
+    }
+  }
+  //
+}
+
+//___________________________________________________
+Bool_t AliReconstruction::TriggerMatches2Alias(const char* trigName, const char* alias)
+{
+  // check if trigger matches to alias
+  TString trName = trigName;
+  if (!fAlias2Trigger) return kFALSE;
+  TNamed* al = (TNamed*)fAlias2Trigger->FindObject(alias);
+  if (!al) return kFALSE;
+  TString altrig = al->GetTitle();
+  return altrig.Contains(Form(" %s ",trigName));
+  //
 }