]>
Commit | Line | Data |
---|---|---|
6a45d03f | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | /* $Id: AliPIDResponseInputHandler 46193 2010-12-21 09:00:14Z wiechula $ */ | |
17 | ||
18 | //----------------------------------------------------------------- | |
19 | // Handler to set up the PID response object and | |
20 | // initialise it correctly for each event | |
21 | // | |
22 | // Origin: | |
23 | // Jens Wiechula (jens.wiechula@cern.ch) | |
24 | // Martin Vala (martin.vala@cern.ch) | |
25 | ||
26 | //----------------------------------------------------------------- | |
27 | ||
28 | ||
29 | #include <TFile.h> | |
30 | #include <TPRegexp.h> | |
31 | ||
32 | #include <AliLog.h> | |
33 | #include <AliVEvent.h> | |
34 | #include "AliAnalysisManager.h" | |
35 | #include "AliMultiInputEventHandler.h" | |
36 | #include "AliPIDResponse.h" | |
37 | ||
38 | #include "AliPIDResponseInputHandler.h" | |
39 | ||
40 | ||
41 | ClassImp(AliPIDResponseInputHandler) | |
42 | ||
43 | //_____________________________________________________________________________ | |
44 | AliPIDResponseInputHandler::AliPIDResponseInputHandler(const char *name) : | |
45 | AliInputEventHandler(name, name), | |
46 | fIsMC(kFALSE), | |
47 | fPIDResponse(0x0), | |
48 | fRun(0), | |
49 | fOldRun(0), | |
50 | fRecoPass(0), | |
51 | fMCurrentMutliIH(0) | |
52 | { | |
53 | // | |
54 | // Default constructor. | |
55 | // | |
56 | AliDebug(AliLog::kDebug + 10, "<-"); | |
57 | AliDebug(AliLog::kDebug + 10, "->"); | |
58 | } | |
59 | ||
60 | //_____________________________________________________________________________ | |
61 | AliPIDResponseInputHandler::~AliPIDResponseInputHandler() | |
62 | { | |
63 | // | |
64 | // Destructor | |
65 | // | |
66 | AliDebug(AliLog::kDebug + 10, "<-"); | |
67 | // delete fArrPidResponseMaster; | |
68 | AliDebug(AliLog::kDebug + 10, "->"); | |
69 | } | |
70 | ||
71 | //_____________________________________________________________________________ | |
72 | Bool_t AliPIDResponseInputHandler::Init(Option_t *opt) | |
73 | { | |
74 | // | |
75 | // Init() is called for all mix input handlers. | |
76 | // | |
77 | AliDebug(AliLog::kDebug + 5, Form("<- opt=%s", opt)); | |
78 | ||
79 | AliDebug(AliLog::kDebug + 5, Form("->")); | |
80 | return kTRUE; | |
81 | } | |
82 | //_____________________________________________________________________________ | |
83 | Bool_t AliPIDResponseInputHandler::Init(TTree *tree, Option_t *opt) | |
84 | { | |
85 | // | |
86 | // Init(const char*path) is called for all mix input handlers. | |
87 | // Create event pool if needed | |
88 | // | |
89 | AliDebug(AliLog::kDebug + 5, Form("<- %p %s opt=%s", (void *) tree, tree->GetName(), opt)); | |
90 | ||
91 | if (fParentHandler) { | |
92 | TString tmp = ""; | |
93 | AliInputEventHandler *ih = 0; | |
94 | fMCurrentMutliIH = dynamic_cast<AliMultiInputEventHandler*>(fParentHandler); | |
95 | if (fMCurrentMutliIH) { | |
96 | ih = fMCurrentMutliIH->GetFirstInputEventHandler(); | |
97 | if (ih) { | |
98 | //pid response object | |
99 | ih->CreatePIDResponse(fIsMC); | |
100 | fPIDResponse = ih->GetPIDResponse(); | |
101 | if (!fPIDResponse) AliFatal("PIDResponse object was not created"); | |
102 | } | |
103 | } | |
104 | } | |
105 | ||
106 | AliDebug(AliLog::kDebug + 5, Form("->")); | |
107 | return kTRUE; | |
108 | } | |
109 | //_____________________________________________________________________________ | |
110 | Bool_t AliPIDResponseInputHandler::Notify() | |
111 | { | |
112 | // | |
113 | // Notify() is called for all mix input handlers | |
114 | // | |
115 | AliDebug(AliLog::kDebug + 5, Form("<-")); | |
116 | AliDebug(AliLog::kDebug + 5, Form("->")); | |
117 | return kTRUE; | |
118 | } | |
119 | ||
120 | //_____________________________________________________________________________ | |
121 | Bool_t AliPIDResponseInputHandler::Notify(const char *path) | |
122 | { | |
123 | // | |
124 | // Notify(const char*path) is called for all mix input handlers | |
125 | // | |
126 | AliDebug(AliLog::kDebug + 5, Form("<- %s", path)); | |
127 | AliDebug(AliLog::kDebug + 5, "->"); | |
128 | return kTRUE; | |
129 | } | |
130 | //_____________________________________________________________________________ | |
131 | Bool_t AliPIDResponseInputHandler::BeginEvent(Long64_t entry) | |
132 | { | |
133 | // | |
134 | // BeginEvent(Long64_t entry) is called for all mix input handlers | |
135 | // | |
136 | AliDebug(AliLog::kDebug + 5, Form("<- %lld", entry)); | |
137 | ||
138 | if (fParentHandler) { | |
139 | TString tmp = ""; | |
140 | AliInputEventHandler *ih = 0; | |
141 | fMCurrentMutliIH = dynamic_cast<AliMultiInputEventHandler*>(fParentHandler); | |
142 | if (fMCurrentMutliIH) { | |
143 | ih = fMCurrentMutliIH->GetFirstInputEventHandler(); | |
144 | if (ih) { | |
145 | //pid response object | |
146 | ih->CreatePIDResponse(fIsMC); | |
147 | fPIDResponse = ih->GetPIDResponse(); | |
148 | if (!fPIDResponse) AliFatal("PIDResponse object was not created"); | |
149 | ||
150 | AliVEvent *event = ih->GetEvent(); | |
151 | if (!event) return kFALSE; | |
152 | fRun = event->GetRunNumber(); | |
153 | ||
154 | if (fRun != fOldRun) { | |
155 | SetRecoInfo(); | |
156 | fOldRun = fRun; | |
157 | } | |
158 | fPIDResponse->SetOADBPath(AliAnalysisManager::GetOADBPath()); | |
159 | fPIDResponse->InitialiseEvent(event,fRecoPass); | |
160 | } | |
161 | } | |
162 | } | |
163 | AliDebug(AliLog::kDebug + 5, "->"); | |
164 | return kTRUE; | |
165 | } | |
166 | ||
167 | //_____________________________________________________________________________ | |
168 | Bool_t AliPIDResponseInputHandler::GetEntry() | |
169 | { | |
170 | AliDebug(AliLog::kDebug + 5, "<-"); | |
171 | AliDebug(AliLog::kDebug + 5, "->"); | |
172 | return kTRUE; | |
173 | } | |
174 | ||
175 | //_____________________________________________________________________________ | |
176 | Bool_t AliPIDResponseInputHandler::FinishEvent() | |
177 | { | |
178 | // | |
179 | // FinishEvent() is called for all mix input handlers | |
180 | // | |
181 | AliDebug(AliLog::kDebug + 5, Form("<-")); | |
182 | AliDebug(AliLog::kDebug + 5, Form("->")); | |
183 | return kTRUE; | |
184 | } | |
185 | ||
186 | //_____________________________________________________________________________ | |
187 | void AliPIDResponseInputHandler::SetRecoInfo() | |
188 | { | |
189 | // | |
190 | // Set reconstruction information | |
191 | // | |
192 | ||
193 | //reset information | |
194 | fRecoPass=0; | |
195 | ||
196 | //Get the current file to check the reconstruction pass (UGLY, but not stored in ESD... ) | |
197 | // AliAnalysisManager *mgr=AliAnalysisManager::GetAnalysisManager(); | |
198 | AliVEventHandler *inputHandler=fMCurrentMutliIH->GetFirstInputEventHandler(); | |
199 | if (!inputHandler) return; | |
200 | ||
201 | TTree *tree= (TTree*)inputHandler->GetTree(); | |
202 | TFile *file= (TFile*)tree->GetCurrentFile(); | |
203 | ||
204 | if (!file) { | |
205 | AliError("Current file not found, cannot set reconstruction information"); | |
206 | return; | |
207 | } | |
208 | ||
209 | //find pass from file name (UGLY, but not stored in ESD... ) | |
210 | TString fileName(file->GetName()); | |
efca0660 | 211 | if (fileName.Contains("/pass1") || fileName.Contains(".pass1")) { |
6a45d03f | 212 | fRecoPass=1; |
efca0660 | 213 | } else if (fileName.Contains("/pass2") || fileName.Contains(".pass2")) { |
6a45d03f | 214 | fRecoPass=2; |
efca0660 | 215 | } else if (fileName.Contains("/pass3") || fileName.Contains(".pass3")) { |
6a45d03f | 216 | fRecoPass=3; |
217 | } | |
ab4db4eb | 218 | |
219 | fPIDResponse->SetCurrentFile(fileName.Data()); | |
6a45d03f | 220 | } |