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