2 // Class AliMultiInputEventHandler
4 // Multi input event handler
7 // Martin Vala (martin.vala@cern.ch)
11 #include "AliMCEventHandler.h"
13 #include "AliMultiInputEventHandler.h"
15 ClassImp(AliMultiInputEventHandler)
17 static Option_t *gCurrentMultiDataType = "ESD";
19 //_____________________________________________________________________________
20 AliMultiInputEventHandler::AliMultiInputEventHandler(const Int_t size, const char *name) :
21 AliInputEventHandler(name, name),
27 // Default constructor.
29 AliDebug(AliLog::kDebug + 10, "<-");
30 fInputHandlers.SetOwner(kTRUE);
31 AliDebug(AliLog::kDebug + 10, "->");
34 //_____________________________________________________________________________
35 AliMultiInputEventHandler::~AliMultiInputEventHandler()
40 AliDebug(AliLog::kDebug + 10, "<-");
41 AliDebug(AliLog::kDebug + 10, "->");
45 //_____________________________________________________________________________
46 AliVEventHandler *AliMultiInputEventHandler::InputEventHandler(const Int_t index)
49 // Returns input handler
51 AliDebug(AliLog::kDebug + 5, Form("<-"));
52 if ((index >= 0) && (index < fBufferSize)) {
53 return (AliVEventHandler *) fInputHandlers.At(index);
55 AliDebug(AliLog::kDebug + 5, Form("->"));
59 //_____________________________________________________________________________
60 void AliMultiInputEventHandler::AddInputEventHandler(AliVEventHandler*inHandler)
63 // Create N (fBufferSize) copies of input handler
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);
72 AliDebug(AliLog::kDebug + 5, Form("->"));
75 //_____________________________________________________________________________
76 Bool_t AliMultiInputEventHandler::Init(Option_t *opt)
79 // Init() is called for all mix input handlers.
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);
88 AliDebug(AliLog::kDebug + 5, Form("->"));
89 return AliInputEventHandler::Init(opt);
91 //_____________________________________________________________________________
92 Bool_t AliMultiInputEventHandler::Init(TTree *tree, Option_t *opt)
95 // Init(const char*path) is called for all mix input handlers.
96 // Create event pool if needed
99 AliDebug(AliLog::kDebug + 5, Form("<- %p %s", (void *) tree, tree->GetName()));
101 AliError(Form("-> tree is null"));
104 AliInputEventHandler *eh = 0;
105 TObjArrayIter next(&fInputHandlers);
106 while ((eh = (AliInputEventHandler *) next())) {
107 eh->Init(tree, fAnalysisType);
109 AliDebug(AliLog::kDebug + 5, Form("->"));
110 return AliInputEventHandler::Init(tree, opt);
112 //_____________________________________________________________________________
113 Bool_t AliMultiInputEventHandler::Notify()
116 // Notify() is called for all mix input handlers
118 AliDebug(AliLog::kDebug + 5, Form("<-"));
119 AliInputEventHandler *eh = 0;
120 TObjArrayIter next(&fInputHandlers);
121 while ((eh = (AliInputEventHandler *) next())) {
124 AliDebug(AliLog::kDebug + 5, Form("->"));
125 return AliInputEventHandler::Notify();
128 //_____________________________________________________________________________
129 Bool_t AliMultiInputEventHandler::Notify(const char *path)
132 // Notify(const char*path) is called for all mix input handlers
134 AliDebug(AliLog::kDebug + 5, Form("<- %s", path));
135 AliInputEventHandler *eh = 0;
136 TObjArrayIter next(&fInputHandlers);
137 while ((eh = (AliInputEventHandler *) next())) {
140 AliDebug(AliLog::kDebug + 5, Form("->"));
141 // return AliInputEventHandler::Notify(path);
142 return AliInputEventHandler::Notify(path);
144 //_____________________________________________________________________________
145 Bool_t AliMultiInputEventHandler::BeginEvent(Long64_t entry)
148 // BeginEvent(Long64_t entry) is called for all mix input handlers
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);
157 AliDebug(AliLog::kDebug + 5, Form("->"));
158 return AliInputEventHandler::BeginEvent(entry);
162 //_____________________________________________________________________________
163 Bool_t AliMultiInputEventHandler::GetEntry()
166 // Sets correct events to every mix events
168 AliDebug(AliLog::kDebug + 5, Form("<-"));
169 AliInputEventHandler *eh = 0;
170 TObjArrayIter next(&fInputHandlers);
171 while ((eh = (AliInputEventHandler *) next())) {
174 AliDebug(AliLog::kDebug + 5, Form("->"));
175 return AliInputEventHandler::GetEntry();
177 //_____________________________________________________________________________
178 Bool_t AliMultiInputEventHandler::FinishEvent()
181 // FinishEvent() is called for all mix input handlers
183 AliDebug(AliLog::kDebug + 5, Form("<-"));
184 AliInputEventHandler *eh = 0;
185 TObjArrayIter next(&fInputHandlers);
186 while ((eh = (AliInputEventHandler *) next())) {
189 AliDebug(AliLog::kDebug + 5, Form("->"));
190 return AliInputEventHandler::FinishEvent();
193 AliInputEventHandler *AliMultiInputEventHandler::GetFirstInputEventHandler()
196 // Return first InputEventHandler
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;
206 AliDebug(AliLog::kDebug + 5, Form("->"));
209 AliMCEventHandler *AliMultiInputEventHandler::GetFirstMCEventHandler()
212 // Return first MCEventHandler
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;
222 AliDebug(AliLog::kDebug + 5, Form("->"));
226 AliMultiInputEventHandler *AliMultiInputEventHandler::GetFirstMultiInputHandler()
229 // Return first MultiInputHandler
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;
239 AliDebug(AliLog::kDebug + 5, Form("->"));
243 //______________________________________________________________________________
244 Option_t *AliMultiInputEventHandler::GetDataType() const
246 // Returns handled data type.
247 return gCurrentMultiDataType;