]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGLF/RESONANCES/AliRsnInputHandler.cxx
Added protection against invalid objects for AOD analysis
[u/mrichter/AliRoot.git] / PWGLF / RESONANCES / AliRsnInputHandler.cxx
CommitLineData
b63357a0 1//
2// Class AliRsnInputHandler
3//
4// AliRsnInputHandler
5// TODO example
6// author:
7// Martin Vala (martin.vala@cern.ch)
8//
9
f34f960b 10#include <Riostream.h>
c865cb1d 11#include "AliLog.h"
12
13#include "AliRsnEvent.h"
14#include "AliMultiInputEventHandler.h"
15#include "AliMixInputEventHandler.h"
16#include "AliMCEventHandler.h"
17
b63357a0 18#include "AliRsnCutSet.h"
c865cb1d 19#include "AliRsnInputHandler.h"
20ClassImp(AliRsnInputHandler)
21
22//_____________________________________________________________________________
23AliRsnInputHandler::AliRsnInputHandler(const char *name) :
24 AliInputEventHandler(name, name),
25 fRsnEvent(0),
b63357a0 26 fRsnSelector(),
27 fRsnEventCuts(0)
28{
29//
30// Default constructor.
31//
32 AliDebug(AliLog::kDebug + 10, "<-");
33 AliDebug(AliLog::kDebug + 10, "->");
34}
35
36//_____________________________________________________________________________
37AliRsnInputHandler::AliRsnInputHandler(const AliRsnInputHandler &copy) :
38 AliInputEventHandler(),
39 fRsnEvent(0),
40 fRsnSelector(),
41 fRsnEventCuts(copy.fRsnEventCuts)
c865cb1d 42{
43//
44// Default constructor.
45//
46 AliDebug(AliLog::kDebug + 10, "<-");
47 AliDebug(AliLog::kDebug + 10, "->");
48}
49
b63357a0 50//_____________________________________________________________________________
61f275d1 51AliRsnInputHandler &AliRsnInputHandler::operator=(const AliRsnInputHandler &copy)
b63357a0 52{
53//
54// Default constructor.
55//
61f275d1 56 if (this == &copy)
57 return *this;
b63357a0 58 fRsnEventCuts = copy.fRsnEventCuts;
59 return *this;
60}
61
62
c865cb1d 63//_____________________________________________________________________________
64AliRsnInputHandler::~AliRsnInputHandler()
65{
66//
67// Destructor
68//
69 AliDebug(AliLog::kDebug + 10, "<-");
70 delete fRsnEvent;
71 AliDebug(AliLog::kDebug + 10, "->");
72}
73
74//_____________________________________________________________________________
75Bool_t AliRsnInputHandler::Init(Option_t *opt)
76{
77//
78// Init() is called for all mix input handlers.
79//
80 AliDebug(AliLog::kDebug + 5, Form("<- opt=%s", opt));
81
82 AliDebug(AliLog::kDebug + 5, Form("->"));
83 return kTRUE;
84}
85//_____________________________________________________________________________
86Bool_t AliRsnInputHandler::Init(TTree *tree, Option_t *opt)
87{
88//
89// Init(const char*path) is called for all mix input handlers.
90// Create event pool if needed
91//
92 AliDebug(AliLog::kDebug + 5, Form("<- %p %s opt=%s", (void *) tree, tree->GetName(), opt));
93 AliDebug(AliLog::kDebug + 5, Form("->"));
94 return kTRUE;
95}
96//_____________________________________________________________________________
97Bool_t AliRsnInputHandler::Notify()
98{
99//
100// Notify() is called for all mix input handlers
101//
102 AliDebug(AliLog::kDebug + 5, Form("<-"));
103 AliDebug(AliLog::kDebug + 5, Form("->"));
104 return kTRUE;
105}
106
107//_____________________________________________________________________________
108Bool_t AliRsnInputHandler::Notify(const char *path)
109{
110//
111// Notify(const char*path) is called for all mix input handlers
112//
113 AliDebug(AliLog::kDebug + 5, Form("<- %s", path));
114 AliDebug(AliLog::kDebug + 5, "->");
115 return kTRUE;
116}
117//_____________________________________________________________________________
118Bool_t AliRsnInputHandler::BeginEvent(Long64_t entry)
119{
120//
121// BeginEvent(Long64_t entry) is called for all mix input handlers
122//
123 AliDebug(AliLog::kDebug + 5, Form("<- %lld", entry));
124
125 if (fParentHandler) {
126 TString tmp = "";
127 AliInputEventHandler *ih = 0;
61f275d1 128 AliMultiInputEventHandler *multiIH = dynamic_cast<AliMultiInputEventHandler *>(fParentHandler);
c865cb1d 129 if (multiIH) {
130 ih = multiIH->GetFirstInputEventHandler();
131 if (ih) {
132 if (!fRsnEvent) fRsnEvent = new AliRsnEvent();
133 fRsnEvent->SetRef(ih->GetEvent());
134 fRsnEvent->SetPIDResponse(ih->GetPIDResponse());
135 if (fRsnEvent->GetRefESD()) {
136 AliMCEventHandler *mcH = multiIH->GetFirstMCEventHandler();
137 if (mcH) fRsnEvent->SetRefMC(mcH->MCEvent());
138 } else if (fRsnEvent->GetRefAOD()) {
f34f960b 139 AliAODEvent *aod = fRsnEvent->GetRefAOD();
61f275d1 140 TClonesArray *listAOD = (TClonesArray *)(aod->GetList()->FindObject(AliAODMCParticle::StdBranchName()));
f34f960b 141 if (listAOD) fRsnEvent->SetRefMC(fRsnEvent->GetRefAOD());
c865cb1d 142 }
143 if (fParentHandler->ParentHandler()) tmp = "MIX";
144 // applying pid cuts
145 //fRsnPIDManager.Reset();
146
147 //fRsnPIDManager.ApplyCuts(fRsnEvent);
148 fRsnSelector.Reset();
61f275d1 149
b63357a0 150 // reject event if needed
151 if (fRsnEventCuts) if (!fRsnEventCuts->IsSelected(fRsnEvent)) return kTRUE;
c865cb1d 152 fRsnSelector.ScanEvent(fRsnEvent);
b63dbf69 153 fRsnSelector.ExecActions(fRsnEvent);
c865cb1d 154 }
155 }
156 }
157 AliDebug(AliLog::kDebug + 5, "->");
158 return kTRUE;
159}
160
161Bool_t AliRsnInputHandler::GetEntry()
162{
163 AliDebug(AliLog::kDebug + 5, "<-");
164 AliDebug(AliLog::kDebug + 5, "->");
165 return kTRUE;
166}
167
168//_____________________________________________________________________________
169Bool_t AliRsnInputHandler::FinishEvent()
170{
171 //
172 // FinishEvent() is called for all mix input handlers
173 //
174 AliDebug(AliLog::kDebug + 5, Form("<-"));
175 AliDebug(AliLog::kDebug + 5, Form("->"));
176 return kTRUE;
177}