]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliReconstruction.cxx
Warnings removed (R.Shahoyan)
[u/mrichter/AliRoot.git] / STEER / AliReconstruction.cxx
index bd7c6aa8e9813740b1afdc7d76e5e365725624a2..6acdbaf1a7db29c08181d77187280aa0cff0a78e 100644 (file)
 #include <THashTable.h>
 #include <TGrid.h>
 #include <TMessage.h>
+#include <TUrl.h>
+#include <TRandom.h>
 
 #include "AliAlignObj.h"
 #include "AliCDBEntry.h"
 #include "AliTriggerConfiguration.h"
 #include "AliV0vertexer.h"
 #include "AliVertexer.h"
+#include "AliTrackleter.h"
 #include "AliVertexerTracks.h"
 #include "AliTriggerRunScalers.h"
 #include "AliCTPTimeParams.h" 
 #include "AliESDHLTDecision.h"
 #include "AliTriggerInput.h"
+#include "AliLHCData.h"
 ClassImp(AliReconstruction)
 
 //_____________________________________________________________________________
@@ -207,6 +211,7 @@ AliReconstruction::AliReconstruction(const char* gAliceFilename) :
   fRunMuonTracking(kFALSE),
   fRunV0Finder(kTRUE),
   fRunCascadeFinder(kTRUE),
+  fRunMultFinder(kTRUE),
   fStopOnError(kTRUE),
   fWriteAlignmentData(kFALSE),
   fWriteESDfriend(kFALSE),
@@ -234,6 +239,7 @@ AliReconstruction::AliReconstruction(const char* gAliceFilename) :
   fFirstEvent(0),
   fLastEvent(-1),
   fNumberOfEventsPerFile((UInt_t)-1),
+  fFractionFriends(0.04),
   fOptions(),
   fLoadAlignFromCDB(kTRUE),
   fLoadAlignData("ALL"),
@@ -242,6 +248,7 @@ AliReconstruction::AliReconstruction(const char* gAliceFilename) :
   fEventInfo(),
   fRunScalers(NULL),
   fCTPTimeParams(NULL),  
+  fCTPTimeAlign(NULL),  
 
   fRunLoader(NULL),
   fRawReader(NULL),
@@ -277,7 +284,9 @@ AliReconstruction::AliReconstruction(const char* gAliceFilename) :
   fhltesd(NULL),
   fesdf(NULL),
   ffile(NULL),
+  ffileF(NULL),
   ftree(NULL),
+  ftreeF(NULL),
   fhlttree(NULL),
   ftVertexer(NULL),
   fIsNewRunLoader(kFALSE),
@@ -296,7 +305,8 @@ AliReconstruction::AliReconstruction(const char* gAliceFilename) :
     fQACycles[iDet] = 999999 ;
     fQAWriteExpert[iDet] = kFALSE ; 
   }
-    
+  fBeamInt[0][0]=fBeamInt[0][1]=fBeamInt[1][0]=fBeamInt[1][1] = -1;
+
   AliPID pid;
 }
 
@@ -309,6 +319,7 @@ AliReconstruction::AliReconstruction(const AliReconstruction& rec) :
   fRunMuonTracking(rec.fRunMuonTracking),
   fRunV0Finder(rec.fRunV0Finder),
   fRunCascadeFinder(rec.fRunCascadeFinder),
+  fRunMultFinder(rec.fRunMultFinder),
   fStopOnError(rec.fStopOnError),
   fWriteAlignmentData(rec.fWriteAlignmentData),
   fWriteESDfriend(rec.fWriteESDfriend),
@@ -336,6 +347,7 @@ AliReconstruction::AliReconstruction(const AliReconstruction& rec) :
   fFirstEvent(rec.fFirstEvent),
   fLastEvent(rec.fLastEvent),
   fNumberOfEventsPerFile(rec.fNumberOfEventsPerFile),
+  fFractionFriends(rec.fFractionFriends),
   fOptions(),
   fLoadAlignFromCDB(rec.fLoadAlignFromCDB),
   fLoadAlignData(rec.fLoadAlignData),
@@ -344,6 +356,7 @@ AliReconstruction::AliReconstruction(const AliReconstruction& rec) :
   fEventInfo(),
   fRunScalers(NULL),
   fCTPTimeParams(NULL),
+  fCTPTimeAlign(NULL),
 
   fRunLoader(NULL),
   fRawReader(NULL),
@@ -379,7 +392,9 @@ AliReconstruction::AliReconstruction(const AliReconstruction& rec) :
   fhltesd(NULL),
   fesdf(NULL),
   ffile(NULL),
+  ffileF(NULL),
   ftree(NULL),
+  ftreeF(NULL),
   fhlttree(NULL),
   ftVertexer(NULL),
   fIsNewRunLoader(rec.fIsNewRunLoader),
@@ -405,6 +420,9 @@ AliReconstruction::AliReconstruction(const AliReconstruction& rec) :
   for (Int_t i = 0; i < rec.fSpecCDBUri.GetEntriesFast(); i++) {
     if (rec.fSpecCDBUri[i]) fSpecCDBUri.Add(rec.fSpecCDBUri[i]->Clone());
   }
+
+  for (int i=2;i--;) for (int j=2;j--;) fBeamInt[i][j] = rec.fBeamInt[i][j];
+
 }
 
 //_____________________________________________________________________________
@@ -425,6 +443,7 @@ AliReconstruction& AliReconstruction::operator = (const AliReconstruction& rec)
   fRunMuonTracking       = rec.fRunMuonTracking;
   fRunV0Finder           = rec.fRunV0Finder;
   fRunCascadeFinder      = rec.fRunCascadeFinder;
+  fRunMultFinder         = rec.fRunMultFinder;
   fStopOnError           = rec.fStopOnError;
   fWriteAlignmentData    = rec.fWriteAlignmentData;
   fWriteESDfriend        = rec.fWriteESDfriend;
@@ -452,6 +471,7 @@ AliReconstruction& AliReconstruction::operator = (const AliReconstruction& rec)
   fFirstEvent                    = rec.fFirstEvent;
   fLastEvent                     = rec.fLastEvent;
   fNumberOfEventsPerFile         = rec.fNumberOfEventsPerFile;
+  fFractionFriends               = rec.fFractionFriends;
 
   for (Int_t i = 0; i < rec.fOptions.GetEntriesFast(); i++) {
     if (rec.fOptions[i]) fOptions.Add(rec.fOptions[i]->Clone());
@@ -471,6 +491,8 @@ AliReconstruction& AliReconstruction::operator = (const AliReconstruction& rec)
 
   delete fCTPTimeParams; fCTPTimeParams = NULL;
   if (rec.fCTPTimeParams) fCTPTimeParams = new AliCTPTimeParams(*rec.fCTPTimeParams);
+  delete fCTPTimeAlign; fCTPTimeAlign = NULL;
+  if (rec.fCTPTimeAlign) fCTPTimeAlign = new AliCTPTimeParams(*rec.fCTPTimeAlign);
 
   fRunLoader       = NULL;
   fRawReader       = NULL;
@@ -520,12 +542,14 @@ AliReconstruction& AliReconstruction::operator = (const AliReconstruction& rec)
   fInitQACalled                = rec.fInitQACalled;
   fWriteQAExpertData           = rec.fWriteQAExpertData;
   fRunPlaneEff                 = rec.fRunPlaneEff;
-
+  for (int i=2;i--;) for (int j=2;j--;) fBeamInt[i][j] = rec.fBeamInt[i][j];
   fesd     = NULL;
   fhltesd  = NULL;
   fesdf    = NULL;
   ffile    = NULL;
+  ffileF   = NULL;
   ftree    = NULL;
+  ftreeF   = NULL;
   fhlttree = NULL;
   ftVertexer = NULL;
   fIsNewRunLoader = rec.fIsNewRunLoader;
@@ -548,6 +572,7 @@ AliReconstruction::~AliReconstruction()
   delete fGRPData;
   delete fRunScalers;
   delete fCTPTimeParams;
+  delete fCTPTimeAlign;
   fOptions.Delete();
   if (fAlignObjArray) {
     fAlignObjArray->Delete();
@@ -1020,8 +1045,9 @@ Bool_t AliReconstruction::InitGRP() {
        !((detMask >> AliDAQ::DetectorID("ITSSDD")) & 0x1) &&
        !((detMask >> AliDAQ::DetectorID("ITSSSD")) & 0x1) ) {
       // switch off the vertexer
-      AliInfo("SPD,SDD,SSD is not in the list of active detectors. Vertexer switched off.");
+      AliInfo("SPD,SDD,SSD is not in the list of active detectors. Vertexer and Trackleter are switched off.");
       fRunVertexFinder = kFALSE;
+      fRunMultFinder = kFALSE;
     }
     if (!((detMask >> AliDAQ::DetectorID("TRG")) & 0x1)) {
       // switch off the reading of CTP raw-data payload
@@ -1137,6 +1163,10 @@ Bool_t AliReconstruction::InitGRP() {
 //_____________________________________________________________________________
 Bool_t AliReconstruction::LoadCDB()
 {
+  // Load CDB entries for all active detectors.
+  // By default we load all the entries in <det>/Calib
+  // folder.
+
   AliCodeTimerAuto("",0);
 
   AliCDBManager::Instance()->Get("GRP/CTP/Config");
@@ -1158,6 +1188,9 @@ Bool_t AliReconstruction::LoadCDB()
 //_____________________________________________________________________________
 Bool_t AliReconstruction::LoadTriggerScalersCDB()
 {
+  // Load CTP scalers from OCDB.
+  // The scalers are checked for consistency.
+
   AliCodeTimerAuto("",0);
 
   AliCDBEntry* entry = AliCDBManager::Instance()->Get("GRP/CTP/Scalers");
@@ -1175,18 +1208,48 @@ Bool_t AliReconstruction::LoadTriggerScalersCDB()
 //_____________________________________________________________________________
 Bool_t AliReconstruction::LoadCTPTimeParamsCDB()
 {
+  // Load CTP timing information (alignment)
+  // from OCDB.
+
   AliCDBEntry* entry = AliCDBManager::Instance()->Get("GRP/CTP/CTPtiming");
+  if (!entry) return kFALSE;
 
-  if (entry) {
+  AliInfo("Found an AliCTPTimeParams in GRP/CTP/CTPtiming, reading it");
+  fCTPTimeParams = dynamic_cast<AliCTPTimeParams*> (entry->GetObject());
+  entry->SetOwner(0);
 
-       AliInfo("Found an AliCTPTimeParams in GRP/CTP/CTPtiming, reading it");
-       fCTPTimeParams = dynamic_cast<AliCTPTimeParams*> (entry->GetObject());
-       entry->SetOwner(0);
-       return kTRUE;
+  AliCDBEntry* entry2 = AliCDBManager::Instance()->Get("GRP/CTP/TimeAlign");
+  if (!entry2) return kFALSE;
+
+  AliInfo("Found an AliCTPTimeParams in GRP/CTP/TimeAlign, reading it");
+  fCTPTimeAlign = dynamic_cast<AliCTPTimeParams*> (entry2->GetObject());
+  entry2->SetOwner(0);
+
+  return kTRUE;
+}
+
+//_____________________________________________________________________________
+Bool_t AliReconstruction::ReadIntensityInfoCDB()
+{
+  // Load LHC DIP data
+  AliCDBEntry* entry = AliCDBManager::Instance()->Get("GRP/GRP/LHCData");
+
+  if (entry) { 
+    AliInfo("Found an AliLHCData in GRP/GRP/LHCData, reading it");
+    AliLHCData* dipData = dynamic_cast<AliLHCData*> (entry->GetObject());
+    for (int ib=2;ib--;) {
+      double intI,intNI;
+      if (dipData->GetMeanIntensity(ib,intI,intNI)>=0) {
+       fBeamInt[ib][0] = intI;
+       fBeamInt[ib][1] = intNI;        
+      }
+    }
+    return kTRUE;
   }
-  
-  return kFALSE; 
+  return kFALSE;
 }
+
+
 //_____________________________________________________________________________
 Bool_t AliReconstruction::Run(const char* input)
 {
@@ -1250,10 +1313,11 @@ Bool_t AliReconstruction::Run(const char* input)
 //_____________________________________________________________________________
 void AliReconstruction::InitRawReader(const char* input)
 {
-  AliCodeTimerAuto("",0);
-
   // Init raw-reader and
   // set the input in case of raw data
+
+  AliCodeTimerAuto("",0);
+
   if (input) fRawInput = input;
   fRawReader = AliRawReader::Create(fRawInput.Data());
   if (!fRawReader) {
@@ -1374,6 +1438,12 @@ void AliReconstruction::Begin(TTree *)
   }
   AliSysInfo::AddStamp("LoadCTPTimeParamsCDB");
 
+  if (!ReadIntensityInfoCDB()) {
+    Abort("ReadIntensityInfoCDB", TSelector::kAbortProcess);
+    return;
+  }
+  AliSysInfo::AddStamp("ReadIntensityInfoCDB");
+
   // Read the reconstruction parameters from OCDB
   if (!InitRecoParams()) {
     AliWarning("Not all detectors have correct RecoParam objects initialized");
@@ -1501,19 +1571,12 @@ void AliReconstruction::SlaveBegin(TTree*)
 
   fesd->WriteToTree(ftree);
   if (fWriteESDfriend) {
-    // careful:
-    // Since we add the branch manually we must 
-    // book and add it after WriteToTree
-    // otherwise it is created twice,
-    // once via writetotree and once here.
-    // The case for AliESDfriend is now 
-    // caught also in AlIESDEvent::WriteToTree but 
-    // be careful when changing the name (AliESDfriend is not 
-    // a TNamed so we had to hardwire it)
-    fesdf = new AliESDfriend();
-    TBranch *br=ftree->Branch("ESDfriend.","AliESDfriend", &fesdf);
-    br->SetFile("AliESDfriends.root");
+    ffileF = TFile::Open("AliESDfriends.root", "RECREATE");
+    ftreeF = new TTree("esdFriendTree", "Tree with ESD Friend objects");
+    fesdf  = new AliESDfriend();
+    ftreeF->Branch("ESDfriend.","AliESDfriend", &fesdf);
     fesd->AddObject(fesdf);
+    ffile->cd();
   }
   ftree->GetUserInfo()->Add(fesd);
 
@@ -1549,7 +1612,7 @@ void AliReconstruction::SlaveBegin(TTree*)
 
   ProcInfo_t procInfo;
   gSystem->GetProcInfo(&procInfo);
-  AliInfo(Form("Current memory usage %d %d", procInfo.fMemResident, procInfo.fMemVirtual));
+  AliInfo(Form("Current memory usage %ld %ld", procInfo.fMemResident, procInfo.fMemVirtual));
   
   //QA
   //Initialize the QA and start of cycle 
@@ -1591,6 +1654,8 @@ Bool_t AliReconstruction::Process(Long64_t entry)
 //_____________________________________________________________________________
 void AliReconstruction::Init(TTree *tree)
 {
+  // Implementation of TSelector::Init()
+  // method
   if (tree == 0) {
     AliError("The input tree is not found!");
     return;
@@ -1614,7 +1679,7 @@ Bool_t AliReconstruction::ProcessEvent(Int_t iEvent)
 
   AliCodeTimerAuto("",0);
 
-  AliESDpid PID;
+  AliESDpid pid;
 
   if (iEvent >= fRunLoader->GetNumberOfEvents()) {
     fRunLoader->SetEventNumber(iEvent);
@@ -1654,7 +1719,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(&pid);
        reconstructor->SetEventInfo(&fEventInfo);
         if (fRunQA) {
           AliQAManager::QAManager()->SetRecoParam(iDet, par) ; 
@@ -1700,6 +1765,12 @@ Bool_t AliReconstruction::ProcessEvent(Int_t iEvent)
 
     fesd->SetRunNumber(fRunLoader->GetHeader()->GetRun());
     fhltesd->SetRunNumber(fRunLoader->GetHeader()->GetRun());
+    
+    ((AliESDRun*)fesd->GetESDRun())->SetDetectorsInDAQ(fRunInfo->GetDetectorMask());
+    ((AliESDRun*)fhltesd->GetESDRun())->SetDetectorsInDAQ(fRunInfo->GetDetectorMask());
+    ((AliESDRun*)fesd->GetESDRun())->SetDetectorsInReco(AliDAQ::DetectorPatternOffline(fFillESD.Data()));
+    ((AliESDRun*)fhltesd->GetESDRun())->SetDetectorsInReco(AliDAQ::DetectorPatternOffline(fFillESD.Data()));
+
     fesd->SetEventNumberInFile(fRunLoader->GetHeader()->GetEventNrInRun());
     fhltesd->SetEventNumberInFile(fRunLoader->GetHeader()->GetEventNrInRun());
 
@@ -1710,8 +1781,16 @@ Bool_t AliReconstruction::ProcessEvent(Int_t iEvent)
     fesd->SetMagneticField(AliTracker::GetBz());
     fhltesd->SetMagneticField(AliTracker::GetBz());
     //
-    ((AliESDRun*)fesd->GetESDRun())->SetBeamEnergyIsSqrtSHalfGeV();
-    ((AliESDRun*)fhltesd->GetESDRun())->SetBeamEnergyIsSqrtSHalfGeV();
+    AliESDRun *esdRun,*esdRunH;
+    esdRun  = (AliESDRun*)fesd->GetESDRun();
+    esdRunH = (AliESDRun*)fhltesd->GetESDRun();
+    esdRun->SetBeamEnergyIsSqrtSHalfGeV();
+    esdRunH->SetBeamEnergyIsSqrtSHalfGeV();
+    //
+    for (int ib=2;ib--;) for (int it=2;it--;) {
+       esdRun->SetMeanIntensity(ib,it, fBeamInt[ib][it]); 
+       esdRunH->SetMeanIntensity(ib,it, fBeamInt[ib][it]); 
+      }
     //
     AliMagF* fld = (AliMagF*)TGeoGlobalMagField::Instance()->GetField();
     if (fld) { // set info needed for field initialization
@@ -1763,7 +1842,7 @@ Bool_t AliReconstruction::ProcessEvent(Int_t iEvent)
 
     // barrel tracking
     if (!fRunTracking.IsNull()) {
-      if (!RunTracking(fesd,PID)) {
+      if (!RunTracking(fesd,pid)) {
        if (fStopOnError) {CleanUp(); return kFALSE;}
       }
     }
@@ -1793,7 +1872,7 @@ Bool_t AliReconstruction::ProcessEvent(Int_t iEvent)
     }
  
     // combined PID
-    PID.MakePID(fesd);
+    pid.MakePID(fesd);
 
     if (fFillTriggerESD) {
       if (!FillTriggerESD(fesd)) {
@@ -1864,17 +1943,31 @@ Bool_t AliReconstruction::ProcessEvent(Int_t iEvent)
        ftVertexer->SetITSMode();
        ftVertexer->SetConstraintOff();
        // get cuts for vertexer from AliGRPRecoParam
+       Bool_t constrSPD=kFALSE;
        if (grpRecoParam) {
         Int_t nCutsVertexer = grpRecoParam->GetVertexerTracksNCuts();
         Double_t *cutsVertexer = new Double_t[nCutsVertexer];
         grpRecoParam->GetVertexerTracksCutsITS(cutsVertexer);
         ftVertexer->SetCuts(cutsVertexer);
         delete [] cutsVertexer; cutsVertexer = NULL; 
-        if(fDiamondProfile && grpRecoParam->GetVertexerTracksConstraintITS())
-          ftVertexer->SetVtxStart(fDiamondProfile);
+        if(grpRecoParam->GetVertexerTracksConstraintITS()) { 
+          if(fDiamondProfile && fDiamondProfile->GetXRes()<kRadius){
+            ftVertexer->SetVtxStart(fDiamondProfile); // apply constraint only if sigmax is smaller than the beam pipe radius 
+          }else{
+            if(fDiamondProfileSPD && fDiamondProfileSPD->GetXRes()<kRadius){
+              ftVertexer->SetVtxStart(fDiamondProfileSPD);
+              constrSPD=kTRUE;
+            }
+          }
+        } 
        }
        AliESDVertex *pvtx=ftVertexer->FindPrimaryVertex(fesd);
        if (pvtx) {
+        if(constrSPD){
+          TString title=pvtx->GetTitle();
+          title.Append("SPD");
+          pvtx->SetTitle(title);
+        }
           if (pvtx->GetStatus()) {
              fesd->SetPrimaryVertexTracks(pvtx);
              for (Int_t i=0; i<ntracks; i++) {
@@ -1897,8 +1990,9 @@ Bool_t AliReconstruction::ProcessEvent(Int_t iEvent)
         grpRecoParam->GetVertexerTracksCutsTPC(cutsVertexer);
         ftVertexer->SetCuts(cutsVertexer);
         delete [] cutsVertexer; cutsVertexer = NULL; 
-        if(fDiamondProfileTPC && grpRecoParam->GetVertexerTracksConstraintTPC())
-          ftVertexer->SetVtxStart(fDiamondProfileTPC);
+        if(fDiamondProfileTPC && grpRecoParam->GetVertexerTracksConstraintTPC()) { 
+          if(fDiamondProfileTPC->GetXRes()<kRadius) ftVertexer->SetVtxStart(fDiamondProfileTPC); // apply constraint only if sigmax is smaller than the beam pipe radius 
+        } 
        }
        pvtx=ftVertexer->FindPrimaryVertex(&trkArray,selectedIdx);
        if (pvtx) {
@@ -1917,8 +2011,8 @@ Bool_t AliReconstruction::ProcessEvent(Int_t iEvent)
     }
     delete[] selectedIdx;
 
-    if(fDiamondProfile) fesd->SetDiamond(fDiamondProfile);
-    
+    if(fDiamondProfile && fDiamondProfile->GetXRes()<kRadius) fesd->SetDiamond(fDiamondProfile);
+    else fesd->SetDiamond(fDiamondProfileSPD);
 
     if (fRunV0Finder) {
        // V0 finding
@@ -1932,6 +2026,16 @@ Bool_t AliReconstruction::ProcessEvent(Int_t 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 
+    // ESD info is available (particulalry, V0s)
+    // vertex finder
+    if (fRunMultFinder) {
+      if (!RunMultFinder(fesd)) {
+       if (fStopOnError) {CleanUp(); return kFALSE;}
+      }
+    }
+
     // write ESD
     if (fCleanESD) CleanESD(fesd);
 
@@ -1955,16 +2059,26 @@ Bool_t AliReconstruction::ProcessEvent(Int_t iEvent)
     pHLTSrc->Copy(*pHLTTgt);
   }
 
-    if (fWriteESDfriend) {
-      //      fesdf->~AliESDfriend();
-      //  new (fesdf) AliESDfriend(); // Reset...
+    if (fWriteESDfriend) 
       fesd->GetESDfriend(fesdf);
-    }
+
     ftree->Fill();
+    if (fWriteESDfriend) {
+      // Sampling
+      Double_t rnd = gRandom->Rndm();
+      if (fFractionFriends < rnd) {
+       fesdf->~AliESDfriend();
+       new (fesdf) AliESDfriend(); // Reset...
+       fesdf->SetSkipBit(kTRUE);
+      }
+
+      ftreeF->Fill();
+    }
 
     // Auto-save the ESD tree in case of prompt reco @P2
     if (fRawReader && fRawReader->UseAutoSaveESD()) {
       ftree->AutoSave("SaveSelf");
+      if (fWriteESDfriend) ftreeF->AutoSave("SaveSelf");
       TFile *friendfile = (TFile *)(gROOT->GetListOfFiles()->FindObject("AliESDfriends.root"));
       if (friendfile) friendfile->Save();
     }
@@ -1989,7 +2103,7 @@ Bool_t AliReconstruction::ProcessEvent(Int_t iEvent)
     aveDMres+=(dMres-aveDMres)/(iEvent-fFirstEvent+1);
     aveDMvir+=(dMvir-aveDMvir)/(iEvent-fFirstEvent+1);
     aveDCPU+=(dCPU-aveDCPU)/(iEvent-fFirstEvent+1);
-    AliInfo(Form("======================= End Event %d: Res %d(%3d <%3d>) Vir %d(%3d <%3d>) CPU %5.2f <%5.2f> ===================",
+    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;
@@ -2056,12 +2170,15 @@ void AliReconstruction::SlaveTerminate()
 
   ffile->cd();
 
-  if (fWriteESDfriend)
-    ftree->SetBranchStatus("ESDfriend*",0);
   // we want to have only one tree version number
   ftree->Write(ftree->GetName(),TObject::kOverwrite);
   fhlttree->Write(fhlttree->GetName(),TObject::kOverwrite);
 
+  if (fWriteESDfriend) {
+    ffileF->cd();
+    ftreeF->Write(ftreeF->GetName(),TObject::kOverwrite);
+  }
+
 // Finish with Plane Efficiency evaluation: before of CleanUp !!!
   if (fRunPlaneEff && !FinishPlaneEff()) {
    AliWarning("Finish PlaneEff evaluation failed");
@@ -2281,7 +2398,7 @@ Bool_t AliReconstruction::RunVertexFinder(AliESDEvent*& esd)
   AliVertexer *vertexer = CreateVertexer();
   if (!vertexer) return kFALSE;
 
-  AliInfo("running the ITS vertex finder");
+  AliInfo(Form("running the ITS vertex finder: %s",vertexer->ClassName()));
   AliESDVertex* vertex = NULL;
   if (fLoader[0]) {
     fLoader[0]->LoadRecPoints();
@@ -2319,10 +2436,11 @@ Bool_t AliReconstruction::RunVertexFinder(AliESDEvent*& esd)
   if(novertices>1){
     for (Int_t kk=1; kk<novertices; kk++)esd->AddPileupVertexSPD(&vpileup[kk]);
   }
+  /*
   // if SPD multiplicity has been determined, it is stored in the ESD
   AliMultiplicity *mult = vertexer->GetMultiplicity();
   if(mult)esd->SetMultiplicity(mult);
-
+  */
   for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
     if (fTracker[iDet]) fTracker[iDet]->SetVertex(vtxPos, vtxErr);
   }  
@@ -2333,6 +2451,40 @@ Bool_t AliReconstruction::RunVertexFinder(AliESDEvent*& esd)
   return kTRUE;
 }
 
+//_____________________________________________________________________________
+Bool_t AliReconstruction::RunMultFinder(AliESDEvent*& esd)
+{
+  // run the trackleter for multiplicity study
+
+  AliCodeTimerAuto("",0)
+
+  AliTrackleter *trackleter = CreateMultFinder();
+  if (!trackleter) return kFALSE;
+
+  AliInfo(Form("running the ITS multiplicity finder: %s",trackleter->ClassName()));
+
+  if (fLoader[0]) {
+    fLoader[0]->LoadRecPoints();
+    TTree* cltree = fLoader[0]->TreeR();
+    if (cltree) {
+      trackleter->Reconstruct(esd,cltree);
+      AliMultiplicity *mult = trackleter->GetMultiplicity();
+      if(mult) esd->SetMultiplicity(mult);
+    }
+    else {
+      AliError("Can't get the ITS cluster tree");
+    }
+    fLoader[0]->UnloadRecPoints();
+  }
+  else {
+    AliError("Can't get the ITS loader");
+  }
+
+  delete trackleter;
+
+  return kTRUE;
+}
+
 //_____________________________________________________________________________
 Bool_t AliReconstruction::RunHLTTracking(AliESDEvent*& esd)
 {
@@ -2635,6 +2787,7 @@ Bool_t AliReconstruction::FillESD(AliESDEvent*& esd, const TString& detectors)
     static Int_t eventNr=0; 
   TString detStr = detectors;
   
+  AliSysInfo::AddStamp(Form("FillESDb%d",eventNr), -19,-19, eventNr);
   for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
   if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
     AliReconstructor* reconstructor = GetReconstructor(iDet);
@@ -2677,7 +2830,7 @@ Bool_t AliReconstruction::FillESD(AliESDEvent*& esd, const TString& detectors)
                   detStr.Data()));
     if (fStopOnError) return kFALSE;
   }
-  AliSysInfo::AddStamp(Form("FillESD%d",eventNr), 0,1, eventNr);
+  AliSysInfo::AddStamp(Form("FillESDe%d",eventNr), -20,-20, eventNr);
   eventNr++;
   return kTRUE;
 }
@@ -2973,6 +3126,25 @@ AliVertexer* AliReconstruction::CreateVertexer()
   return vertexer;
 }
 
+//_____________________________________________________________________________
+AliTrackleter* AliReconstruction::CreateMultFinder()
+{
+// create the ITS trackleter for mult. estimation
+// Please note that the caller is the owner of the
+// trackleter
+
+  AliTrackleter* trackleter = NULL;
+  AliReconstructor* itsReconstructor = GetReconstructor(0);
+  if (itsReconstructor && ((fRunLocalReconstruction.Contains("ITS")) || fRunTracking.Contains("ITS"))) {
+    trackleter = itsReconstructor->CreateMultFinder();
+  }
+  if (!trackleter) {
+    AliWarning("couldn't create a trackleter for ITS");
+  }
+
+  return trackleter;
+}
+
 //_____________________________________________________________________________
 Bool_t AliReconstruction::CreateTrackers(const TString& detectors)
 {
@@ -2994,7 +3166,6 @@ Bool_t AliReconstruction::CreateTrackers(const TString& detectors)
       continue;
     }
 
-
     fTracker[iDet] = reconstructor->CreateTracker();
     if (!fTracker[iDet] && (iDet < 7)) {
       AliWarning(Form("couldn't create a tracker for %s", detName.Data()));
@@ -3131,8 +3302,8 @@ void AliReconstruction::FillRawDataErrorLog(Int_t iEvent, AliESDEvent* esd)
 }
 
 //_____________________________________________________________________________
-void AliReconstruction::CheckQA()
-{
+// void AliReconstruction::CheckQA()
+// {
 // check the QA of SIM for this run and remove the detectors 
 // with status Fatal
   
@@ -3167,7 +3338,7 @@ void AliReconstruction::CheckQA()
 //     fRunLocalReconstruction = newRunLocalReconstruction ; 
 //     fRunTracking            = newRunTracking ; 
 //     fFillESD                = newFillESD ; 
-}
+// }
 
 //_____________________________________________________________________________
 Int_t AliReconstruction::GetDetIndex(const char* detector)
@@ -3237,7 +3408,6 @@ Bool_t AliReconstruction::InitPlaneEff() {
  //  Input: none
  //  Return: kTRUE if all operations have been done properly, kFALSE otherwise
  //
- AliWarning(Form("Implementation of this method not yet completed !! Method return kTRUE"));
 
   fSPDTrackleter = NULL;
   TString detStr = fLoadCDB;
@@ -3285,7 +3455,7 @@ void AliReconstruction::RunAliEVE()
   // successful initialization of AliEVE.
 
   AliInfo("Running AliEVE...");
-  gROOT->ProcessLine(Form("AliEveEventManager::GetMaster()->SetEvent((AliRunLoader*)0x%lx,(AliRawReader*)0x%lx,(AliESDEvent*)0x%lx,(AliESDfriend*)0x%lx);",fRunLoader,fRawReader,fesd,fesdf));
+  gROOT->ProcessLine(Form("AliEveEventManager::GetMaster()->SetEvent((AliRunLoader*)0x%p,(AliRawReader*)0x%p,(AliESDEvent*)0x%p,(AliESDfriend*)0x%p);",fRunLoader,fRawReader,fesd,fesdf));
   gSystem->Run();
 }
 
@@ -3485,7 +3655,7 @@ Bool_t AliReconstruction::GetEventInfo()
   Int_t nclasses = classesArray.GetEntriesFast();
   for( Int_t iclass=0; iclass < nclasses; iclass++ ) {
     AliTriggerClass* trclass = (AliTriggerClass*)classesArray.At(iclass);
-    if (trclass) {
+    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);
@@ -3504,7 +3674,7 @@ Bool_t AliReconstruction::GetEventInfo()
   Int_t ninputs = inputsArray.GetEntriesFast();
   for( Int_t iinput=0; iinput < ninputs; iinput++ ) {
     AliTriggerInput* trginput = (AliTriggerInput*)inputsArray.At(iinput);
-    if (trginput) {
+    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();