]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliMCEventHandler.cxx
Change according to Federico's suggestions (Massimo)
[u/mrichter/AliRoot.git] / STEER / AliMCEventHandler.cxx
index 64315321f2c8e37ed0e1968ccc7ba1a05a25529e..5a5db610d0ddf2f26f6adc1808c1093e796f9a0d 100644 (file)
@@ -79,7 +79,8 @@ AliMCEventHandler::AliMCEventHandler(const char* name, const char* title) :
     fPathName(new TString("./")),
     fExtension(""),
     fFileNumber(0),
-    fEventsPerFile(0)
+    fEventsPerFile(0),
+    fReadTR(kTRUE)
 {
     // Constructor
 }
@@ -92,14 +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;
     //
-    ResetIO();
-
     fFileE = TFile::Open(Form("%sgalice.root", fPathName->Data()));
     if (!fFileE) AliFatal(Form("AliMCEventHandler:galice.root not found in directory %s ! \n", fPathName->Data()));
 
@@ -124,7 +123,7 @@ Bool_t AliMCEventHandler::InitIO(Option_t* opt)
     // 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;
 }
@@ -207,7 +206,7 @@ Bool_t AliMCEventHandler::BeginEvent(Long64_t entry)
     }
 
     if (entry >= fNEvent) {
-       AliWarning(Form("AliMCEventHandler: Event number out of range %5d\n", entry));
+       AliWarning(Form("AliMCEventHandler: Event number out of range %5d %5d\n", entry,fNEvent));
        return kFALSE;
     }
     return GetEvent(entry);
@@ -234,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", "");
@@ -242,6 +244,9 @@ Bool_t AliMCEventHandler::Notify(const char *path)
     *fPathName = fileName;
     printf("AliMCEventHandler::Notify() Path: %s\n", fPathName->Data());
     
+    ResetIO();
+    InitIO("");
+
     return kTRUE;
 }
 
@@ -254,9 +259,10 @@ void AliMCEventHandler::ResetIO()
     delete fTreeE; fTreeE = 0;
 
 // Reset files
-    if (fFileE)  delete fFileE; fFileE = 0;
-    if (fFileK)  delete fFileK; fFileK = 0;
-    if (fFileTR) delete fFileTR; fFileTR = 0;
+    if (fFileE)  {delete fFileE;  fFileE  = 0;}
+    if (fFileK)  {delete fFileK;  fFileK  = 0;}
+    if (fFileTR) {delete fFileTR; fFileTR = 0;}
+    fExtension="";
 }
 
                            
@@ -282,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;