]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliESDInputHandlerRP.cxx
Added new cuts, fixed bug in backround calculation.
[u/mrichter/AliRoot.git] / STEER / AliESDInputHandlerRP.cxx
index c75c122a474675fb00ee22975cd33fb0c1d1cc75..7fb0693bcfc0e62142ea21ac3028f881c1ba2109 100644 (file)
@@ -42,6 +42,7 @@ ClassImp(AliESDInputHandlerRP)
 AliESDInputHandlerRP::AliESDInputHandlerRP() :
     AliESDInputHandler(),
     fRTrees(   new TObjArray()),
+    fRDirs (   new TObjArray()),
     fRFiles(   new TList()),
     fDetectors(new TList()),
     fDirR(0),
@@ -60,6 +61,7 @@ AliESDInputHandlerRP::AliESDInputHandlerRP() :
 AliESDInputHandlerRP::AliESDInputHandlerRP(const char* name, const char* title):
     AliESDInputHandler(name, title),
     fRTrees(   new TObjArray()),
+    fRDirs (   new TObjArray()),
     fRFiles(   new TList()),
     fDetectors(new TList()),
     fDirR(0),
@@ -96,14 +98,18 @@ Bool_t AliESDInputHandlerRP::Init(Option_t* opt)
        } else {
            file = TFile::Open(Form("%s#%s.RecPoints.root", fPathName->Data(), det->GetName()));
        }
-       if (!file) AliFatal(Form("AliESDInputHandlerRP: %s.RecPoints.root not found in %s ! \n", det->GetName(), fPathName->Data()));
+       if (!file) {
+         AliError(Form("AliESDInputHandlerRP: %s.RecPoints.root not found in %s ! \n", det->GetName(), fPathName->Data()));
+         return kFALSE;
+       }
        fRFiles->Add(file);
     }
 
     if (file) {
        fEventsPerFile = file->GetNkeys() - file->GetNProcessIDs();
     } else {
-       AliFatal(Form("AliESDInputHandlerRP: No file with RecPoints found in %s ! \n", fPathName->Data()));
+       AliError(Form("AliESDInputHandlerRP: No file with RecPoints found in %s ! \n", fPathName->Data()));
+       return kFALSE;
     }
     
 
@@ -143,6 +149,7 @@ Bool_t AliESDInputHandlerRP::LoadEvent(Int_t iev)
     // Load the event number iev
     //
     // Calculate the file number
+  if (fEventsPerFile<=0) return kFALSE;
     Int_t inew  = iev / fEventsPerFile;
     if (inew != fFileNumber) {
        fFileNumber = inew;
@@ -156,18 +163,20 @@ Bool_t AliESDInputHandlerRP::LoadEvent(Int_t iev)
     // Tree R
     TIter next(fRFiles);
     TFile* file;
-    Int_t idx = 0;
+    Int_t idx  = 0;
     
     while ((file = (TFile*) next()))
     {
        file->GetObject(folder, fDirR);
+       
        if (!fDirR) {
            AliWarning(Form("AliESDInputHandlerRP: Event #%5d not found\n", iev));
            return kFALSE;
        }
        TTree* tree = 0;
        fDirR->GetObject("TreeR", tree);
-       fRTrees->AddAt(tree, idx++);
+       fRDirs ->AddAt(fDirR, idx  );
+       fRTrees->AddAt(tree,  idx++);
     }
     return kTRUE;
 }
@@ -229,6 +238,7 @@ Bool_t AliESDInputHandlerRP::Notify(const char *path)
       TFile* file = TFile::Open(fPathName->Data());
       TArchiveFile* arch = file->GetArchive();
       members = arch->GetMembers();
+      fPathName->ReplaceAll("#AliESDs.root", "");
     } else {
        // Directory or alien archive
       if (fileName.BeginsWith("alien:")) {
@@ -274,15 +284,17 @@ Bool_t AliESDInputHandlerRP::Notify(const char *path)
     ResetIO();
     InitIO("");
     // Some clean-up
-    members->Delete();
+    if (members) members->Delete();
 
+    AliESDInputHandler::Notify(path);
+    
     return kTRUE;
 }
 
 Bool_t AliESDInputHandlerRP::FinishEvent()
 {
     // Clean-up after each event
-    delete fDirR;  fDirR = 0;
+    fRDirs->Delete();
     AliESDInputHandler::FinishEvent();
     return kTRUE;
 }