]>
Commit | Line | Data |
---|---|---|
cb68eb1d | 1 | //-*- Mode: C++ -*- |
2 | ||
3 | #include "TMath.h" | |
4 | #include "TAxis.h" | |
5 | #include "TSystem.h" | |
6 | #include "TFile.h" | |
7 | #include "TPRegexp.h" | |
8 | ||
9 | #include "AliStack.h" | |
10 | #include "AliMCEvent.h" | |
11 | #include "AliMCParticle.h" | |
12 | #include "AliESDtrackCuts.h" | |
13 | #include "AliESDInputHandler.h" | |
14 | #include "AliESDpid.h" | |
9be43c8e | 15 | #include "AliAODInputHandler.h" |
16 | #include "AliAODEvent.h" | |
17 | #include "AliAODMCParticle.h" | |
cb68eb1d | 18 | #include "AliCentrality.h" |
19 | #include "AliTracker.h" | |
20 | ||
21 | #include "AliAnalysisNetParticleHelper.h" | |
22 | ||
23 | using namespace std; | |
24 | ||
4918c45f | 25 | /** |
26 | * Class for for NetParticle Distributions | |
27 | * -- Helper class for net particle istributions | |
28 | * Authors: Jochen Thaeder <jochen@thaeder.de> | |
29 | * Michael Weber <m.weber@cern.ch> | |
30 | */ | |
cb68eb1d | 31 | |
32 | ClassImp(AliAnalysisNetParticleHelper) | |
33 | ||
3aa68b92 | 34 | /* |
35 | * --------------------------------------------------------------------------------- | |
36 | * particle names | |
37 | * --------------------------------------------------------------------------------- | |
38 | */ | |
39 | ||
478c95cf | 40 | // MW make fgk ... static const |
3aa68b92 | 41 | const Char_t* aPartNames[AliPID::kSPECIES][2] = { |
42 | {"ele", "posi"}, | |
43 | {"mubar", "mu"}, | |
44 | {"pibar", "pi"}, | |
45 | {"kbar", "k"}, | |
46 | {"pbar", "p"} | |
47 | }; | |
48 | ||
49 | const Char_t* aPartTitles[AliPID::kSPECIES][2] = { | |
50 | {"Electron", "Positron"}, | |
51 | {"Anti-Muon", "Muon"}, | |
52 | {"Anti-Pion", "Proton"}, | |
53 | {"Anti-Kaon", "Kaon"}, | |
54 | {"Anti-Proton", "Proton"} | |
55 | }; | |
56 | ||
57 | const Char_t* aPartTitlesLatex[AliPID::kSPECIES][2] = { | |
58 | {"e^{-}", "e^{+}" }, | |
59 | {"#mu^{-}", "#mu^{+}" }, | |
60 | {"#pi^{-}", "#pi^{+}" }, | |
61 | {"K^{-}", "K^{+}" }, | |
62 | {"#bar{p}", "p"} | |
63 | }; | |
64 | ||
cb68eb1d | 65 | /* |
66 | * --------------------------------------------------------------------------------- | |
67 | * Constructor / Destructor | |
68 | * --------------------------------------------------------------------------------- | |
69 | */ | |
70 | ||
71 | //________________________________________________________________________ | |
72 | AliAnalysisNetParticleHelper::AliAnalysisNetParticleHelper() : | |
478c95cf | 73 | fModeDistCreation(0), |
74 | ||
75 | fInputEventHandler(NULL), | |
cb68eb1d | 76 | fPIDResponse(NULL), |
77 | fESD(NULL), | |
9be43c8e | 78 | fAOD(NULL), |
cb68eb1d | 79 | fMCEvent(NULL), |
80 | fStack(NULL), | |
81 | ||
82 | fCentralityBin(-1), | |
83 | fCentralityPercentile(-1.), | |
84 | ||
85 | fCentralityBinMax(7), | |
86 | fVertexZMax(10.), | |
87 | fRapidityMax(0.5), | |
4918c45f | 88 | fPhiMin(0.), |
89 | fPhiMax(TMath::TwoPi()), | |
cb68eb1d | 90 | fMinTrackLengthMC(70.), |
91 | fNSigmaMaxCdd(3.), | |
92 | fNSigmaMaxCzz(3.), | |
93 | ||
94 | fParticleSpecies(AliPID::kProton), | |
cb68eb1d | 95 | |
478c95cf | 96 | fUsePID(kTRUE), |
cb68eb1d | 97 | fNSigmaMaxTPC(2.5), |
98 | fNSigmaMaxTOF(2.5), | |
99 | fMinPtForTOFRequired(0.8), | |
100 | ||
101 | fHEventStat0(NULL), | |
102 | fHEventStat1(NULL), | |
103 | fHEventStatMax(6), | |
104 | ||
105 | fHTriggerStat(NULL), | |
106 | fNTriggers(5), | |
107 | ||
108 | fHCentralityStat(NULL), | |
109 | fNCentralityBins(10), | |
110 | ||
4918c45f | 111 | fEtaCorrFunc(NULL) { |
cb68eb1d | 112 | // Constructor |
113 | ||
114 | AliLog::SetClassDebugLevel("AliAnalysisNetParticleHelper",10); | |
115 | } | |
116 | ||
4918c45f | 117 | const Float_t AliAnalysisNetParticleHelper::fgkfHistBinWitdthRap = 0.075; |
118 | const Float_t AliAnalysisNetParticleHelper::fgkfHistBinWitdthPt = 0.15; // 150 MeV | |
119 | ||
120 | const Float_t AliAnalysisNetParticleHelper::fgkfHistRangeCent[] = {-0.5, 8.5}; | |
121 | const Int_t AliAnalysisNetParticleHelper::fgkfHistNBinsCent = 9 ; | |
122 | ||
123 | const Float_t AliAnalysisNetParticleHelper::fgkfHistRangeEta[] = {-0.9, 0.9}; | |
124 | const Int_t AliAnalysisNetParticleHelper::fgkfHistNBinsEta = Int_t((AliAnalysisNetParticleHelper::fgkfHistRangeEta[1] - | |
125 | AliAnalysisNetParticleHelper::fgkfHistRangeEta[0]) / | |
126 | AliAnalysisNetParticleHelper::fgkfHistBinWitdthRap) +1; | |
127 | ||
128 | const Float_t AliAnalysisNetParticleHelper::fgkfHistRangeRap[] = {-0.5, 0.5}; | |
129 | const Int_t AliAnalysisNetParticleHelper::fgkfHistNBinsRap = Int_t((AliAnalysisNetParticleHelper::fgkfHistRangeRap[1] - | |
130 | AliAnalysisNetParticleHelper::fgkfHistRangeRap[0]) / | |
131 | AliAnalysisNetParticleHelper::fgkfHistBinWitdthRap) +1; | |
132 | ||
133 | const Float_t AliAnalysisNetParticleHelper::fgkfHistRangePhi[] = {0.0, TMath::TwoPi()}; | |
134 | const Int_t AliAnalysisNetParticleHelper::fgkfHistNBinsPhi = 42 ; | |
135 | ||
136 | const Float_t AliAnalysisNetParticleHelper::fgkfHistRangePt[] = {0.1, 3.0}; | |
137 | const Int_t AliAnalysisNetParticleHelper::fgkfHistNBinsPt = Int_t((AliAnalysisNetParticleHelper::fgkfHistRangePt[1] - | |
138 | AliAnalysisNetParticleHelper::fgkfHistRangePt[0]) / | |
139 | AliAnalysisNetParticleHelper::fgkfHistBinWitdthPt); | |
140 | ||
141 | const Float_t AliAnalysisNetParticleHelper::fgkfHistRangeSign[] = {-1.5, 1.5}; | |
142 | const Int_t AliAnalysisNetParticleHelper::fgkfHistNBinsSign = 3; | |
143 | ||
144 | const Char_t* AliAnalysisNetParticleHelper::fgkEventNames[] = {"All", "IsTriggered", "HasVertex", "Vz<Vz_{Max}", "Centrality [0,90]%"}; | |
145 | const Char_t* AliAnalysisNetParticleHelper::fgkCentralityMaxNames[] = {"5", "10", "20", "30", "40", "50", "60", "70", "80", "90", "100"}; | |
146 | const Char_t* AliAnalysisNetParticleHelper::fgkTriggerNames[] = {"kMB", "kCentral", "kSemiCentral", "kEMCEJE", "kEMCEGA" }; | |
147 | const Char_t* AliAnalysisNetParticleHelper::fgkCentralityNames[] = {"0-5%", "5-10%", "10-20%", "20-30%", "30-40%", "40-50%", | |
148 | "50-60%", "60-70%", "70-80%", "80-90%", "90-100%"}; | |
149 | ||
cb68eb1d | 150 | //________________________________________________________________________ |
151 | AliAnalysisNetParticleHelper::~AliAnalysisNetParticleHelper() { | |
152 | // Destructor | |
153 | ||
cb68eb1d | 154 | return; |
155 | } | |
156 | ||
3aa68b92 | 157 | /* |
158 | * --------------------------------------------------------------------------------- | |
159 | * Setter | |
160 | * --------------------------------------------------------------------------------- | |
161 | */ | |
162 | ||
163 | //________________________________________________________________________ | |
164 | void AliAnalysisNetParticleHelper::SetParticleSpecies(AliPID::EParticleType pid) { | |
165 | // -- Set particle species (ID, Name, Title, Title LATEX) | |
8c6128b7 | 166 | |
167 | if ( Int_t(pid) < 0 || Int_t(pid) >= AliPID::kSPECIES) { | |
3aa68b92 | 168 | AliWarning("Particle ID not in AliPID::kSPECIES --> Set to protons"); |
169 | pid = AliPID::kProton; | |
170 | } | |
478c95cf | 171 | |
172 | fParticleSpecies = pid; | |
173 | ||
3aa68b92 | 174 | for (Int_t idxPart = 0; idxPart < 2; ++idxPart) { |
175 | fPartName[idxPart] = aPartNames[fParticleSpecies][idxPart]; | |
176 | fPartTitle[idxPart] = aPartTitles[fParticleSpecies][idxPart]; | |
177 | fPartTitleLatex[idxPart] = aPartTitlesLatex[fParticleSpecies][idxPart]; | |
178 | } | |
179 | } | |
478c95cf | 180 | //________________________________________________________________________ |
181 | void AliAnalysisNetParticleHelper::SetUsePID(Bool_t usePID) { | |
182 | // -- Set usage of PID | |
183 | // > if turn off, set charge types (ID, Name, Title, Title LATEX) | |
184 | ||
185 | fUsePID = usePID; | |
186 | ||
187 | if (!usePID) { | |
188 | fParticleSpecies = AliPID::kUnknown; | |
3aa68b92 | 189 | |
478c95cf | 190 | fPartName[0] = "neg"; |
191 | fPartName[1] = "pos"; | |
192 | fPartTitle[0] = "Negative"; | |
193 | fPartTitle[1] = "Positive"; | |
194 | fPartTitleLatex[0] = "Negative"; | |
195 | fPartTitleLatex[1] = "Positive"; | |
196 | } | |
197 | } | |
3aa68b92 | 198 | |
199 | /* | |
200 | * --------------------------------------------------------------------------------- | |
201 | * Getter | |
202 | * --------------------------------------------------------------------------------- | |
203 | */ | |
204 | ||
205 | //________________________________________________________________________ | |
206 | TString AliAnalysisNetParticleHelper::GetParticleName(Int_t idxPart) { | |
207 | // -- Get particle Name | |
208 | ||
209 | if( idxPart != 0 && idxPart != 1){ | |
210 | AliWarning("Particle type not known --> Set to antiparticles"); | |
211 | idxPart = 0; | |
212 | } | |
213 | ||
214 | return fPartName[idxPart]; | |
215 | } | |
216 | ||
217 | //________________________________________________________________________ | |
218 | TString AliAnalysisNetParticleHelper::GetParticleTitle(Int_t idxPart) { | |
219 | // -- Get particle Title | |
220 | ||
221 | if( idxPart != 0 && idxPart != 1){ | |
222 | AliWarning("Particle type not known --> Set to antiparticles"); | |
223 | idxPart = 0; | |
224 | } | |
225 | ||
226 | return fPartTitle[idxPart]; | |
227 | } | |
228 | ||
229 | //________________________________________________________________________ | |
230 | TString AliAnalysisNetParticleHelper::GetParticleTitleLatex(Int_t idxPart) { | |
231 | // -- Get particle Title LATEX | |
232 | ||
233 | if( idxPart != 0 && idxPart != 1){ | |
234 | AliWarning("Particle type not known --> Set to antiparticles"); | |
235 | idxPart = 0; | |
236 | } | |
237 | ||
238 | return fPartTitleLatex[idxPart]; | |
239 | } | |
240 | ||
cb68eb1d | 241 | /* |
242 | * --------------------------------------------------------------------------------- | |
243 | * Public Methods | |
244 | * --------------------------------------------------------------------------------- | |
245 | */ | |
246 | ||
247 | //________________________________________________________________________ | |
478c95cf | 248 | Int_t AliAnalysisNetParticleHelper::Initialize(Bool_t isMC, Int_t modeDistCreation) { |
cb68eb1d | 249 | // -- Initialize helper |
250 | ||
251 | Int_t iResult = 0; | |
478c95cf | 252 | fModeDistCreation = modeDistCreation; |
cb68eb1d | 253 | |
254 | // -- Setup event cut statistics | |
255 | InitializeEventStats(); | |
256 | ||
257 | // -- Setup trigger statistics | |
258 | InitializeTriggerStats(); | |
259 | ||
260 | // -- Setup centrality statistics | |
261 | InitializeCentralityStats(); | |
262 | ||
263 | // -- Load Eta correction function | |
264 | iResult = InitializeEtaCorrection(isMC); | |
265 | ||
cb68eb1d | 266 | return iResult; |
267 | } | |
268 | ||
269 | //________________________________________________________________________ | |
9be43c8e | 270 | Int_t AliAnalysisNetParticleHelper::SetupEvent(AliESDInputHandler *esdHandler, AliAODInputHandler *aodHandler, AliMCEvent *mcEvent) { |
cb68eb1d | 271 | // -- Setup Event |
478c95cf | 272 | |
cb68eb1d | 273 | // -- Get ESD objects |
9be43c8e | 274 | if(esdHandler){ |
478c95cf | 275 | fInputEventHandler = static_cast<AliInputEventHandler*>(esdHandler); |
276 | fESD = dynamic_cast<AliESDEvent*>(fInputEventHandler->GetEvent()); | |
36ef73d2 | 277 | if (!fESD) { |
278 | AliError("ESD event handler not available"); | |
279 | return -1; | |
280 | } | |
9be43c8e | 281 | } |
282 | ||
283 | // -- Get AOD objects | |
284 | else if(aodHandler){ | |
478c95cf | 285 | fInputEventHandler = static_cast<AliInputEventHandler*>(aodHandler); |
286 | fAOD = dynamic_cast<AliAODEvent*>(fInputEventHandler->GetEvent()); | |
36ef73d2 | 287 | if (!fAOD) { |
288 | AliError("AOD event handler not available"); | |
289 | return -1; | |
290 | } | |
9be43c8e | 291 | } |
cb68eb1d | 292 | |
478c95cf | 293 | // -- Get Common objects |
294 | fPIDResponse = fInputEventHandler->GetPIDResponse(); | |
295 | ||
cb68eb1d | 296 | // -- Get MC objects |
297 | fMCEvent = mcEvent; | |
298 | if (fMCEvent) | |
299 | fStack = fMCEvent->Stack(); | |
300 | ||
301 | // -- Get event centrality | |
302 | // > 0-5|5-10|10-20|20-30|30-40|40-50|50-60|60-70|70-80|80-90 --> 10 bins | |
303 | // > 0 1 2 3 4 5 6 7 8 9 | |
304 | ||
9be43c8e | 305 | AliCentrality *centrality = NULL; |
306 | ||
307 | if(esdHandler) | |
308 | centrality = fESD->GetCentrality(); | |
309 | else if(aodHandler) | |
310 | centrality = fAOD->GetHeader()->GetCentralityP(); | |
311 | ||
36ef73d2 | 312 | if (!centrality) { |
313 | AliError("Centrality not available"); | |
314 | return -1; | |
315 | } | |
8c6128b7 | 316 | |
cb68eb1d | 317 | Int_t centBin = centrality->GetCentralityClass10("V0M"); |
318 | if (centBin == 0) | |
319 | fCentralityBin = centrality->GetCentralityClass5("V0M"); | |
320 | else if (centBin == 10 || centBin == -1.) | |
321 | fCentralityBin = -1; | |
322 | else if (centBin > 0 && centBin < fNCentralityBins) | |
323 | fCentralityBin = centBin + 1; | |
324 | else | |
325 | fCentralityBin = -2; | |
478c95cf | 326 | |
cb68eb1d | 327 | // -- Stay within the max centrality bin |
328 | if (fCentralityBin >= fCentralityBinMax) | |
329 | fCentralityBin = -2; | |
478c95cf | 330 | |
cb68eb1d | 331 | fCentralityPercentile = centrality->GetCentralityPercentile("V0M"); |
332 | ||
478c95cf | 333 | // -- Update TPC pid with eta correction (only for ESDs!!) |
334 | if(esdHandler) | |
9be43c8e | 335 | UpdateEtaCorrectedTPCPid(); |
cb68eb1d | 336 | |
337 | return 0; | |
338 | } | |
339 | ||
340 | /* | |
341 | * --------------------------------------------------------------------------------- | |
342 | * Event / Trigger Statistics | |
343 | * --------------------------------------------------------------------------------- | |
344 | */ | |
345 | ||
346 | //________________________________________________________________________ | |
347 | Bool_t AliAnalysisNetParticleHelper::IsEventTriggered() { | |
348 | // -- Check if Event is triggered and fill Trigger Histogram | |
349 | ||
350 | Bool_t *aTriggerFired = new Bool_t[fNTriggers]; | |
351 | for (Int_t ii = 0; ii < fNTriggers; ++ii) | |
352 | aTriggerFired[ii] = kFALSE; | |
353 | ||
478c95cf | 354 | if ((fInputEventHandler->IsEventSelected() & AliVEvent::kMB)) aTriggerFired[0] = kTRUE; |
355 | if ((fInputEventHandler->IsEventSelected() & AliVEvent::kCentral)) aTriggerFired[1] = kTRUE; | |
356 | if ((fInputEventHandler->IsEventSelected() & AliVEvent::kSemiCentral)) aTriggerFired[2] = kTRUE; | |
357 | if ((fInputEventHandler->IsEventSelected() & AliVEvent::kEMCEJE)) aTriggerFired[3] = kTRUE; | |
358 | if ((fInputEventHandler->IsEventSelected() & AliVEvent::kEMCEGA)) aTriggerFired[4] = kTRUE; | |
9be43c8e | 359 | |
cb68eb1d | 360 | Bool_t isTriggered = kFALSE; |
361 | ||
362 | for (Int_t ii=0; ii<fNTriggers; ++ii) { | |
363 | if(aTriggerFired[ii]) { | |
364 | isTriggered = kTRUE; | |
365 | fHTriggerStat->Fill(ii); | |
366 | } | |
367 | } | |
368 | ||
369 | delete[] aTriggerFired; | |
370 | ||
371 | return isTriggered; | |
372 | } | |
373 | ||
374 | //________________________________________________________________________ | |
375 | Bool_t AliAnalysisNetParticleHelper::IsEventRejected() { | |
376 | // -- Evaluate event statistics histograms | |
377 | ||
378 | Int_t *aEventCuts = new Int_t[fHEventStatMax]; | |
379 | // set aEventCuts[ii] to 1 in case of reject | |
380 | ||
381 | for (Int_t ii=0;ii<fHEventStatMax; ++ii) | |
382 | aEventCuts[ii] = 0; | |
383 | ||
384 | Int_t iCut = 0; | |
385 | ||
386 | // -- 0 - Before Physics Selection | |
387 | aEventCuts[iCut] = 0; | |
388 | ||
389 | // -- 1 - No Trigger fired | |
390 | ++iCut; | |
391 | if (!IsEventTriggered()) | |
392 | aEventCuts[iCut] = 1; | |
393 | ||
394 | // -- 2 - No Vertex | |
395 | ++iCut; | |
9be43c8e | 396 | const AliESDVertex* vtxESD = NULL; |
397 | const AliAODVertex* vtxAOD = NULL; | |
398 | if (fESD){ | |
399 | vtxESD = fESD->GetPrimaryVertexTracks(); | |
400 | if (!vtxESD) | |
401 | aEventCuts[iCut] = 1; | |
402 | } | |
403 | else if (fAOD){ | |
404 | vtxAOD = fAOD->GetPrimaryVertex(); | |
405 | if (!vtxAOD) | |
406 | aEventCuts[iCut] = 1; | |
407 | } | |
cb68eb1d | 408 | |
409 | // -- 3 - Vertex z outside cut window | |
410 | ++iCut; | |
411 | if (vtxESD){ | |
412 | if(TMath::Abs(vtxESD->GetZv()) > fVertexZMax) | |
413 | aEventCuts[iCut] = 1; | |
414 | } | |
9be43c8e | 415 | else if(vtxAOD){ |
416 | if(TMath::Abs(vtxAOD->GetZ()) > fVertexZMax) | |
417 | aEventCuts[iCut] = 1; | |
418 | } | |
cb68eb1d | 419 | else |
420 | aEventCuts[iCut] = 1; | |
478c95cf | 421 | |
cb68eb1d | 422 | // -- 4 - Centrality = -1 (no centrality or not hadronic) |
423 | ++iCut; | |
424 | if(fCentralityBin == -1.) | |
425 | aEventCuts[iCut] = 1; | |
426 | ||
427 | // -- 5 - Centrality < fCentralityMax | |
428 | ++iCut; | |
429 | if(fCentralityBin == -2.) | |
430 | aEventCuts[iCut] = 1; | |
431 | ||
432 | // -- Fill statistics / reject event | |
433 | Bool_t isRejected = FillEventStats(aEventCuts); | |
434 | ||
435 | // -- Cleanup | |
436 | delete[] aEventCuts; | |
437 | ||
438 | return isRejected; | |
439 | } | |
440 | ||
441 | /* | |
442 | * --------------------------------------------------------------------------------- | |
443 | * Accept Particle Methods - private | |
444 | * --------------------------------------------------------------------------------- | |
445 | */ | |
446 | ||
447 | //________________________________________________________________________ | |
fbb73c19 | 448 | Bool_t AliAnalysisNetParticleHelper::IsParticleAcceptedBasicCharged(AliVParticle *particle, Int_t idxMC) { |
9be43c8e | 449 | // -- Check if MC particle is accepted for basic parameters |
450 | ||
451 | if (!particle) | |
452 | return kFALSE; | |
453 | ||
9be43c8e | 454 | // -- check if charged |
0c47a116 | 455 | if (particle->Charge() == 0.0) |
9be43c8e | 456 | return kFALSE; |
0c47a116 | 457 | |
fbb73c19 | 458 | // -- check if physical primary - ESD |
459 | if (fESD) { | |
460 | if(!fStack->IsPhysicalPrimary(idxMC)) | |
461 | return kFALSE; | |
462 | } | |
463 | // -- check if physical primary - AOD | |
464 | else { | |
465 | if(!(static_cast<AliAODMCParticle*>(particle))->IsPhysicalPrimary()) | |
466 | return kFALSE; | |
467 | } | |
cb68eb1d | 468 | |
cb68eb1d | 469 | return kTRUE; |
470 | } | |
fbb73c19 | 471 | |
9be43c8e | 472 | //________________________________________________________________________ |
fbb73c19 | 473 | Bool_t AliAnalysisNetParticleHelper::IsParticleAcceptedBasicNeutral(AliVParticle *particle, Int_t idxMC) { |
9be43c8e | 474 | // -- Check if MC particle is accepted for basic parameters |
475 | ||
476 | if (!particle) | |
477 | return kFALSE; | |
cb68eb1d | 478 | |
9be43c8e | 479 | // -- check if charged |
0c47a116 | 480 | if (particle->Charge() != 0.0) |
9be43c8e | 481 | return kFALSE; |
0c47a116 | 482 | |
fbb73c19 | 483 | // -- check if physical primary - ESD |
484 | if (fESD) { | |
485 | if(!fStack->IsPhysicalPrimary(idxMC)) | |
486 | return kFALSE; | |
487 | } | |
488 | // -- check if physical primary - AOD | |
489 | else { | |
490 | if(!(static_cast<AliAODMCParticle*>(particle))->IsPhysicalPrimary()) | |
491 | return kFALSE; | |
8c6128b7 | 492 | } |
8c6128b7 | 493 | |
494 | return kTRUE; | |
495 | } | |
496 | ||
497 | //________________________________________________________________________ | |
fbb73c19 | 498 | Bool_t AliAnalysisNetParticleHelper::IsParticleAcceptedRapidity(AliVParticle *particle, Double_t &yP) { |
499 | // -- Check if particle is accepted | |
8c6128b7 | 500 | // > in rapidity |
4918c45f | 501 | // > if no pid : return kTRUE, yP = eta |
cb68eb1d | 502 | // > return 0 if not accepted |
503 | ||
478c95cf | 504 | if (!fUsePID) { |
478c95cf | 505 | yP = particle->Eta(); |
4918c45f | 506 | return kTRUE; |
478c95cf | 507 | } |
508 | ||
cb68eb1d | 509 | Double_t mP = AliPID::ParticleMass(fParticleSpecies); |
510 | ||
511 | // -- Calculate rapidities and kinematics | |
512 | Double_t p = particle->P(); | |
513 | Double_t pz = particle->Pz(); | |
514 | ||
515 | Double_t eP = TMath::Sqrt(p*p + mP*mP); | |
516 | yP = 0.5 * TMath::Log((eP + pz) / (eP - pz)); | |
517 | ||
518 | // -- Check Rapidity window | |
519 | if (TMath::Abs(yP) > fRapidityMax) | |
520 | return kFALSE; | |
521 | ||
522 | return kTRUE; | |
523 | } | |
524 | ||
4918c45f | 525 | //________________________________________________________________________ |
fbb73c19 | 526 | Bool_t AliAnalysisNetParticleHelper::IsParticleAcceptedPhi(AliVParticle *particle) { |
4918c45f | 527 | // -- Check if particle is accepted |
528 | // > in phi | |
529 | // > return 0 if not accepted | |
530 | ||
531 | if (particle->Phi() > fPhiMin && particle->Phi() <= fPhiMax) | |
532 | return kTRUE; | |
533 | else if (particle->Phi() < fPhiMin && (particle->Phi() + TMath::TwoPi()) <= fPhiMax) | |
534 | return kTRUE; | |
535 | else | |
536 | return kFALSE; | |
537 | } | |
538 | ||
cb68eb1d | 539 | //_____________________________________________________________________________ |
540 | Bool_t AliAnalysisNetParticleHelper::IsParticleFindable(Int_t label) { | |
541 | // -- Check if MC particle is findable tracks | |
542 | ||
543 | AliMCParticle *mcParticle = static_cast<AliMCParticle*>(fMCEvent->GetTrack(label)); | |
544 | if(!mcParticle) | |
545 | return kFALSE; | |
546 | ||
547 | Int_t counter; | |
548 | Float_t tpcTrackLength = mcParticle->GetTPCTrackLength(AliTracker::GetBz(), 0.05, counter, 3.0); | |
549 | ||
550 | return (tpcTrackLength > fMinTrackLengthMC); | |
551 | } | |
552 | ||
553 | /* | |
554 | * --------------------------------------------------------------------------------- | |
555 | * Accept Track Methods - public | |
556 | * --------------------------------------------------------------------------------- | |
557 | */ | |
9be43c8e | 558 | |
cb68eb1d | 559 | //________________________________________________________________________ |
478c95cf | 560 | Bool_t AliAnalysisNetParticleHelper::IsTrackAcceptedBasicCharged(AliVTrack* track) { |
cb68eb1d | 561 | // -- Check if track is accepted |
562 | // > for basic parameters | |
9be43c8e | 563 | |
cb68eb1d | 564 | if (!track) |
565 | return kFALSE; | |
566 | ||
567 | if (track->Charge() == 0) | |
568 | return kFALSE; | |
569 | ||
9be43c8e | 570 | return kTRUE; |
571 | } | |
572 | ||
cb68eb1d | 573 | //________________________________________________________________________ |
9be43c8e | 574 | Bool_t AliAnalysisNetParticleHelper::IsTrackAcceptedRapidity(AliVTrack *track, Double_t &yP) { |
cb68eb1d | 575 | // -- Check if track is accepted |
576 | // > in rapidity | |
4918c45f | 577 | // > if no pid : return kTRUE |
cb68eb1d | 578 | // > return 0 if not accepted |
579 | ||
478c95cf | 580 | if (!fUsePID) { |
581 | yP = track->Eta(); | |
582 | return kTRUE; | |
583 | } | |
584 | ||
cb68eb1d | 585 | Double_t mP = AliPID::ParticleMass(fParticleSpecies); |
586 | ||
587 | // -- Calculate rapidities and kinematics | |
588 | Double_t pvec[3]; | |
589 | track->GetPxPyPz(pvec); | |
590 | ||
9be43c8e | 591 | Double_t p = track->P(); |
cb68eb1d | 592 | Double_t eP = TMath::Sqrt(p*p + mP*mP); |
593 | yP = 0.5 * TMath::Log((eP + pvec[2]) / (eP - pvec[2])); | |
594 | ||
595 | // -- Check Rapidity window | |
596 | if (TMath::Abs(yP) > fRapidityMax) | |
597 | return kFALSE; | |
598 | ||
599 | return kTRUE; | |
600 | } | |
601 | ||
602 | //________________________________________________________________________ | |
478c95cf | 603 | Bool_t AliAnalysisNetParticleHelper::IsTrackAcceptedDCA(AliVTrack *vTrack) { |
604 | // -- Check if track is accepted - ONLY FOR ESDs so far | |
cb68eb1d | 605 | // > for DCA, if both SPD layers have hits |
478c95cf | 606 | // > For now only Implemented for ESDs |
cb68eb1d | 607 | |
608 | Bool_t isAccepted = kTRUE; | |
609 | ||
478c95cf | 610 | if (!fESD) |
611 | return isAccepted; | |
612 | ||
613 | AliESDtrack* track = dynamic_cast<AliESDtrack*>(vTrack); | |
614 | if (!track) | |
615 | return kFALSE; | |
616 | ||
cb68eb1d | 617 | // -- Get nHits SPD |
618 | if (track->HasPointOnITSLayer(0) && track->HasPointOnITSLayer(1)) { | |
619 | ||
620 | // -- Get DCA nSigmas | |
621 | Float_t dca[2], cov[3]; // dca_xy, dca_z, sigma_xy, sigma_xy_z, sigma_z | |
622 | track->GetImpactParameters(dca,cov); | |
623 | ||
624 | Float_t nSigmaCdd = (cov[0] != 0.) ? dca[0]/TMath::Sqrt(cov[0]) : -9.99; | |
625 | Float_t nSigmaCzz = (cov[2] != 0.) ? dca[1]/TMath::Sqrt(cov[2]) : -9.99; | |
626 | ||
627 | if (fNSigmaMaxCdd != 0.) { | |
628 | if (TMath::Abs(nSigmaCdd) > fNSigmaMaxCdd) | |
629 | isAccepted = kFALSE; | |
630 | } | |
631 | ||
632 | if (fNSigmaMaxCzz != 0.) { | |
633 | if (TMath::Abs(nSigmaCzz) > fNSigmaMaxCzz) | |
634 | isAccepted = kFALSE; | |
635 | } | |
636 | } | |
637 | ||
638 | return isAccepted; | |
639 | } | |
640 | ||
641 | //________________________________________________________________________ | |
9be43c8e | 642 | Bool_t AliAnalysisNetParticleHelper::IsTrackAcceptedPID(AliVTrack *track, Double_t* pid) { |
cb68eb1d | 643 | // -- Check if track is accepted |
644 | // > provides TPC and TOF nSigmas to the argument | |
645 | ||
646 | Bool_t isAcceptedTPC = kFALSE; | |
647 | Bool_t isAcceptedTOF = kTRUE; | |
478c95cf | 648 | |
649 | // -- In case not PID is used | |
650 | if (!fUsePID) { | |
651 | pid[0] = 10.; | |
652 | pid[1] = 10.; | |
653 | return kTRUE; | |
654 | } | |
cb68eb1d | 655 | |
656 | // -- Get PID | |
657 | pid[0] = fPIDResponse->NumberOfSigmasTPC(track, fParticleSpecies); | |
658 | pid[1] = fPIDResponse->NumberOfSigmasTOF(track, fParticleSpecies); | |
659 | ||
660 | // -- Check PID with TPC | |
661 | if (TMath::Abs(pid[0]) < fNSigmaMaxTPC) | |
662 | isAcceptedTPC = kTRUE; | |
663 | ||
664 | // -- Check PID with TOF | |
665 | if (isAcceptedTPC) { | |
666 | ||
667 | // Has TOF PID availible | |
4918c45f | 668 | if (fPIDResponse->CheckPIDStatus(AliPIDResponse::kTOF, track) == AliPIDResponse::kDetPidOk) { |
cb68eb1d | 669 | if (TMath::Abs(pid[1]) < fNSigmaMaxTOF) |
670 | isAcceptedTOF = kTRUE; | |
671 | else | |
672 | isAcceptedTOF = kFALSE; | |
673 | } | |
674 | ||
675 | // Has no TOF PID availible | |
676 | else { | |
d76957cf | 677 | if (track->Pt() >= fMinPtForTOFRequired) |
cb68eb1d | 678 | isAcceptedTOF = kFALSE; |
679 | else | |
680 | isAcceptedTOF = kTRUE; | |
681 | } | |
682 | } // if (isAcceptedTPC) { | |
683 | ||
684 | return (isAcceptedTPC && isAcceptedTOF); | |
685 | } | |
686 | ||
4918c45f | 687 | //________________________________________________________________________ |
688 | Bool_t AliAnalysisNetParticleHelper::IsTrackAcceptedPhi(AliVTrack *track) { | |
689 | // -- Check if track is accepted | |
690 | // > in phi | |
691 | // > return 0 if not accepted | |
692 | ||
693 | if (track->Phi() > fPhiMin && track->Phi() <= fPhiMax) | |
694 | return kTRUE; | |
695 | else if (track->Phi() < fPhiMin && (track->Phi() + TMath::TwoPi()) <= fPhiMax) | |
696 | return kTRUE; | |
697 | else | |
698 | return kFALSE; | |
699 | } | |
700 | ||
cb68eb1d | 701 | /* |
702 | * --------------------------------------------------------------------------------- | |
703 | * Helper Methods | |
704 | * --------------------------------------------------------------------------------- | |
705 | */ | |
706 | ||
707 | //________________________________________________________________________ | |
708 | void AliAnalysisNetParticleHelper::UpdateEtaCorrectedTPCPid() { | |
709 | // -- Update eta corrected TPC pid | |
710 | ||
711 | if (!fEtaCorrFunc) | |
712 | return; | |
713 | ||
714 | for (Int_t idxTrack = 0; idxTrack < fESD->GetNumberOfTracks(); ++idxTrack) { | |
715 | AliESDtrack *track = fESD->GetTrack(idxTrack); | |
716 | ||
717 | // -- Check if charged track is accepted for basic parameters | |
718 | if (!IsTrackAcceptedBasicCharged(track)) | |
719 | continue; | |
720 | ||
721 | Double_t newTPCSignal = track->GetTPCsignal() / fEtaCorrFunc->Eval(track->Eta()); | |
722 | track->SetTPCsignal(newTPCSignal, track->GetTPCsignalSigma(), track->GetTPCsignalN()); | |
723 | } | |
724 | } | |
725 | ||
726 | //________________________________________________________________________ | |
4918c45f | 727 | void AliAnalysisNetParticleHelper::BinLogAxis(const THnBase *hn, Int_t axisNumber) { |
cb68eb1d | 728 | // -- Method for the correct logarithmic binning of histograms |
4918c45f | 729 | // -- and update fMinPtForTOFRequired using the logarithmic scale |
730 | ||
731 | // -- Make logarithmic binning | |
732 | TAxis *axis = hn->GetAxis(axisNumber); | |
733 | Int_t nBins = axis->GetNbins(); | |
cb68eb1d | 734 | |
735 | Double_t from = axis->GetXmin(); | |
736 | Double_t to = axis->GetXmax(); | |
4918c45f | 737 | Double_t *newBins = new Double_t[nBins + 1]; |
cb68eb1d | 738 | |
739 | newBins[0] = from; | |
4918c45f | 740 | Double_t factor = TMath::Power(to/from, 1./nBins); |
cb68eb1d | 741 | |
4918c45f | 742 | for (int ii = 1; ii <= nBins; ii++) |
743 | newBins[ii] = factor * newBins[ii-1]; | |
478c95cf | 744 | |
4918c45f | 745 | axis->Set(nBins, newBins); |
478c95cf | 746 | |
cb68eb1d | 747 | delete [] newBins; |
4918c45f | 748 | |
749 | // -- Update MinPtForTOFRequired | |
750 | for (Int_t ii = 1; ii <= nBins; ++ii) | |
751 | if (axis->GetBinLowEdge(ii) <= fMinPtForTOFRequired && axis->GetBinLowEdge(ii) + axis->GetBinWidth(ii) > fMinPtForTOFRequired) | |
752 | fMinPtForTOFRequired = axis->GetBinLowEdge(ii) + axis->GetBinWidth(ii); | |
cb68eb1d | 753 | } |
754 | ||
755 | /////////////////////////////////////////////////////////////////////////////////// | |
756 | ||
757 | /* | |
758 | * --------------------------------------------------------------------------------- | |
759 | * Initialize - Private | |
760 | * --------------------------------------------------------------------------------- | |
761 | */ | |
762 | ||
763 | //________________________________________________________________________ | |
764 | void AliAnalysisNetParticleHelper::InitializeEventStats() { | |
765 | // -- Initialize event statistics histograms | |
766 | ||
cb68eb1d | 767 | fHEventStat0 = new TH1F("fHEventStat0","Event cut statistics 0;Event Cuts;Events", fHEventStatMax,-0.5,fHEventStatMax-0.5); |
768 | fHEventStat1 = new TH1F("fHEventStat1","Event cut statistics 1;Event Cuts;Events", fHEventStatMax,-0.5,fHEventStatMax-0.5); | |
769 | ||
770 | for ( Int_t ii=0; ii < fHEventStatMax-1; ii++ ) { | |
4918c45f | 771 | fHEventStat0->GetXaxis()->SetBinLabel(ii+1, AliAnalysisNetParticleHelper::fgkEventNames[ii]); |
772 | fHEventStat1->GetXaxis()->SetBinLabel(ii+1, AliAnalysisNetParticleHelper::fgkEventNames[ii]); | |
cb68eb1d | 773 | } |
4918c45f | 774 | |
775 | fHEventStat0->GetXaxis()->SetBinLabel(fHEventStatMax, Form("Centrality [0-%s]%%", AliAnalysisNetParticleHelper::fgkCentralityMaxNames[fCentralityBinMax-1])); | |
776 | fHEventStat1->GetXaxis()->SetBinLabel(fHEventStatMax, Form("Centrality [0-%s]%%", AliAnalysisNetParticleHelper::fgkCentralityMaxNames[fCentralityBinMax-1])); | |
cb68eb1d | 777 | } |
778 | ||
779 | //________________________________________________________________________ | |
780 | void AliAnalysisNetParticleHelper::InitializeTriggerStats() { | |
781 | // -- Initialize trigger statistics histograms | |
782 | ||
cb68eb1d | 783 | fHTriggerStat = new TH1F("fHTriggerStat","Trigger statistics;Trigger;Events", fNTriggers,-0.5,fNTriggers-0.5); |
784 | ||
785 | for ( Int_t ii=0; ii < fNTriggers; ii++ ) | |
4918c45f | 786 | fHTriggerStat->GetXaxis()->SetBinLabel(ii+1, AliAnalysisNetParticleHelper::fgkTriggerNames[ii]); |
cb68eb1d | 787 | } |
788 | ||
789 | //________________________________________________________________________ | |
790 | void AliAnalysisNetParticleHelper::InitializeCentralityStats() { | |
791 | // -- Initialize trigger statistics histograms | |
792 | ||
cb68eb1d | 793 | fHCentralityStat = new TH1F("fHCentralityStat","Centrality statistics;Centrality Bins;Events", |
794 | fNCentralityBins,-0.5,fNCentralityBins-0.5); | |
795 | ||
796 | for ( Int_t ii=0; ii < fNCentralityBins; ii++ ) | |
4918c45f | 797 | fHCentralityStat->GetXaxis()->SetBinLabel(ii+1, AliAnalysisNetParticleHelper::fgkCentralityNames[ii]); |
cb68eb1d | 798 | } |
799 | ||
800 | //________________________________________________________________________ | |
801 | Int_t AliAnalysisNetParticleHelper::InitializeEtaCorrection(Bool_t isMC) { | |
802 | // -- Initialize eta correction maps for TPC pid | |
803 | ||
804 | TFile fileEtaCorrMaps("${ALICE_ROOT}/PWGDQ/dielectron/files/EtaCorrMaps.root"); | |
805 | if (!fileEtaCorrMaps.IsOpen()) | |
806 | return -1; | |
807 | ||
808 | TList *keyList = fileEtaCorrMaps.GetListOfKeys(); | |
809 | ||
810 | TString sList(""); | |
811 | sList = (isMC) ? "LHC11a10" : "LHC10h.pass2"; | |
812 | ||
813 | for (Int_t idx = 0; idx < keyList->GetEntries(); ++idx) { | |
814 | TString keyName = keyList->At(idx)->GetName(); | |
815 | TPRegexp reg(keyName); | |
816 | if (reg.MatchB(sList)){ | |
817 | AliInfo(Form("Using Eta Correction Function: %s",keyName.Data())); | |
818 | fEtaCorrFunc = static_cast<TF1*>(fileEtaCorrMaps.Get(keyName.Data())); | |
819 | return 0; | |
820 | } | |
821 | } | |
822 | ||
823 | return -2; | |
824 | } | |
825 | ||
cb68eb1d | 826 | /* |
827 | * --------------------------------------------------------------------------------- | |
828 | * Event / Trigger Statistics - private | |
829 | * --------------------------------------------------------------------------------- | |
830 | */ | |
831 | ||
832 | //________________________________________________________________________ | |
833 | Bool_t AliAnalysisNetParticleHelper::FillEventStats(Int_t *aEventCuts) { | |
834 | // -- Fill event / centrality statistics | |
835 | ||
836 | Bool_t isRejected = kFALSE; | |
837 | ||
838 | // -- Fill event statistics | |
839 | for (Int_t idx = 0; idx < fHEventStatMax ; ++idx) { | |
9be43c8e | 840 | |
cb68eb1d | 841 | if (aEventCuts[idx]) |
842 | isRejected = kTRUE; | |
843 | else | |
844 | fHEventStat0->Fill(idx); | |
845 | } | |
846 | ||
847 | for (Int_t idx = 0; idx < fHEventStatMax; ++idx) { | |
848 | if (aEventCuts[idx]) | |
849 | break; | |
850 | fHEventStat1->Fill(idx); | |
851 | } | |
852 | ||
853 | // -- Fill centrality statistics of accepted events | |
854 | if (!isRejected) | |
855 | fHCentralityStat->Fill(fCentralityBin); | |
856 | ||
857 | return isRejected; | |
858 | } |