]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliAODInputHandler.cxx
Update of the tag system. 1. Correct implementation of the event ID - period, orbit...
[u/mrichter/AliRoot.git] / STEER / AliAODInputHandler.cxx
index 9f0d5f9bb3826af802acc271ed4485b7980bddfa..8859989e59e15a8b6b891b8f84b32293ae9ad325 100644 (file)
 //     Author: Andreas Morsch, CERN
 //-------------------------------------------------------------------------
 
-#include <TChain.h>
+#include <TTree.h>
+#include <TList.h>
+#include <TNamed.h>
 
 #include "AliAODInputHandler.h"
 #include "AliAODEvent.h"
 
 ClassImp(AliAODInputHandler)
 
+static Option_t *gAODDataType = "AOD";
+
 //______________________________________________________________________________
 AliAODInputHandler::AliAODInputHandler() :
-  AliInputEventHandler()
+    AliInputEventHandler(),
+    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(fChain);
+
+    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);
+}
+
+Option_t *AliAODInputHandler::GetDataType() const
+{
+// Returns handled data type.
+   return gAODDataType;
+}