]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/SPECTRA/LambdaK0PbPb/AliAnalysisTaskLukeV0.cxx
Slimmed down luke's analysis task
[u/mrichter/AliRoot.git] / PWG2 / SPECTRA / LambdaK0PbPb / AliAnalysisTaskLukeV0.cxx
CommitLineData
45b90328 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: AliAnalysisTaskLukeV0.cxx 46301 2011-01-06 14:25:27Z agheata $ */
17
18/* AliAnalysisTaskLukeV0.cxx
19 *
20 * Task analysing lambda, antilambda & K0 spectra
21 *
22 * Based on tutorial example from offline pages
23 * Edited by Arvinder Palaha
24 * Adapted by Luke Hanratty
25 *
26 */
27
28#include "AliAnalysisTaskLukeV0.h"
29
30#include "Riostream.h"
31#include "TChain.h"
32#include "TTree.h"
33#include "TH1F.h"
34#include "TH2F.h"
35#include "TCanvas.h"
36#include "TList.h"
37#include "TPDGCode.h"
38
39#include "AliAnalysisTaskSE.h"
40#include "AliAnalysisManager.h"
41#include "AliStack.h"
42#include "AliESDtrackCuts.h"
43#include "AliESDEvent.h"
44#include "AliESDv0.h"
45#include "AliESDInputHandler.h"
46#include "AliAODEvent.h"
47#include "AliMCEvent.h"
48#include "AliMCVertex.h"
49#include "AliPID.h"
50#include "AliPIDResponse.h"
51
52ClassImp(AliAnalysisTaskLukeV0)
53
54//________________________________________________________________________
55AliAnalysisTaskLukeV0::AliAnalysisTaskLukeV0() // All data members should be initialised here
56 :AliAnalysisTaskSE(),
57 fOutputList(0),
58 fTrackCuts(0),
59 fPIDResponse(0),
45b90328 60 fHistCosPA(0),
45b90328 61 fHistDCAV0Daughters(0),
62 fHistDecayL(0),
45b90328 63 fHistImpactxyN(0),
64 fHistImpactzN(0),
65 fHistImpactxyP(0),
66 fHistImpactzP(0),
889bc324 67 fHistMCLambdacTau(0),
68 fHistMCLambdaNotcTau(0),
69 fHistMCLambdaDecayL(0),
70 fHistMCLambdaNotDecayL(0),
45b90328 71 fHistMcNLambdaPrimary(0),
72 fHistMcNLambda(0),
73 fHistMcNAntilambda(0),
74 fHistMcNKshort(0),
45b90328 75 fHistMK0(0),
45b90328 76 fHistMLa(0),
45b90328 77 fHistMLb(0),
45b90328 78 fHistNLambda(0),
79 fHistNV0(0),
45b90328 80 fHistPtV0(0),
81 fHistPVZ(0),
82 fHistTauLa(0),
45b90328 83 fHistV0Z(0),
84 fHistZ(0),
45b90328 85 fHistBetheBlochTPCNeg(0),
86 fHistBetheBlochTPCPos(0),
45b90328 87 fHistImpactxyImpactz(0),
45b90328 88 fHistMcPMK0Pt(0),
89 fHistMcPMLaPt(0),
90 fHistMcPMLbPt(0),
45b90328 91 fHistMcV0MK0Pt(0),
92 fHistMcV0MLaPt(0),
93 fHistMcV0MLbPt(0),
45b90328 94 fHistMK0Pt(0),
45b90328 95 fHistMLaPt(0),
45b90328 96 fHistMLbPt(0),
45b90328 97 fHistPtArm(0),
45b90328 98 fHistRZ(0),
45b90328 99 fHistXZ(0),
100 fHistYZ(0) // The last in the above list should not have a comma after it
101{
102 // Dummy constructor ALWAYS needed for I/O.
103}
104
105//________________________________________________________________________
106AliAnalysisTaskLukeV0::AliAnalysisTaskLukeV0(const char *name) // All data members should be initialised here
107 :AliAnalysisTaskSE(name),
889bc324 108 fOutputList(0),
45b90328 109 fTrackCuts(0),
110 fPIDResponse(0),
45b90328 111 fHistCosPA(0),
45b90328 112 fHistDCAV0Daughters(0),
113 fHistDecayL(0),
45b90328 114 fHistImpactxyN(0),
115 fHistImpactzN(0),
116 fHistImpactxyP(0),
117 fHistImpactzP(0),
889bc324 118 fHistMCLambdacTau(0),
119 fHistMCLambdaNotcTau(0),
120 fHistMCLambdaDecayL(0),
121 fHistMCLambdaNotDecayL(0),
45b90328 122 fHistMcNLambdaPrimary(0),
123 fHistMcNLambda(0),
124 fHistMcNAntilambda(0),
125 fHistMcNKshort(0),
45b90328 126 fHistMK0(0),
45b90328 127 fHistMLa(0),
45b90328 128 fHistMLb(0),
45b90328 129 fHistNLambda(0),
130 fHistNV0(0),
45b90328 131 fHistPtV0(0),
132 fHistPVZ(0),
133 fHistTauLa(0),
45b90328 134 fHistV0Z(0),
135 fHistZ(0),
45b90328 136 fHistBetheBlochTPCNeg(0),
137 fHistBetheBlochTPCPos(0),
45b90328 138 fHistImpactxyImpactz(0),
45b90328 139 fHistMcPMK0Pt(0),
140 fHistMcPMLaPt(0),
141 fHistMcPMLbPt(0),
45b90328 142 fHistMcV0MK0Pt(0),
143 fHistMcV0MLaPt(0),
144 fHistMcV0MLbPt(0),
45b90328 145 fHistMK0Pt(0),
45b90328 146 fHistMLaPt(0),
45b90328 147 fHistMLbPt(0),
45b90328 148 fHistPtArm(0),
45b90328 149 fHistRZ(0),
45b90328 150 fHistXZ(0),
889bc324 151 fHistYZ(0) // The last in the above list should not have a comma after it
45b90328 152{
153 // Constructor
154 // Define input and output slots here (never in the dummy constructor)
155 // Input slot #0 works with a TChain - it is connected to the default input container
156 // Output slot #1 writes into a TH1 container
157 DefineOutput(1, TList::Class()); // for output list
158}
159
160//________________________________________________________________________
161AliAnalysisTaskLukeV0::~AliAnalysisTaskLukeV0()
162{
163 // Destructor. Clean-up the output list, but not the histograms that are put inside
164 // (the list is owner and will clean-up these histograms). Protect in PROOF case.
165 if (fOutputList && !AliAnalysisManager::GetAnalysisManager()->IsProofMode()) {
166 delete fOutputList;
167 }
168 if (fTrackCuts) delete fTrackCuts;
169}
170
171//________________________________________________________________________
172void AliAnalysisTaskLukeV0::UserCreateOutputObjects()
173{
174 // Create histograms
175 // Called once (on the worker node)
176
177 fOutputList = new TList();
178 fOutputList->SetOwner(); // IMPORTANT!
179
180 fTrackCuts = new AliESDtrackCuts();
181
182 AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager();
183 AliInputEventHandler* inputHandler = (AliInputEventHandler*) (man->GetInputEventHandler());
184 fPIDResponse = inputHandler->GetPIDResponse();
185
45b90328 186 // lambda plot parameters
187 int div = 96;
188 float max = 1.2;
189 float min = 1.08;
190
191 // Create remaining histograms
192 // TH1F first
45b90328 193 fHistCosPA = new TH1F("fHistCosPA", "Cosine of Pointing Angle of V0s; Cos PA; N(v0s)",202,0.8,1.01);
45b90328 194 fHistDCAV0Daughters = new TH1F("fHistDCAV0Daughters", "DCA between V0 daughters; DCA (cm); N V0s", 100, 0, 2);
195 fHistDecayL = new TH1F("fHistDecayL", "Distance between V0 and PV; Distance(cm); N(v0s)",200,-0.1,30);
45b90328 196 fHistImpactxyN = new TH1F("fHistImpactxyN", "RSM DCA between negative particle and primary vertex in xy plane; RSM DCA (cm); N(v0s)",100,0,1);
197 fHistImpactzN = new TH1F("fHistImpactzN", "RSM DCA between negative particle and primary vertex in z direction; RSM DCA (cm); N(v0s)",100,0,1);
198 fHistImpactxyP = new TH1F("fHistImpactxyP", "RSM DCA between positive particle and primary vertex in xy plane; RSM DCA (cm); N(v0s)",100,0,1);
199 fHistImpactzP = new TH1F("fHistImpactzP", "RSM DCA between positive particle and primary vertex in z direction; RSM DCA (cm); N(v0s)",100,0,1);
889bc324 200 fHistMCLambdacTau = new TH1F("fHistMCLambdacTau", "Lifetime under Lambda mass hypothesis of MC lambda; Lifetime(s); N(v0s)",200,0,100);
201 fHistMCLambdaNotcTau = new TH1F("fHistMCLambdaNotcTau", "Lifetime under Lambda mass hypothesis of MC lambda background; Lifetime(s); N(v0s)",200,0,100);
202 fHistMCLambdaDecayL = new TH1F("fHistMCLambdaDecayL", "Distance between V0 and PV of MC Lambda; Distance(cm); N(v0s)",200,-0.1,30);
203 fHistMCLambdaNotDecayL = new TH1F("fHistMCLambdaNotDecayL", "Distance between V0 and PV of MC Lambda background; Distance(cm); N(v0s)",200,-0.1,30);
45b90328 204 fHistMcNLambdaPrimary = new TH1F("fHistMcNLambdaPrimary","Number of primary lambdas in MC; NLambdas; i",6,-0.25,2.25);
205 fHistMcNLambda = new TH1F("fHistMcNLambda","Number of lambdas in MC; NLambdas; i",31,-0.5,30);
206 fHistMcNAntilambda = new TH1F("fHistMcNAntilambda","Number of antilambdas in MC; NAntiLambdas; i",31,-0.5,30);
207 fHistMcNKshort = new TH1F("fHistMcNKshort","Number of K0s in MC; NKshort; i",31,-0.5,30);
45b90328 208 fHistMK0 = new TH1F("fHistMK0","K0Short Mass; M(#pi^{+}#pi^{-}) (GeV/c^{2}); dN/dM (0.12 GeV/c^{2})^{-1}",140,0.414,0.582);
45b90328 209 fHistMLa = new TH1F("fHistMLa","Lambda Mass; M(p#pi^{-}) (GeV/c^{2}); dN/dM (0.125 GeV/c^{2})^{-1}",div,min,max);
45b90328 210 fHistMLb = new TH1F("fHistMLb","AntiLambda Mass; M(#bar{p}#pi^{+}) (GeV/c^{2}); dN/dM (0.125 GeV/c^{2})^{-1}",div,min,max);
45b90328 211 fHistNLambda = new TH1F("fHistNLambda", "Number of lambda per event; N(lambda); N(events)",50,-0.5,49.5);
212 fHistNV0 = new TH1F("fHistNV0","V0 frequency distribution; Number of V0 Candidates",1000,0,100000);
45b90328 213 fHistPtV0 = new TH1F("fHistPtV0","V0 P_{T}; P_{T} (GeV/c);dN/dP_{T} (GeV/c)^{-1}",40,0.,4.);
214 fHistPVZ = new TH1F("fHistPVZ","Z primary; Z (cm); Counts",100,-10,10);
215 fHistTauLa = new TH1F("fHistTauLa", "Lifetime under Lambda mass hypothesis; Lifetime(s); N(v0s)",200,0,100);
45b90328 216 fHistV0Z = new TH1F("fHistV0Z","Z decay; Z (cm); Counts",100,-10,10);
217 fHistZ = new TH1F("fHistZ","Z decay - Z primary; Z (cm); Counts",100,-10,10);
218
219 //TH2F follow
45b90328 220 fHistBetheBlochTPCNeg = new TH2F("fHistBetheBlochTPCNeg","-dE/dX against Momentum for negative daughter from TPC; Log10 P (GeV); -dE/dx (keV/cm ?)",1000,-1,1,1000,0,200);
221 fHistBetheBlochTPCPos = new TH2F("fHistBetheBlochTPCPos","-dE/dX against Momentum for positive daughter from TPC; Log10 P (GeV); -dE/dx (keV/cm ?)",1000,-1,1,1000,0,200);
45b90328 222 fHistImpactxyImpactz = new TH2F("fHistImpactxyImpactz", "RSM DCA between negative particle and primary vertex in xy plane; RSM DCA xy (cm); RSM DCA z (cm)",100,0,1,100,0,10);
45b90328 223 fHistMcPMK0Pt = new TH2F("fHistMcPMK0Pt","Monte Carlo primary K0 Mass versus Pt; P_{perp} (GeV/c); K0 Mass (GeV/c^2)",200,0,10,140,0.414,0.582);
224 fHistMcPMLaPt = new TH2F("fHistMcPMLaPt","Monte Carlo primary (& sigma0) Lambda Mass versus Pt; P_{perp} (GeV/c); M(p#pi^{-}) (GeV/c^2)",200,0,10,96,1.08,1.2);
225 fHistMcPMLbPt = new TH2F("fHistMcPMLbPt","Monte Carlo primary (& sigma0) AntiLambda Mass versus Pt; P_{perp} (GeV/c); M(#bar{p}#pi^{+}) (GeV/c^2)",200,0,10,96,1.08,1.2);
45b90328 226 fHistMcV0MK0Pt = new TH2F("fHistMcV0MK0Pt","Monte Carlo V0s passing cuts. K0 Mass versus Pt; P_{perp} (GeV/c); K0 Mass (GeV/c^2)",200,0,10,140,0.414,0.582);
227 fHistMcV0MLaPt = new TH2F("fHistMcV0MLaPt","Monte Carlo V0s passing cuts. Lambda Mass versus Pt; P_{perp} (GeV/c); Lambda Mass (GeV/c^2)",200,0,10,96,1.08,1.2);
228 fHistMcV0MLbPt = new TH2F("fHistMcV0MLbPt","Monte Carlo V0s passing cuts. Antilambda Mass versus Pt; P_{perp} (GeV/c); Antilambda Mass (GeV/c^2)",200,0,10,96,1.08,1.2);
45b90328 229 fHistMK0Pt = new TH2F("fHistMK0Pt","K0 Mass versus Pt; P_{perp} (GeV/c); K0 Mass (GeV/c^2)",200,0,10,140,0.414,0.582);
45b90328 230 fHistMLaPt = new TH2F("fHistMLaPt","Lambda Mass versus Pt; P_{perp} (GeV/c); M(p#pi^{-}) (GeV/c^2)",200,0,10,96,1.08,1.2);
45b90328 231 fHistMLbPt = new TH2F("fHistMLbPt","AntiLambda Mass versus Pt; P_{perp} (GeV/c); M(#bar{p}#pi^{+}) (GeV/c^2)",200,0,10,96,1.08,1.2);
45b90328 232 fHistPtArm = new TH2F("fHistPtArm","Podolanski-Armenteros Plot; #alpha; P_{perp} (GeV/c)",40,-1,1,80,0,0.5);
45b90328 233 fHistPtV0Z = new TH2F("fHistPtV0Z","Pt of V0 vs Z position; Pt (GeV/c); Z (cm)",200,-0.1,1.9,200,-50,50);
234 fHistRZ = new TH2F("fHistRZ","R decay versus Z decay; Z (cm); R (cm)",100,-50,50,120,0,220);
45b90328 235 fHistXZ = new TH2F("fHistXZ","X decay versus Z decay; Z (cm); X (cm)",100,-50,50,200,-200,200);
236 fHistYZ = new TH2F("fHistYZ","Y decay versus Z decay; Z (cm); Y (cm)",100,-50,50,200,-200,200);
237
238
239
240 // All histograms must be added to output list
241
45b90328 242 fOutputList->Add(fHistCosPA);
45b90328 243 fOutputList->Add(fHistDCAV0Daughters);
244 fOutputList->Add(fHistDecayL);
45b90328 245 fOutputList->Add(fHistImpactxyN);
246 fOutputList->Add(fHistImpactzN);
247 fOutputList->Add(fHistImpactxyP);
248 fOutputList->Add(fHistImpactzP);
889bc324 249 fOutputList->Add(fHistMCLambdacTau);
250 fOutputList->Add(fHistMCLambdaNotcTau);
251 fOutputList->Add(fHistMCLambdaDecayL);
252 fOutputList->Add(fHistMCLambdaNotDecayL);
45b90328 253 fOutputList->Add(fHistMcNLambdaPrimary);
254 fOutputList->Add(fHistMcNLambda);
255 fOutputList->Add(fHistMcNAntilambda);
256 fOutputList->Add(fHistMcNKshort);
45b90328 257 fOutputList->Add(fHistMK0);
45b90328 258 fOutputList->Add(fHistMLa);
45b90328 259 fOutputList->Add(fHistMLb);
45b90328 260 fOutputList->Add(fHistNLambda);
261 fOutputList->Add(fHistNV0);
45b90328 262 fOutputList->Add(fHistPtV0);
263 fOutputList->Add(fHistPVZ);
264 fOutputList->Add(fHistTauLa);
45b90328 265 fOutputList->Add(fHistV0Z);
266 fOutputList->Add(fHistZ);
45b90328 267 fOutputList->Add(fHistBetheBlochTPCNeg);
268 fOutputList->Add(fHistBetheBlochTPCPos);
45b90328 269 fOutputList->Add(fHistImpactxyImpactz);
45b90328 270 fOutputList->Add(fHistMcPMK0Pt);
271 fOutputList->Add(fHistMcPMLaPt);
272 fOutputList->Add(fHistMcPMLbPt);
45b90328 273 fOutputList->Add(fHistMcV0MK0Pt);
274 fOutputList->Add(fHistMcV0MLaPt);
275 fOutputList->Add(fHistMcV0MLbPt);
45b90328 276 fOutputList->Add(fHistMK0Pt);
45b90328 277 fOutputList->Add(fHistMLaPt);
45b90328 278 fOutputList->Add(fHistMLbPt);
45b90328 279 fOutputList->Add(fHistPtArm);
45b90328 280 fOutputList->Add(fHistRZ);
45b90328 281 fOutputList->Add(fHistXZ);
282 fOutputList->Add(fHistYZ);
283
284
285 PostData(1, fOutputList); // Post data for ALL output slots >0 here, to get at least an empty histogram
286}
287
288//________________________________________________________________________
289void AliAnalysisTaskLukeV0::UserExec(Option_t *)
290{
291 // Main loop
292 // Called for each event
293
294 // paramaters used for most cuts, to minimise editing
295 double cutCosPa(0.998), cutcTau(2);
296 double cutNImpact(-999), cutDCA(0.4);
297 double cutBetheBloch(3);
298 double cutMinNClustersTPC(70), cutMaxChi2PerClusterTPC(-999);
889bc324 299 double isMonteCarlo(true);
45b90328 300 double cutEta(0.8);
301
302 //Track Cuts set here
303 if(cutMinNClustersTPC != -999)
304 {(fTrackCuts->SetMinNClustersTPC(int(cutMinNClustersTPC)));}
305 if(cutMaxChi2PerClusterTPC != -999)
306 {fTrackCuts->SetMaxChi2PerClusterTPC(cutMaxChi2PerClusterTPC);}
307 fTrackCuts->SetAcceptKinkDaughters(kFALSE);
308 fTrackCuts->SetRequireTPCRefit(kTRUE);
309
310
311 // Create pointer to reconstructed event
312
313 AliVEvent *event = InputEvent();
314 if (!event) { Printf("ERROR: Could not retrieve event"); return; }
315
316 // create pointer to event
317 AliESDEvent* fESD = dynamic_cast<AliESDEvent*>(event);
318 if (!fESD) {
319 AliError("Cannot get the ESD event");
320 return;
321 }
322
323 /*********************************************************************/
324 // MONTE CARLO SECTION
325 // This section loops over all MC tracks
326
327 int nLambdaMC = 0;
328 int nAntilambdaMC = 0;
329 int nKshortMC = 0;
330
331 if(isMonteCarlo)
332 {
333
334 // If the task accesses MC info, this can be done as in the commented block below:
335
336 // Create pointer to reconstructed event
337 AliMCEvent *mcEvent = MCEvent();
338 if (!mcEvent)
339 {
340 Printf("ERROR: Could not retrieve MC event");
341 //return;
342 }
343 else
344 {
345 Printf("MC particles: %d", mcEvent->GetNumberOfTracks());
346 }
347
348 // set up a stack for use in check for primary/stable particles
349 AliStack* mcStack = mcEvent->Stack();
350 if( !mcStack ) { Printf( "Stack not available"); return; }
351
352 AliMCVertex *mcpv = (AliMCVertex *) mcEvent->GetPrimaryVertex();
353 Double_t mcpvPos[3];
354 if (mcpv != 0)
355 {
356 mcpv->GetXYZ(mcpvPos);
357 }
358 else
359 {
360 Printf("ERROR: Could not resolve MC primary vertex");
361 return;
362 }
363
364 //loop over all MC tracks
365 for(Int_t iMCtrack = 0; iMCtrack < mcEvent->GetNumberOfTracks(); iMCtrack++)
366 {
367
368 //booleans to check if track is La, Lb, K0 and primary
369 bool lambdaMC = false;
370 bool antilambdaMC = false;
371 bool kshortMC = false;
372 bool isprimaryMC = false;
373
374 AliMCParticle *mcPart = dynamic_cast<AliMCParticle *>(mcEvent->GetTrack(iMCtrack));
375
376 if(mcPart->PdgCode() == kLambda0)
377 {
378 lambdaMC = true;
379 nLambdaMC++;
380 }
381 else if(mcPart->PdgCode() == kK0Short)
382 {
383 kshortMC = true;
384 nKshortMC++;
385 }
386 else if(mcPart->PdgCode() == kLambda0Bar)
387 {
388 antilambdaMC = true;
389 nAntilambdaMC++;
390 }
391
45b90328 392
45b90328 393 Int_t motherLabel = mcPart->GetMother();
45b90328 394 AliMCParticle *mcMother = dynamic_cast<AliMCParticle *>(mcEvent->GetTrack(motherLabel));
45b90328 395 double motherType = -1;
396 if(motherLabel >= 0)
397 {motherType = mcMother->PdgCode();}
398
889bc324 399 // this block of code is used to include primary Sigma0 decays as primary lambda/antilambda
45b90328 400 bool sigma0MC = false;
401 if(motherType == 3212 || motherType == -3212)
402 {
403 if(mcEvent->IsPhysicalPrimary(motherLabel))
404 {sigma0MC = true;}
405 }
406
407
408 if(mcEvent->IsPhysicalPrimary(iMCtrack) || sigma0MC)
409 {
410 isprimaryMC = true;
411 if(lambdaMC)
412 {
413 fHistMcNLambdaPrimary->Fill(1);
45b90328 414 if(TMath::Abs(mcPart->Y())<=0.5)
889bc324 415 {fHistMcPMLaPt->Fill(mcPart->Pt(),mcPart->M());}
45b90328 416 }
417 if(antilambdaMC)
418 {
419 if(TMath::Abs(mcPart->Y())<=0.5)
420 {fHistMcPMLbPt->Fill(mcPart->Pt(),mcPart->M());}
421 }
422 if(kshortMC)
423 {
424 if(TMath::Abs(mcPart->Y())<=0.5)
425 {fHistMcPMK0Pt->Fill(mcPart->Pt(),mcPart->M());}
426 }
427 }
428 else
429 {
430 isprimaryMC = false;
431 if(lambdaMC)
432 {
433 fHistMcNLambdaPrimary->Fill(2);
45b90328 434 }
435 }
436
437 }
438
439
440 }
441
442
443 fHistMcNLambda->Fill(nLambdaMC);
444 fHistMcNAntilambda->Fill(nAntilambdaMC);
445 fHistMcNKshort->Fill(nKshortMC);
446
447 //END OF MONTE CARLO SECTION
448 /*********************************************************************/
449
450
451
452
453
454 // Do some fast cuts first
455 // check for good reconstructed vertex
456 if(!(fESD->GetPrimaryVertex()->GetStatus())) return;
457 // if vertex is from spd vertexZ, require more stringent cut
458 if (fESD->GetPrimaryVertex()->IsFromVertexerZ()) {
459 if (fESD->GetPrimaryVertex()->GetDispersion()>0.02 || fESD->GetPrimaryVertex()->GetZRes()>0.25 ) return; // bad vertex from VertexerZ
460 }
461
462 Double_t tV0Position[3];
463 Double_t tPVPosition[3];
464 Double_t radius;
465
466 // physics selection
467 UInt_t maskIsSelected = ((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected();
468 if(!maskIsSelected)
469 {
470 //printf("Event failed physics selection\n");
471 return;
472 }
473
474 //if additional initial cuts wanted, can set conditions here
475 bool isCut = (fESD->GetNumberOfTracks()==0);
476 if (isCut)
477 {return;}
478
479 //gets primary vertex for the event
480 const AliESDVertex *kPv = ((AliESDEvent *)fESD)->GetPrimaryVertex();
481 if ( kPv != 0 )
482 {
483 tPVPosition[0] = kPv->GetXv();
484 tPVPosition[1] = kPv->GetYv();
485 tPVPosition[2] = kPv->GetZv();
486 if( tPVPosition[2] == 0. )
487 {
488 //printf("WARNING: Primary vertex a Z = 0, aborting\n");
489 return;
490 }
491 }
492 else
493 {
494 //printf("ERROR: Primary vertex not found\n");
495 return;
496 }
497 if( !kPv->GetStatus())
498 {return;}
499
500
501
502
503 int nLambda(0);
504 int nV0s(0);
45b90328 505
506 // V0 loop - runs over every v0 in the event
507 for (Int_t iV0 = 0; iV0 < fESD->GetNumberOfV0s(); iV0++)
508 {
509
510 AliESDv0 *v0 = fESD->GetV0(iV0);
511 if (!v0)
512 {
513 printf("ERROR: Could not receive v0 %d\n", iV0);
514 continue;
515 }
516
517 bool lambdaCandidate = true;
518 bool antilambdaCandidate = true;
519 bool kshortCandidate = true;
520
521 // keep only events of interest for fHistMLa plots
522
523 if (v0->GetEffMass(4,2) < 1.08 || v0->GetEffMass(4,2) > 1.2 || TMath::Abs(v0->Y(3122))>0.5 )
524 {lambdaCandidate = false;}
525 if (v0->GetEffMass(2,4) < 1.08 || v0->GetEffMass(2,4) > 1.2 || TMath::Abs(v0->Y(-3122))>0.5)
526 {antilambdaCandidate = false;}
527 if (v0->GetEffMass(2,2) < 0.414 || v0->GetEffMass(2,2) > 0.582 || TMath::Abs(v0->Y(310))>0.5)
528 {kshortCandidate = false;}
529 if (v0->GetOnFlyStatus())
530 {continue;}
531
532 if(!isMonteCarlo)
533 {if(lambdaCandidate == false && antilambdaCandidate == false && kshortCandidate == false)
534 {continue;}}
535
536
537 //gets details of the v0
538 v0->GetXYZ(tV0Position[0],tV0Position[1],tV0Position[2]);
539 radius = TMath::Sqrt(tV0Position[0]*tV0Position[0]+tV0Position[1]*tV0Position[1]);
540
541 double decayLength = (sqrt((tV0Position[0]-tPVPosition[0])*(tV0Position[0]-tPVPosition[0])+(tV0Position[1]-tPVPosition[1])*(tV0Position[1]-tPVPosition[1])+(tV0Position[2]-tPVPosition[2])*(tV0Position[2]-tPVPosition[2])));
542 double cTauLa = decayLength*(v0->GetEffMass(4,2))/(v0->P());
543 double cTauLb = decayLength*(v0->GetEffMass(2,4))/(v0->P());
544 double cTauK0 = decayLength*(v0->GetEffMass(2,2))/(v0->P());
545
546 Int_t indexP, indexN;
547 indexP = TMath::Abs(v0->GetPindex());
548 AliESDtrack *posTrack = ((AliESDEvent*)fESD)->GetTrack(indexP);
549 indexN = TMath::Abs(v0->GetNindex());
550 AliESDtrack *negTrack = ((AliESDEvent*)fESD)->GetTrack(indexN);
551
552 if(!posTrack || !negTrack)
553 {continue;}
554
555 double pTrackMomentum[3];
556 double nTrackMomentum[3];
557 double pV0x, pV0y, pV0z;
558 posTrack->GetConstrainedPxPyPz(pTrackMomentum);
559 negTrack->GetConstrainedPxPyPz(nTrackMomentum);
560 v0->GetPxPyPz(pV0x, pV0y, pV0z);
561
889bc324 562 //const double kMLambda = 1.115;
45b90328 563 const double kMProton = 0.938;
889bc324 564 //const double kMPi = 0.140;
45b90328 565
566 double pPos2 = sqrt(pTrackMomentum[0]*pTrackMomentum[0]+pTrackMomentum[1]*pTrackMomentum[1]+pTrackMomentum[2]*pTrackMomentum[2]);
567 double pNeg2 = sqrt(nTrackMomentum[0]*nTrackMomentum[0]+nTrackMomentum[1]*nTrackMomentum[1]+nTrackMomentum[2]*nTrackMomentum[2]);
889bc324 568 //double pV02 = sqrt(pV0x*pV0x+pV0y*pV0y+pV0z*pV0z);
45b90328 569
570 //to prevent segfaults when ratios etc taken
889bc324 571 //if(pV02 < 0.01 || pPos2 <0.01 || pNeg2 <0.01)
572 //{continue;}
45b90328 573
574 Float_t pImpactxy(0), pImpactz(0);
575 Float_t nImpactxy(0), nImpactz(0);
576 posTrack->GetImpactParameters(pImpactxy,pImpactz);
577 negTrack->GetImpactParameters(nImpactxy,nImpactz);
578 nImpactxy = sqrt((nImpactxy*nImpactxy));
579 nImpactz = sqrt((nImpactz *nImpactz ));
580 pImpactxy = sqrt((pImpactxy*pImpactxy));
581 pImpactz = sqrt((pImpactz *pImpactz ));
582
583 /*********************************************************************/
584 // Cuts are implemented here.
585
586 if(!(fTrackCuts->IsSelected(posTrack)) || !(fTrackCuts->IsSelected(negTrack)))
587 {
588 lambdaCandidate = false;
589 antilambdaCandidate = false;
590 kshortCandidate = false;
591 }
592
593 //extra cut to account for difference between p2 & p1 data
594 if(nImpactxy < 0.1 || pImpactxy < 0.1)
595 {
596 lambdaCandidate = false;
597 antilambdaCandidate = false;
598 kshortCandidate = false;
599 }
600
601 //psuedorapidity cut
602 if(cutEta != -999)
603 {
604 if(TMath::Abs(posTrack->Eta()) > cutEta || TMath::Abs(negTrack->Eta()) >cutEta)
605 {
606 lambdaCandidate = false;
607 antilambdaCandidate = false;
608 kshortCandidate = false;
609 }
610 }
611
612 //pointing angle cut
613 if(cutCosPa != -999)
614 {
615 if (v0->GetV0CosineOfPointingAngle(tPVPosition[0],tPVPosition[1],tPVPosition[2]) < cutCosPa)
616 {
617 lambdaCandidate = false;
618 antilambdaCandidate = false;
619 kshortCandidate = false;
620 }
621 }
622
623 //lifetime cut
624 if(cutcTau != -999)
625 {
626 if(cTauLa < cutcTau)
627 {
628 lambdaCandidate = false;
629 }
630 if(cTauLb < cutcTau)
631 {
632 antilambdaCandidate = false;
633 }
634 if(cTauK0 < cutcTau)
635 {
636 kshortCandidate = false;
637 }
638
639 }
640
641 // Impact paramater cut (on neg particle)
642 if(cutNImpact != -999)
643 {
644 if(nImpactxy < cutNImpact || nImpactz < cutNImpact)
645 {
646 lambdaCandidate = false;
647 }
648 if(pImpactxy < cutNImpact || pImpactz < cutNImpact)
649 {
650 antilambdaCandidate = false;
651 }
652 }
653
654
655 // DCA between daughterscut
656 if(cutDCA != -999)
657 {
658 if(v0->GetDcaV0Daughters() > cutDCA)
659 {
660 lambdaCandidate = false;
661 antilambdaCandidate = false;
662 kshortCandidate = false;
663 }
664 }
665
666 // Bethe Bloch cut. Made sightly complicated as options for crude cuts still included. Should probably reduce to just 'official' cuts
667 if(cutBetheBloch != -999)
668 {
669 if(posTrack->GetTPCsignal() <0 || negTrack->GetTPCsignal()<0)
670 {continue;}
671
672 if(lambdaCandidate)
673 {
674 if(cutBetheBloch > 0)
675 {
676 if(TMath::Abs(fPIDResponse->NumberOfSigmasTPC(posTrack, AliPID::kProton)) > cutBetheBloch )
677 {lambdaCandidate = false;}
678 if(TMath::Abs(fPIDResponse->NumberOfSigmasTPC(negTrack, AliPID::kPion)) > cutBetheBloch )
679 {lambdaCandidate = false;}
680 }
681
682 if(cutBetheBloch == -4)
683 {
684 if(isMonteCarlo)
685 {
686 double beta2 = TMath::Power((pPos2/TMath::Sqrt((pPos2*pPos2+0.9*0.9))),2);
687 double gamma2 = 1.0/(1.0-beta2);
688 if(posTrack->GetTPCsignal() < (2.0/beta2)*(TMath::Log(1e6*beta2*gamma2)-beta2))
689 {lambdaCandidate = false;}
690 }
691 else
692 {
693 double beta2 = TMath::Power((pPos2/TMath::Sqrt((pPos2*pPos2+kMProton*kMProton))),2);
694 double gamma2 = 1.0/(1.0-beta2);
695 if(posTrack->GetTPCsignal() < (2.3/beta2)*(TMath::Log(1e6*beta2*gamma2)-beta2))
696 {lambdaCandidate = false;}
697 }
698 }
699
700 }
701
702 if(antilambdaCandidate)
703 {
704 if(cutBetheBloch > 0)
705 {
706 if(TMath::Abs(fPIDResponse->NumberOfSigmasTPC(negTrack, AliPID::kProton)) > cutBetheBloch )
707 {antilambdaCandidate = false;}
708 if(TMath::Abs(fPIDResponse->NumberOfSigmasTPC(posTrack, AliPID::kPion)) > cutBetheBloch )
709 {antilambdaCandidate = false;}
710 }
711
712 if(cutBetheBloch == -4)
713 {
714 if(isMonteCarlo)
715 {
716 double beta2 = TMath::Power((pNeg2/TMath::Sqrt((pNeg2*pNeg2+0.9*0.9))),2);
717 double gamma2 = 1.0/(1.0-beta2);
718 if(negTrack->GetTPCsignal() < (2.0/beta2)*(TMath::Log(1e6*beta2*gamma2)-beta2))
719 {antilambdaCandidate = false;}
720 }
721 else
722 {
723 double beta2 = TMath::Power((pNeg2/TMath::Sqrt((pNeg2*pNeg2+0.9*0.9))),2);
724 double gamma2 = 1.0/(1.0-beta2);
725 if(negTrack->GetTPCsignal() < (2.3/beta2)*(TMath::Log(1e6*beta2*gamma2)-beta2))
726 {antilambdaCandidate = false;}
727 }
728 }
729
730 }
731
732 if(kshortCandidate)
733 {
734 if(cutBetheBloch > 0)
735 {
736 if(TMath::Abs(fPIDResponse->NumberOfSigmasTPC(negTrack, AliPID::kPion)) > cutBetheBloch )
737 {kshortCandidate = false;}
738 if(TMath::Abs(fPIDResponse->NumberOfSigmasTPC(posTrack, AliPID::kPion)) > cutBetheBloch )
739 {kshortCandidate = false;}
740 }
741
742
743 if(cutBetheBloch == -4)
744 {
745 double par0 = 0.20;
746 double par1 = 4.2;
747 double par2 = 1000000;
748
749 if(isMonteCarlo)
750 {
751 double beta2 = TMath::Power((pNeg2/TMath::Sqrt((pNeg2*pNeg2+par0*par0))),2);
752 double gamma2 = 1.0/(1.0-beta2);
753 if(negTrack->GetTPCsignal() > (par1/beta2)*(TMath::Log(par2*beta2*gamma2)-beta2) && TMath::Log10(pNeg2) > -0.6)
754 {kshortCandidate = false;}
755
756 beta2 = TMath::Power((pPos2/TMath::Sqrt((pPos2*pPos2+par0*par0))),2);
757 gamma2 = 1.0/(1.0-beta2);
758 if(posTrack->GetTPCsignal() > (par1/beta2)*(TMath::Log(par2*beta2*gamma2)-beta2) && TMath::Log10(pNeg2) > -0.6)
759 {kshortCandidate = false;}
760 }
761 else
762 {
763 double beta2 = TMath::Power((pNeg2/TMath::Sqrt((pNeg2*pNeg2+par0*par0))),2);
764 double gamma2 = 1.0/(1.0-beta2);
765 if(negTrack->GetTPCsignal() > (par1/beta2)*(TMath::Log(par2*beta2*gamma2)-beta2) && TMath::Log10(pNeg2) > -0.6)
766 {kshortCandidate = false;}
767
768 beta2 = TMath::Power((pPos2/TMath::Sqrt((pPos2*pPos2+par0*par0))),2);
769 gamma2 = 1.0/(1.0-beta2);
770 if(posTrack->GetTPCsignal() > (par1/beta2)*(TMath::Log(par2*beta2*gamma2)-beta2) && TMath::Log10(pPos2) > -0.6)
771 {kshortCandidate = false;}
772 }
773 }
774
775 }
776 }
777
778 // Selection of random cuts which I've been playing with
779 /*if(nImpactxy > 3 || pImpactxy > 2)
780 {
781 lambdaCandidate = false;
782 }*/
783
784 /*if(nImpactxy < 0.4 || pImpactxy < 0.4 || nImpactxy > 2.5 || pImpactxy >2.5)
785 {
786 antilambdaCandidate = false;
787 } */
788
889bc324 789 if(decayLength > 15 )
790 {lambdaCandidate = false;}
45b90328 791
792 // Cuts to look at just lowpt region of lambdas
889bc324 793 //if(v0->Pt() < 0.3 || v0->Pt() > 0.7 || !lambdaCandidate)
794 //{continue;}
45b90328 795
796 // cuts to just look at signal/background region of lambda mass
797 //if(!((v0->GetEffMass(4,2) >= 1.096 && v0->GetEffMass(4,2) < 1.106) || (v0->GetEffMass(4,2) >= 1.126 && v0->GetEffMass(4,2) < 1.136) ))
798 //if(!(v0->GetEffMass(4,2) >= 1.106 && v0->GetEffMass(4,2) < 1.126 ))
799 //{continue;}
800 /*********************************************************************/
801
802 /*********************************************************************/
803 // MONTE CARLO SECTION 2
804 // this section looks at the individual V0s
805
806 bool mcLambdaCandidate = true;
807 bool mcAntilambdaCandidate = true;
808 bool mcK0Candidate = true;
45b90328 809 bool realParticle = true;
810
811 if(isMonteCarlo)
812 {
813
814 AliMCEvent *mcEvent = MCEvent();
815 AliStack* mcStack = mcEvent->Stack();
816 if( !mcStack ) { Printf( "Stack not available"); return; }
817
818 TParticle *negParticle = mcStack->Particle( TMath::Abs(negTrack->GetLabel()));
819 TParticle *posParticle = mcStack->Particle( TMath::Abs(posTrack->GetLabel()));
820
821 Int_t negParticleMotherLabel = negParticle->GetFirstMother();
822 Int_t posParticleMotherLabel = posParticle->GetFirstMother();
823
824 if( negParticleMotherLabel == -1 || posParticleMotherLabel == -1)
825 {
826 realParticle = false;
827 mcLambdaCandidate = false;
828 mcAntilambdaCandidate = false;
829 mcK0Candidate =false;
830 }
831
45b90328 832 if( negParticleMotherLabel != posParticleMotherLabel)
833 {
834 mcLambdaCandidate = false;
835 mcAntilambdaCandidate = false;
836 mcK0Candidate =false;
837 }
838
839 if(realParticle == true)
840 {
841 AliMCParticle *mcPart2 = dynamic_cast<AliMCParticle *>(mcEvent->GetTrack(negParticleMotherLabel));
889bc324 842
45b90328 843 if(mcPart2->PdgCode() != kLambda0)
844 {mcLambdaCandidate = false;}
845 if(mcPart2->PdgCode() != kLambda0Bar)
846 {mcAntilambdaCandidate = false;}
847 if(mcPart2->PdgCode() != kK0Short)
848 {mcK0Candidate =false;}
889bc324 849
45b90328 850 if(mcLambdaCandidate && lambdaCandidate)
851 {
45b90328 852 fHistMcV0MLaPt->Fill(v0->Pt(),v0->GetEffMass(4,2));
853 }
854 if(mcAntilambdaCandidate && antilambdaCandidate)
855 {
45b90328 856 fHistMcV0MLbPt->Fill(v0->Pt(),v0->GetEffMass(2,4));
857 }
858 if(mcK0Candidate && kshortCandidate)
859 {
45b90328 860 fHistMcV0MK0Pt->Fill(v0->Pt(),v0->GetEffMass(2,2));
861 }
45b90328 862 }
863
889bc324 864 if(mcLambdaCandidate && lambdaCandidate)
45b90328 865 {
889bc324 866 fHistMCLambdacTau->Fill(cTauLa);
867 fHistMCLambdaDecayL->Fill(decayLength);
45b90328 868 }
889bc324 869 if(!mcLambdaCandidate && lambdaCandidate)
45b90328 870 {
889bc324 871 fHistMCLambdaNotcTau->Fill(cTauLa);
872 fHistMCLambdaNotDecayL->Fill(decayLength);
45b90328 873 }
889bc324 874
875 }
876
45b90328 877
878 // END OF MONTE CARLO SECTION 2
879 /*********************************************************************/
880
881 //remove all non-candidates
882 if(lambdaCandidate == false && antilambdaCandidate == false && kshortCandidate == false)
883 {continue;}
884
885
886 //count number of valid v0s
887 nV0s+=1;
888
889 /*********************************************************************/
890 //This section fills histograms
891
45b90328 892 fHistDCAV0Daughters->Fill(v0->GetDcaV0Daughters());
45b90328 893 fHistCosPA->Fill(v0->GetV0CosineOfPointingAngle(tPVPosition[0],tPVPosition[1],tPVPosition[2]));
894 fHistDecayL->Fill(decayLength);
45b90328 895 fHistTauLa->Fill(cTauLa);
45b90328 896
889bc324 897 fHistBetheBlochTPCPos->Fill(TMath::Log10(pPos2),posTrack->GetTPCsignal());
898 fHistBetheBlochTPCNeg->Fill(TMath::Log10(pNeg2),negTrack->GetTPCsignal());
45b90328 899
45b90328 900 fHistImpactxyN->Fill(nImpactxy);
901 fHistImpactzN->Fill(nImpactz);
902 fHistImpactxyP->Fill(pImpactxy);
903 fHistImpactzP->Fill(pImpactz);
904
45b90328 905 fHistImpactxyImpactz->Fill(nImpactxy,nImpactz);
906
907 fHistV0Z->Fill(tV0Position[2]);
908 fHistZ->Fill(tV0Position[2]-tPVPosition[2]);
889bc324 909
45b90328 910 fHistRZ->Fill(tV0Position[2],radius);
911 fHistPtV0Z->Fill(v0->Pt(),tV0Position[2]);
912
913 fHistPtArm->Fill(v0->AlphaV0(),v0->PtArmV0());
914 fHistXZ->Fill(tV0Position[2],tV0Position[0]);
915 fHistYZ->Fill(tV0Position[2],tV0Position[1]);
45b90328 916 fHistPtV0->Fill(v0->Pt());
917
918 //effective mass histograms
919
920 //sets assumed particle type of pos/neg daughters.
921 // 0 = electron, 1 = Muon, 2 = pion, 3 = kaon, 4 = proton.
922 int dPos = 0;
923 int dNeg = 0;
924
925 // v0->ChangeMassHypothesis(kLambda0);
926 dPos = 4;
927 dNeg = 2;
928 if(v0->GetEffMass(dPos,dNeg) > 1.11 && v0->GetEffMass(dPos,dNeg) < 1.13)
929 {
930 if(!(v0->GetOnFlyStatus()))
931 {
932 nLambda++;
933 }
934 }
935 if(lambdaCandidate)
936 {
889bc324 937 fHistMLa->Fill(v0->GetEffMass(dPos,dNeg));
45b90328 938 fHistMLaPt->Fill(v0->Pt(),v0->GetEffMass(dPos,dNeg));
939 }
940
941 // v0->ChangeMassHypothesis(kK0Short);
942 dPos = 2;
943 dNeg = 2;
944 if(kshortCandidate)
945 {
946 fHistMK0->Fill(v0->GetEffMass(dPos,dNeg));
45b90328 947 fHistMK0Pt->Fill(v0->Pt(),v0->GetEffMass(dPos,dNeg));
948 }
949 // v0->ChangeMassHypothesis(kLambda0Bar);
950 dPos = 2;
951 dNeg = 4;
952 if(antilambdaCandidate)
953 {
954 fHistMLb->Fill(v0->GetEffMass(dPos,dNeg));
45b90328 955 fHistMLbPt->Fill(v0->Pt(),v0->GetEffMass(dPos,dNeg));
956 }
889bc324 957
45b90328 958 }
959
45b90328 960
961 fHistPVZ->Fill(tPVPosition[2]);
962 fHistNV0->Fill(nV0s);
45b90328 963 fHistNLambda->Fill(nLambda);
964
889bc324 965 // NEW HISTO should be filled before this point, as PostData puts the
45b90328 966 // information for this iteration of the UserExec in the container
967 PostData(1, fOutputList);
968}
969
970
971//________________________________________________________________________
972void AliAnalysisTaskLukeV0::Terminate(Option_t *)
973{
974 // Draw result to screen, or perform fitting, normalizations
975 // Called once at the end of the query
976
977 fOutputList = dynamic_cast<TList*> (GetOutputData(1));
978 if(!fOutputList) { Printf("ERROR: could not retrieve TList fOutputList"); return; }
979
980 }