]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliMCEventHandler.cxx
New more general analysis implemention for particle identification and correlation...
[u/mrichter/AliRoot.git] / STEER / AliMCEventHandler.cxx
index c205cda6433b43d5a8ad8b54653bd5d4e805810f..5a5db610d0ddf2f26f6adc1808c1093e796f9a0d 100644 (file)
@@ -57,7 +57,8 @@ AliMCEventHandler::AliMCEventHandler() :
     fPathName(new TString("./")),
     fExtension(""),
     fFileNumber(0),
-    fEventsPerFile(0)
+    fEventsPerFile(0),
+    fReadTR(kTRUE)
 {
     // Default constructor
 }
@@ -78,7 +79,8 @@ AliMCEventHandler::AliMCEventHandler(const char* name, const char* title) :
     fPathName(new TString("./")),
     fExtension(""),
     fFileNumber(0),
-    fEventsPerFile(0)
+    fEventsPerFile(0),
+    fReadTR(kTRUE)
 {
     // Constructor
 }
@@ -91,10 +93,12 @@ AliMCEventHandler::~AliMCEventHandler()
     delete fFileTR;
 }
 
-Bool_t AliMCEventHandler::InitIO(Option_t* /*opt*/) 
+Bool_t AliMCEventHandler::Init(Option_t* opt)
 { 
     // Initialize input
     //
+    if (!(strcmp(opt, "proof")) || !(strcmp(opt, "local"))) return kTRUE;
+    //
     fFileE = TFile::Open(Form("%sgalice.root", fPathName->Data()));
     if (!fFileE) AliFatal(Form("AliMCEventHandler:galice.root not found in directory %s ! \n", fPathName->Data()));
 
@@ -111,13 +115,15 @@ Bool_t AliMCEventHandler::InitIO(Option_t* /*opt*/)
     fEventsPerFile = fFileK->GetNkeys() - fFileK->GetNProcessIDs();
     //
     // Tree TR
-    fFileTR = TFile::Open(Form("%sTrackRefs%s.root", fPathName->Data(), fExtension));
-    if (!fFileTR) AliWarning(Form("AliMCEventHandler:TrackRefs.root not found in directory %s ! \n", fPathName->Data()));
+    if (fReadTR) {
+      fFileTR = TFile::Open(Form("%sTrackRefs%s.root", fPathName->Data(), fExtension));
+      if (!fFileTR) AliWarning(Form("AliMCEventHandler:TrackRefs.root not found in directory %s ! \n", fPathName->Data()));
+    }
     //
     // Reset the event number
     fEvent      = -1;
     fFileNumber =  0;
-    
+    printf("AliMCEvenHandler::Init() %d\n",__LINE__);
     AliInfo(Form("AliMCEventHandler:Number of events in this directory %5d \n", fNEvent));
     return kTRUE;
 }
@@ -189,15 +195,21 @@ Bool_t AliMCEventHandler::OpenFile(Int_t i)
     return ok;
 }
 
-Bool_t AliMCEventHandler::BeginEvent()
+Bool_t AliMCEventHandler::BeginEvent(Long64_t entry)
 { 
     // Read the next event
-    fEvent++;
-    if (fEvent >= fNEvent) {
-       AliWarning(Form("AliMCEventHandler: Event number out of range %5d\n", fEvent));
+    if (entry == -1) {
+       fEvent++;
+       entry = fEvent;
+    } else {
+       fEvent = entry;
+    }
+
+    if (entry >= fNEvent) {
+       AliWarning(Form("AliMCEventHandler: Event number out of range %5d %5d\n", entry,fNEvent));
        return kFALSE;
     }
-    return GetEvent(fEvent);
+    return GetEvent(entry);
 }
 
 Int_t AliMCEventHandler::GetParticleAndTR(Int_t i, TParticle*& particle, TClonesArray*& trefs)
@@ -221,6 +233,9 @@ Bool_t AliMCEventHandler::Notify(const char *path)
     if(fileName.Contains("AliESDs.root")){
        fileName.ReplaceAll("AliESDs.root", "");
     }
+    else if(fileName.Contains("AliAOD.root")){
+       fileName.ReplaceAll("AliAOD.root", "");
+    }
     else if(fileName.Contains("galice.root")){
        // for running with galice and kinematics alone...
        fileName.ReplaceAll("galice.root", "");
@@ -231,21 +246,23 @@ Bool_t AliMCEventHandler::Notify(const char *path)
     
     ResetIO();
     InitIO("");
+
     return kTRUE;
 }
-    
+
 void AliMCEventHandler::ResetIO()
 {
 //  Clear header and stack
     fMCEvent->Clean();
     
-// Delete Tree E    
+// Delete Tree E
     delete fTreeE; fTreeE = 0;
-    
+
 // Reset files
-    if (fFileE)  delete fFileE;
-    if (fFileK)  delete fFileK;
-    if (fFileTR) delete fFileTR;
+    if (fFileE)  {delete fFileE;  fFileE  = 0;}
+    if (fFileK)  {delete fFileK;  fFileK  = 0;}
+    if (fFileTR) {delete fFileTR; fFileTR = 0;}
+    fExtension="";
 }
 
                            
@@ -271,7 +288,7 @@ Bool_t AliMCEventHandler::TerminateIO()
 }
     
 
-void AliMCEventHandler::SetInputPath(char* fname)
+void AliMCEventHandler::SetInputPath(const char* fname)
 {
     // Set the input path name
     delete fPathName;