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 // using mixing input hadnler from Base class
108 // for me fParentHandler would be better name
109 eh->SetParentHandler(this);
110 eh->Init(tree, fAnalysisType);
112 AliDebug(AliLog::kDebug + 5, Form("->"));
113 return AliInputEventHandler::Init(tree, opt);
115 //_____________________________________________________________________________
116 Bool_t AliMultiInputEventHandler::Notify()
119 // Notify() is called for all mix input handlers
121 AliDebug(AliLog::kDebug + 5, Form("<-"));
122 AliInputEventHandler *eh = 0;
123 TObjArrayIter next(&fInputHandlers);
124 while ((eh = (AliInputEventHandler *) next())) {
127 AliDebug(AliLog::kDebug + 5, Form("->"));
128 return AliInputEventHandler::Notify();
131 //_____________________________________________________________________________
132 Bool_t AliMultiInputEventHandler::Notify(const char *path)
135 // Notify(const char*path) is called for all mix input handlers
137 AliDebug(AliLog::kDebug + 5, Form("<- %s", path));
138 AliInputEventHandler *eh = 0;
139 TObjArrayIter next(&fInputHandlers);
140 while ((eh = (AliInputEventHandler *) next())) {
143 AliDebug(AliLog::kDebug + 5, Form("->"));
144 // return AliInputEventHandler::Notify(path);
145 return AliInputEventHandler::Notify(path);
147 //_____________________________________________________________________________
148 Bool_t AliMultiInputEventHandler::BeginEvent(Long64_t entry)
151 // BeginEvent(Long64_t entry) is called for all mix input handlers
153 AliDebug(AliLog::kDebug + 5, Form("<- %lld", entry));
154 AliInputEventHandler *eh = 0;
155 TObjArrayIter next(&fInputHandlers);
156 while ((eh = (AliInputEventHandler *) next())) {
157 eh->BeginEvent(entry);
160 AliDebug(AliLog::kDebug + 5, Form("->"));
161 return AliInputEventHandler::BeginEvent(entry);
165 //_____________________________________________________________________________
166 Bool_t AliMultiInputEventHandler::GetEntry()
169 // Sets correct events to every mix events
171 AliDebug(AliLog::kDebug + 5, Form("<-"));
172 AliInputEventHandler *eh = 0;
173 TObjArrayIter next(&fInputHandlers);
174 while ((eh = (AliInputEventHandler *) next())) {
177 AliDebug(AliLog::kDebug + 5, Form("->"));
178 return AliInputEventHandler::GetEntry();
180 //_____________________________________________________________________________
181 Bool_t AliMultiInputEventHandler::FinishEvent()
184 // FinishEvent() is called for all mix input handlers
186 AliDebug(AliLog::kDebug + 5, Form("<-"));
187 AliInputEventHandler *eh = 0;
188 TObjArrayIter next(&fInputHandlers);
189 while ((eh = (AliInputEventHandler *) next())) {
192 AliDebug(AliLog::kDebug + 5, Form("->"));
193 return AliInputEventHandler::FinishEvent();
196 AliInputEventHandler *AliMultiInputEventHandler::GetFirstInputEventHandler()
199 // Return first InputEventHandler
201 AliDebug(AliLog::kDebug + 5, Form("<-"));
202 AliVEventHandler *eh = 0;
203 AliInputEventHandler *handler = 0;
204 TObjArrayIter next(&fInputHandlers);
205 while ((eh = (AliVEventHandler *) next())) {
206 handler = dynamic_cast<AliInputEventHandler *>(eh);
207 if (handler) return handler;
209 AliDebug(AliLog::kDebug + 5, Form("->"));
212 AliMCEventHandler *AliMultiInputEventHandler::GetFirstMCEventHandler()
215 // Return first MCEventHandler
217 AliDebug(AliLog::kDebug + 5, Form("<-"));
218 AliVEventHandler *eh = 0;
219 AliMCEventHandler *handler = 0;
220 TObjArrayIter next(&fInputHandlers);
221 while ((eh = (AliVEventHandler *) next())) {
222 handler = dynamic_cast<AliMCEventHandler *>(eh);
223 if (handler) return handler;
225 AliDebug(AliLog::kDebug + 5, Form("->"));
229 AliMultiInputEventHandler *AliMultiInputEventHandler::GetFirstMultiInputHandler()
232 // Return first MultiInputHandler
234 AliDebug(AliLog::kDebug + 5, Form("<-"));
235 AliVEventHandler *eh = 0;
236 AliMultiInputEventHandler *handler = 0;
237 TObjArrayIter next(&fInputHandlers);
238 while ((eh = (AliVEventHandler *) next())) {
239 handler = dynamic_cast<AliMultiInputEventHandler *>(eh);
240 if (handler) return handler;
242 AliDebug(AliLog::kDebug + 5, Form("->"));
246 //______________________________________________________________________________
247 Option_t *AliMultiInputEventHandler::GetDataType() const
249 // Returns handled data type.
250 return gCurrentMultiDataType;
253 //______________________________________________________________________________
254 UInt_t AliMultiInputEventHandler::IsEventSelected()
256 // returns if event is selected
258 AliInputEventHandler *firstIH = dynamic_cast<AliInputEventHandler*> (GetFirstInputEventHandler());
260 return firstIH->IsEventSelected();
263 return fIsSelectedResult;
266 //______________________________________________________________________________
267 AliPIDResponse* AliMultiInputEventHandler::GetPIDResponse()
269 // retrieve PID response
271 AliInputEventHandler *firstIH = dynamic_cast<AliInputEventHandler*> (GetFirstInputEventHandler());
273 return firstIH->GetPIDResponse();
279 //______________________________________________________________________________
280 void AliMultiInputEventHandler::CreatePIDResponse(Bool_t isMC)
282 // create PID response
283 AliInputEventHandler *firstIH = dynamic_cast<AliInputEventHandler*> (GetFirstInputEventHandler());
285 firstIH->CreatePIDResponse(isMC);