]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGLF/STRANGENESS/LambdaK0/AliAnalysisTaskExtractV0AOD.cxx
Merge branch 'feature-movesplit'
[u/mrichter/AliRoot.git] / PWGLF / STRANGENESS / LambdaK0 / AliAnalysisTaskExtractV0AOD.cxx
CommitLineData
a0879a26 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
73#include "AliESDtrackCuts.h"
74#include "AliInputEventHandler.h"
75#include "AliAnalysisManager.h"
76#include "AliMCEventHandler.h"
77
78#include "AliCFContainer.h"
79#include "AliMultiplicity.h"
80
81#include "AliESDcascade.h"
82#include "AliAODcascade.h"
83#include "AliESDUtils.h"
84#include "AliESDHeader.h"
85#include "AliAODTrack.h"
86#include "AliAnalysisTaskExtractV0AOD.h"
87
88//debugging purposes
89#include "TObjectTable.h"
90
91ClassImp(AliAnalysisTaskExtractV0AOD)
92
93AliAnalysisTaskExtractV0AOD::AliAnalysisTaskExtractV0AOD()
94 : AliAnalysisTaskSE(), fListHistV0(0), fTree(0), fPIDResponse(0),
95 fkIsNuclear ( kFALSE ),
96 fkLowEnergyPP ( kFALSE ),
97 fkUseOnTheFly ( kFALSE ),
5336fa37 98 fTriggerMask ( "kMB" ),
048f4f8f 99//------------------------------------------------
100// Variables for tree
101//------------------------------------------------
102
103 fTreeVariableChi2V0(0),
104 fTreeVariableDcaV0Daughters(0),
105 fTreeVariableDcaV0ToPrimVertex(0),
106 fTreeVariableDcaPosToPrimVertex(0),
107 fTreeVariableDcaNegToPrimVertex(0),
108 fTreeVariableV0CosineOfPointingAngle(0),
109 fTreeVariableV0Radius(0),
110 fTreeVariablePt(0),
111 fTreeVariableRapK0Short(0),
112 fTreeVariableRapLambda(0),
113 fTreeVariableInvMassK0s(0),
114 fTreeVariableInvMassLambda(0),
115 fTreeVariableInvMassAntiLambda(0),
116 fTreeVariableAlphaV0(0),
117 fTreeVariablePtArmV0(0),
118 fTreeVariableNegTotMomentum(0),
119 fTreeVariablePosTotMomentum(0),
120 fTreeVariableNegdEdxSig(0),
121 fTreeVariablePosdEdxSig(0),
122 fTreeVariableNegEta(0),
123 fTreeVariablePosEta(0),
124
125 fTreeVariableNSigmasPosProton(0),
126 fTreeVariableNSigmasPosPion(0),
127 fTreeVariableNSigmasNegProton(0),
128 fTreeVariableNSigmasNegPion(0),
129
130 fTreeVariableDistOverTotMom(0),
131 fTreeVariableLeastNbrCrossedRows(0),
132 fTreeVariableLeastRatioCrossedRowsOverFindable(0),
133 fTreeVariableMultiplicity(0),
134
135 fTreeVariableRunNumber(0),
136 fTreeVariableEventNumber(0),
137
a0879a26 138
139//------------------------------------------------
140// HISTOGRAMS
141// --- Filled on an Event-by-event basis
142//------------------------------------------------
143 fHistV0MultiplicityBeforeTrigSel(0),
144 fHistV0MultiplicityForTrigEvt(0),
145 fHistV0MultiplicityForSelEvt(0),
146 fHistV0MultiplicityForSelEvtNoTPCOnly(0),
147 fHistV0MultiplicityForSelEvtNoTPCOnlyNoPileup(0),
148 fHistMultiplicityBeforeTrigSel(0),
149 fHistMultiplicityForTrigEvt(0),
150 fHistMultiplicity(0),
151 fHistMultiplicityNoTPCOnly(0),
152 fHistMultiplicityNoTPCOnlyNoPileup(0),
153 fHistPVx(0),
154 fHistPVy(0),
155 fHistPVz(0),
156 fHistPVxAnalysis(0),
157 fHistPVyAnalysis(0),
158 fHistPVzAnalysis(0),
159 fHistSwappedV0Counter(0)
160{
161 // Dummy Constructor
162}
163
164AliAnalysisTaskExtractV0AOD::AliAnalysisTaskExtractV0AOD(const char *name)
165 : AliAnalysisTaskSE(name), fListHistV0(0), fTree(0), fPIDResponse(0),
166 fkIsNuclear ( kFALSE ),
167 fkLowEnergyPP ( kFALSE ),
168 fkUseOnTheFly ( kFALSE ),
5336fa37 169 fTriggerMask ( "kMB" ),
a0879a26 170
048f4f8f 171//------------------------------------------------
172// Variables for tree
173//------------------------------------------------
174
175 fTreeVariableChi2V0(0),
176 fTreeVariableDcaV0Daughters(0),
177 fTreeVariableDcaV0ToPrimVertex(0),
178 fTreeVariableDcaPosToPrimVertex(0),
179 fTreeVariableDcaNegToPrimVertex(0),
180 fTreeVariableV0CosineOfPointingAngle(0),
181 fTreeVariableV0Radius(0),
182 fTreeVariablePt(0),
183 fTreeVariableRapK0Short(0),
184 fTreeVariableRapLambda(0),
185 fTreeVariableInvMassK0s(0),
186 fTreeVariableInvMassLambda(0),
187 fTreeVariableInvMassAntiLambda(0),
188 fTreeVariableAlphaV0(0),
189 fTreeVariablePtArmV0(0),
190 fTreeVariableNegTotMomentum(0),
191 fTreeVariablePosTotMomentum(0),
192 fTreeVariableNegdEdxSig(0),
193 fTreeVariablePosdEdxSig(0),
194 fTreeVariableNegEta(0),
195 fTreeVariablePosEta(0),
196
197 fTreeVariableNSigmasPosProton(0),
198 fTreeVariableNSigmasPosPion(0),
199 fTreeVariableNSigmasNegProton(0),
200 fTreeVariableNSigmasNegPion(0),
201
202 fTreeVariableDistOverTotMom(0),
203 fTreeVariableLeastNbrCrossedRows(0),
204 fTreeVariableLeastRatioCrossedRowsOverFindable(0),
205 fTreeVariableMultiplicity(0),
206
207 fTreeVariableRunNumber(0),
208 fTreeVariableEventNumber(0),
209
a0879a26 210//------------------------------------------------
211// HISTOGRAMS
212// --- Filled on an Event-by-event basis
213//------------------------------------------------
214 fHistV0MultiplicityBeforeTrigSel(0),
215 fHistV0MultiplicityForTrigEvt(0),
216 fHistV0MultiplicityForSelEvt(0),
217 fHistV0MultiplicityForSelEvtNoTPCOnly(0),
218 fHistV0MultiplicityForSelEvtNoTPCOnlyNoPileup(0),
219 fHistMultiplicityBeforeTrigSel(0),
220 fHistMultiplicityForTrigEvt(0),
221 fHistMultiplicity(0),
222 fHistMultiplicityNoTPCOnly(0),
223 fHistMultiplicityNoTPCOnlyNoPileup(0),
224 fHistPVx(0),
225 fHistPVy(0),
226 fHistPVz(0),
227 fHistPVxAnalysis(0),
228 fHistPVyAnalysis(0),
229 fHistPVzAnalysis(0),
230 fHistSwappedV0Counter(0)
231{
232 // Constructor
233 // Output slot #0 writes into a TList container (Lambda Histos and fTree)
234 DefineOutput(1, TList::Class());
235 DefineOutput(2, TTree::Class());
236}
237
238
239AliAnalysisTaskExtractV0AOD::~AliAnalysisTaskExtractV0AOD()
240{
241//------------------------------------------------
242// DESTRUCTOR
243//------------------------------------------------
244
245 if (fListHistV0){
246 delete fListHistV0;
247 fListHistV0 = 0x0;
248 }
249 if (fTree){
250 delete fTree;
251 fTree = 0x0;
252 }
253}
254
255
256
257//________________________________________________________________________
258void AliAnalysisTaskExtractV0AOD::UserCreateOutputObjects()
259{
260
261 //Create File-resident Tree, please.
262 OpenFile(2);
263 // Called once
264 fTree = new TTree("fTree","V0Candidates");
265
266//------------------------------------------------
267// fTree Branch definitions
268//------------------------------------------------
269
270//-----------BASIC-INFO---------------------------
271/* 1*/ fTree->Branch("fTreeVariableChi2V0",&fTreeVariableChi2V0,"fTreeVariableChi2V0/F");
272/* 2*/ fTree->Branch("fTreeVariableDcaV0Daughters",&fTreeVariableDcaV0Daughters,"fTreeVariableDcaV0Daughters/F");
273/* 3*/ fTree->Branch("fTreeVariableDcaPosToPrimVertex",&fTreeVariableDcaPosToPrimVertex,"fTreeVariableDcaPosToPrimVertex/F");
274/* 4*/ fTree->Branch("fTreeVariableDcaNegToPrimVertex",&fTreeVariableDcaNegToPrimVertex,"fTreeVariableDcaNegToPrimVertex/F");
275/* 5*/ fTree->Branch("fTreeVariableV0Radius",&fTreeVariableV0Radius,"fTreeVariableV0Radius/F");
276/* 6*/ fTree->Branch("fTreeVariablePt",&fTreeVariablePt,"fTreeVariablePt/F");
277/* 7*/ fTree->Branch("fTreeVariableRapK0Short",&fTreeVariableRapK0Short,"fTreeVariableRapK0Short/F");
278/* 8*/ fTree->Branch("fTreeVariableRapLambda",&fTreeVariableRapLambda,"fTreeVariableRapLambda/F");
279/* 9*/ fTree->Branch("fTreeVariableInvMassK0s",&fTreeVariableInvMassK0s,"fTreeVariableInvMassK0s/F");
280/*10*/ fTree->Branch("fTreeVariableInvMassLambda",&fTreeVariableInvMassLambda,"fTreeVariableInvMassLambda/F");
281/*11*/ fTree->Branch("fTreeVariableInvMassAntiLambda",&fTreeVariableInvMassAntiLambda,"fTreeVariableInvMassAntiLambda/F");
282/*12*/ fTree->Branch("fTreeVariableV0CosineOfPointingAngle",&fTreeVariableV0CosineOfPointingAngle,"fTreeVariableV0CosineOfPointingAngle/F");
283/*13*/ fTree->Branch("fTreeVariableAlphaV0",&fTreeVariableAlphaV0,"fTreeVariableAlphaV0/F");
284/*14*/ fTree->Branch("fTreeVariablePtArmV0",&fTreeVariablePtArmV0,"fTreeVariablePtArmV0/F");
285/*15*/ fTree->Branch("fTreeVariableLeastNbrCrossedRows",&fTreeVariableLeastNbrCrossedRows,"fTreeVariableLeastNbrCrossedRows/I");
286/*16*/ fTree->Branch("fTreeVariableLeastRatioCrossedRowsOverFindable",&fTreeVariableLeastRatioCrossedRowsOverFindable,"fTreeVariableLeastRatioCrossedRowsOverFindable/F");
287//-----------MULTIPLICITY-INFO--------------------
288/*17*/ fTree->Branch("fTreeVariableMultiplicity",&fTreeVariableMultiplicity,"fTreeVariableMultiplicity/I");
289//------------------------------------------------
290/*18*/ fTree->Branch("fTreeVariableDistOverTotMom",&fTreeVariableDistOverTotMom,"fTreeVariableDistOverTotMom/F");
291/*19*/ fTree->Branch("fTreeVariableNSigmasPosProton",&fTreeVariableNSigmasPosProton,"fTreeVariableNSigmasPosProton/F");
292/*20*/ fTree->Branch("fTreeVariableNSigmasPosPion",&fTreeVariableNSigmasPosPion,"fTreeVariableNSigmasPosPion/F");
293/*21*/ fTree->Branch("fTreeVariableNSigmasNegProton",&fTreeVariableNSigmasNegProton,"fTreeVariableNSigmasNegProton/F");
294/*22*/ fTree->Branch("fTreeVariableNSigmasNegPion",&fTreeVariableNSigmasNegPion,"fTreeVariableNSigmasNegPion/F");
295/*23*/ fTree->Branch("fTreeVariableNegEta",&fTreeVariableNegEta,"fTreeVariableNegEta/F");
296/*24*/ fTree->Branch("fTreeVariablePosEta",&fTreeVariablePosEta,"fTreeVariablePosEta/F");
297/*25*/ fTree->Branch("fTreeVariableRunNumber",&fTreeVariableRunNumber,"fTreeVariableRunNumber/I");
298/*26*/ fTree->Branch("fTreeVariableEventNumber",&fTreeVariableEventNumber,"fTreeVariableEventNumber/l");
299
300//------------------------------------------------
301// Particle Identification Setup
302//------------------------------------------------
303
304 AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager();
305 AliInputEventHandler* inputHandler = (AliInputEventHandler*) (man->GetInputEventHandler());
306 fPIDResponse = inputHandler->GetPIDResponse();
307
308//Skipped. Will use Local setup.
309
310//------------------------------------------------
311// V0 Multiplicity Histograms
312//------------------------------------------------
313
314 // Create histograms
315 //Create File-resident Tree, please.
316 OpenFile(1);
317
318 fListHistV0 = new TList();
319 fListHistV0->SetOwner(); // See http://root.cern.ch/root/html/TCollection.html#TCollection:SetOwner
320
321 if(! fHistV0MultiplicityBeforeTrigSel) {
322 fHistV0MultiplicityBeforeTrigSel = new TH1F("fHistV0MultiplicityBeforeTrigSel",
323 "V0s per event (before Trig. Sel.);Nbr of V0s/Evt;Events",
324 25, 0, 25);
325 fListHistV0->Add(fHistV0MultiplicityBeforeTrigSel);
326 }
327
328 if(! fHistV0MultiplicityForTrigEvt) {
329 fHistV0MultiplicityForTrigEvt = new TH1F("fHistV0MultiplicityForTrigEvt",
330 "V0s per event (for triggered evt);Nbr of V0s/Evt;Events",
331 25, 0, 25);
332 fListHistV0->Add(fHistV0MultiplicityForTrigEvt);
333 }
334
335 if(! fHistV0MultiplicityForSelEvt) {
336 fHistV0MultiplicityForSelEvt = new TH1F("fHistV0MultiplicityForSelEvt",
337 "V0s per event;Nbr of V0s/Evt;Events",
338 25, 0, 25);
339 fListHistV0->Add(fHistV0MultiplicityForSelEvt);
340 }
341
342 if(! fHistV0MultiplicityForSelEvtNoTPCOnly) {
343 fHistV0MultiplicityForSelEvtNoTPCOnly = new TH1F("fHistV0MultiplicityForSelEvtNoTPCOnly",
344 "V0s per event;Nbr of V0s/Evt;Events",
345 25, 0, 25);
346 fListHistV0->Add(fHistV0MultiplicityForSelEvtNoTPCOnly);
347 }
348
349 if(! fHistV0MultiplicityForSelEvtNoTPCOnlyNoPileup) {
350 fHistV0MultiplicityForSelEvtNoTPCOnlyNoPileup = new TH1F("fHistV0MultiplicityForSelEvtNoTPCOnlyNoPileup",
351 "V0s per event;Nbr of V0s/Evt;Events",
352 25, 0, 25);
353 fListHistV0->Add(fHistV0MultiplicityForSelEvtNoTPCOnlyNoPileup);
354 }
355
356//------------------------------------------------
357// Track Multiplicity Histograms
358//------------------------------------------------
359
360 if(! fHistMultiplicityBeforeTrigSel) {
361 fHistMultiplicityBeforeTrigSel = new TH1F("fHistMultiplicityBeforeTrigSel",
362 "Tracks per event;Nbr of Tracks;Events",
363 200, 0, 200);
364 fListHistV0->Add(fHistMultiplicityBeforeTrigSel);
365 }
366 if(! fHistMultiplicityForTrigEvt) {
367 fHistMultiplicityForTrigEvt = new TH1F("fHistMultiplicityForTrigEvt",
368 "Tracks per event;Nbr of Tracks;Events",
369 200, 0, 200);
370 fListHistV0->Add(fHistMultiplicityForTrigEvt);
371 }
372 if(! fHistMultiplicity) {
373 fHistMultiplicity = new TH1F("fHistMultiplicity",
374 "Tracks per event;Nbr of Tracks;Events",
375 200, 0, 200);
376 fListHistV0->Add(fHistMultiplicity);
377 }
378 if(! fHistMultiplicityNoTPCOnly) {
379 fHistMultiplicityNoTPCOnly = new TH1F("fHistMultiplicityNoTPCOnly",
380 "Tracks per event;Nbr of Tracks;Events",
381 200, 0, 200);
382 fListHistV0->Add(fHistMultiplicityNoTPCOnly);
383 }
384 if(! fHistMultiplicityNoTPCOnlyNoPileup) {
385 fHistMultiplicityNoTPCOnlyNoPileup = new TH1F("fHistMultiplicityNoTPCOnlyNoPileup",
386 "Tracks per event;Nbr of Tracks;Events",
387 200, 0, 200);
388 fListHistV0->Add(fHistMultiplicityNoTPCOnlyNoPileup);
389 }
390
391 if(! fHistPVx) {
392 fHistPVx = new TH1F("fHistPVx",
393 "PV x position;Nbr of Evts;x",
394 2000, -0.5, 0.5);
395 fListHistV0->Add(fHistPVx);
396 }
397 if(! fHistPVy) {
398 fHistPVy = new TH1F("fHistPVy",
399 "PV y position;Nbr of Evts;y",
400 2000, -0.5, 0.5);
401 fListHistV0->Add(fHistPVy);
402 }
403 if(! fHistPVz) {
404 fHistPVz = new TH1F("fHistPVz",
405 "PV z position;Nbr of Evts;z",
406 400, -20, 20);
407 fListHistV0->Add(fHistPVz);
408 }
409 if(! fHistPVxAnalysis) {
410 fHistPVxAnalysis = new TH1F("fHistPVxAnalysis",
411 "PV x position;Nbr of Evts;x",
412 2000, -0.5, 0.5);
413 fListHistV0->Add(fHistPVxAnalysis);
414 }
415 if(! fHistPVyAnalysis) {
416 fHistPVyAnalysis = new TH1F("fHistPVyAnalysis",
417 "PV y position;Nbr of Evts;y",
418 2000, -0.5, 0.5);
419 fListHistV0->Add(fHistPVyAnalysis);
420 }
421 if(! fHistPVzAnalysis) {
422 fHistPVzAnalysis = new TH1F("fHistPVzAnalysis",
423 "PV z position;Nbr of Evts;z",
424 400, -20, 20);
425 fListHistV0->Add(fHistPVzAnalysis);
426 }
427 if(! fHistSwappedV0Counter) {
428 fHistSwappedV0Counter = new TH1F("fHistSwappedV0Counter",
429 "Swap or not histo;Swapped (1) or not (0); count",
430 2, 0, 2);
431 fListHistV0->Add(fHistSwappedV0Counter);
432 }
433 //Regular output: Histograms
434 PostData(1, fListHistV0);
435 //TTree Object: Saved to base directory. Should cache to disk while saving.
436 //(Important to avoid excessive memory usage, particularly when merging)
437 PostData(2, fTree);
438
439}// end UserCreateOutputObjects
440
441
442//________________________________________________________________________
443void AliAnalysisTaskExtractV0AOD::UserExec(Option_t *)
444{
445
446 // Main loop
447 // Called for each event
448 //gObjectTable->Print();
449 AliAODEvent *lAODevent = 0x0;
450
451 //AliAODEvent *lAODevent = 0x0;
452 Int_t nV0s = -1;
453
454 Double_t lBestPrimaryVtxPos[3] = {-100.0, -100.0, -100.0};
455 Double_t lMagneticField = -10.;
456
457 // Connect to the InputEvent
458 // After these lines, we should have an ESD/AOD event + the number of cascades in it.
459
460 // Appropriate for ESD analysis!
461
462 lAODevent = dynamic_cast<AliAODEvent*>( InputEvent() );
463 if (!lAODevent) {
464 AliWarning("ERROR: lAODevent not available \n");
465 return;
466 }
467 fTreeVariableRunNumber = lAODevent->GetRunNumber();
468 fTreeVariableEventNumber =
469 ( ( ((ULong64_t)lAODevent->GetPeriodNumber() ) << 36 ) |
470 ( ((ULong64_t)lAODevent->GetOrbitNumber () ) << 12 ) |
471 ((ULong64_t)lAODevent->GetBunchCrossNumber() ) );
472
473 //REVISED multiplicity estimator after 'multiplicity day' (2011)
474 Int_t lMultiplicity = -100;
475
476 if(fkIsNuclear == kFALSE) lMultiplicity = -1;
477
478 //---> If this is a nuclear collision, then go nuclear on "multiplicity" variable...
479 //---> Warning: Experimental
480 if(fkIsNuclear == kTRUE){
481 AliCentrality* centrality;
482 centrality = lAODevent->GetCentrality();
483 lMultiplicity = ( ( Int_t ) ( centrality->GetCentralityPercentile( "V0M" ) ) );
484 if (centrality->GetQuality()>1) {
485 PostData(1, fListHistV0);
486 PostData(2, fTree);
487 return;
488 }
489 }
490
491 //Set variable for filling tree afterwards!
492 //---> pp case......: GetReferenceMultiplicity
493 //---> Pb-Pb case...: Centrality by V0M
494 fTreeVariableMultiplicity = lMultiplicity;
495 fHistMultiplicityBeforeTrigSel->Fill ( lMultiplicity );
496 fHistV0MultiplicityBeforeTrigSel->Fill ( lAODevent->GetNumberOfV0s() );
497
498//------------------------------------------------
499// Physics Selection
500//------------------------------------------------
501
502// new method
503 UInt_t maskIsSelected = ((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected();
504 Bool_t isSelected = 0;
5336fa37 505 //kMB: default selection, also if fTriggerMask is something not understood...
a0879a26 506 isSelected = (maskIsSelected & AliVEvent::kMB) == AliVEvent::kMB;
507
5336fa37 508 if( fTriggerMask == "kINT7" )
509 isSelected = (maskIsSelected & AliVEvent::kINT7) == AliVEvent::kINT7;
510 if( fTriggerMask == "kINT8" )
511 isSelected = (maskIsSelected & AliVEvent::kINT8) == AliVEvent::kINT8;
512 if( fTriggerMask == "kAnyINT" )
513 isSelected = (maskIsSelected & AliVEvent::kAnyINT) == AliVEvent::kAnyINT;
514
a0879a26 515 //pp at 2.76TeV: special case, ignore FastOnly
516 if ( (fkLowEnergyPP == kTRUE) && (maskIsSelected& AliVEvent::kFastOnly) ){
517 PostData(1, fListHistV0);
518 PostData(2, fTree);
519 return;
520 }
521 //Standard Min-Bias Selection
522 if ( ! isSelected ) {
523 PostData(1, fListHistV0);
524 PostData(2, fTree);
525 return;
526 }
527
528//------------------------------------------------
529// After Trigger Selection
530//------------------------------------------------
531
532 nV0s = lAODevent->GetNumberOfV0s();
533
534 fHistV0MultiplicityForTrigEvt ->Fill( nV0s );
535 fHistMultiplicityForTrigEvt ->Fill( lMultiplicity );
536
537//------------------------------------------------
538// Getting: Primary Vertex + MagField Info
539//------------------------------------------------
540
541 const AliAODVertex *lPrimaryBestAODVtx = lAODevent->GetPrimaryVertex();
542 // get the best primary vertex available for the event
543 // As done in AliCascadeVertexer, we keep the one which is the best one available.
544 // between : Tracking vertex > SPD vertex > TPC vertex > default SPD vertex
545 // This one will be used for next calculations (DCA essentially)
546 lPrimaryBestAODVtx->GetXYZ( lBestPrimaryVtxPos );
547
548 Double_t tPrimaryVtxPosition[3];
549 const AliVVertex *primaryVtx = lAODevent->GetPrimaryVertex();
550 tPrimaryVtxPosition[0] = primaryVtx->GetX();
551 tPrimaryVtxPosition[1] = primaryVtx->GetY();
552 tPrimaryVtxPosition[2] = primaryVtx->GetZ();
553 fHistPVx->Fill( tPrimaryVtxPosition[0] );
554 fHistPVy->Fill( tPrimaryVtxPosition[1] );
555 fHistPVz->Fill( tPrimaryVtxPosition[2] );
556
557//------------------------------------------------
558// Primary Vertex Z position: SKIP
559//------------------------------------------------
560
561 if(TMath::Abs(lBestPrimaryVtxPos[2]) > 10.0 ) {
562 AliWarning("Pb / | Z position of Best Prim Vtx | > 10.0 cm ... return !");
563 PostData(1, fListHistV0);
564 PostData(2, fTree);
565 return;
566 }
567
568 lMagneticField = lAODevent->GetMagneticField( );
569 fHistV0MultiplicityForSelEvt ->Fill( nV0s );
570 fHistMultiplicity->Fill(lMultiplicity);
571
572//------------------------------------------------
573// Only look at events with well-established PV
574//------------------------------------------------
575
576 const AliAODVertex *lPrimaryTrackingAODVtxCheck = lAODevent->GetPrimaryVertex();
577 const AliAODVertex *lPrimarySPDVtx = lAODevent->GetPrimaryVertexSPD();
578 if (!lPrimarySPDVtx && !lPrimaryTrackingAODVtxCheck ){
579 AliWarning("Pb / No SPD prim. vertex nor prim. Tracking vertex ... return !");
580 PostData(1, fListHistV0);
581 PostData(2, fTree);
582 return;
583 }
584
585 fHistV0MultiplicityForSelEvtNoTPCOnly ->Fill( nV0s );
586 fHistMultiplicityNoTPCOnly->Fill(lMultiplicity);
587
588//------------------------------------------------
589// Pileup Rejection
590//------------------------------------------------
591
592 // FIXME : quality selection regarding pile-up rejection
593 if(lAODevent->IsPileupFromSPD() && !fkIsNuclear){// minContributors=3, minZdist=0.8, nSigmaZdist=3., nSigmaDiamXY=2., nSigmaDiamZ=5. -> see http://alisoft.cern.ch/viewvc/trunk/STEER/AliESDEvent.h?root=AliRoot&r1=41914&r2=42199&pathrev=42199
594 PostData(1, fListHistV0);
595 PostData(2, fTree);
596 return;
597 }
598 fHistV0MultiplicityForSelEvtNoTPCOnlyNoPileup ->Fill( nV0s );
599 fHistMultiplicityNoTPCOnlyNoPileup->Fill(lMultiplicity);
600
601//------------------------------------------------
602// MAIN LAMBDA LOOP STARTS HERE
603//------------------------------------------------
604
605 //if( ! (lAODevent->GetPrimaryVertex()->IsFromVertexerZ() ) ){
606 fHistPVxAnalysis->Fill( tPrimaryVtxPosition[0] );
607 fHistPVyAnalysis->Fill( tPrimaryVtxPosition[1] );
608 fHistPVzAnalysis->Fill( tPrimaryVtxPosition[2] );
609 //}
610
611//Variable definition
612 Int_t lOnFlyStatus = 0;// nv0sOn = 0, nv0sOff = 0;
613 Double_t lChi2V0 = 0;
614 Double_t lDcaV0Daughters = 0, lDcaV0ToPrimVertex = 0;
615 Double_t lDcaPosToPrimVertex = 0, lDcaNegToPrimVertex = 0;
616 Double_t lV0CosineOfPointingAngle = 0;
617 Double_t lV0Radius = 0, lPt = 0;
618 Double_t lRapK0Short = 0, lRapLambda = 0;
619 Double_t lInvMassK0s = 0, lInvMassLambda = 0, lInvMassAntiLambda = 0;
620 Double_t lAlphaV0 = 0, lPtArmV0 = 0;
621
622 Double_t fMinV0Pt = 0;
623 Double_t fMaxV0Pt = 100;
624
625 Int_t nv0s = 0;
626 nv0s = lAODevent->GetNumberOfV0s();
627
628 //for (Int_t iV0 = 0; iV0 < nv0s; iV0++)
629 for (Int_t iV0 = 0; iV0 < nv0s; iV0++) //extra-crazy test
630 {// This is the begining of the V0 loop
631 AliAODv0 *v0 = lAODevent->GetV0(iV0);
632 if (!v0) continue;
633
634 //Obsolete at AOD level...
635 //---> Fix On-the-Fly candidates, count how many swapped
636 //if( v0->GetParamN()->Charge() > 0 && v0->GetParamP()->Charge() < 0 ){
637 // fHistSwappedV0Counter -> Fill( 1 );
638 //}else{
639 // fHistSwappedV0Counter -> Fill( 0 );
640 //}
641 //if ( fkUseOnTheFly ) CheckChargeV0(v0);
642
643 Double_t tDecayVertexV0[3]; v0->GetXYZ(tDecayVertexV0);
644 Double_t tV0mom[3];
645 v0->GetPxPyPz( tV0mom );
646 Double_t lV0TotalMomentum = TMath::Sqrt(
647 tV0mom[0]*tV0mom[0]+tV0mom[1]*tV0mom[1]+tV0mom[2]*tV0mom[2] );
648
649 lV0Radius = TMath::Sqrt(tDecayVertexV0[0]*tDecayVertexV0[0]+tDecayVertexV0[1]*tDecayVertexV0[1]);
650 lPt = v0->Pt();
651 lRapK0Short = v0->RapK0Short();
652 lRapLambda = v0->RapLambda();
653 if ((lPt<fMinV0Pt)||(fMaxV0Pt<lPt)) continue;
654
22644944 655 //UInt_t lKeyPos = (UInt_t)TMath::Abs(v0->GetPosID());
656 //UInt_t lKeyNeg = (UInt_t)TMath::Abs(v0->GetPosID());
a0879a26 657
658 Double_t lMomPos[3]; //v0->GetPPxPyPz(lMomPos[0],lMomPos[1],lMomPos[2]);
659 Double_t lMomNeg[3]; //v0->GetNPxPyPz(lMomNeg[0],lMomNeg[1],lMomNeg[2]);
660 lMomPos[0] = v0->MomPosX();
661 lMomPos[1] = v0->MomPosY();
662 lMomPos[2] = v0->MomPosZ();
663 lMomNeg[0] = v0->MomNegX();
664 lMomNeg[1] = v0->MomNegY();
665 lMomNeg[2] = v0->MomNegZ();
666
667 AliAODTrack *pTrack=(AliAODTrack *)v0->GetDaughter(0); //0->Positive Daughter
668 AliAODTrack *nTrack=(AliAODTrack *)v0->GetDaughter(1); //1->Negative Daughter
669 if (!pTrack || !nTrack) {
670 Printf("ERROR: Could not retreive one of the daughter track");
671 continue;
672 }
673
674 //Daughter Eta for Eta selection, afterwards
675 fTreeVariableNegEta = nTrack->Eta();
676 fTreeVariablePosEta = pTrack->Eta();
677
678 // Filter like-sign V0 (next: add counter and distribution)
679 if ( pTrack->Charge() == nTrack->Charge()){
680 continue;
681 }
682
683 //Quick test this far!
684
685
686 //________________________________________________________________________
687 // Track quality cuts
688 Float_t lPosTrackCrossedRows = pTrack->GetTPCClusterInfo(2,1);
689 Float_t lNegTrackCrossedRows = nTrack->GetTPCClusterInfo(2,1);
690 fTreeVariableLeastNbrCrossedRows = (Int_t) lPosTrackCrossedRows;
691 if( lNegTrackCrossedRows < fTreeVariableLeastNbrCrossedRows )
692 fTreeVariableLeastNbrCrossedRows = (Int_t) lNegTrackCrossedRows;
693
694 // TPC refit condition (done during reconstruction for Offline but not for On-the-fly)
695 if( !(pTrack->GetStatus() & AliESDtrack::kTPCrefit)) continue;
696 if( !(nTrack->GetStatus() & AliESDtrack::kTPCrefit)) continue;
697
698 if ( ( ( pTrack->GetTPCClusterInfo(2,1) ) < 70 ) || ( ( nTrack->GetTPCClusterInfo(2,1) ) < 70 ) ) continue;
699
700 //GetKinkIndex condition
701 //if( pTrack->GetKinkIndex(0)>0 || nTrack->GetKinkIndex(0)>0 ) continue;
702
703 //Findable clusters > 0 condition
704 if( pTrack->GetTPCNclsF()<=0 || nTrack->GetTPCNclsF()<=0 ) continue;
705
706 //Compute ratio Crossed Rows / Findable clusters
707 //Note: above test avoids division by zero!
708 Float_t lPosTrackCrossedRowsOverFindable = lPosTrackCrossedRows / ((double)(pTrack->GetTPCNclsF()));
709 Float_t lNegTrackCrossedRowsOverFindable = lNegTrackCrossedRows / ((double)(nTrack->GetTPCNclsF()));
710
711 fTreeVariableLeastRatioCrossedRowsOverFindable = lPosTrackCrossedRowsOverFindable;
712 if( lNegTrackCrossedRowsOverFindable < fTreeVariableLeastRatioCrossedRowsOverFindable )
713 fTreeVariableLeastRatioCrossedRowsOverFindable = lNegTrackCrossedRowsOverFindable;
714
715 //Lowest Cut Level for Ratio Crossed Rows / Findable = 0.8, set here
716 if ( fTreeVariableLeastRatioCrossedRowsOverFindable < 0.8 ) continue;
717
718 //End track Quality Cuts
719 //________________________________________________________________________
720
721
722 //ESD code: obsolete
723 //lDcaPosToPrimVertex = TMath::Abs(pTrack->GetD(tPrimaryVtxPosition[0],
724 // tPrimaryVtxPosition[1],
725 // lMagneticField) );
726
727 //lDcaNegToPrimVertex = TMath::Abs(nTrack->GetD(tPrimaryVtxPosition[0],
728 // tPrimaryVtxPosition[1],
729 // lMagneticField) );
730
731 lDcaPosToPrimVertex = v0->DcaPosToPrimVertex();
732 lDcaNegToPrimVertex = v0->DcaNegToPrimVertex();
733
734
735 lOnFlyStatus = v0->GetOnFlyStatus();
736 lChi2V0 = v0->Chi2V0();
737 lDcaV0Daughters = v0->DcaV0Daughters();
738 lDcaV0ToPrimVertex = v0->DcaV0ToPrimVertex();
739 lV0CosineOfPointingAngle = v0->CosPointingAngle(tPrimaryVtxPosition);
740 fTreeVariableV0CosineOfPointingAngle=lV0CosineOfPointingAngle;
741
742 // Getting invariant mass infos directly from ESD
743 lInvMassK0s = v0->MassK0Short();
744 lInvMassLambda = v0->MassLambda();
745 lInvMassAntiLambda = v0->MassAntiLambda();
746 lAlphaV0 = v0->AlphaV0();
747 lPtArmV0 = v0->PtArmV0();
748
749 fTreeVariablePt = v0->Pt();
750 fTreeVariableChi2V0 = lChi2V0;
751 fTreeVariableDcaV0ToPrimVertex = lDcaV0ToPrimVertex;
752 fTreeVariableDcaV0Daughters = lDcaV0Daughters;
753 fTreeVariableV0CosineOfPointingAngle = lV0CosineOfPointingAngle;
754 fTreeVariableV0Radius = lV0Radius;
755 fTreeVariableDcaPosToPrimVertex = lDcaPosToPrimVertex;
756 fTreeVariableDcaNegToPrimVertex = lDcaNegToPrimVertex;
757 fTreeVariableInvMassK0s = lInvMassK0s;
758 fTreeVariableInvMassLambda = lInvMassLambda;
759 fTreeVariableInvMassAntiLambda = lInvMassAntiLambda;
760 fTreeVariableRapK0Short = lRapK0Short;
761 fTreeVariableRapLambda = lRapLambda;
762 fTreeVariableAlphaV0 = lAlphaV0;
763 fTreeVariablePtArmV0 = lPtArmV0;
764
765 //Official means of acquiring N-sigmas
766 fTreeVariableNSigmasPosProton = fPIDResponse->NumberOfSigmasTPC( pTrack, AliPID::kProton );
767 fTreeVariableNSigmasPosPion = fPIDResponse->NumberOfSigmasTPC( pTrack, AliPID::kPion );
768 fTreeVariableNSigmasNegProton = fPIDResponse->NumberOfSigmasTPC( nTrack, AliPID::kProton );
769 fTreeVariableNSigmasNegPion = fPIDResponse->NumberOfSigmasTPC( nTrack, AliPID::kPion );
770
771//This requires an Invariant Mass Hypothesis afterwards
772 fTreeVariableDistOverTotMom = TMath::Sqrt(
773 TMath::Power( tDecayVertexV0[0] - lBestPrimaryVtxPos[0] , 2) +
774 TMath::Power( tDecayVertexV0[1] - lBestPrimaryVtxPos[1] , 2) +
775 TMath::Power( tDecayVertexV0[2] - lBestPrimaryVtxPos[2] , 2)
776 );
777 fTreeVariableDistOverTotMom /= (lV0TotalMomentum+1e-10); //avoid division by zero, to be sure
778
779//------------------------------------------------
780// Fill Tree!
781//------------------------------------------------
782
783// The conditionals are meant to decrease excessive
784// memory usage!
785
786//First Selection: Reject OnFly
787 if( (lOnFlyStatus == 0 && fkUseOnTheFly == kFALSE) || (lOnFlyStatus != 0 && fkUseOnTheFly == kTRUE ) ){
788 //Second Selection: rough 20-sigma band, parametric.
789 //K0Short: Enough to parametrize peak broadening with linear function.
790 Double_t lUpperLimitK0Short = (5.63707e-01) + (1.14979e-02)*fTreeVariablePt;
791 Double_t lLowerLimitK0Short = (4.30006e-01) - (1.10029e-02)*fTreeVariablePt;
792 //Lambda: Linear (for higher pt) plus exponential (for low-pt broadening)
793 //[0]+[1]*x+[2]*TMath::Exp(-[3]*x)
794 Double_t lUpperLimitLambda = (1.13688e+00) + (5.27838e-03)*fTreeVariablePt + (8.42220e-02)*TMath::Exp(-(3.80595e+00)*fTreeVariablePt);
795 Double_t lLowerLimitLambda = (1.09501e+00) - (5.23272e-03)*fTreeVariablePt - (7.52690e-02)*TMath::Exp(-(3.46339e+00)*fTreeVariablePt);
796 //Do Selection
797 if( (fTreeVariableInvMassLambda < lUpperLimitLambda && fTreeVariableInvMassLambda > lLowerLimitLambda ) ||
798 (fTreeVariableInvMassAntiLambda < lUpperLimitLambda && fTreeVariableInvMassAntiLambda > lLowerLimitLambda ) ||
799 (fTreeVariableInvMassK0s < lUpperLimitK0Short && fTreeVariableInvMassK0s > lLowerLimitK0Short ) ){
800 //Pre-selection in case this is AA...
dab4b971 801 //if( fkIsNuclear == kFALSE ) fTree->Fill();
802 //if( fkIsNuclear == kTRUE){
a0879a26 803 //If this is a nuclear collision___________________
804 // ... pre-filter with TPC, daughter eta selection
dab4b971 805 //if( (fTreeVariableInvMassLambda < lUpperLimitLambda && fTreeVariableInvMassLambda > lLowerLimitLambda
806 // && TMath::Abs(fTreeVariableNSigmasPosProton) < 6.0 && TMath::Abs(fTreeVariableNSigmasNegPion) < 6.0 ) ||
807 // (fTreeVariableInvMassAntiLambda < lUpperLimitLambda && fTreeVariableInvMassAntiLambda > lLowerLimitLambda
808 // && TMath::Abs(fTreeVariableNSigmasNegProton) < 6.0 && TMath::Abs(fTreeVariableNSigmasPosPion) < 6.0 ) ||
809 // (fTreeVariableInvMassK0s < lUpperLimitK0Short && fTreeVariableInvMassK0s > lLowerLimitK0Short
810 // && TMath::Abs(fTreeVariableNSigmasNegPion) < 6.0 && TMath::Abs(fTreeVariableNSigmasPosPion) < 6.0 ) ){
a0879a26 811 //insane test
812 if ( TMath::Abs(fTreeVariableNegEta)<0.8 && TMath::Abs(fTreeVariablePosEta)<0.8 ) fTree->Fill();
dab4b971 813 //}
814 //}//end nuclear_____________________________________
a0879a26 815 }
816 }
817
818//------------------------------------------------
819// Fill tree over.
820//------------------------------------------------
821
822 }// This is the end of the V0 loop
823
824 // Post output data.
825 PostData(1, fListHistV0);
826 PostData(2, fTree);
827
828
829}
830
831//________________________________________________________________________
832void AliAnalysisTaskExtractV0AOD::Terminate(Option_t *)
833{
834 // Draw result to the screen
835 // Called once at the end of the query
836 // This will draw the V0 candidate multiplicity, whose
837 // number of entries corresponds to the number of triggered events.
838 TList *cRetrievedList = 0x0;
839 cRetrievedList = (TList*)GetOutputData(1);
840 if(!cRetrievedList){
841 Printf("ERROR - AliAnalysisTaskExtractV0AOD : ouput data container list not available\n");
842 return;
843 }
844 fHistV0MultiplicityForTrigEvt = dynamic_cast<TH1F*> ( cRetrievedList->FindObject("fHistV0MultiplicityForTrigEvt") );
845 if (!fHistV0MultiplicityForTrigEvt) {
846 Printf("ERROR - AliAnalysisTaskExtractV0AOD : fHistV0MultiplicityForTrigEvt not available");
847 return;
848 }
849 TCanvas *canCheck = new TCanvas("AliAnalysisTaskExtractV0AOD","V0 Multiplicity",10,10,510,510);
850 canCheck->cd(1)->SetLogy();
851 fHistV0MultiplicityForTrigEvt->SetMarkerStyle(22);
852 fHistV0MultiplicityForTrigEvt->DrawCopy("E");
853}
854
855//________________________________________________________________________
856void AliAnalysisTaskExtractV0AOD::CheckChargeV0(AliESDv0 *v0)
857{
858 // This function checks charge of negative and positive daughter tracks.
859 // If incorrectly defined (onfly vertexer), swaps out.
860 if( v0->GetParamN()->Charge() > 0 && v0->GetParamP()->Charge() < 0 ){
861 //V0 daughter track swapping is required! Note: everything is swapped here... P->N, N->P
862 Long_t lCorrectNidx = v0->GetPindex();
863 Long_t lCorrectPidx = v0->GetNindex();
864 Double32_t lCorrectNmom[3];
865 Double32_t lCorrectPmom[3];
866 v0->GetPPxPyPz( lCorrectNmom[0], lCorrectNmom[1], lCorrectNmom[2] );
867 v0->GetNPxPyPz( lCorrectPmom[0], lCorrectPmom[1], lCorrectPmom[2] );
868
869 AliExternalTrackParam lCorrectParamN(
870 v0->GetParamP()->GetX() ,
871 v0->GetParamP()->GetAlpha() ,
872 v0->GetParamP()->GetParameter() ,
873 v0->GetParamP()->GetCovariance()
874 );
875 AliExternalTrackParam lCorrectParamP(
876 v0->GetParamN()->GetX() ,
877 v0->GetParamN()->GetAlpha() ,
878 v0->GetParamN()->GetParameter() ,
879 v0->GetParamN()->GetCovariance()
880 );
881 lCorrectParamN.SetMostProbablePt( v0->GetParamP()->GetMostProbablePt() );
882 lCorrectParamP.SetMostProbablePt( v0->GetParamN()->GetMostProbablePt() );
883
884 //Get Variables___________________________________________________
885 Double_t lDcaV0Daughters = v0 -> GetDcaV0Daughters();
886 Double_t lCosPALocal = v0 -> GetV0CosineOfPointingAngle();
887 Bool_t lOnFlyStatusLocal = v0 -> GetOnFlyStatus();
888
889 //Create Replacement Object_______________________________________
890 AliESDv0 *v0correct = new AliESDv0(lCorrectParamN,lCorrectNidx,lCorrectParamP,lCorrectPidx);
891 v0correct->SetDcaV0Daughters ( lDcaV0Daughters );
892 v0correct->SetV0CosineOfPointingAngle ( lCosPALocal );
893 v0correct->ChangeMassHypothesis ( kK0Short );
894 v0correct->SetOnFlyStatus ( lOnFlyStatusLocal );
895
896 //Reverse Cluster info..._________________________________________
897 v0correct->SetClusters( v0->GetClusters( 1 ), v0->GetClusters ( 0 ) );
898
899 *v0 = *v0correct;
900 //Proper cleanup..._______________________________________________
901 v0correct->Delete();
902 v0correct = 0x0;
903
904 //Just another cross-check and output_____________________________
905 if( v0->GetParamN()->Charge() > 0 && v0->GetParamP()->Charge() < 0 ) {
906 AliWarning("Found Swapped Charges, tried to correct but something FAILED!");
907 }else{
908 //AliWarning("Found Swapped Charges and fixed.");
909 }
910 //________________________________________________________________
911 }else{
912 //Don't touch it! ---
913 //Printf("Ah, nice. Charges are already ordered...");
914 }
915 return;
916}