]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliAODInputHandler.cxx
fix
[u/mrichter/AliRoot.git] / STEER / AliAODInputHandler.cxx
CommitLineData
397596ed 1/**************************************************************************
2 * Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16/* $Id$ */
17
18//-------------------------------------------------------------------------
19// Event handler for AOD input
20// Author: Andreas Morsch, CERN
21//-------------------------------------------------------------------------
22
933fd60f 23#include <TTree.h>
26772015 24#include <TList.h>
25#include <TNamed.h>
397596ed 26
27#include "AliAODInputHandler.h"
28#include "AliAODEvent.h"
29
30ClassImp(AliAODInputHandler)
31
c2b6979d 32static Option_t *gAODDataType = "AOD";
33
397596ed 34//______________________________________________________________________________
35AliAODInputHandler::AliAODInputHandler() :
90e04a88 36 AliInputEventHandler(),
4195c9c9 37 fEvent(0),
26772015 38 fFriends(new TList())
397596ed 39{
26772015 40 // Default constructor
397596ed 41}
42
43//______________________________________________________________________________
26772015 44AliAODInputHandler::AliAODInputHandler(const char* name, const char* title):
45 AliInputEventHandler(name, title),
46 fEvent(0),
47 fFriends(new TList())
397596ed 48{
26772015 49 // Constructor
397596ed 50}
51
52//______________________________________________________________________________
26772015 53AliAODInputHandler::~AliAODInputHandler()
397596ed 54{
26772015 55// Destructor
56 fFriends->Delete();
397596ed 57}
58
26772015 59
300d5701 60Bool_t AliAODInputHandler::Init(TTree* tree, Option_t* /*opt*/)
397596ed 61{
300d5701 62 // Initialisation necessary for each new tree
63 fTree = tree;
26772015 64 TIter next(fFriends);
65 TNamed* obj;
ced57103 66
8ac4fa64 67 while((obj = (TNamed*)next())) {
ced57103 68 if (fTree->GetTree()) {
69 (fTree->GetTree())->AddFriend("aodTree", obj->GetName());
70 } else {
71 fTree->AddFriend("aodTree", obj->GetName());
72 }
4195c9c9 73 }
74
300d5701 75 if (!fTree) return kFALSE;
397596ed 76 // Get pointer to AOD event
300d5701 77 if (fEvent) {
78 delete fEvent;
79 fEvent = 0;
80 }
397596ed 81 fEvent = new AliAODEvent();
300d5701 82
933fd60f 83 fEvent->ReadFromTree(fTree);
397596ed 84 return kTRUE;
85}
86
fbb264e0 87Bool_t AliAODInputHandler::BeginEvent(Long64_t /*entry*/)
88{
89 //
b11170c6 90 //if (fTree) fTree->BranchRef();
fbb264e0 91 return kTRUE;
92}
93
26772015 94void AliAODInputHandler::AddFriend(char* filename)
95{
96 // Add a friend tree
97 TNamed* obj = new TNamed(filename, filename);
98 fFriends->Add(obj);
99}
c2b6979d 100
101Option_t *AliAODInputHandler::GetDataType() const
102{
103// Returns handled data type.
104 return gAODDataType;
105}