]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/ESD/AliESDInputHandler.cxx
Make friends available after the AliAnalysisManager::Init() phase
[u/mrichter/AliRoot.git] / STEER / ESD / AliESDInputHandler.cxx
index 73ff42ca05e946690288f74717f6092074a8de0f..864dbb5bf8f91beb8bad31091a8e58052a517a97 100644 (file)
@@ -100,9 +100,9 @@ Bool_t AliESDInputHandler::Init(TTree* tree,  Option_t* opt)
     if (!fEvent) fEvent = new AliESDEvent();
     fEvent->ReadFromTree(fTree);
     fNEvents = fTree->GetEntries();
+    if (fReadFriends) ConnectFriends();
 
     if (fMixingHandler) fMixingHandler->Init(tree,  opt);
-
     return kTRUE;
 }
 
@@ -155,26 +155,15 @@ void AliESDInputHandler::CheckSelectionMask()
    if (!fEventCuts || !IsUserCallSelectionMask()) return;
    fIsSelectedResult = fEventCuts->GetSelectionMask((AliESDEvent*)fEvent);
 }
-   
-//______________________________________________________________________________
-Bool_t  AliESDInputHandler::FinishEvent()
-{
-    // Finish the event 
-  if(fEvent)fEvent->Reset();
-  if (fMixingHandler) fMixingHandler->FinishEvent();
-  return kTRUE;
-} 
 
 //______________________________________________________________________________
-Bool_t AliESDInputHandler::Notify(const char* path)
+void AliESDInputHandler::ConnectFriends()
 {
-  // Notify a directory change
-  static Bool_t firsttime = kFALSE;
-  AliInfo(Form("Directory change %s \n", path));
+// Connect the friends tree as soon as available.
   //
   // Handle the friends first
   //
-  if (!fTree->FindBranch("ESDfriend.") && fReadFriends) {
+  if (!fTree->FindBranch("ESDfriend.")) {
     // Try to add ESDfriend. branch as friend
       TString esdFriendTreeFName;
       esdFriendTreeFName = (fTree->GetCurrentFile())->GetName();
@@ -192,7 +181,28 @@ Bool_t AliESDInputHandler::Notify(const char* path)
     cTree->SetBranchStatus("ESDfriend.", 1);
     fFriend = (AliESDfriend*)(fEvent->FindListObject("AliESDfriend"));
     if (fFriend) cTree->SetBranchAddress("ESDfriend.", &fFriend);
-  } 
+  }
+}
+
+//______________________________________________________________________________
+Bool_t  AliESDInputHandler::FinishEvent()
+{
+    // Finish the event 
+  if(fEvent)fEvent->Reset();
+  if (fMixingHandler) fMixingHandler->FinishEvent();
+  return kTRUE;
+} 
+
+//______________________________________________________________________________
+Bool_t AliESDInputHandler::Notify(const char* path)
+{
+  // Notify a directory change
+  static Bool_t firsttime = kFALSE;
+  AliInfo(Form("Directory change %s \n", path));
+  //
+  // Handle the friends first
+  //
+  if (fReadFriends) ConnectFriends();
   //
   //
   SwitchOffBranches();