]>
Commit | Line | Data |
---|---|---|
d6f334b5 | 1 | // $Id$ |
2 | // | |
3 | // Hadronic correction task. | |
4 | // | |
1f6c8e39 | 5 | // Author: R.Reed, C.Loizides, S.Aiola |
d6f334b5 | 6 | |
7 | #include <TChain.h> | |
0b777a09 | 8 | #include <TClonesArray.h> |
35789a2d | 9 | #include <TH1F.h> |
10 | #include <TH2F.h> | |
d6f334b5 | 11 | #include <TList.h> |
bcf52e4a | 12 | |
3a385c49 | 13 | #include "AliAnalysisManager.h" |
d6f334b5 | 14 | #include "AliAODEvent.h" |
1f6c8e39 | 15 | #include "AliAODCaloCluster.h" |
d6f334b5 | 16 | #include "AliESDCaloCluster.h" |
1f6c8e39 | 17 | #include "AliVTrack.h" |
0b777a09 | 18 | #include "AliPicoTrack.h" |
35789a2d | 19 | #include "AliVEventHandler.h" |
1f6c8e39 | 20 | #include "AliEmcalParticle.h" |
1b4db73a | 21 | #include "AliEMCALGeometry.h" |
bcf52e4a | 22 | |
35789a2d | 23 | #include "AliHadCorrTask.h" |
0b777a09 | 24 | |
25 | ClassImp(AliHadCorrTask) | |
26 | ||
27 | //________________________________________________________________________ | |
d6f334b5 | 28 | AliHadCorrTask::AliHadCorrTask() : |
1f6c8e39 | 29 | AliAnalysisTaskEmcal("AliHadCorrTask", kFALSE), |
d6f334b5 | 30 | fOutCaloName(), |
a3f43e7e | 31 | fPhiMatch(0.05), |
32 | fEtaMatch(0.025), | |
32bf39af | 33 | fDoTrackClus(0), |
f22cb876 | 34 | fHadCorr(0), |
1f6c8e39 | 35 | fEexclCell(0), |
1b4db73a | 36 | fEsdMode(kTRUE), |
f22cb876 | 37 | fOutClusters(0), |
0b777a09 | 38 | fHistNclusvsCent(0), |
39 | fHistNclusMatchvsCent(0), | |
f22cb876 | 40 | fHistEbefore(0), |
4711c521 | 41 | fHistEafter(0), |
42 | fHistEoPCent(0), | |
32bf39af | 43 | fHistNMatchCent(0), |
1b4db73a | 44 | fHistNClusMatchCent(0) |
0b777a09 | 45 | { |
d6f334b5 | 46 | // Default constructor. |
0b777a09 | 47 | |
a3f43e7e | 48 | for(Int_t i=0; i<8; i++) { |
9f52c61f | 49 | fHistEsubPch[i] = 0; |
50 | fHistEsubPchRat[i] = 0; | |
51 | ||
a3f43e7e | 52 | if (i<4) { |
1f6c8e39 | 53 | fHistMatchEvsP[i] = 0; |
54 | fHistMatchdRvsEP[i] = 0; | |
55 | fHistNMatchEnergy[i] = 0; | |
9f52c61f | 56 | |
57 | for(Int_t j=0; j<4; j++) | |
58 | fHistNCellsEnergy[i][j] = 0; | |
a3f43e7e | 59 | } |
9f52c61f | 60 | |
fbc9afc4 | 61 | for(Int_t j=0; j<9; j++) { |
9f52c61f | 62 | for(Int_t k=0; k<2; k++) |
1f6c8e39 | 63 | fHistMatchEtaPhi[i][j][k] = 0; |
a3f43e7e | 64 | } |
65 | } | |
0b777a09 | 66 | } |
67 | ||
5d845887 | 68 | //________________________________________________________________________ |
69 | AliHadCorrTask::AliHadCorrTask(const char *name, Bool_t histo) : | |
1f6c8e39 | 70 | AliAnalysisTaskEmcal(name, histo), |
5d845887 | 71 | fOutCaloName("CaloClustersCorr"), |
72 | fPhiMatch(0.05), | |
73 | fEtaMatch(0.025), | |
a89e2005 | 74 | fDoTrackClus(1), |
5d845887 | 75 | fHadCorr(0), |
1f6c8e39 | 76 | fEexclCell(0), |
1b4db73a | 77 | fEsdMode(kTRUE), |
5d845887 | 78 | fOutClusters(0), |
5d845887 | 79 | fHistNclusvsCent(0), |
80 | fHistNclusMatchvsCent(0), | |
81 | fHistEbefore(0), | |
82 | fHistEafter(0), | |
83 | fHistEoPCent(0), | |
84 | fHistNMatchCent(0), | |
1b4db73a | 85 | fHistNClusMatchCent(0) |
5d845887 | 86 | { |
87 | // Standard constructor. | |
88 | ||
1b4db73a | 89 | for(Int_t i=0; i<8; i++) { |
9f52c61f | 90 | fHistEsubPch[i] = 0; |
91 | fHistEsubPchRat[i] = 0; | |
92 | ||
5d845887 | 93 | if (i<4) { |
9f52c61f | 94 | fHistMatchEvsP[i] = 0; |
95 | fHistMatchdRvsEP[i] = 0; | |
96 | fHistNMatchEnergy[i] = 0; | |
97 | ||
98 | for(Int_t j=0; j<4; j++) | |
1f6c8e39 | 99 | fHistNCellsEnergy[i][j] = 0; |
5d845887 | 100 | } |
9f52c61f | 101 | |
5d845887 | 102 | for(Int_t j=0; j<9; j++) { |
9f52c61f | 103 | for(Int_t k=0; k<2; k++) |
1f6c8e39 | 104 | fHistMatchEtaPhi[i][j][k] = 0; |
5d845887 | 105 | } |
106 | } | |
1b4db73a | 107 | |
108 | SetMakeGeneralHistograms(histo); | |
5d845887 | 109 | |
110 | fBranchNames="ESD:AliESDRun.,AliESDHeader.,PrimaryVertex."; | |
d6f334b5 | 111 | } |
0b777a09 | 112 | |
113 | //________________________________________________________________________ | |
114 | AliHadCorrTask::~AliHadCorrTask() | |
115 | { | |
116 | // Destructor | |
117 | } | |
118 | ||
d6f334b5 | 119 | //________________________________________________________________________ |
120 | Int_t AliHadCorrTask::GetMomBin(Double_t p) const | |
121 | { | |
122 | // Get momenum bin. | |
123 | ||
124 | Int_t pbin=-1; | |
4f833c06 | 125 | if (p<0.5) |
d6f334b5 | 126 | pbin=0; |
fbc9afc4 | 127 | else if (p>=0.5 && p<1.0) |
d6f334b5 | 128 | pbin=1; |
fbc9afc4 | 129 | else if (p>=1.0 && p<1.5) |
d6f334b5 | 130 | pbin=2; |
fbc9afc4 | 131 | else if (p>=1.5 && p<2.) |
d6f334b5 | 132 | pbin=3; |
fbc9afc4 | 133 | else if (p>=2. && p<3.) |
d6f334b5 | 134 | pbin=4; |
fbc9afc4 | 135 | else if (p>=3. && p<4.) |
136 | pbin=5; | |
137 | else if (p>=4. && p<5.) | |
138 | pbin=6; | |
139 | else if (p>=5. && p<8.) | |
140 | pbin=7; | |
141 | else if (p>=8.) | |
142 | pbin=8; | |
d6f334b5 | 143 | |
144 | return pbin; | |
145 | } | |
146 | ||
f6e8a928 | 147 | //________________________________________________________________________ |
148 | Double_t AliHadCorrTask::GetEtaSigma(Int_t pbin) const | |
149 | { | |
4f833c06 | 150 | // Get sigma in eta. |
151 | ||
1f6c8e39 | 152 | Double_t EtaSigma[9]={0.0097,0.0075,0.0059,0.0055,0.0053,0.005,0.005,0.0045,0.0042}; |
f6e8a928 | 153 | return 2.0*EtaSigma[pbin]; |
154 | } | |
1f6c8e39 | 155 | |
f6e8a928 | 156 | //________________________________________________________________________ |
157 | Double_t AliHadCorrTask::GetPhiMean(Int_t pbin, Int_t centbin) const | |
158 | { | |
4f833c06 | 159 | // Get phi mean. |
160 | ||
161 | if (centbin==0) { | |
f6e8a928 | 162 | Double_t PhiMean[9]={0.036, |
163 | 0.021, | |
164 | 0.0121, | |
165 | 0.0084, | |
166 | 0.0060, | |
167 | 0.0041, | |
168 | 0.0031, | |
169 | 0.0022, | |
170 | 0.001}; | |
171 | return PhiMean[pbin]; | |
4f833c06 | 172 | } else if (centbin==1) { |
f6e8a928 | 173 | Double_t PhiMean[9]={0.036, |
174 | 0.021, | |
175 | 0.0121, | |
176 | 0.0084, | |
177 | 0.0060, | |
178 | 0.0041, | |
179 | 0.0031, | |
180 | 0.0022, | |
181 | 0.001}; | |
182 | return PhiMean[pbin]; | |
4f833c06 | 183 | } else if (centbin==2) { |
f6e8a928 | 184 | Double_t PhiMean[9]={0.036, |
185 | 0.021, | |
186 | 0.0121, | |
187 | 0.0084, | |
188 | 0.0060, | |
189 | 0.0041, | |
190 | 0.0031, | |
191 | 0.0022, | |
192 | 0.001}; | |
193 | return PhiMean[pbin]; | |
4f833c06 | 194 | } else if (centbin==3) { |
f6e8a928 | 195 | Double_t PhiMean[9]={0.036, |
196 | 0.021, | |
197 | 0.0121, | |
198 | 0.0084, | |
199 | 0.0060, | |
200 | 0.0041, | |
201 | 0.0031, | |
202 | 0.0022, | |
203 | 0.001}; | |
204 | return PhiMean[pbin]; | |
4f833c06 | 205 | } else if (centbin==4) { |
f6e8a928 | 206 | Double_t PhiMean[9]={0.036, |
207 | 0.021, | |
208 | 0.0127, | |
209 | 0.0089, | |
210 | 0.0068, | |
211 | 0.0049, | |
212 | 0.0038, | |
213 | 0.0028, | |
214 | 0.0018}; | |
215 | return PhiMean[pbin]*(-1.); | |
4f833c06 | 216 | } else if (centbin==5) { |
f6e8a928 | 217 | Double_t PhiMean[9]={0.036, |
218 | 0.021, | |
219 | 0.0127, | |
220 | 0.0089, | |
221 | 0.0068, | |
222 | 0.0048, | |
223 | 0.0038, | |
224 | 0.0028, | |
225 | 0.0018}; | |
226 | return PhiMean[pbin]*(-1.); | |
4f833c06 | 227 | } else if (centbin==6) { |
f6e8a928 | 228 | Double_t PhiMean[9]={0.036, |
229 | 0.021, | |
230 | 0.0127, | |
231 | 0.0089, | |
232 | 0.0068, | |
233 | 0.0045, | |
234 | 0.0035, | |
235 | 0.0028, | |
236 | 0.0018}; | |
237 | return PhiMean[pbin]*(-1.); | |
4f833c06 | 238 | } else if (centbin==7) { |
f6e8a928 | 239 | Double_t PhiMean[9]={0.036, |
240 | 0.021, | |
241 | 0.0127, | |
242 | 0.0089, | |
243 | 0.0068, | |
244 | 0.0043, | |
245 | 0.0035, | |
246 | 0.0028, | |
247 | 0.0018}; | |
248 | return PhiMean[pbin]*(-1.); | |
249 | } | |
250 | ||
251 | return 0; | |
f6e8a928 | 252 | } |
1f6c8e39 | 253 | |
f6e8a928 | 254 | //________________________________________________________________________ |
255 | Double_t AliHadCorrTask::GetPhiSigma(Int_t pbin, Int_t centbin) const | |
256 | { | |
4f833c06 | 257 | // Get phi sigma. |
258 | ||
259 | if (centbin==0) { | |
f6e8a928 | 260 | Double_t PhiSigma[9]={0.0221, |
261 | 0.0128, | |
262 | 0.0074, | |
263 | 0.0064, | |
264 | 0.0059, | |
265 | 0.0055, | |
266 | 0.0052, | |
267 | 0.0049, | |
268 | 0.0045}; | |
269 | return 2.*PhiSigma[pbin]; | |
4f833c06 | 270 | } else if (centbin==1) { |
f6e8a928 | 271 | Double_t PhiSigma[9]={0.0217, |
272 | 0.0120, | |
273 | 0.0076, | |
274 | 0.0066, | |
275 | 0.0062, | |
276 | 0.0058, | |
277 | 0.0054, | |
278 | 0.0054, | |
279 | 0.0045}; | |
280 | return 2.*PhiSigma[pbin]; | |
4f833c06 | 281 | } else if (centbin==2) { |
f6e8a928 | 282 | Double_t PhiSigma[9]={0.0211, |
283 | 0.0124, | |
284 | 0.0080, | |
285 | 0.0070, | |
286 | 0.0067, | |
287 | 0.0061, | |
288 | 0.0059, | |
289 | 0.0054, | |
290 | 0.0047}; | |
291 | return 2.*PhiSigma[pbin]; | |
4f833c06 | 292 | } else if (centbin==3) { |
f6e8a928 | 293 | Double_t PhiSigma[9]={0.0215, |
294 | 0.0124, | |
295 | 0.0082, | |
296 | 0.0073, | |
297 | 0.0069, | |
298 | 0.0064, | |
299 | 0.0060, | |
300 | 0.0055, | |
301 | 0.0047}; | |
302 | return 2.*PhiSigma[pbin]; | |
4f833c06 | 303 | } else if (centbin==4) { |
f6e8a928 | 304 | Double_t PhiSigma[9]={0.0199, |
305 | 0.0108, | |
306 | 0.0072, | |
307 | 0.0071, | |
308 | 0.0060, | |
309 | 0.0055, | |
310 | 0.0052, | |
311 | 0.0049, | |
312 | 0.0045}; | |
313 | return 2.*PhiSigma[pbin]; | |
4f833c06 | 314 | } else if (centbin==5) { |
f6e8a928 | 315 | Double_t PhiSigma[9]={0.0200, |
316 | 0.0110, | |
317 | 0.0074, | |
318 | 0.0071, | |
319 | 0.0064, | |
320 | 0.0059, | |
321 | 0.0055, | |
322 | 0.0052, | |
323 | 0.0045}; | |
324 | return 2.*PhiSigma[pbin]; | |
4f833c06 | 325 | } else if (centbin==6) { |
f6e8a928 | 326 | Double_t PhiSigma[9]={0.0202, |
327 | 0.0113, | |
328 | 0.0077, | |
329 | 0.0071, | |
330 | 0.0069, | |
331 | 0.0064, | |
332 | 0.0060, | |
333 | 0.0055, | |
334 | 0.0050}; | |
335 | return 2.*PhiSigma[pbin]; | |
4f833c06 | 336 | } else if (centbin==7) { |
f6e8a928 | 337 | Double_t PhiSigma[9]={0.0205, |
338 | 0.0113, | |
339 | 0.0080, | |
340 | 0.0074, | |
341 | 0.0078, | |
342 | 0.0067, | |
343 | 0.0062, | |
344 | 0.0055, | |
345 | 0.0050}; | |
346 | return 2.*PhiSigma[pbin]; | |
347 | } | |
348 | ||
349 | return 0; | |
f6e8a928 | 350 | } |
351 | ||
0b777a09 | 352 | //________________________________________________________________________ |
353 | void AliHadCorrTask::UserCreateOutputObjects() | |
354 | { | |
d6f334b5 | 355 | // Create my user objects. |
0b777a09 | 356 | |
5d845887 | 357 | if (!fCreateHisto) |
358 | return; | |
359 | ||
1b4db73a | 360 | AliAnalysisTaskEmcal::UserCreateOutputObjects(); |
0b777a09 | 361 | |
1f6c8e39 | 362 | TString name; |
bcf52e4a | 363 | |
a3f43e7e | 364 | for(Int_t icent=0; icent<8; ++icent) { |
fbc9afc4 | 365 | for(Int_t ipt=0; ipt<9; ++ipt) { |
1f6c8e39 | 366 | for(Int_t ieta=0; ieta<2; ++ieta) { |
1f6c8e39 | 367 | name = Form("fHistMatchEtaPhi_%i_%i_%i",icent,ipt,ieta); |
368 | fHistMatchEtaPhi[icent][ipt][ieta] = new TH2F(name, name, 200, -0.1, 0.1, 400, -0.2, 0.2); | |
369 | fOutput->Add(fHistMatchEtaPhi[icent][ipt][ieta]); | |
370 | } | |
4711c521 | 371 | } |
372 | ||
1f6c8e39 | 373 | name = Form("fHistEsubPch_%i",icent); |
374 | fHistEsubPch[icent]=new TH1F(name, name, 400, 0., 100.); | |
375 | fOutput->Add(fHistEsubPch[icent]); | |
376 | ||
377 | name = Form("fHistEsubPchRat_%i",icent); | |
378 | fHistEsubPchRat[icent]=new TH2F(name, name, 400, 0., 200., 1000, 0., 10.); | |
379 | fOutput->Add(fHistEsubPchRat[icent]); | |
1f6c8e39 | 380 | |
4f833c06 | 381 | if (icent<4) { |
1b4db73a | 382 | for(Int_t itrk=0; itrk<4; ++itrk) { |
383 | name = Form("fHistNCellsEnergy_%i_%i",icent,itrk); | |
384 | fHistNCellsEnergy[icent][itrk] = new TH2F(name, name, 1000, 0, 100, 101, -0.5, 100.5); | |
385 | fOutput->Add(fHistNCellsEnergy[icent][itrk]); | |
386 | } | |
387 | ||
1f6c8e39 | 388 | name = Form("fHistMatchEvsP_%i",icent); |
a3f43e7e | 389 | fHistMatchEvsP[icent] = new TH2F(name, name, 400, 0., 200., 1000, 0., 10.); |
1f6c8e39 | 390 | fOutput->Add(fHistMatchEvsP[icent]); |
0b777a09 | 391 | |
a3f43e7e | 392 | name = Form("fHistMatchdRvsEP_%i",icent); |
393 | fHistMatchdRvsEP[icent] = new TH2F(name, name, 1000, 0., 1., 1000, 0., 10.); | |
1f6c8e39 | 394 | fOutput->Add(fHistMatchdRvsEP[icent]); |
395 | ||
396 | name = Form("fHistNMatchEnergy_%i",icent); | |
397 | fHistNMatchEnergy[icent] = new TH2F(name, name, 1000, 0, 100, 101, -0.5, 100.5); | |
398 | fOutput->Add(fHistNMatchEnergy[icent]); | |
a3f43e7e | 399 | } |
d6f334b5 | 400 | } |
0b777a09 | 401 | |
d6f334b5 | 402 | fHistNclusvsCent = new TH1F("Nclusvscent", "NclusVsCent", 100, 0, 100); |
403 | fHistNclusMatchvsCent = new TH1F("NclusMatchvscent", "NclusMatchVsCent", 100, 0, 100); | |
a89e2005 | 404 | fHistEbefore = new TH1F("Ebefore", "Ebefore", 100, 0, 100); |
405 | fHistEafter = new TH1F("Eafter", "Eafter", 100, 0, 100); | |
d6f334b5 | 406 | fHistEoPCent = new TH2F("EoPCent", "EoPCent", 100, 0, 100, 1000, 0, 10); |
1f6c8e39 | 407 | fHistNMatchCent = new TH2F("NMatchesCent", "NMatchesCent", 100, 0, 100, 11, -0.5, 10.5); |
1b4db73a | 408 | fHistNClusMatchCent = new TH2F("NClusMatchesCent", "NClusMatchesCent", 100, 0, 100, 11, -0.5, 10.5); |
1f6c8e39 | 409 | |
410 | fOutput->Add(fHistNclusMatchvsCent); | |
411 | fOutput->Add(fHistNclusvsCent); | |
412 | fOutput->Add(fHistEbefore); | |
413 | fOutput->Add(fHistEafter); | |
414 | fOutput->Add(fHistEoPCent); | |
415 | fOutput->Add(fHistNMatchCent); | |
1b4db73a | 416 | fOutput->Add(fHistNClusMatchCent); |
1f6c8e39 | 417 | |
418 | PostData(1, fOutput); | |
0b777a09 | 419 | } |
420 | ||
1b4db73a | 421 | //________________________________________________________________________ |
422 | void AliHadCorrTask::ExecOnce() | |
423 | { | |
0983dd5b | 424 | // Do base class initializations and if it fails -> bail out |
425 | if (!fInitialized) | |
426 | AliAnalysisTaskEmcal::ExecOnce(); | |
427 | if (!fInitialized) | |
428 | return; | |
429 | ||
1b4db73a | 430 | // Init the analysis. |
431 | ||
7030f36f | 432 | AliAnalysisTaskEmcal::ExecOnce(); |
433 | ||
434 | if (!fInitialized) | |
435 | return; | |
436 | ||
1b4db73a | 437 | if (dynamic_cast<AliAODEvent*>(InputEvent())) |
438 | fEsdMode = kFALSE; | |
439 | ||
440 | if (fEsdMode) { // optimization in case autobranch loading is off | |
441 | AliAnalysisManager *am = AliAnalysisManager::GetAnalysisManager(); | |
442 | if (fCaloName == "CaloClusters") | |
443 | am->LoadBranch("CaloClusters"); | |
444 | if (fTracksName == "Tracks") | |
445 | am->LoadBranch("Tracks"); | |
446 | am->LoadBranch("Centrality."); | |
447 | } | |
448 | ||
449 | if (fEsdMode) | |
450 | fOutClusters = new TClonesArray("AliESDCaloCluster"); | |
451 | else | |
452 | fOutClusters = new TClonesArray("AliAODCaloCluster"); | |
453 | ||
454 | fOutClusters->SetName(fOutCaloName); | |
455 | ||
456 | // post output in event if not yet present | |
457 | if (!(InputEvent()->FindListObject(fOutCaloName))) { | |
458 | InputEvent()->AddObject(fOutClusters); | |
459 | } | |
460 | else { | |
7030f36f | 461 | fInitialized = kFALSE; |
1b4db73a | 462 | AliFatal(Form("%s: Container with same name %s already present. Aborting", GetName(), fOutCaloName.Data())); |
0983dd5b | 463 | fInitialized = kFALSE; |
1b4db73a | 464 | return; |
465 | } | |
1b4db73a | 466 | } |
467 | ||
468 | //________________________________________________________________________ | |
469 | void AliHadCorrTask::DoTrackLoop() | |
470 | { | |
471 | const Int_t Ntracks = fTracks->GetEntries(); | |
472 | for (Int_t iTrk = 0; iTrk < Ntracks; ++iTrk) { | |
473 | Int_t NmatchClus = 0; | |
474 | ||
475 | AliEmcalParticle *emctrack = static_cast<AliEmcalParticle*>(fTracks->At(iTrk)); | |
476 | if (!emctrack) | |
477 | continue; | |
478 | if (!emctrack->IsEMCAL()) | |
479 | continue; | |
480 | ||
481 | AliVTrack *track = emctrack->GetTrack(); | |
482 | if (!track) | |
483 | continue; | |
484 | if (!AcceptTrack(track)) | |
485 | continue; | |
486 | ||
487 | if (track->GetTrackEtaOnEMCal() < fGeom->GetArm1EtaMin() + fEtaMatch || | |
488 | track->GetTrackEtaOnEMCal() > fGeom->GetArm1EtaMax() - fEtaMatch || | |
489 | track->GetTrackPhiOnEMCal() < fGeom->GetArm1PhiMin() * TMath::DegToRad() + fPhiMatch || | |
490 | track->GetTrackPhiOnEMCal() > fGeom->GetArm1PhiMax() * TMath::DegToRad() - fPhiMatch) | |
491 | continue; | |
492 | ||
493 | Int_t Nclus = emctrack->GetNumberOfMatchedObj(); | |
494 | ||
495 | for (Int_t iClus = 0; iClus < Nclus; ++iClus) { | |
496 | AliEmcalParticle *emccluster = static_cast<AliEmcalParticle*>(fCaloClusters->At(iClus)); | |
497 | if (!emccluster) | |
498 | continue; | |
499 | ||
500 | AliVCluster *cluster = emccluster->GetCluster(); | |
501 | if (!cluster) | |
502 | continue; | |
503 | if (!AcceptCluster(cluster)) | |
504 | continue; | |
505 | ||
506 | Double_t etadiff = 999; | |
507 | Double_t phidiff = 999; | |
508 | AliPicoTrack::GetEtaPhiDiff(track, cluster, phidiff, etadiff); | |
509 | ||
510 | if (TMath::Abs(phidiff) < fPhiMatch && TMath::Abs(etadiff) < fEtaMatch) | |
511 | NmatchClus++; | |
512 | } | |
513 | fHistNClusMatchCent->Fill(fCent, NmatchClus); | |
514 | } | |
515 | } | |
516 | ||
1f6c8e39 | 517 | //________________________________________________________________________ |
518 | void AliHadCorrTask::DoMatchedTracksLoop(AliEmcalParticle *emccluster, Double_t &totalTrkP, Int_t &Nmatches) | |
519 | { | |
c7d52659 | 520 | // Do the loop over matched tracks for cluster emccluster. |
1f6c8e39 | 521 | |
522 | AliVCluster *cluster = emccluster->GetCluster(); | |
523 | Int_t iClus = emccluster->IdInCollection(); | |
524 | Double_t energyclus = cluster->E(); | |
525 | ||
526 | // loop over matched tracks | |
c7d52659 | 527 | const Int_t Ntrks = emccluster->GetNumberOfMatchedObj(); |
1f6c8e39 | 528 | for (Int_t i = 0; i < Ntrks; ++i) { |
529 | Int_t iTrack = emccluster->GetMatchedObjId(i); | |
530 | Double_t dR = emccluster->GetMatchedObjDistance(i); | |
531 | ||
4f833c06 | 532 | AliEmcalParticle *emctrack = static_cast<AliEmcalParticle*>(fTracks->At(iTrack)); |
1f6c8e39 | 533 | if (!emctrack) |
534 | continue; | |
1f6c8e39 | 535 | AliVTrack *track = emctrack->GetTrack(); |
536 | if (!track) | |
537 | continue; | |
538 | if (!AcceptTrack(track)) | |
539 | continue; | |
540 | ||
875b35fc | 541 | // check if track also points to cluster |
542 | if (fDoTrackClus && (track->GetEMCALcluster()) != iClus) | |
543 | continue; | |
544 | ||
1f6c8e39 | 545 | Double_t etadiff = 999; |
546 | Double_t phidiff = 999; | |
547 | AliPicoTrack::GetEtaPhiDiff(track, cluster, phidiff, etadiff); | |
548 | ||
549 | Double_t mom = track->P(); | |
550 | Int_t mombin = GetMomBin(mom); | |
551 | Int_t centbinch = fCentBin; | |
c7d52659 | 552 | if (track->Charge()<0) |
1f6c8e39 | 553 | centbinch += 4; |
554 | ||
555 | if (fCreateHisto) { | |
556 | Int_t etabin = 0; | |
557 | if(track->Eta() > 0) etabin=1; | |
1f6c8e39 | 558 | fHistMatchEtaPhi[centbinch][mombin][etabin]->Fill(etadiff, phidiff); |
559 | } | |
560 | ||
c7d52659 | 561 | Double_t etaCut = 0.0; |
562 | Double_t phiCutlo = 0.0; | |
563 | Double_t phiCuthi = 0.0; | |
1f6c8e39 | 564 | |
4f833c06 | 565 | if (fPhiMatch > 0) { |
c7d52659 | 566 | phiCutlo = -fPhiMatch; |
875b35fc | 567 | phiCuthi = +fPhiMatch; |
568 | } else { | |
c7d52659 | 569 | phiCutlo = GetPhiMean(mombin, centbinch) - GetPhiSigma(mombin, fCentBin); |
570 | phiCuthi = GetPhiMean(mombin, centbinch) + GetPhiSigma(mombin, fCentBin); | |
1f6c8e39 | 571 | } |
572 | ||
573 | if (fEtaMatch > 0) { | |
c7d52659 | 574 | etaCut = fEtaMatch; |
875b35fc | 575 | } else { |
c7d52659 | 576 | etaCut = GetEtaSigma(mombin); |
3a385c49 | 577 | } |
3a385c49 | 578 | |
c7d52659 | 579 | if ((phidiff < phiCuthi && phidiff > phiCutlo) && TMath::Abs(etadiff) < etaCut) { |
875b35fc | 580 | ++Nmatches; |
581 | totalTrkP += track->P(); | |
582 | ||
583 | if (fCreateHisto) { | |
584 | if (fHadCorr > 1 && mombin > -1) { | |
585 | fHistMatchdRvsEP[fCentBin]->Fill(dR, energyclus / mom); | |
586 | } | |
1f6c8e39 | 587 | } |
588 | } | |
589 | } | |
3a385c49 | 590 | } |
591 | ||
0b777a09 | 592 | //________________________________________________________________________ |
1f6c8e39 | 593 | Bool_t AliHadCorrTask::Run() |
0b777a09 | 594 | { |
1f6c8e39 | 595 | // Run the hadronic correction |
d6f334b5 | 596 | |
1b4db73a | 597 | if (fCreateHisto) |
598 | DoTrackLoop(); | |
599 | ||
d6f334b5 | 600 | // delete output |
601 | fOutClusters->Delete(); | |
0b777a09 | 602 | |
85835c5b | 603 | // loop over all clusters |
604 | const Int_t Nclus = fCaloClusters->GetEntries(); | |
a89e2005 | 605 | for (Int_t iClus = 0, clusCount=0; iClus < Nclus; ++iClus) { |
4f833c06 | 606 | AliEmcalParticle *emccluster = static_cast<AliEmcalParticle*>(fCaloClusters->At(iClus)); |
1f6c8e39 | 607 | if (!emccluster) |
d6f334b5 | 608 | continue; |
609 | ||
1f6c8e39 | 610 | AliVCluster *cluster = emccluster->GetCluster(); |
611 | if (!cluster) | |
612 | continue; | |
613 | if (!AcceptCluster(cluster)) | |
d6f334b5 | 614 | continue; |
615 | ||
1f6c8e39 | 616 | Double_t energyclus = 0; |
62206c47 | 617 | if (fCreateHisto) |
618 | fHistEbefore->Fill(fCent, cluster->E()); | |
32bf39af | 619 | |
d6f334b5 | 620 | // apply correction / subtraction |
bcf52e4a | 621 | if (fHadCorr > 0) { |
d6f334b5 | 622 | // to subtract only the closest track set fHadCor to a % |
623 | // to subtract all tracks within the cut set fHadCor to %+1 | |
1f6c8e39 | 624 | if (fHadCorr > 1) |
625 | energyclus = ApplyHadCorrAllTracks(emccluster, fHadCorr - 1); | |
626 | else | |
627 | energyclus = ApplyHadCorrOneTrack(emccluster, fHadCorr); | |
0b777a09 | 628 | } |
bcf52e4a | 629 | |
630 | if (energyclus < 0) | |
d6f334b5 | 631 | energyclus = 0; |
d6f334b5 | 632 | |
bcf52e4a | 633 | if (energyclus > 0) { // create corrected cluster |
d6f334b5 | 634 | AliVCluster *oc; |
1b4db73a | 635 | if (fEsdMode) { |
4f833c06 | 636 | AliESDCaloCluster *ec = dynamic_cast<AliESDCaloCluster*>(cluster); |
637 | if (!ec) | |
638 | continue; | |
639 | oc = new ((*fOutClusters)[clusCount]) AliESDCaloCluster(*ec); | |
640 | } else { | |
641 | AliAODCaloCluster *ac = dynamic_cast<AliAODCaloCluster*>(cluster); | |
642 | if (!ac) | |
643 | continue; | |
644 | oc = new ((*fOutClusters)[clusCount]) AliAODCaloCluster(*ac); | |
645 | } | |
d6f334b5 | 646 | oc->SetE(energyclus); |
1f6c8e39 | 647 | |
d6f334b5 | 648 | ++clusCount; |
1f6c8e39 | 649 | |
650 | if (fCreateHisto) | |
651 | fHistEafter->Fill(fCent, energyclus); | |
d6f334b5 | 652 | } |
0b777a09 | 653 | } |
1f6c8e39 | 654 | |
655 | return kTRUE; | |
656 | } | |
bcf52e4a | 657 | |
1f6c8e39 | 658 | //________________________________________________________________________ |
659 | Double_t AliHadCorrTask::ApplyHadCorrOneTrack(AliEmcalParticle *emccluster, Double_t hadCorr) | |
660 | { | |
4f833c06 | 661 | // Apply the hadronic correction with one track only. |
662 | ||
1f6c8e39 | 663 | AliVCluster *cluster = emccluster->GetCluster(); |
181a0a09 | 664 | Double_t energyclus = cluster->E(); |
665 | Int_t iMin = emccluster->GetMatchedObjId(); | |
1f6c8e39 | 666 | if (iMin < 0) |
667 | return energyclus; | |
668 | ||
4f833c06 | 669 | AliEmcalParticle *emctrack = static_cast<AliEmcalParticle*>(fTracks->At(iMin)); |
1f6c8e39 | 670 | if (!emctrack) |
671 | return energyclus; | |
672 | ||
181a0a09 | 673 | // check if track also points to cluster |
674 | Int_t cid = emctrack->GetMatchedObjId(); | |
875b35fc | 675 | if (fDoTrackClus && (cid!=emccluster->IdInCollection())) |
c7d52659 | 676 | return energyclus; |
677 | ||
1f6c8e39 | 678 | AliVTrack *track = emctrack->GetTrack(); |
679 | if (!track) | |
680 | return energyclus; | |
681 | ||
682 | Double_t mom = track->P(); | |
683 | if (mom == 0) | |
684 | return energyclus; | |
685 | ||
686 | Double_t dRmin = emccluster->GetMatchedObjDistance(); | |
687 | Double_t dEtaMin = 1e9; | |
688 | Double_t dPhiMin = 1e9; | |
689 | AliPicoTrack::GetEtaPhiDiff(track, cluster, dPhiMin, dEtaMin); | |
690 | ||
691 | Int_t mombin = GetMomBin(mom); | |
692 | Int_t centbinch = fCentBin; | |
c7d52659 | 693 | if (track->Charge()<0) |
1f6c8e39 | 694 | centbinch += 4; |
695 | ||
181a0a09 | 696 | // plot some histograms if switched on |
1f6c8e39 | 697 | if (fCreateHisto) { |
698 | Int_t etabin = 0; | |
699 | if(track->Eta() > 0) | |
700 | etabin = 1; | |
701 | ||
702 | fHistMatchEtaPhi[centbinch][mombin][etabin]->Fill(dEtaMin, dPhiMin); | |
703 | ||
704 | if (mom > 0) { | |
705 | fHistMatchEvsP[fCentBin]->Fill(energyclus, energyclus / mom); | |
706 | fHistEoPCent->Fill(fCent, energyclus / mom); | |
707 | fHistMatchdRvsEP[fCentBin]->Fill(dRmin, energyclus / mom); | |
708 | } | |
709 | } | |
710 | ||
181a0a09 | 711 | // define eta/phi cuts |
c7d52659 | 712 | Double_t etaCut = 0.0; |
713 | Double_t phiCutlo = 0.0; | |
714 | Double_t phiCuthi = 0.0; | |
1f6c8e39 | 715 | if (fPhiMatch > 0) { |
c7d52659 | 716 | phiCutlo = -fPhiMatch; |
875b35fc | 717 | phiCuthi = +fPhiMatch; |
1f6c8e39 | 718 | } |
719 | else { | |
c7d52659 | 720 | phiCutlo = GetPhiMean(mombin, centbinch) - GetPhiSigma(mombin, fCentBin); |
721 | phiCuthi = GetPhiMean(mombin, centbinch) + GetPhiSigma(mombin, fCentBin); | |
1f6c8e39 | 722 | } |
723 | if(fEtaMatch > 0) { | |
c7d52659 | 724 | etaCut = fEtaMatch; |
1f6c8e39 | 725 | } |
726 | else { | |
c7d52659 | 727 | etaCut = GetEtaSigma(mombin); |
1f6c8e39 | 728 | } |
729 | ||
181a0a09 | 730 | // apply the correction if the track is in the eta/phi window |
c7d52659 | 731 | if ((dPhiMin < phiCuthi && dPhiMin > phiCutlo) && TMath::Abs(dEtaMin) < etaCut) { |
875b35fc | 732 | energyclus -= hadCorr * mom; |
1f6c8e39 | 733 | } |
734 | ||
735 | return energyclus; | |
0b777a09 | 736 | } |
4711c521 | 737 | |
0b777a09 | 738 | //________________________________________________________________________ |
1f6c8e39 | 739 | Double_t AliHadCorrTask::ApplyHadCorrAllTracks(AliEmcalParticle *emccluster, Double_t hadCorr) |
0b777a09 | 740 | { |
4f833c06 | 741 | // Apply the hadronic correction with all tracks. |
742 | ||
1f6c8e39 | 743 | AliVCluster *cluster = emccluster->GetCluster(); |
744 | ||
745 | Double_t energyclus = cluster->E(); | |
746 | Double_t cNcells = cluster->GetNCells(); | |
747 | ||
748 | Double_t totalTrkP = 0.0; // count total track momentum | |
749 | Int_t Nmatches = 0; // count total number of matches | |
750 | ||
181a0a09 | 751 | // do the loop over the matched tracks and get the number of matches and the total momentum |
1f6c8e39 | 752 | DoMatchedTracksLoop(emccluster, totalTrkP, Nmatches); |
753 | ||
754 | Double_t Esub = hadCorr * totalTrkP; | |
62206c47 | 755 | |
756 | if (Esub > energyclus) | |
757 | Esub = energyclus; | |
758 | ||
181a0a09 | 759 | // applying Peter's proposed algorithm |
760 | // never subtract the full energy of the cluster | |
1b4db73a | 761 | Double_t clusEexcl = fEexclCell * cNcells; |
762 | if (energyclus < clusEexcl) | |
763 | clusEexcl = energyclus; | |
62206c47 | 764 | if ((energyclus - Esub) < clusEexcl) |
765 | Esub = (energyclus - clusEexcl); | |
766 | ||
1b4db73a | 767 | Double_t EoP = 0; |
768 | if (totalTrkP>0) | |
769 | EoP = energyclus / totalTrkP; | |
1f6c8e39 | 770 | |
181a0a09 | 771 | // plot some histograms if switched on |
772 | if (fCreateHisto) { | |
1b4db73a | 773 | fHistNclusvsCent->Fill(fCent); |
1f6c8e39 | 774 | fHistNMatchCent->Fill(fCent, Nmatches); |
775 | fHistNMatchEnergy[fCentBin]->Fill(energyclus, Nmatches); | |
776 | ||
777 | if(Nmatches > 0) | |
778 | fHistNclusMatchvsCent->Fill(fCent); | |
1b4db73a | 779 | |
780 | if(Nmatches < 3) | |
781 | fHistNCellsEnergy[fCentBin][Nmatches]->Fill(energyclus, cNcells); | |
782 | else | |
1f6c8e39 | 783 | fHistNCellsEnergy[fCentBin][3]->Fill(energyclus, cNcells); |
784 | ||
785 | if (EoP > 0) { | |
786 | fHistEoPCent->Fill(fCent, EoP); | |
787 | fHistMatchEvsP[fCentBin]->Fill(energyclus, EoP); | |
788 | } | |
789 | ||
1b4db73a | 790 | if (Nmatches == 1 && totalTrkP > 0) { |
1f6c8e39 | 791 | Int_t iMin = emccluster->GetMatchedObjId(); |
4f833c06 | 792 | AliEmcalParticle *emctrack = static_cast<AliEmcalParticle*>(fTracks->At(iMin)); |
1f6c8e39 | 793 | AliVTrack *track = emctrack->GetTrack(); |
794 | Int_t centbinchm = fCentBin; | |
c7d52659 | 795 | if (track->Charge()<0) |
1f6c8e39 | 796 | centbinchm += 4; |
797 | ||
f54a0dd2 | 798 | fHistEsubPchRat[centbinchm]->Fill(totalTrkP, Esub / totalTrkP); |
1f6c8e39 | 799 | fHistEsubPch[centbinchm]->Fill(totalTrkP, Esub); |
800 | } | |
801 | } | |
1f6c8e39 | 802 | |
181a0a09 | 803 | // apply the correction |
1f6c8e39 | 804 | energyclus -= Esub; |
805 | ||
806 | return energyclus; | |
0b777a09 | 807 | } |
808 |