]>
Commit | Line | Data |
---|---|---|
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 | ||
30 | ClassImp(AliAODInputHandler) | |
31 | ||
c2b6979d | 32 | static Option_t *gAODDataType = "AOD"; |
33 | ||
397596ed | 34 | //______________________________________________________________________________ |
35 | AliAODInputHandler::AliAODInputHandler() : | |
90e04a88 | 36 | AliInputEventHandler(), |
4195c9c9 | 37 | fEvent(0), |
26772015 | 38 | fFriends(new TList()) |
397596ed | 39 | { |
26772015 | 40 | // Default constructor |
397596ed | 41 | } |
42 | ||
43 | //______________________________________________________________________________ | |
26772015 | 44 | AliAODInputHandler::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 | 53 | AliAODInputHandler::~AliAODInputHandler() |
397596ed | 54 | { |
26772015 | 55 | // Destructor |
56 | fFriends->Delete(); | |
397596ed | 57 | } |
58 | ||
26772015 | 59 | |
300d5701 | 60 | Bool_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; | |
d329cad3 | 66 | |
67 | if (!fTree) return kFALSE; | |
68 | ||
8ac4fa64 | 69 | while((obj = (TNamed*)next())) { |
ced57103 | 70 | if (fTree->GetTree()) { |
71 | (fTree->GetTree())->AddFriend("aodTree", obj->GetName()); | |
72 | } else { | |
73 | fTree->AddFriend("aodTree", obj->GetName()); | |
74 | } | |
4195c9c9 | 75 | } |
d329cad3 | 76 | |
77 | ||
78 | SwitchOffBranches(); | |
79 | SwitchOnBranches(); | |
4195c9c9 | 80 | |
397596ed | 81 | // Get pointer to AOD event |
300d5701 | 82 | if (fEvent) { |
83 | delete fEvent; | |
84 | fEvent = 0; | |
85 | } | |
397596ed | 86 | fEvent = new AliAODEvent(); |
300d5701 | 87 | |
933fd60f | 88 | fEvent->ReadFromTree(fTree); |
397596ed | 89 | return kTRUE; |
90 | } | |
91 | ||
fbb264e0 | 92 | Bool_t AliAODInputHandler::BeginEvent(Long64_t /*entry*/) |
93 | { | |
94 | // | |
b11170c6 | 95 | //if (fTree) fTree->BranchRef(); |
fbb264e0 | 96 | return kTRUE; |
97 | } | |
98 | ||
26772015 | 99 | void AliAODInputHandler::AddFriend(char* filename) |
100 | { | |
101 | // Add a friend tree | |
102 | TNamed* obj = new TNamed(filename, filename); | |
103 | fFriends->Add(obj); | |
104 | } | |
c2b6979d | 105 | |
106 | Option_t *AliAODInputHandler::GetDataType() const | |
107 | { | |
108 | // Returns handled data type. | |
109 | return gAODDataType; | |
110 | } |