]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliAODInputHandler.cxx
Cast to AliMCParticle* needed with new implementation of AliMCEvent
[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>
fb0cfe69 26#include <TFile.h>
397596ed 27
28#include "AliAODInputHandler.h"
29#include "AliAODEvent.h"
30
31ClassImp(AliAODInputHandler)
32
c2b6979d 33static Option_t *gAODDataType = "AOD";
34
397596ed 35//______________________________________________________________________________
36AliAODInputHandler::AliAODInputHandler() :
90e04a88 37 AliInputEventHandler(),
4195c9c9 38 fEvent(0),
26772015 39 fFriends(new TList())
397596ed 40{
26772015 41 // Default constructor
397596ed 42}
43
44//______________________________________________________________________________
26772015 45AliAODInputHandler::AliAODInputHandler(const char* name, const char* title):
46 AliInputEventHandler(name, title),
47 fEvent(0),
48 fFriends(new TList())
397596ed 49{
26772015 50 // Constructor
397596ed 51}
52
53//______________________________________________________________________________
26772015 54AliAODInputHandler::~AliAODInputHandler()
397596ed 55{
26772015 56// Destructor
57 fFriends->Delete();
397596ed 58}
59
26772015 60
300d5701 61Bool_t AliAODInputHandler::Init(TTree* tree, Option_t* /*opt*/)
397596ed 62{
300d5701 63 // Initialisation necessary for each new tree
64 fTree = tree;
26772015 65 TIter next(fFriends);
66 TNamed* obj;
d329cad3 67
68 if (!fTree) return kFALSE;
d20b6757 69 fTree->GetEntry(0);
fb0cfe69 70 TString aodTreeFName,aodFriendTreeFName;
71
8ac4fa64 72 while((obj = (TNamed*)next())) {
ced57103 73 if (fTree->GetTree()) {
fb0cfe69 74 aodTreeFName = (fTree->GetTree()->GetCurrentFile())->GetName();
75 aodFriendTreeFName = aodTreeFName;
76 aodFriendTreeFName.ReplaceAll("AliAOD.root",obj->GetName());
77 aodFriendTreeFName.ReplaceAll("AliAODs.root",obj->GetName());
78 (fTree->GetTree())->AddFriend("aodTree", aodFriendTreeFName.Data());
ced57103 79 } else {
d20b6757 80 aodTreeFName = (fTree->GetCurrentFile())->GetName();
81 aodFriendTreeFName = aodTreeFName;
82 aodFriendTreeFName.ReplaceAll("AliAOD.root",obj->GetName());
83 aodFriendTreeFName.ReplaceAll("AliAODs.root",obj->GetName());
84 fTree->AddFriend("aodTree", aodFriendTreeFName.Data());
ced57103 85 }
4195c9c9 86 }
d329cad3 87
88
89 SwitchOffBranches();
90 SwitchOnBranches();
4195c9c9 91
397596ed 92 // Get pointer to AOD event
316cf4cc 93 if (!fEvent) fEvent = new AliAODEvent();
300d5701 94
933fd60f 95 fEvent->ReadFromTree(fTree);
397596ed 96 return kTRUE;
97}
98
fbb264e0 99Bool_t AliAODInputHandler::BeginEvent(Long64_t /*entry*/)
100{
101 //
b11170c6 102 //if (fTree) fTree->BranchRef();
fbb264e0 103 return kTRUE;
104}
105
26772015 106void AliAODInputHandler::AddFriend(char* filename)
107{
108 // Add a friend tree
109 TNamed* obj = new TNamed(filename, filename);
110 fFriends->Add(obj);
111}
c2b6979d 112
113Option_t *AliAODInputHandler::GetDataType() const
114{
115// Returns handled data type.
116 return gAODDataType;
117}