]>
Commit | Line | Data |
---|---|---|
379713ad | 1 | // |
2 | // Class AliMultiInputEventHandler | |
3 | // | |
4 | // Multi input event handler | |
5 | // TODO example | |
6 | // author: | |
7 | // Martin Vala (martin.vala@cern.ch) | |
8 | // | |
9 | ||
10 | #include "AliLog.h" | |
11 | #include "AliMCEventHandler.h" | |
12 | ||
13 | #include "AliMultiInputEventHandler.h" | |
14 | ||
15 | ClassImp(AliMultiInputEventHandler) | |
16 | ||
17 | static Option_t *gCurrentMultiDataType = "ESD"; | |
18 | ||
19 | //_____________________________________________________________________________ | |
20 | AliMultiInputEventHandler::AliMultiInputEventHandler(const Int_t size, const char *name) : | |
21 | AliInputEventHandler(name, name), | |
22 | fBufferSize(size), | |
23 | fInputHandlers(), | |
24 | fAnalysisType(0) | |
25 | { | |
26 | // | |
27 | // Default constructor. | |
28 | // | |
29 | AliDebug(AliLog::kDebug + 10, "<-"); | |
30 | fInputHandlers.SetOwner(kTRUE); | |
31 | AliDebug(AliLog::kDebug + 10, "->"); | |
32 | } | |
33 | ||
34 | //_____________________________________________________________________________ | |
35 | AliMultiInputEventHandler::~AliMultiInputEventHandler() | |
36 | { | |
37 | // | |
38 | // Destructor | |
39 | // | |
40 | AliDebug(AliLog::kDebug + 10, "<-"); | |
41 | AliDebug(AliLog::kDebug + 10, "->"); | |
42 | } | |
43 | ||
44 | ||
45 | //_____________________________________________________________________________ | |
46 | AliVEventHandler *AliMultiInputEventHandler::InputEventHandler(const Int_t index) | |
47 | { | |
48 | // | |
49 | // Returns input handler | |
50 | // | |
51 | AliDebug(AliLog::kDebug + 5, Form("<-")); | |
52 | if ((index >= 0) && (index < fBufferSize)) { | |
53 | return (AliVEventHandler *) fInputHandlers.At(index); | |
54 | } | |
55 | AliDebug(AliLog::kDebug + 5, Form("->")); | |
56 | return 0; | |
57 | } | |
58 | ||
59 | //_____________________________________________________________________________ | |
60 | void AliMultiInputEventHandler::AddInputEventHandler(AliVEventHandler*inHandler) | |
61 | { | |
62 | // | |
63 | // Create N (fBufferSize) copies of input handler | |
64 | // | |
65 | if (inHandler->InheritsFrom("AliESDInputHandler")) gCurrentMultiDataType = "ESD"; | |
66 | if (inHandler->InheritsFrom("AliAODInputHandler")) gCurrentMultiDataType = "AOD"; | |
67 | AliDebug(AliLog::kDebug + 5, Form("<-")); | |
68 | AliDebug(AliLog::kDebug + 5, Form("Creating %d input event handlers ...", fBufferSize)); | |
69 | AliDebug(AliLog::kDebug + 5, Form("Adding input handler with index %d ...", fBufferSize)); | |
70 | fInputHandlers.Add(inHandler); | |
71 | fBufferSize++; | |
72 | AliDebug(AliLog::kDebug + 5, Form("->")); | |
73 | } | |
74 | ||
75 | //_____________________________________________________________________________ | |
76 | Bool_t AliMultiInputEventHandler::Init(Option_t *opt) | |
77 | { | |
78 | // | |
79 | // Init() is called for all mix input handlers. | |
80 | // | |
81 | fAnalysisType = opt; | |
82 | AliDebug(AliLog::kDebug + 5, Form("<- \"%s\"", opt)); | |
83 | AliInputEventHandler *eh = 0; | |
84 | TObjArrayIter next(&fInputHandlers); | |
85 | while ((eh = (AliInputEventHandler *) next())) { | |
86 | eh->Init(fAnalysisType); | |
87 | } | |
88 | AliDebug(AliLog::kDebug + 5, Form("->")); | |
89 | return AliInputEventHandler::Init(opt); | |
90 | } | |
91 | //_____________________________________________________________________________ | |
92 | Bool_t AliMultiInputEventHandler::Init(TTree *tree, Option_t *opt) | |
93 | { | |
94 | // | |
95 | // Init(const char*path) is called for all mix input handlers. | |
96 | // Create event pool if needed | |
97 | // | |
98 | fAnalysisType = opt; | |
99 | AliDebug(AliLog::kDebug + 5, Form("<- %p %s", (void *) tree, tree->GetName())); | |
100 | if (!tree) { | |
101 | AliError(Form("-> tree is null")); | |
102 | return kFALSE; | |
103 | } | |
104 | AliInputEventHandler *eh = 0; | |
105 | TObjArrayIter next(&fInputHandlers); | |
106 | while ((eh = (AliInputEventHandler *) next())) { | |
107 | eh->Init(tree, fAnalysisType); | |
108 | } | |
109 | AliDebug(AliLog::kDebug + 5, Form("->")); | |
110 | return AliInputEventHandler::Init(tree, opt); | |
111 | } | |
112 | //_____________________________________________________________________________ | |
113 | Bool_t AliMultiInputEventHandler::Notify() | |
114 | { | |
115 | // | |
116 | // Notify() is called for all mix input handlers | |
117 | // | |
118 | AliDebug(AliLog::kDebug + 5, Form("<-")); | |
119 | AliInputEventHandler *eh = 0; | |
120 | TObjArrayIter next(&fInputHandlers); | |
121 | while ((eh = (AliInputEventHandler *) next())) { | |
122 | eh->Notify(); | |
123 | } | |
124 | AliDebug(AliLog::kDebug + 5, Form("->")); | |
125 | return AliInputEventHandler::Notify(); | |
126 | } | |
127 | ||
128 | //_____________________________________________________________________________ | |
129 | Bool_t AliMultiInputEventHandler::Notify(const char *path) | |
130 | { | |
131 | // | |
132 | // Notify(const char*path) is called for all mix input handlers | |
133 | // | |
134 | AliDebug(AliLog::kDebug + 5, Form("<- %s", path)); | |
135 | AliInputEventHandler *eh = 0; | |
136 | TObjArrayIter next(&fInputHandlers); | |
137 | while ((eh = (AliInputEventHandler *) next())) { | |
138 | eh->Notify(path); | |
139 | } | |
140 | AliDebug(AliLog::kDebug + 5, Form("->")); | |
141 | // return AliInputEventHandler::Notify(path); | |
142 | return AliInputEventHandler::Notify(path); | |
143 | } | |
144 | //_____________________________________________________________________________ | |
145 | Bool_t AliMultiInputEventHandler::BeginEvent(Long64_t entry) | |
146 | { | |
147 | // | |
148 | // BeginEvent(Long64_t entry) is called for all mix input handlers | |
149 | // | |
150 | AliDebug(AliLog::kDebug + 5, Form("<- %lld", entry)); | |
151 | AliInputEventHandler *eh = 0; | |
152 | TObjArrayIter next(&fInputHandlers); | |
153 | while ((eh = (AliInputEventHandler *) next())) { | |
154 | eh->BeginEvent(entry); | |
155 | } | |
156 | GetEntry(); | |
157 | AliDebug(AliLog::kDebug + 5, Form("->")); | |
158 | return AliInputEventHandler::BeginEvent(entry); | |
159 | } | |
160 | ||
161 | ||
162 | //_____________________________________________________________________________ | |
163 | Bool_t AliMultiInputEventHandler::GetEntry() | |
164 | { | |
165 | // | |
166 | // Sets correct events to every mix events | |
167 | // | |
168 | AliDebug(AliLog::kDebug + 5, Form("<-")); | |
169 | AliInputEventHandler *eh = 0; | |
170 | TObjArrayIter next(&fInputHandlers); | |
171 | while ((eh = (AliInputEventHandler *) next())) { | |
172 | eh->GetEntry(); | |
173 | } | |
174 | AliDebug(AliLog::kDebug + 5, Form("->")); | |
175 | return AliInputEventHandler::GetEntry(); | |
176 | } | |
177 | //_____________________________________________________________________________ | |
178 | Bool_t AliMultiInputEventHandler::FinishEvent() | |
179 | { | |
180 | // | |
181 | // FinishEvent() is called for all mix input handlers | |
182 | // | |
183 | AliDebug(AliLog::kDebug + 5, Form("<-")); | |
184 | AliInputEventHandler *eh = 0; | |
185 | TObjArrayIter next(&fInputHandlers); | |
186 | while ((eh = (AliInputEventHandler *) next())) { | |
187 | eh->FinishEvent(); | |
188 | } | |
189 | AliDebug(AliLog::kDebug + 5, Form("->")); | |
190 | return AliInputEventHandler::FinishEvent(); | |
191 | } | |
192 | ||
193 | AliInputEventHandler *AliMultiInputEventHandler::GetFirstInputEventHandler() | |
194 | { | |
195 | // | |
196 | // Return first InputEventHandler | |
197 | // | |
198 | AliDebug(AliLog::kDebug + 5, Form("<-")); | |
199 | AliVEventHandler *eh = 0; | |
200 | AliInputEventHandler *handler = 0; | |
201 | TObjArrayIter next(&fInputHandlers); | |
202 | while ((eh = (AliVEventHandler *) next())) { | |
203 | handler = dynamic_cast<AliInputEventHandler *>(eh); | |
204 | if (handler) return handler; | |
205 | } | |
206 | AliDebug(AliLog::kDebug + 5, Form("->")); | |
207 | return 0; | |
208 | } | |
209 | AliMCEventHandler *AliMultiInputEventHandler::GetFirstMCEventHandler() | |
210 | { | |
211 | // | |
212 | // Return first MCEventHandler | |
213 | // | |
214 | AliDebug(AliLog::kDebug + 5, Form("<-")); | |
215 | AliVEventHandler *eh = 0; | |
216 | AliMCEventHandler *handler = 0; | |
217 | TObjArrayIter next(&fInputHandlers); | |
218 | while ((eh = (AliVEventHandler *) next())) { | |
219 | handler = dynamic_cast<AliMCEventHandler *>(eh); | |
220 | if (handler) return handler; | |
221 | } | |
222 | AliDebug(AliLog::kDebug + 5, Form("->")); | |
223 | return 0; | |
224 | } | |
225 | ||
226 | AliMultiInputEventHandler *AliMultiInputEventHandler::GetFirstMultiInputHandler() | |
227 | { | |
228 | // | |
229 | // Return first MultiInputHandler | |
230 | // | |
231 | AliDebug(AliLog::kDebug + 5, Form("<-")); | |
232 | AliVEventHandler *eh = 0; | |
233 | AliMultiInputEventHandler *handler = 0; | |
234 | TObjArrayIter next(&fInputHandlers); | |
235 | while ((eh = (AliVEventHandler *) next())) { | |
236 | handler = dynamic_cast<AliMultiInputEventHandler *>(eh); | |
237 | if (handler) return handler; | |
238 | } | |
239 | AliDebug(AliLog::kDebug + 5, Form("->")); | |
240 | return 0; | |
241 | } | |
242 | ||
243 | //______________________________________________________________________________ | |
244 | Option_t *AliMultiInputEventHandler::GetDataType() const | |
245 | { | |
246 | // Returns handled data type. | |
247 | return gCurrentMultiDataType; | |
248 | } |