]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliAODInputHandler.cxx
Additional protection: no update of V0 momentum without mag. field
[u/mrichter/AliRoot.git] / STEER / AliAODInputHandler.cxx
index 13f55237096cac9b81c29540a1075ee1a444d2b9..d1913032da0ff10fb5725e68679439a990cf8b00 100644 (file)
@@ -21,6 +21,8 @@
 //-------------------------------------------------------------------------
 
 #include <TTree.h>
+#include <TList.h>
+#include <TNamed.h>
 
 #include "AliAODInputHandler.h"
 #include "AliAODEvent.h"
@@ -30,28 +32,66 @@ ClassImp(AliAODInputHandler)
 //______________________________________________________________________________
 AliAODInputHandler::AliAODInputHandler() :
     AliInputEventHandler(),
-    fEvent(0)
+    fEvent(0),
+    fFriends(new TList())
 {
-  // default constructor
+  // Default constructor
 }
 
 //______________________________________________________________________________
-AliAODInputHandler::~AliAODInputHandler() 
+AliAODInputHandler::AliAODInputHandler(const char* name, const char* title):
+  AliInputEventHandler(name, title),
+  fEvent(0),
+  fFriends(new TList())
 {
-// destructor
+    // Constructor
 }
 
 //______________________________________________________________________________
-AliAODInputHandler::AliAODInputHandler(const char* name, const char* title):
-    AliInputEventHandler(name, title)
+AliAODInputHandler::~AliAODInputHandler() 
 {
+// Destructor
+    fFriends->Delete();
 }
 
-Bool_t AliAODInputHandler::InitIO(Option_t* /*opt*/)
+
+Bool_t AliAODInputHandler::Init(TTree* tree, Option_t* /*opt*/)
 {
+    // Initialisation necessary for each new tree
+    fTree = tree;
+    TIter next(fFriends);
+    TNamed* obj;
+    
+    while(obj = (TNamed*)next()) {
+       if (fTree->GetTree()) {
+           (fTree->GetTree())->AddFriend("aodTree", obj->GetName());
+       } else {
+           fTree->AddFriend("aodTree", obj->GetName());
+       }
+    }
+    
+    if (!fTree) return kFALSE;
     // Get pointer to AOD event
+    if (fEvent) {
+      delete fEvent;
+      fEvent = 0;
+    }
     fEvent = new AliAODEvent();
+
     fEvent->ReadFromTree(fTree);
     return kTRUE;
 }
 
+Bool_t AliAODInputHandler::BeginEvent(Long64_t /*entry*/)
+{
+    //
+    //if (fTree) fTree->BranchRef();
+    return kTRUE;
+}
+
+void AliAODInputHandler::AddFriend(char* filename)
+{
+    // Add a friend tree 
+    TNamed* obj = new TNamed(filename, filename);
+    fFriends->Add(obj);
+}