]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGLF/STRANGENESS/LambdaK0/AliAnalysisTaskExtractV0pPb.cxx
Merge branch 'TPCdev' of https://git.cern.ch/reps/AliRoot into TPCdev
[u/mrichter/AliRoot.git] / PWGLF / STRANGENESS / LambdaK0 / AliAnalysisTaskExtractV0pPb.cxx
CommitLineData
bd3cbe60 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// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
17//
18// Modified version of AliAnalysisTaskCheckCascade.cxx.
19// This is a 'hybrid' output version, in that it uses a classic TTree
20// ROOT object to store the candidates, plus a couple of histograms filled on
21// a per-event basis for storing variables too numerous to put in a tree.
22//
23// --- Added bits of code for checking V0s
24// (from AliAnalysisTaskCheckStrange.cxx)
25//
26// --- Algorithm Description
27// 1. Perform Physics Selection
28// 2. Perform Primary Vertex |z|<10cm selection
29// 3. Perform Primary Vertex NoTPCOnly vertexing selection (>0 contrib.)
30// 4. Perform Pileup Rejection
31// 5. Analysis Loops:
32// 5a. Fill TTree object with V0 information, candidates
33//
34// Please Report Any Bugs!
35//
36// --- David Dobrigkeit Chinellato
37// (david.chinellato@gmail.com)
38//
39// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
40
41class TTree;
42class TParticle;
43class TVector3;
44
45//class AliMCEventHandler;
46//class AliMCEvent;
47//class AliStack;
48
49class AliESDVertex;
50class AliAODVertex;
51class AliESDv0;
52class AliAODv0;
53
54#include <Riostream.h>
55#include "TList.h"
56#include "TH1.h"
57#include "TH2.h"
58#include "TH3.h"
59#include "THnSparse.h"
60#include "TVector3.h"
61#include "TCanvas.h"
62#include "TMath.h"
63#include "TLegend.h"
64#include "AliLog.h"
65#include "AliCentrality.h"
66#include "AliESDEvent.h"
67#include "AliAODEvent.h"
68#include "AliV0vertexer.h"
69#include "AliCascadeVertexer.h"
70#include "AliESDpid.h"
71#include "AliESDtrack.h"
72#include "AliESDtrackCuts.h"
73#include "AliInputEventHandler.h"
74#include "AliAnalysisManager.h"
75#include "AliMCEventHandler.h"
76
77#include "AliCFContainer.h"
78#include "AliMultiplicity.h"
79
80#include "AliESDcascade.h"
81#include "AliAODcascade.h"
82#include "AliESDUtils.h"
83#include "AliESDHeader.h"
84
85#include "AliAnalysisUtils.h"
86#include "AliAnalysisTaskExtractV0pPb.h"
87
88//debugging purposes
89#include "TObjectTable.h"
90
91ClassImp(AliAnalysisTaskExtractV0pPb)
92
93AliAnalysisTaskExtractV0pPb::AliAnalysisTaskExtractV0pPb()
94 : AliAnalysisTaskSE(), fListHistV0(0), fTree(0), fTreeEvents(0), fPIDResponse(0),
95 fTPCdEdxSelection ( kTRUE ),
96//------------------------------------------------
97// Initialize
98 fTreeVariableChi2V0(0),
99 fTreeVariableDcaV0Daughters(0),
100 fTreeVariableDcaV0ToPrimVertex(0),
101 fTreeVariableDcaPosToPrimVertex(0),
102 fTreeVariableDcaNegToPrimVertex(0),
19e6f9a3 103 fTreeVariableDCAV0ToPrimVertex(0),
bd3cbe60 104 fTreeVariableV0CosineOfPointingAngle(0),
105 fTreeVariableV0Radius(0),
106 fTreeVariablePt(0),
107 fTreeVariableRapK0Short(0),
108 fTreeVariableRapLambda(0),
109 fTreeVariableInvMassK0s(0),
110 fTreeVariableInvMassLambda(0),
111 fTreeVariableInvMassAntiLambda(0),
112 fTreeVariableAlphaV0(0),
113 fTreeVariablePtArmV0(0),
114 fTreeVariableNegTotMomentum(0),
115 fTreeVariablePosTotMomentum(0),
116 fTreeVariableNegdEdxSig(0),
117 fTreeVariablePosdEdxSig(0),
118 fTreeVariableNegEta(0),
119 fTreeVariablePosEta(0),
120
121 fTreeVariableNSigmasPosProton(0),
122 fTreeVariableNSigmasPosPion(0),
123 fTreeVariableNSigmasNegProton(0),
124 fTreeVariableNSigmasNegPion(0),
125
126 fTreeVariableDistOverTotMom(0),
127 fTreeVariableLeastNbrCrossedRows(0),
128 fTreeVariableLeastRatioCrossedRowsOverFindable(0),
129 fTreeVariableCentrality(0),
130
131//Event Tree
132 fTreeEventsCentrality(0),
133
134//------------------------------------------------
135// HISTOGRAMS
136// --- Filled on an Event-by-event basis
137//------------------------------------------------
138 //V0A Centrality
139 fHistCentralityProcessed(0),
140 fHistCentralityTrigEvt(0),
141 fHistCentralityHasVtx(0),
142 fHistCentralityVtxZ(0)
143{
144 // Dummy Constructor
145}
146
147AliAnalysisTaskExtractV0pPb::AliAnalysisTaskExtractV0pPb(const char *name)
148 : AliAnalysisTaskSE(name), fListHistV0(0), fTree(0), fTreeEvents(0), fPIDResponse(0),
149 fTPCdEdxSelection ( kTRUE ),
150//------------------------------------------------
151// Initialize
152 fTreeVariableChi2V0(0),
153 fTreeVariableDcaV0Daughters(0),
154 fTreeVariableDcaV0ToPrimVertex(0),
155 fTreeVariableDcaPosToPrimVertex(0),
156 fTreeVariableDcaNegToPrimVertex(0),
19e6f9a3 157 fTreeVariableDCAV0ToPrimVertex(0),
bd3cbe60 158 fTreeVariableV0CosineOfPointingAngle(0),
159 fTreeVariableV0Radius(0),
160 fTreeVariablePt(0),
161 fTreeVariableRapK0Short(0),
162 fTreeVariableRapLambda(0),
163 fTreeVariableInvMassK0s(0),
164 fTreeVariableInvMassLambda(0),
165 fTreeVariableInvMassAntiLambda(0),
166 fTreeVariableAlphaV0(0),
167 fTreeVariablePtArmV0(0),
168 fTreeVariableNegTotMomentum(0),
169 fTreeVariablePosTotMomentum(0),
170 fTreeVariableNegdEdxSig(0),
171 fTreeVariablePosdEdxSig(0),
172 fTreeVariableNegEta(0),
173 fTreeVariablePosEta(0),
174
175 fTreeVariableNSigmasPosProton(0),
176 fTreeVariableNSigmasPosPion(0),
177 fTreeVariableNSigmasNegProton(0),
178 fTreeVariableNSigmasNegPion(0),
179
180 fTreeVariableDistOverTotMom(0),
181 fTreeVariableLeastNbrCrossedRows(0),
182 fTreeVariableLeastRatioCrossedRowsOverFindable(0),
183 fTreeVariableCentrality(0),
184
185//Event Tree
186 fTreeEventsCentrality(0),
187
188//------------------------------------------------
189// HISTOGRAMS
190// --- Filled on an Event-by-event basis
191//------------------------------------------------
192 //V0A Centrality
193 fHistCentralityProcessed(0),
194 fHistCentralityTrigEvt(0),
195 fHistCentralityHasVtx(0),
196 fHistCentralityVtxZ(0)
197{
198 // Output slot #0 writes into a TList container (Lambda Histos and fTree)
199 DefineOutput(1, TList::Class());
200 DefineOutput(2, TTree::Class());
201 DefineOutput(3, TTree::Class());
202}
203
204
205AliAnalysisTaskExtractV0pPb::~AliAnalysisTaskExtractV0pPb()
206{
207//------------------------------------------------
208// DESTRUCTOR
209//------------------------------------------------
210
211 if (fListHistV0){
212 delete fListHistV0;
213 fListHistV0 = 0x0;
214 }
215 if (fTree){
216 delete fTree;
217 fTree = 0x0;
218 }
219 if (fTreeEvents){
220 delete fTreeEvents;
f1e4ccc3 221 fTreeEvents = 0x0;
bd3cbe60 222 }
223}
224
225
226
227//________________________________________________________________________
228void AliAnalysisTaskExtractV0pPb::UserCreateOutputObjects()
229{
230
231 //Create File-resident Tree, please.
232 OpenFile(2);
233 // Called once
234 fTree = new TTree("fTree","V0Candidates");
235
236//------------------------------------------------
237// fTree Branch definitions
238//------------------------------------------------
239
240//-----------BASIC-INFO---------------------------
241/* 1*/ fTree->Branch("fTreeVariableChi2V0",&fTreeVariableChi2V0,"fTreeVariableChi2V0/F");
242/* 2*/ fTree->Branch("fTreeVariableDcaV0Daughters",&fTreeVariableDcaV0Daughters,"fTreeVariableDcaV0Daughters/F");
243/* 3*/ fTree->Branch("fTreeVariableDcaPosToPrimVertex",&fTreeVariableDcaPosToPrimVertex,"fTreeVariableDcaPosToPrimVertex/F");
244/* 4*/ fTree->Branch("fTreeVariableDcaNegToPrimVertex",&fTreeVariableDcaNegToPrimVertex,"fTreeVariableDcaNegToPrimVertex/F");
245/* 5*/ fTree->Branch("fTreeVariableV0Radius",&fTreeVariableV0Radius,"fTreeVariableV0Radius/F");
246/* 6*/ fTree->Branch("fTreeVariablePt",&fTreeVariablePt,"fTreeVariablePt/F");
247/* 7*/ fTree->Branch("fTreeVariableRapK0Short",&fTreeVariableRapK0Short,"fTreeVariableRapK0Short/F");
248/* 8*/ fTree->Branch("fTreeVariableRapLambda",&fTreeVariableRapLambda,"fTreeVariableRapLambda/F");
249/* 9*/ fTree->Branch("fTreeVariableInvMassK0s",&fTreeVariableInvMassK0s,"fTreeVariableInvMassK0s/F");
250/*10*/ fTree->Branch("fTreeVariableInvMassLambda",&fTreeVariableInvMassLambda,"fTreeVariableInvMassLambda/F");
251/*11*/ fTree->Branch("fTreeVariableInvMassAntiLambda",&fTreeVariableInvMassAntiLambda,"fTreeVariableInvMassAntiLambda/F");
19e6f9a3 252/*12*/ fTree->Branch("fTreeVariableDCAV0ToPrimVertex",&fTreeVariableDCAV0ToPrimVertex,"fTreeVariableDCAV0ToPrimVertex/F");
bd3cbe60 253/*12*/ fTree->Branch("fTreeVariableV0CosineOfPointingAngle",&fTreeVariableV0CosineOfPointingAngle,"fTreeVariableV0CosineOfPointingAngle/F");
254/*13*/ fTree->Branch("fTreeVariableAlphaV0",&fTreeVariableAlphaV0,"fTreeVariableAlphaV0/F");
255/*14*/ fTree->Branch("fTreeVariablePtArmV0",&fTreeVariablePtArmV0,"fTreeVariablePtArmV0/F");
256/*15*/ fTree->Branch("fTreeVariableLeastNbrCrossedRows",&fTreeVariableLeastNbrCrossedRows,"fTreeVariableLeastNbrCrossedRows/I");
257/*16*/ fTree->Branch("fTreeVariableLeastRatioCrossedRowsOverFindable",&fTreeVariableLeastRatioCrossedRowsOverFindable,"fTreeVariableLeastRatioCrossedRowsOverFindable/F");
258//-----------MULTIPLICITY-INFO--------------------
259/*17*/ fTree->Branch("fTreeVariableCentrality",&fTreeVariableCentrality,"fTreeVariableCentrality/F");
260//------------------------------------------------
261/*18*/ fTree->Branch("fTreeVariableDistOverTotMom",&fTreeVariableDistOverTotMom,"fTreeVariableDistOverTotMom/F");
262/*19*/ fTree->Branch("fTreeVariableNSigmasPosProton",&fTreeVariableNSigmasPosProton,"fTreeVariableNSigmasPosProton/F");
263/*20*/ fTree->Branch("fTreeVariableNSigmasPosPion",&fTreeVariableNSigmasPosPion,"fTreeVariableNSigmasPosPion/F");
264/*21*/ fTree->Branch("fTreeVariableNSigmasNegProton",&fTreeVariableNSigmasNegProton,"fTreeVariableNSigmasNegProton/F");
265/*22*/ fTree->Branch("fTreeVariableNSigmasNegPion",&fTreeVariableNSigmasNegPion,"fTreeVariableNSigmasNegPion/F");
266/*23*/ fTree->Branch("fTreeVariableNegEta",&fTreeVariableNegEta,"fTreeVariableNegEta/F");
267/*24*/ fTree->Branch("fTreeVariablePosEta",&fTreeVariablePosEta,"fTreeVariablePosEta/F");
268
269//------------------------------------------------
270// fTreeEvents Branch definitions
271//------------------------------------------------
272
273 fTreeEvents = new TTree("fTreeEvents","Events");
f4870e85 274/*01*/ fTreeEvents->Branch("fTreeEventsCentrality",&fTreeEventsCentrality,"fTreeEventsCentrality/F");
bd3cbe60 275
276//------------------------------------------------
277// Particle Identification Setup
278//------------------------------------------------
279
280 AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager();
281 AliInputEventHandler* inputHandler = (AliInputEventHandler*) (man->GetInputEventHandler());
282 fPIDResponse = inputHandler->GetPIDResponse();
283
284//------------------------------------------------
285// V0 Multiplicity Histograms
286//------------------------------------------------
287
288 // Create histograms
289 //Create File-resident Tree, please.
290 OpenFile(1);
291
292 fListHistV0 = new TList();
293 fListHistV0->SetOwner(); // See http://root.cern.ch/root/html/TCollection.html#TCollection:SetOwner
294
295//------------------------------------------------
296// V0A Centrality Histograms
297//------------------------------------------------
298
299 //Default V0A Centrality (if PbPb)
300 if(! fHistCentralityProcessed) {
301 fHistCentralityProcessed = new TH1F("fHistCentralityProcessed",
302 "All processed Events;V0A Centrality;Events",
303 200, 0, 100);
304 fListHistV0->Add(fHistCentralityProcessed);
305 }
306 if(! fHistCentralityTrigEvt) {
307 fHistCentralityTrigEvt = new TH1F("fHistCentralityTrigEvt",
308 "PS selected Events;V0A Centrality;Events",
309 200, 0, 100);
310 fListHistV0->Add(fHistCentralityTrigEvt);
311 }
312 if(! fHistCentralityHasVtx) {
313 fHistCentralityHasVtx = new TH1F("fHistCentralityHasVtx",
314 "Events having Vertex;V0A Centrality;Events",
315 200, 0, 100);
316 fListHistV0->Add(fHistCentralityHasVtx);
317 }
318 if(! fHistCentralityVtxZ) {
319 fHistCentralityVtxZ = new TH1F("fHistCentralityVtxZ",
320 "Vertex |z|<10cm;V0A Centrality;Events",
321 200, 0, 100);
322 fListHistV0->Add(fHistCentralityVtxZ);
323 }
324
325 //Regular output: Histograms
326 PostData(1, fListHistV0);
327 //TTree Object: Saved to base directory. Should cache to disk while saving.
328 //(Important to avoid excessive memory usage, particularly when merging)
329 PostData(2, fTree);
330 PostData(3, fTreeEvents);
331
332}// end UserCreateOutputObjects
333
334
335//________________________________________________________________________
336void AliAnalysisTaskExtractV0pPb::UserExec(Option_t *)
337{
338 // Main loop
339 // Called for each event
340 //gObjectTable->Print();
341 AliESDEvent *lESDevent = 0x0;
342
343 //AliAODEvent *lAODevent = 0x0;
344
345 Double_t lTrkgPrimaryVtxPos[3] = {-100.0, -100.0, -100.0};
346 Double_t lBestPrimaryVtxPos[3] = {-100.0, -100.0, -100.0};
347 Double_t lMagneticField = -10.;
348
349 // Connect to the InputEvent
350 // After these lines, we should have an ESD/AOD event + the number of cascades in it.
351
352 // Appropriate for ESD analysis!
353
354 lESDevent = dynamic_cast<AliESDEvent*>( InputEvent() );
355 if (!lESDevent) {
356 AliWarning("ERROR: lESDevent not available \n");
357 return;
358 }
359
360 //REVISED multiplicity estimator after 'multiplicity day' (2011)
361 Float_t lMultiplicity = -100;
362 fTreeVariableCentrality = -100;
363
364 //---> If this is a nuclear collision, then go nuclear on "multiplicity" variable...
365 //---> Warning: Experimental
366 AliCentrality* centrality;
367 centrality = lESDevent->GetCentrality();
368 if (centrality->GetQuality()>1) {
369 PostData(1, fListHistV0);
370 PostData(2, fTree);
371 PostData(3, fTreeEvents);
372 return;
373 }
374 lMultiplicity = centrality->GetCentralityPercentile( "V0A" );
375
376
377 //Set variable for filling tree afterwards!
b2e7de7f 378 //---> Always V0A
bd3cbe60 379 fTreeVariableCentrality = lMultiplicity;
380 fTreeEventsCentrality = lMultiplicity;
381
382 fHistCentralityProcessed->Fill ( fTreeVariableCentrality );
383
384
385//------------------------------------------------
386// Physics Selection
387//------------------------------------------------
388
389 // new method
390 UInt_t maskIsSelected = ((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected();
391 Bool_t isSelected = 0;
392 isSelected = (maskIsSelected & AliVEvent::kINT7) == AliVEvent::kINT7;
393
394 //Trigger Selection for kINT7
395 if ( !isSelected ) {
396 PostData(1, fListHistV0);
397 PostData(2, fTree);
398 PostData(3, fTreeEvents);
399 return;
400 }
401
402//------------------------------------------------
403// After Trigger Selection
404//------------------------------------------------
405
406 fHistCentralityTrigEvt -> Fill( fTreeVariableCentrality );
407
408//------------------------------------------------
409// Getting: Primary Vertex + MagField Info
410//------------------------------------------------
411
412 const AliESDVertex *lPrimaryTrackingESDVtx = lESDevent->GetPrimaryVertexTracks();
413 // get the vtx stored in ESD found with tracks
414 lPrimaryTrackingESDVtx->GetXYZ( lTrkgPrimaryVtxPos );
415
416 const AliESDVertex *lPrimaryBestESDVtx = lESDevent->GetPrimaryVertex();
417 // get the best primary vertex available for the event
418 // As done in AliCascadeVertexer, we keep the one which is the best one available.
419 // between : Tracking vertex > SPD vertex > TPC vertex > default SPD vertex
420 // This one will be used for next calculations (DCA essentially)
421 lPrimaryBestESDVtx->GetXYZ( lBestPrimaryVtxPos );
422
423 Double_t tPrimaryVtxPosition[3];
424 const AliVVertex *primaryVtx = lESDevent->GetPrimaryVertex();
425 tPrimaryVtxPosition[0] = primaryVtx->GetX();
426 tPrimaryVtxPosition[1] = primaryVtx->GetY();
427 tPrimaryVtxPosition[2] = primaryVtx->GetZ();
428
429 //------------------------------------------------
430 // Primary Vertex Requirements Section:
431 // ---> pp and PbPb: Only requires |z|<10cm
432 // ---> pPb: all requirements checked at this stage
433 //------------------------------------------------
434
435 //Roberto's PV selection criteria, implemented 17th April 2013
436
437 /* vertex selection */
438 Bool_t fHasVertex = kFALSE;
439
440 const AliESDVertex *vertex = lESDevent->GetPrimaryVertexTracks();
441 if (vertex->GetNContributors() < 1) {
442 vertex = lESDevent->GetPrimaryVertexSPD();
443 if (vertex->GetNContributors() < 1) fHasVertex = kFALSE;
444 else fHasVertex = kTRUE;
445 TString vtxTyp = vertex->GetTitle();
446 Double_t cov[6]={0};
447 vertex->GetCovarianceMatrix(cov);
448 Double_t zRes = TMath::Sqrt(cov[5]);
449 if (vtxTyp.Contains("vertexer:Z") && (zRes>0.25)) fHasVertex = kFALSE;
450 }
451 else fHasVertex = kTRUE;
452
453 //Is First event in chunk rejection: Still present!
454 if(fHasVertex == kFALSE) {
455 AliWarning("Pb / | PV does not satisfy selection criteria!");
456 PostData(1, fListHistV0);
457 PostData(2, fTree);
458 PostData(3, fTreeEvents);
459 return;
460 }
461
462 fHistCentralityHasVtx -> Fill ( fTreeVariableCentrality );
463
464 //17 April Fix: Always do primary vertex Z selection, after pA vertex selection from Roberto
465 if(TMath::Abs(lBestPrimaryVtxPos[2]) > 10.0) {
466 AliWarning("Pb / | pPb case | Z position of Best Prim Vtx | > 10.0 cm ... return !");
467 PostData(1, fListHistV0);
468 PostData(2, fTree);
469 PostData(3, fTreeEvents);
470 return;
471 }
472
473 fHistCentralityVtxZ -> Fill ( fTreeVariableCentrality );
474 lMagneticField = lESDevent->GetMagneticField( );
475
012f8525 476 //Fill Event Tree: Analysis Selection Level
477 fTreeEvents->Fill();
478
bd3cbe60 479//------------------------------------------------
480// MAIN LAMBDA LOOP STARTS HERE
481//------------------------------------------------
482
483//Variable definition
484 Int_t lOnFlyStatus = 0;// nv0sOn = 0, nv0sOff = 0;
485 Double_t lChi2V0 = 0;
486 Double_t lDcaV0Daughters = 0, lDcaV0ToPrimVertex = 0;
487 Double_t lDcaPosToPrimVertex = 0, lDcaNegToPrimVertex = 0;
488 Double_t lV0CosineOfPointingAngle = 0;
489 Double_t lV0Radius = 0, lPt = 0;
490 Double_t lRapK0Short = 0, lRapLambda = 0;
491 Double_t lInvMassK0s = 0, lInvMassLambda = 0, lInvMassAntiLambda = 0;
492 Double_t lAlphaV0 = 0, lPtArmV0 = 0;
493
494 Double_t fMinV0Pt = 0;
495 Double_t fMaxV0Pt = 100;
496
497 Int_t nv0s = 0;
498 nv0s = lESDevent->GetNumberOfV0s();
499
500 //for (Int_t iV0 = 0; iV0 < nv0s; iV0++)
501 for (Int_t iV0 = 0; iV0 < nv0s; iV0++) //extra-crazy test
502 {// This is the begining of the V0 loop
503 AliESDv0 *v0 = ((AliESDEvent*)lESDevent)->GetV0(iV0);
504 if (!v0) continue;
505
506 Double_t tDecayVertexV0[3]; v0->GetXYZ(tDecayVertexV0[0],tDecayVertexV0[1],tDecayVertexV0[2]);
507
508 Double_t tV0mom[3];
509 v0->GetPxPyPz( tV0mom[0],tV0mom[1],tV0mom[2] );
510 Double_t lV0TotalMomentum = TMath::Sqrt(
511 tV0mom[0]*tV0mom[0]+tV0mom[1]*tV0mom[1]+tV0mom[2]*tV0mom[2] );
512
513 lV0Radius = TMath::Sqrt(tDecayVertexV0[0]*tDecayVertexV0[0]+tDecayVertexV0[1]*tDecayVertexV0[1]);
514
515 lPt = v0->Pt();
516 lRapK0Short = v0->RapK0Short();
517 lRapLambda = v0->RapLambda();
518 if ((lPt<fMinV0Pt)||(fMaxV0Pt<lPt)) continue;
519
520 UInt_t lKeyPos = (UInt_t)TMath::Abs(v0->GetPindex());
521 UInt_t lKeyNeg = (UInt_t)TMath::Abs(v0->GetNindex());
522
523 Double_t lMomPos[3]; v0->GetPPxPyPz(lMomPos[0],lMomPos[1],lMomPos[2]);
524 Double_t lMomNeg[3]; v0->GetNPxPyPz(lMomNeg[0],lMomNeg[1],lMomNeg[2]);
525
526 AliESDtrack *pTrack=((AliESDEvent*)lESDevent)->GetTrack(lKeyPos);
527 AliESDtrack *nTrack=((AliESDEvent*)lESDevent)->GetTrack(lKeyNeg);
528 if (!pTrack || !nTrack) {
529 Printf("ERROR: Could not retreive one of the daughter track");
530 continue;
531 }
532
533 //Daughter Eta for Eta selection, afterwards
534 fTreeVariableNegEta = nTrack->Eta();
535 fTreeVariablePosEta = pTrack->Eta();
536
537 // Filter like-sign V0 (next: add counter and distribution)
538 if ( pTrack->GetSign() == nTrack->GetSign()){
539 continue;
540 }
541
542 //________________________________________________________________________
543 // Track quality cuts
544 Float_t lPosTrackCrossedRows = pTrack->GetTPCClusterInfo(2,1);
545 Float_t lNegTrackCrossedRows = nTrack->GetTPCClusterInfo(2,1);
546 fTreeVariableLeastNbrCrossedRows = (Int_t) lPosTrackCrossedRows;
547 if( lNegTrackCrossedRows < fTreeVariableLeastNbrCrossedRows )
548 fTreeVariableLeastNbrCrossedRows = (Int_t) lNegTrackCrossedRows;
549
550 // TPC refit condition (done during reconstruction for Offline but not for On-the-fly)
551 if( !(pTrack->GetStatus() & AliESDtrack::kTPCrefit)) continue;
552 if( !(nTrack->GetStatus() & AliESDtrack::kTPCrefit)) continue;
553
554 //Get status flags
555 //fTreeVariablePosTrackStatus = pTrack->GetStatus();
556 //fTreeVariableNegTrackStatus = nTrack->GetStatus();
557
558 if ( ( ( pTrack->GetTPCClusterInfo(2,1) ) < 70 ) || ( ( nTrack->GetTPCClusterInfo(2,1) ) < 70 ) ) continue;
559
560 //GetKinkIndex condition
561 if( pTrack->GetKinkIndex(0)>0 || nTrack->GetKinkIndex(0)>0 ) continue;
562
563 //Findable clusters > 0 condition
564 if( pTrack->GetTPCNclsF()<=0 || nTrack->GetTPCNclsF()<=0 ) continue;
565
566 //Compute ratio Crossed Rows / Findable clusters
567 //Note: above test avoids division by zero!
568 Float_t lPosTrackCrossedRowsOverFindable = lPosTrackCrossedRows / ((double)(pTrack->GetTPCNclsF()));
569 Float_t lNegTrackCrossedRowsOverFindable = lNegTrackCrossedRows / ((double)(nTrack->GetTPCNclsF()));
570
571 fTreeVariableLeastRatioCrossedRowsOverFindable = lPosTrackCrossedRowsOverFindable;
572 if( lNegTrackCrossedRowsOverFindable < fTreeVariableLeastRatioCrossedRowsOverFindable )
573 fTreeVariableLeastRatioCrossedRowsOverFindable = lNegTrackCrossedRowsOverFindable;
574
575 //Lowest Cut Level for Ratio Crossed Rows / Findable = 0.8, set here
576 //if ( fTreeVariableLeastRatioCrossedRowsOverFindable < 0.8 ) continue;
577
578 //End track Quality Cuts
579 //________________________________________________________________________
580
581 lDcaPosToPrimVertex = TMath::Abs(pTrack->GetD(tPrimaryVtxPosition[0],
582 tPrimaryVtxPosition[1],
583 lMagneticField) );
584
585 lDcaNegToPrimVertex = TMath::Abs(nTrack->GetD(tPrimaryVtxPosition[0],
586 tPrimaryVtxPosition[1],
587 lMagneticField) );
588
589 lOnFlyStatus = v0->GetOnFlyStatus();
590 lChi2V0 = v0->GetChi2V0();
591 lDcaV0Daughters = v0->GetDcaV0Daughters();
592 lDcaV0ToPrimVertex = v0->GetD(tPrimaryVtxPosition[0],tPrimaryVtxPosition[1],tPrimaryVtxPosition[2]);
593 lV0CosineOfPointingAngle = v0->GetV0CosineOfPointingAngle(tPrimaryVtxPosition[0],tPrimaryVtxPosition[1],tPrimaryVtxPosition[2]);
19e6f9a3 594 fTreeVariableDCAV0ToPrimVertex=lV0CosineOfPointingAngle;
bd3cbe60 595 fTreeVariableV0CosineOfPointingAngle=lV0CosineOfPointingAngle;
596
597 // Getting invariant mass infos directly from ESD
598 v0->ChangeMassHypothesis(310);
599 lInvMassK0s = v0->GetEffMass();
600 v0->ChangeMassHypothesis(3122);
601 lInvMassLambda = v0->GetEffMass();
602 v0->ChangeMassHypothesis(-3122);
603 lInvMassAntiLambda = v0->GetEffMass();
604 lAlphaV0 = v0->AlphaV0();
605 lPtArmV0 = v0->PtArmV0();
606
607 fTreeVariablePt = v0->Pt();
608 fTreeVariableChi2V0 = lChi2V0;
609 fTreeVariableDcaV0ToPrimVertex = lDcaV0ToPrimVertex;
610 fTreeVariableDcaV0Daughters = lDcaV0Daughters;
611 fTreeVariableV0CosineOfPointingAngle = lV0CosineOfPointingAngle;
612 fTreeVariableV0Radius = lV0Radius;
613 fTreeVariableDcaPosToPrimVertex = lDcaPosToPrimVertex;
614 fTreeVariableDcaNegToPrimVertex = lDcaNegToPrimVertex;
615 fTreeVariableInvMassK0s = lInvMassK0s;
616 fTreeVariableInvMassLambda = lInvMassLambda;
617 fTreeVariableInvMassAntiLambda = lInvMassAntiLambda;
618 fTreeVariableRapK0Short = lRapK0Short;
619 fTreeVariableRapLambda = lRapLambda;
620 fTreeVariableAlphaV0 = lAlphaV0;
621 fTreeVariablePtArmV0 = lPtArmV0;
622
623 //Official means of acquiring N-sigmas
624 fTreeVariableNSigmasPosProton = fPIDResponse->NumberOfSigmasTPC( pTrack, AliPID::kProton );
625 fTreeVariableNSigmasPosPion = fPIDResponse->NumberOfSigmasTPC( pTrack, AliPID::kPion );
626 fTreeVariableNSigmasNegProton = fPIDResponse->NumberOfSigmasTPC( nTrack, AliPID::kProton );
627 fTreeVariableNSigmasNegPion = fPIDResponse->NumberOfSigmasTPC( nTrack, AliPID::kPion );
628
629//This requires an Invariant Mass Hypothesis afterwards
630 fTreeVariableDistOverTotMom = TMath::Sqrt(
631 TMath::Power( tDecayVertexV0[0] - lBestPrimaryVtxPos[0] , 2) +
632 TMath::Power( tDecayVertexV0[1] - lBestPrimaryVtxPos[1] , 2) +
633 TMath::Power( tDecayVertexV0[2] - lBestPrimaryVtxPos[2] , 2)
634 );
635 fTreeVariableDistOverTotMom /= (lV0TotalMomentum+1e-10); //avoid division by zero, to be sure
636
637//------------------------------------------------
638// Fill Tree!
639//------------------------------------------------
640
641 // The conditionals are meant to decrease excessive
642 // memory usage!
643
644 //First Selection: Reject OnFly
645 if( lOnFlyStatus == 0 ){
646 //Second Selection: rough 20-sigma band, parametric.
647 //K0Short: Enough to parametrize peak broadening with linear function.
648 Double_t lUpperLimitK0Short = (5.63707e-01) + (1.14979e-02)*fTreeVariablePt;
649 Double_t lLowerLimitK0Short = (4.30006e-01) - (1.10029e-02)*fTreeVariablePt;
650 //Lambda: Linear (for higher pt) plus exponential (for low-pt broadening)
651 //[0]+[1]*x+[2]*TMath::Exp(-[3]*x)
652 Double_t lUpperLimitLambda = (1.13688e+00) + (5.27838e-03)*fTreeVariablePt + (8.42220e-02)*TMath::Exp(-(3.80595e+00)*fTreeVariablePt);
653 Double_t lLowerLimitLambda = (1.09501e+00) - (5.23272e-03)*fTreeVariablePt - (7.52690e-02)*TMath::Exp(-(3.46339e+00)*fTreeVariablePt);
654 //Do Selection
655 if( (fTreeVariableInvMassLambda < lUpperLimitLambda && fTreeVariableInvMassLambda > lLowerLimitLambda ) ||
656 (fTreeVariableInvMassAntiLambda < lUpperLimitLambda && fTreeVariableInvMassAntiLambda > lLowerLimitLambda ) ||
657 (fTreeVariableInvMassK0s < lUpperLimitK0Short && fTreeVariableInvMassK0s > lLowerLimitK0Short ) ){
658 //Pre-selection in case this is AA...
659 //If this is a nuclear collision___________________
660 // ... pre-filter with TPC, daughter eta selection
661 if( (fTreeVariableInvMassLambda < lUpperLimitLambda && fTreeVariableInvMassLambda > lLowerLimitLambda
662 && ( fTPCdEdxSelection==kFALSE ||( fTPCdEdxSelection==kTRUE && TMath::Abs(fTreeVariableNSigmasPosProton) < 6.0 && TMath::Abs(fTreeVariableNSigmasNegPion) < 6.0 ) ) ) ||
663 (fTreeVariableInvMassAntiLambda < lUpperLimitLambda && fTreeVariableInvMassAntiLambda > lLowerLimitLambda
664 && ( fTPCdEdxSelection==kFALSE ||( fTPCdEdxSelection==kTRUE && TMath::Abs(fTreeVariableNSigmasNegProton) < 6.0 && TMath::Abs(fTreeVariableNSigmasPosPion) < 6.0 ) ) ) ||
665 (fTreeVariableInvMassK0s < lUpperLimitK0Short && fTreeVariableInvMassK0s > lLowerLimitK0Short
666 && ( fTPCdEdxSelection==kFALSE ||( fTPCdEdxSelection==kTRUE && TMath::Abs(fTreeVariableNSigmasNegPion) < 6.0 && TMath::Abs(fTreeVariableNSigmasPosPion) < 6.0 ) ) ) ){
667 //insane test
668 if ( TMath::Abs(fTreeVariableNegEta)<0.8 && TMath::Abs(fTreeVariablePosEta)<0.8) fTree->Fill();
669 }
670 }//end nuclear_____________________________________
671 }
672
673//------------------------------------------------
674// Fill tree over.
675//------------------------------------------------
676
677 }// This is the end of the V0 loop
678
679 // Post output data.
680 PostData(1, fListHistV0);
681 PostData(2, fTree);
682 PostData(3, fTreeEvents);
683}
684
685//________________________________________________________________________
686void AliAnalysisTaskExtractV0pPb::Terminate(Option_t *)
687{
688 // Draw result to the screen
689 // Called once at the end of the query
690 // This will draw the V0 candidate multiplicity, whose
691 // number of entries corresponds to the number of triggered events.
692 TList *cRetrievedList = 0x0;
693 cRetrievedList = (TList*)GetOutputData(1);
694 if(!cRetrievedList){
695 Printf("ERROR - AliAnalysisTaskExtractV0pPb : ouput data container list not available\n");
696 return;
697 }
698 fHistCentralityProcessed = dynamic_cast<TH1F*> ( cRetrievedList->FindObject("fHistCentralityProcessed") );
699 if (!fHistCentralityProcessed) {
700 Printf("ERROR - AliAnalysisTaskExtractV0pPb : fHistV0MultiplicityForTrigEvt not available");
701 return;
702 }
703 TCanvas *canCheck = new TCanvas("AliAnalysisTaskExtractV0pPb","V0 Multiplicity",10,10,510,510);
704 canCheck->cd(1)->SetLogy();
705 fHistCentralityProcessed->SetMarkerStyle(22);
706 fHistCentralityProcessed->DrawCopy("E");
707}