Line data Source code
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 170 : ClassImp(AliMultiInputEventHandler)
16 :
17 : static Option_t *gCurrentMultiDataType = "ESD";
18 :
19 : //_____________________________________________________________________________
20 : AliMultiInputEventHandler::AliMultiInputEventHandler(const Int_t size, const char *name) :
21 0 : AliInputEventHandler(name, name),
22 0 : fBufferSize(size),
23 0 : fInputHandlers(),
24 0 : fAnalysisType(0)
25 0 : {
26 : //
27 : // Default constructor.
28 : //
29 0 : AliDebug(AliLog::kDebug + 10, "<-");
30 0 : fInputHandlers.SetOwner(kTRUE);
31 0 : AliDebug(AliLog::kDebug + 10, "->");
32 0 : }
33 :
34 : //_____________________________________________________________________________
35 : AliMultiInputEventHandler::~AliMultiInputEventHandler()
36 0 : {
37 : //
38 : // Destructor
39 : //
40 0 : AliDebug(AliLog::kDebug + 10, "<-");
41 0 : AliDebug(AliLog::kDebug + 10, "->");
42 0 : }
43 :
44 :
45 : //_____________________________________________________________________________
46 : AliVEventHandler *AliMultiInputEventHandler::InputEventHandler(const Int_t index)
47 : {
48 : //
49 : // Returns input handler
50 : //
51 0 : AliDebug(AliLog::kDebug + 5, Form("<-"));
52 0 : if ((index >= 0) && (index < fBufferSize)) {
53 0 : return (AliVEventHandler *) fInputHandlers.At(index);
54 : }
55 0 : AliDebug(AliLog::kDebug + 5, Form("->"));
56 0 : return 0;
57 0 : }
58 :
59 : //_____________________________________________________________________________
60 : void AliMultiInputEventHandler::AddInputEventHandler(AliVEventHandler*inHandler)
61 : {
62 : //
63 : // Create N (fBufferSize) copies of input handler
64 : //
65 0 : if (inHandler->InheritsFrom("AliESDInputHandler")) gCurrentMultiDataType = "ESD";
66 0 : if (inHandler->InheritsFrom("AliAODInputHandler")) gCurrentMultiDataType = "AOD";
67 0 : AliDebug(AliLog::kDebug + 5, Form("<-"));
68 0 : AliDebug(AliLog::kDebug + 5, Form("Creating %d input event handlers ...", fBufferSize));
69 0 : AliDebug(AliLog::kDebug + 5, Form("Adding input handler with index %d ...", fBufferSize));
70 0 : fInputHandlers.Add(inHandler);
71 0 : fBufferSize++;
72 0 : AliDebug(AliLog::kDebug + 5, Form("->"));
73 0 : }
74 :
75 : //_____________________________________________________________________________
76 : Bool_t AliMultiInputEventHandler::Init(Option_t *opt)
77 : {
78 : //
79 : // Init() is called for all mix input handlers.
80 : //
81 0 : fAnalysisType = opt;
82 0 : AliDebug(AliLog::kDebug + 5, Form("<- \"%s\"", opt));
83 : AliInputEventHandler *eh = 0;
84 0 : TObjArrayIter next(&fInputHandlers);
85 0 : while ((eh = (AliInputEventHandler *) next())) {
86 0 : eh->Init(fAnalysisType);
87 : }
88 0 : AliDebug(AliLog::kDebug + 5, Form("->"));
89 0 : return AliInputEventHandler::Init(opt);
90 0 : }
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 0 : fAnalysisType = opt;
99 0 : AliDebug(AliLog::kDebug + 5, Form("<- %p %s", (void *) tree, tree->GetName()));
100 0 : if (!tree) {
101 0 : AliError(Form("-> tree is null"));
102 0 : return kFALSE;
103 : }
104 : AliInputEventHandler *eh = 0;
105 0 : TObjArrayIter next(&fInputHandlers);
106 0 : while ((eh = (AliInputEventHandler *) next())) {
107 : // using mixing input hadnler from Base class
108 : // for me fParentHandler would be better name
109 0 : eh->SetParentHandler(this);
110 0 : eh->Init(tree, fAnalysisType);
111 : }
112 0 : AliDebug(AliLog::kDebug + 5, Form("->"));
113 0 : return AliInputEventHandler::Init(tree, opt);
114 0 : }
115 : //_____________________________________________________________________________
116 : Bool_t AliMultiInputEventHandler::Notify()
117 : {
118 : //
119 : // Notify() is called for all mix input handlers
120 : //
121 0 : AliDebug(AliLog::kDebug + 5, Form("<-"));
122 : AliInputEventHandler *eh = 0;
123 0 : TObjArrayIter next(&fInputHandlers);
124 0 : while ((eh = (AliInputEventHandler *) next())) {
125 0 : eh->Notify();
126 : }
127 0 : AliDebug(AliLog::kDebug + 5, Form("->"));
128 0 : return AliInputEventHandler::Notify();
129 0 : }
130 :
131 : //_____________________________________________________________________________
132 : Bool_t AliMultiInputEventHandler::Notify(const char *path)
133 : {
134 : //
135 : // Notify(const char*path) is called for all mix input handlers
136 : //
137 0 : AliDebug(AliLog::kDebug + 5, Form("<- %s", path));
138 : AliInputEventHandler *eh = 0;
139 0 : TObjArrayIter next(&fInputHandlers);
140 0 : while ((eh = (AliInputEventHandler *) next())) {
141 0 : eh->Notify(path);
142 : }
143 0 : AliDebug(AliLog::kDebug + 5, Form("->"));
144 : // return AliInputEventHandler::Notify(path);
145 0 : return AliInputEventHandler::Notify(path);
146 0 : }
147 : //_____________________________________________________________________________
148 : Bool_t AliMultiInputEventHandler::BeginEvent(Long64_t entry)
149 : {
150 : //
151 : // BeginEvent(Long64_t entry) is called for all mix input handlers
152 : //
153 0 : AliDebug(AliLog::kDebug + 5, Form("<- %lld", entry));
154 : AliInputEventHandler *eh = 0;
155 0 : TObjArrayIter next(&fInputHandlers);
156 0 : while ((eh = (AliInputEventHandler *) next())) {
157 0 : eh->BeginEvent(entry);
158 : }
159 0 : GetEntry();
160 0 : AliDebug(AliLog::kDebug + 5, Form("->"));
161 0 : return AliInputEventHandler::BeginEvent(entry);
162 0 : }
163 :
164 :
165 : //_____________________________________________________________________________
166 : Bool_t AliMultiInputEventHandler::GetEntry()
167 : {
168 : //
169 : // Sets correct events to every mix events
170 : //
171 0 : AliDebug(AliLog::kDebug + 5, Form("<-"));
172 : AliInputEventHandler *eh = 0;
173 0 : TObjArrayIter next(&fInputHandlers);
174 0 : while ((eh = (AliInputEventHandler *) next())) {
175 0 : eh->GetEntry();
176 : }
177 0 : AliDebug(AliLog::kDebug + 5, Form("->"));
178 0 : return AliInputEventHandler::GetEntry();
179 0 : }
180 : //_____________________________________________________________________________
181 : Bool_t AliMultiInputEventHandler::FinishEvent()
182 : {
183 : //
184 : // FinishEvent() is called for all mix input handlers
185 : //
186 0 : AliDebug(AliLog::kDebug + 5, Form("<-"));
187 : AliInputEventHandler *eh = 0;
188 0 : TObjArrayIter next(&fInputHandlers);
189 0 : while ((eh = (AliInputEventHandler *) next())) {
190 0 : eh->FinishEvent();
191 : }
192 0 : AliDebug(AliLog::kDebug + 5, Form("->"));
193 0 : return AliInputEventHandler::FinishEvent();
194 0 : }
195 :
196 : AliInputEventHandler *AliMultiInputEventHandler::GetFirstInputEventHandler()
197 : {
198 : //
199 : // Return first InputEventHandler
200 : //
201 0 : AliDebug(AliLog::kDebug + 5, Form("<-"));
202 : AliVEventHandler *eh = 0;
203 : AliInputEventHandler *handler = 0;
204 0 : TObjArrayIter next(&fInputHandlers);
205 0 : while ((eh = (AliVEventHandler *) next())) {
206 0 : handler = dynamic_cast<AliInputEventHandler *>(eh);
207 0 : if (handler) return handler;
208 : }
209 0 : AliDebug(AliLog::kDebug + 5, Form("->"));
210 0 : return 0;
211 0 : }
212 : AliMCEventHandler *AliMultiInputEventHandler::GetFirstMCEventHandler()
213 : {
214 : //
215 : // Return first MCEventHandler
216 : //
217 0 : AliDebug(AliLog::kDebug + 5, Form("<-"));
218 : AliVEventHandler *eh = 0;
219 : AliMCEventHandler *handler = 0;
220 0 : TObjArrayIter next(&fInputHandlers);
221 0 : while ((eh = (AliVEventHandler *) next())) {
222 0 : handler = dynamic_cast<AliMCEventHandler *>(eh);
223 0 : if (handler) return handler;
224 : }
225 0 : AliDebug(AliLog::kDebug + 5, Form("->"));
226 0 : return 0;
227 0 : }
228 :
229 : AliMultiInputEventHandler *AliMultiInputEventHandler::GetFirstMultiInputHandler()
230 : {
231 : //
232 : // Return first MultiInputHandler
233 : //
234 0 : AliDebug(AliLog::kDebug + 5, Form("<-"));
235 : AliVEventHandler *eh = 0;
236 : AliMultiInputEventHandler *handler = 0;
237 0 : TObjArrayIter next(&fInputHandlers);
238 0 : while ((eh = (AliVEventHandler *) next())) {
239 0 : handler = dynamic_cast<AliMultiInputEventHandler *>(eh);
240 0 : if (handler) return handler;
241 : }
242 0 : AliDebug(AliLog::kDebug + 5, Form("->"));
243 0 : return 0;
244 0 : }
245 :
246 : //______________________________________________________________________________
247 : Option_t *AliMultiInputEventHandler::GetDataType() const
248 : {
249 : // Returns handled data type.
250 0 : return gCurrentMultiDataType;
251 : }
252 :
253 : //______________________________________________________________________________
254 : UInt_t AliMultiInputEventHandler::IsEventSelected()
255 : {
256 : // returns if event is selected
257 :
258 0 : AliInputEventHandler *firstIH = dynamic_cast<AliInputEventHandler*> (GetFirstInputEventHandler());
259 0 : if (firstIH) {
260 0 : return firstIH->IsEventSelected();
261 : }
262 :
263 0 : return fIsSelectedResult;
264 0 : }
265 :
266 : //______________________________________________________________________________
267 : AliPIDResponse* AliMultiInputEventHandler::GetPIDResponse()
268 : {
269 : // retrieve PID response
270 :
271 0 : AliInputEventHandler *firstIH = dynamic_cast<AliInputEventHandler*> (GetFirstInputEventHandler());
272 0 : if (firstIH) {
273 0 : return firstIH->GetPIDResponse();
274 : }
275 :
276 0 : return 0x0;
277 0 : }
278 :
279 : //______________________________________________________________________________
280 : void AliMultiInputEventHandler::CreatePIDResponse(Bool_t isMC)
281 : {
282 : // create PID response
283 0 : AliInputEventHandler *firstIH = dynamic_cast<AliInputEventHandler*> (GetFirstInputEventHandler());
284 0 : if (firstIH) {
285 0 : firstIH->CreatePIDResponse(isMC);
286 0 : }
287 0 : }
|