]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliReconstruction.cxx
- Renaming fEventNumber (and the associated getters/setters) to
[u/mrichter/AliRoot.git] / STEER / AliReconstruction.cxx
index 441bd0d480659897a2ac4cbfc002b15bec6754a1..1c03396d3c38e4a63dde28e408170e19b6f9b3b4 100644 (file)
 // The index -1 (default) can be used for the last event to indicate no      //
 // upper limit of the event range.                                           //
 //                                                                           //
+// In case of raw-data reconstruction the user can modify the default        //
+// number of events per digits/clusters/tracks file. In case the option      //
+// is not used the number is set 1. In case the user provides 0, than        //
+// the number of events is equal to the number of events inside the          //
+// raw-data file (i.e. one digits/clusters/tracks file):                     //
+//                                                                           //
+//   rec.SetNumberOfEventsPerFile(...);                                      //
+//                                                                           //
+//                                                                           //
 // The name of the galice file can be changed from the default               //
 // "galice.root" by passing it as argument to the AliReconstruction          //
 // constructor or by                                                         //
 #include "AliTracker.h"
 #include "AliVertexer.h"
 #include "AliVertexerTracks.h"
+#include "AliV0vertexer.h"
+#include "AliCascadeVertexer.h"
 #include "AliHeader.h"
 #include "AliGenEventHeader.h"
 #include "AliPID.h"
@@ -152,7 +163,7 @@ ClassImp(AliReconstruction)
 
 
 //_____________________________________________________________________________
-const char* AliReconstruction::fgkDetectorName[AliReconstruction::fgkNDetectors] = {"ITS", "TPC", "TRD", "TOF", "PHOS", "RICH", "EMCAL", "MUON", "FMD", "ZDC", "PMD", "START", "VZERO", "CRT", "HLT"};
+const char* AliReconstruction::fgkDetectorName[AliReconstruction::fgkNDetectors] = {"ITS", "TPC", "TRD", "TOF", "PHOS", "HMPID", "EMCAL", "MUON", "FMD", "ZDC", "PMD", "T0", "VZERO", "ACORDE", "HLT"};
 
 //_____________________________________________________________________________
 AliReconstruction::AliReconstruction(const char* gAliceFilename, const char* cdbUri,
@@ -165,6 +176,7 @@ AliReconstruction::AliReconstruction(const char* gAliceFilename, const char* cdb
   fStopOnError(kFALSE),
   fWriteAlignmentData(kFALSE),
   fWriteESDfriend(kFALSE),
+  fWriteAOD(kFALSE),
   fFillTriggerESD(kTRUE),
 
   fRunLocalReconstruction("ALL"),
@@ -175,6 +187,7 @@ AliReconstruction::AliReconstruction(const char* gAliceFilename, const char* cdb
   fEquipIdMap(""),
   fFirstEvent(0),
   fLastEvent(-1),
+  fNumberOfEventsPerFile(1),
   fCheckPointLevel(0),
   fOptions(),
   fLoadAlignFromCDB(kTRUE),
@@ -210,6 +223,7 @@ AliReconstruction::AliReconstruction(const AliReconstruction& rec) :
   fStopOnError(rec.fStopOnError),
   fWriteAlignmentData(rec.fWriteAlignmentData),
   fWriteESDfriend(rec.fWriteESDfriend),
+  fWriteAOD(rec.fWriteAOD),
   fFillTriggerESD(rec.fFillTriggerESD),
 
   fRunLocalReconstruction(rec.fRunLocalReconstruction),
@@ -220,6 +234,7 @@ AliReconstruction::AliReconstruction(const AliReconstruction& rec) :
   fEquipIdMap(rec.fEquipIdMap),
   fFirstEvent(rec.fFirstEvent),
   fLastEvent(rec.fLastEvent),
+  fNumberOfEventsPerFile(rec.fNumberOfEventsPerFile),
   fCheckPointLevel(0),
   fOptions(),
   fLoadAlignFromCDB(rec.fLoadAlignFromCDB),
@@ -671,11 +686,11 @@ Bool_t AliReconstruction::Run(const char* input)
     AliInfo(Form("processing event %d", iEvent));
     fRunLoader->GetEvent(iEvent);
 
-    char fileName[256];
-    sprintf(fileName, "ESD_%d.%d_final.root", 
+    char aFileName[256];
+    sprintf(aFileName, "ESD_%d.%d_final.root", 
            fRunLoader->GetHeader()->GetRun(), 
            fRunLoader->GetHeader()->GetEventNrInRun());
-    if (!gSystem->AccessPathName(fileName)) continue;
+    if (!gSystem->AccessPathName(aFileName)) continue;
 
     // local reconstruction
     if (!fRunLocalReconstruction.IsNull()) {
@@ -687,8 +702,8 @@ Bool_t AliReconstruction::Run(const char* input)
     esd = new AliESD; hltesd = new AliESD;
     esd->SetRunNumber(fRunLoader->GetHeader()->GetRun());
     hltesd->SetRunNumber(fRunLoader->GetHeader()->GetRun());
-    esd->SetEventNumber(fRunLoader->GetHeader()->GetEventNrInRun());
-    hltesd->SetEventNumber(fRunLoader->GetHeader()->GetEventNrInRun());
+    esd->SetEventNumberInFile(fRunLoader->GetHeader()->GetEventNrInRun());
+    hltesd->SetEventNumberInFile(fRunLoader->GetHeader()->GetEventNrInRun());
 
     // Set magnetic field from the tracker
     esd->SetMagneticField(AliTracker::GetBz());
@@ -746,8 +761,32 @@ Bool_t AliReconstruction::Run(const char* input)
       }
     }
 
-    esd->SetPrimaryVertex(tVertexer.FindPrimaryVertex(esd));
+    //Try to improve the reconstructed primary vertex position using the tracks
+    AliESDVertex *pvtx=tVertexer.FindPrimaryVertex(esd);
+    if (pvtx)
+    if (pvtx->GetStatus()) {
+       // Store the improved primary vertex
+       esd->SetPrimaryVertex(pvtx);
+       // Propagate the tracks to the DCA to the improved primary vertex
+       Double_t somethingbig = 777.;
+       Double_t bz = esd->GetMagneticField();
+       Int_t nt=esd->GetNumberOfTracks();
+       while (nt--) {
+        AliESDtrack *t = esd->GetTrack(nt);
+         t->RelateToVertex(pvtx, bz, somethingbig);
+       } 
+    }
+
+    {
+    // V0 finding
+    AliV0vertexer vtxer;
+    vtxer.Tracks2V0vertices(esd);
 
+    // Cascade finding
+    AliCascadeVertexer cvtxer;
+    cvtxer.V0sTracks2CascadeVertices(esd);
+    }
     // write ESD
     if (fWriteESDfriend) {
        esdf=new AliESDfriend();
@@ -773,6 +812,10 @@ Bool_t AliReconstruction::Run(const char* input)
   tree->Write();
   hlttree->Write();
 
+  if (fWriteAOD) {
+    CreateAOD(file);
+  }
+
   // Create tags for the events in the ESD tree (the ESD tree is always present)
   // In case of empty events the tags will contain dummy values
   CreateTag(file);
@@ -1276,12 +1319,16 @@ Bool_t AliReconstruction::FillRawEventHeaderESD(AliESD*& esd)
   // 
 
   AliInfo("Filling information from RawReader Header");
+  esd->SetBunchCrossNumber(0);
+  esd->SetOrbitNumber(0);
   esd->SetTimeStamp(0);
   esd->SetEventType(0);
   const AliRawEventHeaderBase * eventHeader = fRawReader->GetEventHeader();
   if (eventHeader){
+    esd->SetBunchCrossNumber((eventHeader->GetP("Id")[0]));
+    esd->SetOrbitNumber((eventHeader->GetP("Id")[1]));
     esd->SetTimeStamp((eventHeader->Get("Timestamp")));  
-    esd->SetEventType((eventHeader->Get("Type")));  
+    esd->SetEventType((eventHeader->Get("Type")));
   }
 
   return kTRUE;
@@ -1384,6 +1431,10 @@ Bool_t AliReconstruction::InitRunLoader()
       iEvent++;
     }
     fRawReader->RewindEvents();
+    if (fNumberOfEventsPerFile > 0)
+      fRunLoader->SetNumberOfEventsPerFile(fNumberOfEventsPerFile);
+    else
+      fRunLoader->SetNumberOfEventsPerFile(iEvent);
     fRunLoader->WriteHeader("OVERWRITE");
     fRunLoader->CdGAFile();
     fRunLoader->Write(0, TObject::kOverwrite);
@@ -1408,10 +1459,10 @@ AliReconstructor* AliReconstruction::GetReconstructor(Int_t iDet)
 
   if (detName == "HLT") {
     if (!gROOT->GetClass("AliLevel3")) {
-      gSystem->Load("libAliL3Src.so");
-      gSystem->Load("libAliL3Misc.so");
-      gSystem->Load("libAliL3Hough.so");
-      gSystem->Load("libAliL3Comp.so");
+      gSystem->Load("libAliHLTSrc.so");
+      gSystem->Load("libAliHLTMisc.so");
+      gSystem->Load("libAliHLTHough.so");
+      gSystem->Load("libAliHLTComp.so");
     }
   }
 
@@ -1451,7 +1502,7 @@ AliReconstructor* AliReconstruction::GetReconstructor(Int_t iDet)
        ->CreateDetectorFolders(fRunLoader->GetEventFolder(), 
                                detName, detName);
       // first check if a plugin is defined for the loader
-      TPluginHandler* pluginHandler = 
+      pluginHandler = 
        pluginManager->FindHandler("AliLoader", detName);
       // if not, add a plugin for it
       if (!pluginHandler) {
@@ -1572,7 +1623,7 @@ Bool_t AliReconstruction::ReadESD(AliESD*& esd, const char* recStep) const
   if (!esd) return kFALSE;
   char fileName[256];
   sprintf(fileName, "ESD_%d.%d_%s.root", 
-         esd->GetRunNumber(), esd->GetEventNumber(), recStep);
+         esd->GetRunNumber(), esd->GetEventNumberInFile(), recStep);
   if (gSystem->AccessPathName(fileName)) return kFALSE;
 
   AliInfo(Form("reading ESD from file %s", fileName));
@@ -1600,7 +1651,7 @@ void AliReconstruction::WriteESD(AliESD* esd, const char* recStep) const
   if (!esd) return;
   char fileName[256];
   sprintf(fileName, "ESD_%d.%d_%s.root", 
-         esd->GetRunNumber(), esd->GetEventNumber(), recStep);
+         esd->GetRunNumber(), esd->GetEventNumberInFile(), recStep);
 
   AliDebug(1, Form("writing ESD to file %s", fileName));
   TFile* file = TFile::Open(fileName, "recreate");
@@ -1675,7 +1726,7 @@ void AliReconstruction::CreateTag(TFile* file)
   b->GetEntry(fFirstEvent);
   Int_t iInitRunNumber = esd->GetRunNumber();
   
-  Int_t iNumberOfEvents = b->GetEntries();
+  Int_t iNumberOfEvents = (Int_t)b->GetEntries();
   if(fLastEvent != -1) iNumberOfEvents = fLastEvent + 1;
   for (Int_t iEventNumber = fFirstEvent; iEventNumber < iNumberOfEvents; iEventNumber++) {
     ntrack = 0;
@@ -1881,7 +1932,7 @@ void AliReconstruction::CreateTag(TFile* file)
     tag->SetRunId(iInitRunNumber);
     tag->AddEventTag(*evTag);
   }
-  if(fLastEvent == -1) lastEvent = b->GetEntries();
+  if(fLastEvent == -1) lastEvent = (Int_t)b->GetEntries();
   else lastEvent = fLastEvent;
        
   ttag.Fill();
@@ -1902,6 +1953,15 @@ void AliReconstruction::CreateTag(TFile* file)
   delete evTag;
 }
 
+//_____________________________________________________________________________
+void AliReconstruction::CreateAOD(TFile* esdFile)
+{
+  // do nothing for now
+
+  return;
+}
+
+
 void AliReconstruction::WriteAlignmentData(AliESD* esd)
 {
   // Write space-points which are then used in the alignment procedures