]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG4/GammaConv/AliV0Reader.cxx
Added functionality to read cuts from string, in addition some added resolution plots...
[u/mrichter/AliRoot.git] / PWG4 / GammaConv / AliV0Reader.cxx
CommitLineData
a0b94e5c 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: Ana Marin, Kathrin Koch, Kenneth Aamodt *
5 * Version 1.0 *
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// Class used to do analysis on conversion pairs
19//---------------------------------------------
20////////////////////////////////////////////////
21
22// --- ROOT system ---
23#include <TMath.h>
24
25//---- ANALYSIS system ----
26#include "AliV0Reader.h"
27#include "AliAnalysisManager.h"
28#include "AliESDInputHandler.h"
29#include "AliESDtrack.h"
30#include "AliMCEvent.h"
31#include "AliKFVertex.h"
32
33#include "AliStack.h"
34#include "AliMCEventHandler.h"
10d100d4 35#include "AliESDpid.h"
5e55d806 36#include "AliGammaConversionBGHandler.h"
037dc2db 37#include "AliESDtrackCuts.h"
38
a0b94e5c 39
40class iostream;
41class AliESDv0;
42class TFormula;
43
44using namespace std;
45
46ClassImp(AliV0Reader)
47
48
49
50AliV0Reader::AliV0Reader() :
51 TObject(),
52 fMCStack(NULL),
48682642 53 // fMCTruth(NULL),
a0b94e5c 54 fMCEvent(NULL), // for CF
55 fChain(NULL),
48682642 56 // fESDHandler(NULL),
a0b94e5c 57 fESDEvent(NULL),
4a6157dc 58 fCFManager(NULL),
10d100d4 59 fESDpid(NULL),
a0b94e5c 60 fHistograms(NULL),
61 fCurrentV0IndexNumber(0),
62 fCurrentV0(NULL),
63 fCurrentNegativeKFParticle(NULL),
64 fCurrentPositiveKFParticle(NULL),
65 fCurrentMotherKFCandidate(NULL),
66 fCurrentNegativeESDTrack(NULL),
67 fCurrentPositiveESDTrack(NULL),
68 fNegativeTrackLorentzVector(NULL),
69 fPositiveTrackLorentzVector(NULL),
70 fMotherCandidateLorentzVector(NULL),
71 fCurrentXValue(0),
72 fCurrentYValue(0),
73 fCurrentZValue(0),
74 fPositiveTrackPID(0),
75 fNegativeTrackPID(0),
76 fNegativeMCParticle(NULL),
77 fPositiveMCParticle(NULL),
78 fMotherMCParticle(NULL),
79 fMotherCandidateKFMass(0),
80 fMotherCandidateKFWidth(0),
81 fUseKFParticle(kTRUE),
82 fUseESDTrack(kFALSE),
83 fDoMC(kFALSE),
84 fMaxR(10000),// 100 meter(outside of ALICE)
85 fEtaCut(0.),
86 fPtCut(0.),
48682642 87 fSinglePtCut(0.),
a0b94e5c 88 fMaxZ(0.),
48682642 89 fMinClsTPC(0.),
a0b94e5c 90 fLineCutZRSlope(0.),
91 fLineCutZValue(0.),
92 fChi2CutConversion(0.),
93 fChi2CutMeson(0.),
94 fPIDProbabilityCutNegativeParticle(0),
95 fPIDProbabilityCutPositiveParticle(0),
9640a3d1 96 fDodEdxSigmaCut(kFALSE),
97 fPIDnSigmaAboveElectronLine(100),
98 fPIDnSigmaBelowElectronLine(-100),
99 fPIDnSigmaAbovePionLine(-100),
100 fPIDMinPnSigmaAbovePionLine(100),
a0b94e5c 101 fXVertexCut(0.),
102 fYVertexCut(0.),
103 fZVertexCut(0.),
104 fNSigmaMass(0.),
105 fUseImprovedVertex(kFALSE),
106 fUseOwnXYZCalculation(kFALSE),
1e7846f4 107 fDoCF(kFALSE),
77880bd8 108 fUseOnFlyV0Finder(kTRUE),
cb90a330 109 fUpdateV0AlreadyCalled(kFALSE),
5e55d806 110 fCurrentEventGoodV0s(NULL),
111// fPreviousEventGoodV0s(),
87f6de3e 112 fCalculateBackground(kFALSE),
5e55d806 113 fBGEventHandler(NULL),
037dc2db 114 fBGEventInitialized(kFALSE),
115 fEsdTrackCuts(NULL),
116 fNumberOfESDTracks(0)
a0b94e5c 117{
10d100d4 118 fESDpid = new AliESDpid;
a0b94e5c 119}
120
121
122AliV0Reader::AliV0Reader(const AliV0Reader & original) :
123 TObject(original),
124 fMCStack(original.fMCStack),
48682642 125 // fMCTruth(original.fMCTruth),
a0b94e5c 126 fMCEvent(original.fMCEvent), // for CF
127 fChain(original.fChain),
48682642 128 // fESDHandler(original.fESDHandler),
a0b94e5c 129 fESDEvent(original.fESDEvent),
4a6157dc 130 fCFManager(original.fCFManager),
10d100d4 131 fESDpid(original.fESDpid),
a0b94e5c 132 fHistograms(original.fHistograms),
133 fCurrentV0IndexNumber(original.fCurrentV0IndexNumber),
134 fCurrentV0(original.fCurrentV0),
135 fCurrentNegativeKFParticle(original.fCurrentNegativeKFParticle),
136 fCurrentPositiveKFParticle(original.fCurrentPositiveKFParticle),
137 fCurrentMotherKFCandidate(original.fCurrentMotherKFCandidate),
138 fCurrentNegativeESDTrack(original.fCurrentNegativeESDTrack),
139 fCurrentPositiveESDTrack(original.fCurrentPositiveESDTrack),
140 fNegativeTrackLorentzVector(original.fNegativeTrackLorentzVector),
141 fPositiveTrackLorentzVector(original.fPositiveTrackLorentzVector),
142 fMotherCandidateLorentzVector(original.fMotherCandidateLorentzVector),
143 fCurrentXValue(original.fCurrentXValue),
144 fCurrentYValue(original.fCurrentYValue),
145 fCurrentZValue(original.fCurrentZValue),
146 fPositiveTrackPID(original.fPositiveTrackPID),
147 fNegativeTrackPID(original.fNegativeTrackPID),
148 fNegativeMCParticle(original.fNegativeMCParticle),
149 fPositiveMCParticle(original.fPositiveMCParticle),
150 fMotherMCParticle(original.fMotherMCParticle),
151 fMotherCandidateKFMass(original.fMotherCandidateKFMass),
152 fMotherCandidateKFWidth(original.fMotherCandidateKFWidth),
153 fUseKFParticle(kTRUE),
154 fUseESDTrack(kFALSE),
155 fDoMC(kFALSE),
156 fMaxR(original.fMaxR),
157 fEtaCut(original.fEtaCut),
158 fPtCut(original.fPtCut),
48682642 159 fSinglePtCut(original.fSinglePtCut),
a0b94e5c 160 fMaxZ(original.fMaxZ),
48682642 161 fMinClsTPC(original.fMinClsTPC),
a0b94e5c 162 fLineCutZRSlope(original.fLineCutZRSlope),
163 fLineCutZValue(original.fLineCutZValue),
164 fChi2CutConversion(original.fChi2CutConversion),
165 fChi2CutMeson(original.fChi2CutMeson),
166 fPIDProbabilityCutNegativeParticle(original.fPIDProbabilityCutNegativeParticle),
167 fPIDProbabilityCutPositiveParticle(original.fPIDProbabilityCutPositiveParticle),
9640a3d1 168 fDodEdxSigmaCut(original.fDodEdxSigmaCut),
169 fPIDnSigmaAboveElectronLine(original.fPIDnSigmaAboveElectronLine),
170 fPIDnSigmaBelowElectronLine(original.fPIDnSigmaBelowElectronLine),
171 fPIDnSigmaAbovePionLine(original.fPIDnSigmaAbovePionLine),
172 fPIDMinPnSigmaAbovePionLine(original.fPIDMinPnSigmaAbovePionLine),
a0b94e5c 173 fXVertexCut(original.fXVertexCut),
174 fYVertexCut(original.fYVertexCut),
175 fZVertexCut(original.fZVertexCut),
176 fNSigmaMass(original.fNSigmaMass),
177 fUseImprovedVertex(original.fUseImprovedVertex),
178 fUseOwnXYZCalculation(original.fUseOwnXYZCalculation),
1e7846f4 179 fDoCF(original.fDoCF),
77880bd8 180 fUseOnFlyV0Finder(original.fUseOnFlyV0Finder),
cb90a330 181 fUpdateV0AlreadyCalled(original.fUpdateV0AlreadyCalled),
a0b94e5c 182 fCurrentEventGoodV0s(original.fCurrentEventGoodV0s),
5e55d806 183 // fPreviousEventGoodV0s(original.fPreviousEventGoodV0s),
87f6de3e 184 fCalculateBackground(original.fCalculateBackground),
5e55d806 185 fBGEventHandler(original.fBGEventHandler),
037dc2db 186 fBGEventInitialized(original.fBGEventInitialized),
187 fEsdTrackCuts(original.fEsdTrackCuts),
188 fNumberOfESDTracks(original.fNumberOfESDTracks)
a0b94e5c 189{
190
191}
192
193
194AliV0Reader & AliV0Reader::operator = (const AliV0Reader & /*source*/)
195{
196 // assignment operator
197 return *this;
198}
9640a3d1 199AliV0Reader::~AliV0Reader()
200{
10d100d4 201 if(fESDpid){
202 delete fESDpid;
9640a3d1 203 }
204}
a0b94e5c 205
48682642 206//____________________________________________________________________________
207void AliV0Reader::SetInputAndMCEvent(AliVEvent* esd, AliMCEvent* mc) {
208 // Connect the data pointers
209
210 SetInputEvent(esd);
211 SetMC(mc);
212
213}
214
215
a0b94e5c 216void AliV0Reader::Initialize(){
217 //see header file for documentation
5e55d806 218
cb90a330 219 fUpdateV0AlreadyCalled = kFALSE;
48682642 220
221 /*
a0b94e5c 222 // Get the input handler from the manager
223 fESDHandler = (AliESDInputHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
224 if(fESDHandler == NULL){
225 //print warning here
226 }
48682642 227
a0b94e5c 228 // Get pointer to esd event from input handler
229 fESDEvent = fESDHandler->GetEvent();
230 if(fESDEvent == NULL){
231 //print warning here
232 }
48682642 233
a0b94e5c 234 //Get pointer to MCTruth
235 fMCTruth = (AliMCEventHandler*)((AliAnalysisManager::GetAnalysisManager())->GetMCtruthEventHandler());
48682642 236 */
237
238
239
240 // fMCTruth = mcH->MCEvent();
241 // fMC = mcH->MCEvent();
242 // stack = fMC->Stack();
243
244
245 //if(fMCTruth == NULL){
a0b94e5c 246 //print warning here
48682642 247 // fDoMC = kFALSE;
248 //}
249
250 if(fMCEvent == NULL){
251 fDoMC = kFALSE;
a0b94e5c 252 }
48682642 253
a0b94e5c 254 //Get pointer to the mc stack
48682642 255 // if(fMCTruth){
256 if(fMCEvent){
257 fMCStack = fMCEvent->Stack();
61374d97 258 if(fMCStack == NULL){
259 //print warning here
260 }
5e55d806 261 // Better parameters for MonteCarlo from A. Kalweit 2010/01/8
10d100d4 262 fESDpid->GetTPCResponse().SetBetheBlochParameters( 2.15898e+00/50.,
5e55d806 263 1.75295e+01,
264 3.40030e-09,
265 1.96178e+00,
266 3.91720e+00);
267 }
268 else{
269 // Better parameters for data from A. Kalweit 2010/01/8
10d100d4 270 fESDpid->GetTPCResponse().SetBetheBlochParameters(0.0283086,
5e55d806 271 2.63394e+01,
272 5.04114e-11,
273 2.12543e+00,
274 4.88663e+00);
a0b94e5c 275 }
276
a0b94e5c 277 // for CF
278 //Get pointer to the mc event
b74269dc 279 if(fDoCF && fDoMC){
48682642 280 //fMCEvent = fMCTruth->MCEvent();
1e7846f4 281 if(fMCEvent == NULL){
282 //print warning here
283 fDoCF = kFALSE;
284 }
285 }
a0b94e5c 286
287 AliKFParticle::SetField(fESDEvent->GetMagneticField());
5e55d806 288
289 // fCurrentEventGoodV0s = new TClonesArray("TClonesArray", 0);
63e16c52 290 if(fCurrentEventGoodV0s == NULL){
291 fCurrentEventGoodV0s = new TClonesArray("AliKFParticle", 0);
292 }
5e55d806 293
87f6de3e 294 if(fCalculateBackground == kTRUE){
295 if(fBGEventInitialized == kFALSE){
037dc2db 296
87f6de3e 297
037dc2db 298 Double_t *zBinLimitsArray = new Double_t[8];
299 zBinLimitsArray[0] = -50.00;
300 zBinLimitsArray[1] = -4.07;
301 zBinLimitsArray[2] = -2.17;
302 zBinLimitsArray[3] = -0.69;
303 zBinLimitsArray[4] = 0.69;
304 zBinLimitsArray[5] = 2.17;
305 zBinLimitsArray[6] = 4.11;
306 zBinLimitsArray[7] = 50.00;
87f6de3e 307
037dc2db 308 Double_t *multiplicityBinLimitsArray= new Double_t[5];
309 multiplicityBinLimitsArray[0] = 0;
310 multiplicityBinLimitsArray[1] = 8.5;
311 multiplicityBinLimitsArray[2] = 16.5;
312 multiplicityBinLimitsArray[3] = 27.5;
313 multiplicityBinLimitsArray[4] = 41.5;
48682642 314
315 fBGEventHandler = new AliGammaConversionBGHandler(8,5,10);
87f6de3e 316
037dc2db 317 /*
318 // ---------------------------------
319 Double_t *zBinLimitsArray = new Double_t[1];
320 zBinLimitsArray[0] = 999999.00;
321
322 Double_t *multiplicityBinLimitsArray= new Double_t[1];
323 multiplicityBinLimitsArray[0] = 99999999.00;
324 fBGEventHandler = new AliGammaConversionBGHandler(1,1,10);
325 // ---------------------------------
326 */
87f6de3e 327 fBGEventHandler->Initialize(zBinLimitsArray, multiplicityBinLimitsArray);
328 fBGEventInitialized = kTRUE;
329 }
5e55d806 330 }
a0b94e5c 331}
332
333AliESDv0* AliV0Reader::GetV0(Int_t index){
334 //see header file for documentation
335 fCurrentV0 = fESDEvent->GetV0(index);
336 UpdateV0Information();
337 return fCurrentV0;
338}
339
340Bool_t AliV0Reader::CheckForPrimaryVertex(){
037dc2db 341 //see headerfile for documentation
a0b94e5c 342 return fESDEvent->GetPrimaryVertex()->GetNContributors()>0;
343}
344
77880bd8 345
346Bool_t AliV0Reader::CheckV0FinderStatus(Int_t index){
037dc2db 347 // see headerfile for documentation
77880bd8 348 if(fUseOnFlyV0Finder){
77880bd8 349 if(!GetV0(index)->GetOnFlyStatus()){
350 return kFALSE;
351 }
352 }
353 if(!fUseOnFlyV0Finder){
51b95cb0 354 if(GetV0(index)->GetOnFlyStatus()){
77880bd8 355 return kFALSE;
356 }
357 }
77880bd8 358 return kTRUE;
359}
360
361
362
a0b94e5c 363Bool_t AliV0Reader::NextV0(){
364 //see header file for documentation
037dc2db 365
a0b94e5c 366 Bool_t iResult=kFALSE;
367 while(fCurrentV0IndexNumber<fESDEvent->GetNumberOfV0s()){
368 fCurrentV0 = fESDEvent->GetV0(fCurrentV0IndexNumber);
037dc2db 369
1b832bb9 370 fUpdateV0AlreadyCalled=kFALSE;
371
037dc2db 372 if(fHistograms != NULL){
373 fHistograms->FillHistogram("ESD_AllV0s_InvMass",GetMotherCandidateMass());
374 }
a0b94e5c 375
376 // moved it up here so that the correction framework can access pt and eta information
377 if(UpdateV0Information() == kFALSE){
378 fCurrentV0IndexNumber++;
379 continue;
380 }
cb90a330 381
a0b94e5c 382 Double_t containerInput[3];
1e7846f4 383 if(fDoCF){
384 containerInput[0] = GetMotherCandidatePt();
385 containerInput[1] = GetMotherCandidateEta();
386 containerInput[2] = GetMotherCandidateMass();
387 }
ebcfaa7e 388 /*
389 if(fDoCF){
390 containerInput[0] = GetMotherCandidatePt();
391 containerInput[1] = GetMotherCandidateEta();
392 containerInput[2] = GetMotherCandidateMass();
393
394 fCFManager->GetParticleContainer()->Fill(containerInput,kStepLikeSign); // for CF
395 fCFManager->GetParticleContainer()->Fill(containerInput,kStepTPCRefit); // for CF
396 fCFManager->GetParticleContainer()->Fill(containerInput,kStepKinks); // for CF
397 }
398 */
399
a0b94e5c 400 //checks if on the fly mode is set
48e7eac2 401 if ( !CheckV0FinderStatus(fCurrentV0IndexNumber) ){
a0b94e5c 402 if(fHistograms != NULL){
403 fHistograms->FillHistogram("ESD_CutGetOnFly_InvMass",GetMotherCandidateMass());
404 }
405 fCurrentV0IndexNumber++;
406 continue;
407 }
1e7846f4 408 if(fDoCF){
409 fCFManager->GetParticleContainer()->Fill(containerInput,kStepGetOnFly); // for CF
410 }
ebcfaa7e 411
412 if(fHistograms != NULL){
413 fHistograms->FillHistogram("ESD_AllV0sCurrentFinder_InvMass",GetMotherCandidateMass());
414 }
48682642 415
416 Double_t armenterosQtAlfa[2];
417 GetArmenterosQtAlfa(GetNegativeKFParticle(),
418 GetPositiveKFParticle(),
419 GetMotherCandidateKFCombination(),
420 armenterosQtAlfa);
421
422 fHistograms->FillHistogram("ESD_AllV0sCurrentFinder_alfa_qt",armenterosQtAlfa[1],armenterosQtAlfa[0]);
423
424
ebcfaa7e 425 if(fCurrentNegativeESDTrack->GetSign() == fCurrentPositiveESDTrack->GetSign()){ // avoid like sign
426 // iResult=kFALSE;
427 if(fHistograms != NULL ){
428 fHistograms->FillHistogram("ESD_CutLikeSign_InvMass",GetMotherCandidateMass());
429 // to avoid filling the other cut histograms. So in this case fUpdateV0AlreadyCalled also serves as a flag for the histogram filling
430 // it will anyway be set to true at the end of the UpdateV0Information function, and there are no return until the end
431 // fUpdateV0AlreadyCalled = kTRUE;
432 }
433 fCurrentV0IndexNumber++;
434 continue;
435 }
436 if(fDoCF){
437 fCFManager->GetParticleContainer()->Fill(containerInput,kStepLikeSign); // for CF
438 }
439
440
441 if( !(fCurrentNegativeESDTrack->GetStatus() & AliESDtrack::kTPCrefit) ||
442 !(fCurrentPositiveESDTrack->GetStatus() & AliESDtrack::kTPCrefit) ){
443 // if( !(fCurrentNegativeESDTrack->GetStatus() & AliESDtrack::kITSrefit) ||
444 // !(fCurrentPositiveESDTrack->GetStatus() & AliESDtrack::kITSrefit) ){
445 // iResult=kFALSE;
446 if(fHistograms != NULL){
447 fHistograms->FillHistogram("ESD_CutRefit_InvMass",GetMotherCandidateMass());
448 // to avoid filling the other cut histograms. So in this case fUpdateV0AlreadyCalled also serves as a flag for the histogram filling
449 // it will anyway be set to true at the end of the UpdateV0Information function, and there are no return until the end
450 //fUpdateV0AlreadyCalled = kTRUE;
451 }
452 fCurrentV0IndexNumber++;
453 continue;
454 }
455 if(fDoCF){
456 fCFManager->GetParticleContainer()->Fill(containerInput,kStepTPCRefit); // for CF
457 }
458
459
460
461 if( fCurrentNegativeESDTrack->GetKinkIndex(0) > 0 ||
462 fCurrentPositiveESDTrack->GetKinkIndex(0) > 0) {
463 //iResult=kFALSE;
464 if(fHistograms != NULL ){
465 fHistograms->FillHistogram("ESD_CutKink_InvMass",GetMotherCandidateMass());
466 // to avoid filling the other cut histograms. So in this case fUpdateV0AlreadyCalled also serves as a flag for the histogram filling
467 // it will anyway be set to true at the end of the UpdateV0Information function, and there are no return until the end
468 //fUpdateV0AlreadyCalled = kTRUE;
469 }
470 fCurrentV0IndexNumber++;
471 continue;
472 }
473
474 if(fDoCF){
475 fCFManager->GetParticleContainer()->Fill(containerInput,kStepKinks); // for CF
476 }
477
478
479 if(fDodEdxSigmaCut == kTRUE){
480 if( fESDpid->NumberOfSigmasTPC(fCurrentPositiveESDTrack,AliPID::kElectron)<fPIDnSigmaBelowElectronLine ||
481 fESDpid->NumberOfSigmasTPC(fCurrentPositiveESDTrack,AliPID::kElectron)>fPIDnSigmaAboveElectronLine ||
482 fESDpid->NumberOfSigmasTPC(fCurrentNegativeESDTrack,AliPID::kElectron)<fPIDnSigmaBelowElectronLine ||
483 fESDpid->NumberOfSigmasTPC(fCurrentNegativeESDTrack,AliPID::kElectron)>fPIDnSigmaAboveElectronLine ){
484 //iResult=kFALSE;
485 if(fHistograms != NULL ){
486 fHistograms->FillHistogram("ESD_CutdEdxSigmaElectronLine_InvMass",GetMotherCandidateMass());
487 // to avoid filling the other cut histograms. So in this case fUpdateV0AlreadyCalled also serves as a flag for the histogram filling
488 // it will anyway be set to true at the end of the UpdateV0Information function, and there are no return until the end
489 //fUpdateV0AlreadyCalled = kTRUE;
490 }
491 fCurrentV0IndexNumber++;
492 continue;
493 }
494 if(fDoCF){
495 fCFManager->GetParticleContainer()->Fill(containerInput,kStepdEdx_electronselection); // for CF
496 }
497
498 if( fCurrentPositiveESDTrack->P()>fPIDMinPnSigmaAbovePionLine){
499 if(fESDpid->NumberOfSigmasTPC(fCurrentPositiveESDTrack,AliPID::kElectron)>fPIDnSigmaBelowElectronLine &&
500 fESDpid->NumberOfSigmasTPC(fCurrentPositiveESDTrack,AliPID::kElectron)<fPIDnSigmaAboveElectronLine&&
501 fESDpid->NumberOfSigmasTPC(fCurrentPositiveESDTrack,AliPID::kPion)<fPIDnSigmaAbovePionLine){
502 // iResult=kFALSE;
503 if(fHistograms != NULL){
504 fHistograms->FillHistogram("ESD_CutdEdxSigmaPionLine_InvMass",GetMotherCandidateMass());
505 // to avoid filling the other cut histograms. So in this case fUpdateV0AlreadyCalled also serves as a flag for the histogram filling
506 // it will anyway be set to true at the end of the UpdateV0Information function, and there are no return until the end
507 //fUpdateV0AlreadyCalled = kTRUE;
508 }
509 fCurrentV0IndexNumber++;
510 continue;
511 }
512 }
513
514 if( fCurrentNegativeESDTrack->P()>fPIDMinPnSigmaAbovePionLine){
515 if(fESDpid->NumberOfSigmasTPC(fCurrentNegativeESDTrack,AliPID::kElectron)>fPIDnSigmaBelowElectronLine &&
516 fESDpid->NumberOfSigmasTPC(fCurrentNegativeESDTrack,AliPID::kElectron)<fPIDnSigmaAboveElectronLine&&
517 fESDpid->NumberOfSigmasTPC(fCurrentNegativeESDTrack,AliPID::kPion)<fPIDnSigmaAbovePionLine){
518 // iResult=kFALSE;
519 if(fHistograms != NULL){
520 fHistograms->FillHistogram("ESD_CutdEdxSigmaPionLine_InvMass",GetMotherCandidateMass());
521 // to avoid filling the other cut histograms. So in this case fUpdateV0AlreadyCalled also serves as a flag for the histogram filling
522 // it will anyway be set to true at the end of the UpdateV0Information function, and there are no return until the end
523 //fUpdateV0AlreadyCalled = kTRUE;
524 }
525 fCurrentV0IndexNumber++;
526 continue;
527 }
528 }
529 if(fDoCF){
530 fCFManager->GetParticleContainer()->Fill(containerInput,kStepdEdx_pionrejection); // for CF
531 }
532
533 }
cb90a330 534
a0b94e5c 535 //checks if we have a prim vertex
536 if(fESDEvent->GetPrimaryVertex()->GetNContributors()<=0) {
537 if(fHistograms != NULL){
538 fHistograms->FillHistogram("ESD_CutNContributors_InvMass",GetMotherCandidateMass());
539 }
540 fCurrentV0IndexNumber++;
541 continue;
542 }
1e7846f4 543 if(fDoCF){
544 fCFManager->GetParticleContainer()->Fill(containerInput,kStepNContributors); // for CF
545 }
a0b94e5c 546
547 //Check the pid probability
548 if(CheckPIDProbability(fPIDProbabilityCutNegativeParticle,fPIDProbabilityCutPositiveParticle)==kFALSE){
549 if(fHistograms != NULL){
550 fHistograms->FillHistogram("ESD_CutPIDProb_InvMass",GetMotherCandidateMass());
551 }
552 fCurrentV0IndexNumber++;
553 continue;
554 }
1e7846f4 555 if(fDoCF){
556 fCFManager->GetParticleContainer()->Fill(containerInput,kStepTPCPID); // for CF
557 }
a0b94e5c 558
a0b94e5c 559 if(GetXYRadius()>fMaxR){ // cuts on distance from collision point
560 if(fHistograms != NULL){
561 fHistograms->FillHistogram("ESD_CutR_InvMass",GetMotherCandidateMass());
562 }
563 fCurrentV0IndexNumber++;
564 continue;
1e7846f4 565 }
566 if(fDoCF){
567 fCFManager->GetParticleContainer()->Fill(containerInput,kStepR); // for CF
568 }
a0b94e5c 569
570
571 if((TMath::Abs(fCurrentZValue)*fLineCutZRSlope)-fLineCutZValue > GetXYRadius() ){ // cuts out regions where we do not reconstruct
572 if(fHistograms != NULL){
573 fHistograms->FillHistogram("ESD_CutLine_InvMass",GetMotherCandidateMass());
574 }
575 fCurrentV0IndexNumber++;
576 continue;
1e7846f4 577 }
578 if(fDoCF){
579 fCFManager->GetParticleContainer()->Fill(containerInput,kStepLine); // for CF
580 }
a0b94e5c 581
582 if(TMath::Abs(fCurrentZValue) > fMaxZ ){ // cuts out regions where we do not reconstruct
583 if(fHistograms != NULL){
584 fHistograms->FillHistogram("ESD_CutZ_InvMass",GetMotherCandidateMass());
585 }
586 fCurrentV0IndexNumber++;
587 continue;
1e7846f4 588 }
589 if(fDoCF){
590 fCFManager->GetParticleContainer()->Fill(containerInput,kStepZ); // for CF
591 }
a0b94e5c 592
593 /* Moved further up so corr framework can work
594 if(UpdateV0Information() == kFALSE){
595 fCurrentV0IndexNumber++;
596 continue;
597 }
598 */
48682642 599 if(fCurrentNegativeESDTrack->GetNcls(1) < fMinClsTPC || fCurrentPositiveESDTrack->GetNcls(1) < fMinClsTPC ){
600 if(fHistograms != NULL){
601 fHistograms->FillHistogram("ESD_CutMinNClsTPC_InvMass",GetMotherCandidateMass());
602 }
603 fCurrentV0IndexNumber++;
604 continue;
605 }
606 if(fDoCF){
607 fCFManager->GetParticleContainer()->Fill(containerInput,kStepMinClsTPC); // for CF
608 }
9640a3d1 609
a0b94e5c 610
611 if(fUseKFParticle){
48682642 612
613
614 if( fCurrentNegativeKFParticle->GetPt()< fSinglePtCut || fCurrentPositiveKFParticle->GetPt()< fSinglePtCut){
615 if(fHistograms != NULL){
616 fHistograms->FillHistogram("ESD_CutSinglePt_InvMass",GetMotherCandidateMass());
617 }
618 fCurrentV0IndexNumber++;
619 continue;
620 }
621 if(fDoCF){
622 fCFManager->GetParticleContainer()->Fill(containerInput,kStepSinglePt); // for CF
623 }
624
625
a0b94e5c 626 if(fCurrentMotherKFCandidate->GetNDF()<=0){
627 if(fHistograms != NULL){
628 fHistograms->FillHistogram("ESD_CutNDF_InvMass",GetMotherCandidateMass());
629 }
630 fCurrentV0IndexNumber++;
631 continue;
632 }
1e7846f4 633 if(fDoCF){
634 fCFManager->GetParticleContainer()->Fill(containerInput,kStepNDF); // for CF
635 }
a0b94e5c 636
637 Double_t chi2V0 = fCurrentMotherKFCandidate->GetChi2()/fCurrentMotherKFCandidate->GetNDF();
638 if(chi2V0 > fChi2CutConversion || chi2V0 <=0){
639 if(fHistograms != NULL){
640 fHistograms->FillHistogram("ESD_CutChi2_InvMass",GetMotherCandidateMass());
641 }
642 fCurrentV0IndexNumber++;
643 continue;
644 }
1e7846f4 645 if(fDoCF){
646 fCFManager->GetParticleContainer()->Fill(containerInput,kStepChi2); // for CF
647 }
a0b94e5c 648
649 if(TMath::Abs(fMotherCandidateLorentzVector->Eta())> fEtaCut){
650 if(fHistograms != NULL){
651 fHistograms->FillHistogram("ESD_CutEta_InvMass",GetMotherCandidateMass());
652 }
653 fCurrentV0IndexNumber++;
654 continue;
655 }
1e7846f4 656 if(fDoCF){
657 fCFManager->GetParticleContainer()->Fill(containerInput,kStepEta); // for CF
658 }
a0b94e5c 659
660 if(fMotherCandidateLorentzVector->Pt()<fPtCut){
661 if(fHistograms != NULL){
662 fHistograms->FillHistogram("ESD_CutPt_InvMass",GetMotherCandidateMass());
663 }
664 fCurrentV0IndexNumber++;
665 continue;
666 }
1e7846f4 667 if(fDoCF){
668 fCFManager->GetParticleContainer()->Fill(containerInput,kStepPt); // for CF
669 }
a0b94e5c 670
671 }
672 else if(fUseESDTrack){
673 //TODO
674 }
9640a3d1 675
676 if(fHistograms != NULL){
677 fHistograms->FillHistogram("ESD_GoodV0s_InvMass",GetMotherCandidateMass());
678 }
679
5e55d806 680 // fCurrentEventGoodV0s.push_back(*fCurrentMotherKFCandidate);
681
682 new((*fCurrentEventGoodV0s)[fCurrentEventGoodV0s->GetEntriesFast()]) AliKFParticle(*fCurrentMotherKFCandidate);
683
a0b94e5c 684 iResult=kTRUE;//means we have a v0 who survived all the cuts applied
685
686 fCurrentV0IndexNumber++;
687
688 break;
689 }
690 return iResult;
691}
692
693Bool_t AliV0Reader::UpdateV0Information(){
694 //see header file for documentation
695
696 Bool_t iResult=kTRUE; // for taking out not refitted, kinks and like sign tracks
697
698 Bool_t switchTracks = kFALSE;
699
700 fCurrentNegativeESDTrack = fESDEvent->GetTrack(fCurrentV0->GetNindex());
701 fCurrentPositiveESDTrack = fESDEvent->GetTrack(fCurrentV0->GetPindex());
ebcfaa7e 702
703 if(fCurrentPositiveESDTrack->GetSign() == -1 && fCurrentNegativeESDTrack->GetSign() == 1){ // switch wrong signed tracks
704 fCurrentNegativeESDTrack = fESDEvent->GetTrack(fCurrentV0->GetPindex());
705 fCurrentPositiveESDTrack = fESDEvent->GetTrack(fCurrentV0->GetNindex());
706 switchTracks = kTRUE;
707 }
a0b94e5c 708
a0b94e5c 709 if(fCurrentNegativeKFParticle != NULL){
710 delete fCurrentNegativeKFParticle;
711 }
712 if(switchTracks == kFALSE){
713 fCurrentNegativeKFParticle = new AliKFParticle(*(fCurrentV0->GetParamN()),fNegativeTrackPID);
714 }
715 else{
716 fCurrentNegativeKFParticle = new AliKFParticle(*(fCurrentV0->GetParamP()),fNegativeTrackPID);
717 }
718
719 if(fCurrentPositiveKFParticle != NULL){
720 delete fCurrentPositiveKFParticle;
721 }
722 if(switchTracks == kFALSE){
723 fCurrentPositiveKFParticle = new AliKFParticle(*(fCurrentV0->GetParamP()),fPositiveTrackPID);
724 }
725 else{
726 fCurrentPositiveKFParticle = new AliKFParticle(*(fCurrentV0->GetParamN()),fPositiveTrackPID);
727 }
728
729 if(fCurrentMotherKFCandidate != NULL){
730 delete fCurrentMotherKFCandidate;
731 }
732 fCurrentMotherKFCandidate = new AliKFParticle(*fCurrentNegativeKFParticle,*fCurrentPositiveKFParticle);
733
734
735 if(fPositiveTrackPID==-11 && fNegativeTrackPID==11){
736 fCurrentMotherKFCandidate->SetMassConstraint(0,fNSigmaMass);
737 }
738
739 if(fUseImprovedVertex == kTRUE){
740 AliKFVertex primaryVertexImproved(*GetPrimaryVertex());
741 primaryVertexImproved+=*fCurrentMotherKFCandidate;
742 fCurrentMotherKFCandidate->SetProductionVertex(primaryVertexImproved);
743 }
744
745 fCurrentMotherKFCandidate->GetMass(fMotherCandidateKFMass,fMotherCandidateKFWidth);
ebcfaa7e 746
a0b94e5c 747 if(fNegativeTrackLorentzVector != NULL){
748 delete fNegativeTrackLorentzVector;
749 }
750 if(fUseKFParticle){
751 fNegativeTrackLorentzVector = new TLorentzVector(fCurrentNegativeKFParticle->Px(),fCurrentNegativeKFParticle->Py(),fCurrentNegativeKFParticle->Pz());
752 }
753 else if(fUseESDTrack){
754 fNegativeTrackLorentzVector = new TLorentzVector(fCurrentNegativeESDTrack->Px(),fCurrentNegativeESDTrack->Py(),fCurrentNegativeESDTrack->Pz());
755 }
756
757 if(fPositiveTrackLorentzVector != NULL){
758 delete fPositiveTrackLorentzVector;
759 }
760 if(fUseKFParticle){
761 fPositiveTrackLorentzVector = new TLorentzVector(fCurrentPositiveKFParticle->Px(),fCurrentPositiveKFParticle->Py(),fCurrentPositiveKFParticle->Pz());
762 }
763 else if(fUseESDTrack){
764 fPositiveTrackLorentzVector = new TLorentzVector(fCurrentPositiveESDTrack->Px(),fCurrentPositiveESDTrack->Py(),fCurrentPositiveESDTrack->Pz());
765 }
766
767 if(fMotherCandidateLorentzVector != NULL){
768 delete fMotherCandidateLorentzVector;
769 }
770 if(fUseKFParticle){
771 fMotherCandidateLorentzVector = new TLorentzVector(*fNegativeTrackLorentzVector + *fPositiveTrackLorentzVector);
772 }
773 else if(fUseESDTrack){
774 fMotherCandidateLorentzVector = new TLorentzVector(*fNegativeTrackLorentzVector + *fPositiveTrackLorentzVector);
775 }
776
777 if(fPositiveTrackPID==-11 && fNegativeTrackPID==11){
778 fMotherCandidateLorentzVector->SetXYZM(fMotherCandidateLorentzVector->Px() ,fMotherCandidateLorentzVector->Py(),fMotherCandidateLorentzVector->Pz(),0.);
779 }
780
781
782 if(fDoMC == kTRUE){
783 fMotherMCParticle= NULL;
784 fNegativeMCParticle = fMCStack->Particle(TMath::Abs(fESDEvent->GetTrack(fCurrentV0->GetNindex())->GetLabel()));
785 fPositiveMCParticle = fMCStack->Particle(TMath::Abs(fESDEvent->GetTrack(fCurrentV0->GetPindex())->GetLabel()));
786 if(fPositiveMCParticle->GetMother(0)>-1){
787 fMotherMCParticle = fMCStack->Particle(fPositiveMCParticle->GetMother(0));
788 }
789 }
790
a0b94e5c 791
792 // for CF
ebcfaa7e 793// Double_t containerInput[3];
794// if(fDoCF){
795// containerInput[0] = GetMotherCandidatePt();
796// containerInput[1] = GetMotherCandidateEta();
797// containerInput[2] = GetMotherCandidateMass();
1e7846f4 798
ebcfaa7e 799// fCFManager->GetParticleContainer()->Fill(containerInput,kStepLikeSign); // for CF
800// fCFManager->GetParticleContainer()->Fill(containerInput,kStepTPCRefit); // for CF
801// fCFManager->GetParticleContainer()->Fill(containerInput,kStepKinks); // for CF
802// }
cb90a330 803
804
805 if(fUseOwnXYZCalculation == kFALSE){
806 fCurrentV0->GetXYZ(fCurrentXValue,fCurrentYValue,fCurrentZValue);
807 }
808 else{
809 Double_t convpos[2];
810 convpos[0]=0;
811 convpos[1]=0;
812 GetConvPosXY(GetPositiveESDTrack(),GetNegativeESDTrack(),GetMagneticField(),convpos);
813 fCurrentXValue = convpos[0];
814 fCurrentYValue = convpos[1];
815 fCurrentZValue = GetConvPosZ(GetPositiveESDTrack(),GetNegativeESDTrack(),GetMagneticField());
816 }
ebcfaa7e 817 /*
51372c5d 818 if(fCurrentNegativeESDTrack->GetSign() == fCurrentPositiveESDTrack->GetSign()){ // avoid like sign
819 iResult=kFALSE;
ebcfaa7e 820 if(fHistograms != NULL && fUpdateV0AlreadyCalled == kFALSE && doFillHistos == kTRUE){
51372c5d 821 fHistograms->FillHistogram("ESD_CutLikeSign_InvMass",GetMotherCandidateMass());
822 // to avoid filling the other cut histograms. So in this case fUpdateV0AlreadyCalled also serves as a flag for the histogram filling
823 // it will anyway be set to true at the end of the UpdateV0Information function, and there are no return until the end
824 fUpdateV0AlreadyCalled = kTRUE;
825 }
826 }
827
51372c5d 828 if( !(fCurrentNegativeESDTrack->GetStatus() & AliESDtrack::kTPCrefit) ||
829 !(fCurrentPositiveESDTrack->GetStatus() & AliESDtrack::kTPCrefit) ){
830 // if( !(fCurrentNegativeESDTrack->GetStatus() & AliESDtrack::kITSrefit) ||
831 // !(fCurrentPositiveESDTrack->GetStatus() & AliESDtrack::kITSrefit) ){
832 iResult=kFALSE;
ebcfaa7e 833 if(fHistograms != NULL && fUpdateV0AlreadyCalled == kFALSE && doFillHistos == kTRUE){
51372c5d 834 fHistograms->FillHistogram("ESD_CutRefit_InvMass",GetMotherCandidateMass());
835 // to avoid filling the other cut histograms. So in this case fUpdateV0AlreadyCalled also serves as a flag for the histogram filling
836 // it will anyway be set to true at the end of the UpdateV0Information function, and there are no return until the end
837 fUpdateV0AlreadyCalled = kTRUE;
838 }
839 }
840
841 if( fCurrentNegativeESDTrack->GetKinkIndex(0) > 0 ||
842 fCurrentPositiveESDTrack->GetKinkIndex(0) > 0) {
843
844 iResult=kFALSE;
ebcfaa7e 845 if(fHistograms != NULL && fUpdateV0AlreadyCalled == kFALSE && doFillHistos == kTRUE ){
51372c5d 846 fHistograms->FillHistogram("ESD_CutKink_InvMass",GetMotherCandidateMass());
847 // to avoid filling the other cut histograms. So in this case fUpdateV0AlreadyCalled also serves as a flag for the histogram filling
848 // it will anyway be set to true at the end of the UpdateV0Information function, and there are no return until the end
849 fUpdateV0AlreadyCalled = kTRUE;
850 }
851 }
852
853 if(fDodEdxSigmaCut == kTRUE){
cb90a330 854
51372c5d 855 if( fESDpid->NumberOfSigmasTPC(fCurrentPositiveESDTrack,AliPID::kElectron)<fPIDnSigmaBelowElectronLine ||
856 fESDpid->NumberOfSigmasTPC(fCurrentPositiveESDTrack,AliPID::kElectron)>fPIDnSigmaAboveElectronLine ||
857 fESDpid->NumberOfSigmasTPC(fCurrentNegativeESDTrack,AliPID::kElectron)<fPIDnSigmaBelowElectronLine ||
858 fESDpid->NumberOfSigmasTPC(fCurrentNegativeESDTrack,AliPID::kElectron)>fPIDnSigmaAboveElectronLine ){
859 iResult=kFALSE;
ebcfaa7e 860 if(fHistograms != NULL && fUpdateV0AlreadyCalled == kFALSE && doFillHistos == kTRUE){
51372c5d 861 fHistograms->FillHistogram("ESD_CutdEdxSigmaElectronLine_InvMass",GetMotherCandidateMass());
862 // to avoid filling the other cut histograms. So in this case fUpdateV0AlreadyCalled also serves as a flag for the histogram filling
863 // it will anyway be set to true at the end of the UpdateV0Information function, and there are no return until the end
864 fUpdateV0AlreadyCalled = kTRUE;
865 }
866 }
867 if( fCurrentPositiveESDTrack->P()>fPIDMinPnSigmaAbovePionLine){
868 if(fESDpid->NumberOfSigmasTPC(fCurrentPositiveESDTrack,AliPID::kElectron)>fPIDnSigmaBelowElectronLine &&
869 fESDpid->NumberOfSigmasTPC(fCurrentPositiveESDTrack,AliPID::kElectron)<fPIDnSigmaAboveElectronLine&&
870 fESDpid->NumberOfSigmasTPC(fCurrentPositiveESDTrack,AliPID::kPion)<fPIDnSigmaAbovePionLine){
871 iResult=kFALSE;
ebcfaa7e 872 if(fHistograms != NULL && fUpdateV0AlreadyCalled == kFALSE && doFillHistos == kTRUE){
51372c5d 873 fHistograms->FillHistogram("ESD_CutdEdxSigmaPionLine_InvMass",GetMotherCandidateMass());
874 // to avoid filling the other cut histograms. So in this case fUpdateV0AlreadyCalled also serves as a flag for the histogram filling
875 // it will anyway be set to true at the end of the UpdateV0Information function, and there are no return until the end
876 fUpdateV0AlreadyCalled = kTRUE;
877 }
878 }
879 }
880
881 if( fCurrentNegativeESDTrack->P()>fPIDMinPnSigmaAbovePionLine){
882 if(fESDpid->NumberOfSigmasTPC(fCurrentNegativeESDTrack,AliPID::kElectron)>fPIDnSigmaBelowElectronLine &&
883 fESDpid->NumberOfSigmasTPC(fCurrentNegativeESDTrack,AliPID::kElectron)<fPIDnSigmaAboveElectronLine&&
884 fESDpid->NumberOfSigmasTPC(fCurrentNegativeESDTrack,AliPID::kPion)<fPIDnSigmaAbovePionLine){
885 iResult=kFALSE;
ebcfaa7e 886 if(fHistograms != NULL && fUpdateV0AlreadyCalled == kFALSE && doFillHistos == kTRUE ){
51372c5d 887 fHistograms->FillHistogram("ESD_CutdEdxSigmaPionLine_InvMass",GetMotherCandidateMass());
888 // to avoid filling the other cut histograms. So in this case fUpdateV0AlreadyCalled also serves as a flag for the histogram filling
889 // it will anyway be set to true at the end of the UpdateV0Information function, and there are no return until the end
890 fUpdateV0AlreadyCalled = kTRUE;
891 }
892 }
893 }
894 }
ebcfaa7e 895 */
cb90a330 896 fUpdateV0AlreadyCalled = kTRUE;
897
a0b94e5c 898 return iResult;
899}
900
901
902
903Bool_t AliV0Reader::HasSameMCMother(){
904 //see header file for documentation
905
906 Bool_t iResult = kFALSE;
907 if(fDoMC == kTRUE){
908 if(fNegativeMCParticle != NULL && fPositiveMCParticle != NULL){
909 if(fNegativeMCParticle->GetMother(0) == fPositiveMCParticle->GetMother(0))
910 if(fMotherMCParticle){
911 iResult = kTRUE;
912 }
913 }
914 }
915 return iResult;
916}
917
918Bool_t AliV0Reader::CheckPIDProbability(Double_t negProbCut, Double_t posProbCut){
919 //see header file for documentation
920
921 Bool_t iResult=kFALSE;
922
923 Double_t *posProbArray = new Double_t[10];
924 Double_t *negProbArray = new Double_t[10];
925 AliESDtrack* negTrack = fESDEvent->GetTrack(fCurrentV0->GetNindex());
926 AliESDtrack* posTrack = fESDEvent->GetTrack(fCurrentV0->GetPindex());
927
928 negTrack->GetTPCpid(negProbArray);
929 posTrack->GetTPCpid(posProbArray);
930
4a6157dc 931 // if(negProbArray != NULL && posProbArray != NULL){ // this is not allowed anymore for some reason(RC19)
932 if(negProbArray && posProbArray){
a0b94e5c 933 if(negProbArray[GetSpeciesIndex(-1)]>=negProbCut && posProbArray[GetSpeciesIndex(1)]>=posProbCut){
934 iResult=kTRUE;
935 }
936 }
937 delete [] posProbArray;
938 delete [] negProbArray;
939 return iResult;
940}
941
942void AliV0Reader::GetPIDProbability(Double_t &negPIDProb,Double_t & posPIDProb){
4a6157dc 943 // see header file for documentation
944
a0b94e5c 945 Double_t *posProbArray = new Double_t[10];
946 Double_t *negProbArray = new Double_t[10];
947 AliESDtrack* negTrack = fESDEvent->GetTrack(fCurrentV0->GetNindex());
948 AliESDtrack* posTrack = fESDEvent->GetTrack(fCurrentV0->GetPindex());
949
950 negTrack->GetTPCpid(negProbArray);
951 posTrack->GetTPCpid(posProbArray);
952
4a6157dc 953 // if(negProbArray!=NULL && posProbArray!=NULL){ // this is not allowed anymore for some reason(RC19)
954 if(negProbArray && posProbArray){
a0b94e5c 955 negPIDProb = negProbArray[GetSpeciesIndex(-1)];
956 posPIDProb = posProbArray[GetSpeciesIndex(1)];
957 }
958 delete [] posProbArray;
959 delete [] negProbArray;
960}
961
962void AliV0Reader::UpdateEventByEventData(){
963 //see header file for documentation
5e55d806 964 if(fCurrentEventGoodV0s->GetEntriesFast() >0 ){
87f6de3e 965 if(fCalculateBackground){
037dc2db 966 fBGEventHandler->AddEvent(fCurrentEventGoodV0s,fESDEvent->GetPrimaryVertex()->GetZ(),CountESDTracks());
967 //filling z and multiplicity histograms
968 fHistograms->FillHistogram("ESD_Z_distribution",fESDEvent->GetPrimaryVertex()->GetZ());
969 fHistograms->FillHistogram("ESD_multiplicity_distribution",CountESDTracks());
970 fHistograms->FillHistogram("ESD_ZvsMultiplicity",fESDEvent->GetPrimaryVertex()->GetZ(),CountESDTracks());
87f6de3e 971 }
a0b94e5c 972 }
5e55d806 973 fCurrentEventGoodV0s->Delete();
a0b94e5c 974 fCurrentV0IndexNumber=0;
037dc2db 975 fNumberOfESDTracks=0;
26923b22 976 // fBGEventHandler->PrintBGArray(); // for debugging
a0b94e5c 977}
978
979
980Double_t AliV0Reader::GetNegativeTrackPhi() const{
981 //see header file for documentation
982
983 Double_t offset=0;
984 if(fNegativeTrackLorentzVector->Phi()> TMath::Pi()){
985 offset = -2*TMath::Pi();
986 }
987 return fNegativeTrackLorentzVector->Phi()+offset;
988}
989
990Double_t AliV0Reader::GetPositiveTrackPhi() const{
991 //see header file for documentation
992
993 Double_t offset=0;
994 if(fPositiveTrackLorentzVector->Phi()> TMath::Pi()){
995 offset = -2*TMath::Pi();
996 }
997 return fPositiveTrackLorentzVector->Phi()+offset;
998}
999
1000Double_t AliV0Reader::GetMotherCandidatePhi() const{
1001 //see header file for documentation
1002
1003 Double_t offset=0;
1004 if(fMotherCandidateLorentzVector->Phi()> TMath::Pi()){
1005 offset = -2*TMath::Pi();
1006 }
1007 return fMotherCandidateLorentzVector->Phi()+offset;
1008}
1009
1010
1011Double_t AliV0Reader::GetMotherCandidateRapidity() const{
1012 //see header file for documentation
1013
1014 Double_t rapidity=0;
1015 if(fMotherCandidateLorentzVector->Energy() - fMotherCandidateLorentzVector->Pz() == 0 || fMotherCandidateLorentzVector->Energy() + fMotherCandidateLorentzVector->Pz() == 0) rapidity=0;
1016 else rapidity = 0.5*(TMath::Log((fMotherCandidateLorentzVector->Energy() + fMotherCandidateLorentzVector->Pz()) / (fMotherCandidateLorentzVector->Energy()-fMotherCandidateLorentzVector->Pz())));
1017 return rapidity;
1018
1019}
1020
1021
1022
1023
1024
1025Int_t AliV0Reader::GetSpeciesIndex(Int_t chargeOfTrack){
1026 //see header file for documentation
1027
1028 Int_t iResult = 10; // Unknown particle
1029
1030 if(chargeOfTrack==-1){ //negative track
1031 switch(abs(fNegativeTrackPID)){
1032 case 11: //electron
1033 iResult = 0;
1034 break;
1035 case 13: //muon
1036 iResult = 1;
1037 break;
1038 case 211: //pion
1039 iResult = 2;
1040 break;
1041 case 321: //kaon
1042 iResult = 3;
1043 break;
1044 case 2212: //proton
1045 iResult = 4;
1046 break;
1047 case 22: //photon
1048 iResult = 5;
1049 break;
1050 case 111: //pi0
1051 iResult = 6;
1052 break;
1053 case 2112: //neutron
1054 iResult = 7;
1055 break;
1056 case 311: //K0
1057 iResult = 8;
1058 break;
1059
1060 //Put in here for kSPECIES::kEleCon ????
1061 }
1062 }
1063 else if(chargeOfTrack==1){ //positive track
1064 switch(abs(fPositiveTrackPID)){
1065 case 11: //electron
1066 iResult = 0;
1067 break;
1068 case 13: //muon
1069 iResult = 1;
1070 break;
1071 case 211: //pion
1072 iResult = 2;
1073 break;
1074 case 321: //kaon
1075 iResult = 3;
1076 break;
1077 case 2212: //proton
1078 iResult = 4;
1079 break;
1080 case 22: //photon
1081 iResult = 5;
1082 break;
1083 case 111: //pi0
1084 iResult = 6;
1085 break;
1086 case 2112: //neutron
1087 iResult = 7;
1088 break;
1089 case 311: //K0
1090 iResult = 8;
1091 break;
1092
1093 //Put in here for kSPECIES::kEleCon ????
1094 }
1095 }
1096 else{
1097 //Wrong parameter.. Print warning
1098 }
1099 return iResult;
1100}
1101
4a6157dc 1102Bool_t AliV0Reader::GetHelixCenter(AliESDtrack* track, Double_t b,Int_t charge, Double_t center[2]){
a0b94e5c 1103 // see header file for documentation
1104
1105 Double_t pi = 3.14159265358979323846;
1106
1107 Double_t helix[6];
1108 track->GetHelixParameters(helix,b);
1109
1110 Double_t xpos = helix[5];
1111 Double_t ypos = helix[0];
1112 Double_t radius = TMath::Abs(1./helix[4]);
1113 Double_t phi = helix[2];
1114
1115 if(phi < 0){
1116 phi = phi + 2*pi;
1117 }
1118
1119 phi -= pi/2.;
1120 Double_t xpoint = radius * TMath::Cos(phi);
1121 Double_t ypoint = radius * TMath::Sin(phi);
1122
6272370b 1123 if(b<0){
1124 if(charge > 0){
1125 xpoint = - xpoint;
1126 ypoint = - ypoint;
1127 }
1128
1129 if(charge < 0){
1130 xpoint = xpoint;
1131 ypoint = ypoint;
1132 }
a0b94e5c 1133 }
6272370b 1134 if(b>0){
1135 if(charge > 0){
1136 xpoint = xpoint;
1137 ypoint = ypoint;
1138 }
a0b94e5c 1139
6272370b 1140 if(charge < 0){
1141 xpoint = - xpoint;
1142 ypoint = - ypoint;
1143 }
a0b94e5c 1144 }
1145 center[0] = xpos + xpoint;
1146 center[1] = ypos + ypoint;
1147
1148 return 1;
1149}
1150
4a6157dc 1151Bool_t AliV0Reader::GetConvPosXY(AliESDtrack* ptrack, AliESDtrack* ntrack, Double_t b, Double_t convpos[2]){
a0b94e5c 1152 //see header file for documentation
1153
1154 Double_t helixcenterpos[2];
1155 GetHelixCenter(ptrack,b,ptrack->Charge(),helixcenterpos);
1156
1157 Double_t helixcenterneg[2];
1158 GetHelixCenter(ntrack,b,ntrack->Charge(),helixcenterneg);
1159
1160 Double_t poshelix[6];
1161 ptrack->GetHelixParameters(poshelix,b);
1162 Double_t posradius = TMath::Abs(1./poshelix[4]);
1163
1164 Double_t neghelix[6];
1165 ntrack->GetHelixParameters(neghelix,b);
1166 Double_t negradius = TMath::Abs(1./neghelix[4]);
1167
1168 Double_t xpos = helixcenterpos[0];
1169 Double_t ypos = helixcenterpos[1];
1170 Double_t xneg = helixcenterneg[0];
1171 Double_t yneg = helixcenterneg[1];
1172
1173 convpos[0] = (xpos*negradius + xneg*posradius)/(negradius+posradius);
1174 convpos[1] = (ypos*negradius+ yneg*posradius)/(negradius+posradius);
1175
1176 return 1;
1177}
1178
1179
1180
4a6157dc 1181Double_t AliV0Reader::GetConvPosZ(AliESDtrack* ptrack,AliESDtrack* ntrack, Double_t b){
a0b94e5c 1182 //see header file for documentation
1183
1184 Double_t helixpos[6];
1185 ptrack->GetHelixParameters(helixpos,b);
1186
1187 Double_t helixneg[6];
1188 ntrack->GetHelixParameters(helixneg,b);
1189
1190 Double_t negtrackradius = TMath::Abs(1./helixneg[4]);
1191 Double_t postrackradius = TMath::Abs(1./helixpos[4]);
1192
1193 Double_t pi = 3.14159265358979323846;
1194
1195 Double_t convpos[2];
1196 GetConvPosXY(ptrack,ntrack,b,convpos);
1197
1198 Double_t convposx = convpos[0];
1199 Double_t convposy = convpos[1];
1200
1201 Double_t helixcenterpos[2];
1202 GetHelixCenter(ptrack,b,ptrack->Charge(),helixcenterpos);
1203
1204 Double_t helixcenterneg[2];
1205 GetHelixCenter(ntrack,b,ntrack->Charge(),helixcenterneg);
1206
1207 Double_t xpos = helixcenterpos[0];
1208 Double_t ypos = helixcenterpos[1];
1209 Double_t xneg = helixcenterneg[0];
1210 Double_t yneg = helixcenterneg[1];
1211
4a6157dc 1212 Double_t deltaXPos = convposx - xpos;
1213 Double_t deltaYPos = convposy - ypos;
a0b94e5c 1214
4a6157dc 1215 Double_t deltaXNeg = convposx - xneg;
1216 Double_t deltaYNeg = convposy - yneg;
a0b94e5c 1217
4a6157dc 1218 Double_t alphaPos = pi + TMath::ATan2(-deltaYPos,-deltaXPos);
1219 Double_t alphaNeg = pi + TMath::ATan2(-deltaYNeg,-deltaXNeg);
a0b94e5c 1220
4a6157dc 1221 Double_t vertexXNeg = xneg + TMath::Abs(negtrackradius)*
1222 TMath::Cos(alphaNeg);
1223 Double_t vertexYNeg = yneg + TMath::Abs(negtrackradius)*
1224 TMath::Sin(alphaNeg);
a0b94e5c 1225
4a6157dc 1226 Double_t vertexXPos = xpos + TMath::Abs(postrackradius)*
1227 TMath::Cos(alphaPos);
1228 Double_t vertexYPos = ypos + TMath::Abs(postrackradius)*
1229 TMath::Sin(alphaPos);
a0b94e5c 1230
1231 Double_t x0neg = helixneg[5];
1232 Double_t y0neg = helixneg[0];
1233
1234 Double_t x0pos = helixpos[5];
1235 Double_t y0pos = helixpos[0];
1236
4a6157dc 1237 Double_t dNeg = TMath::Sqrt((vertexXNeg - x0neg)*(vertexXNeg - x0neg)
1238 +(vertexYNeg - y0neg)*(vertexYNeg - y0neg));
a0b94e5c 1239
4a6157dc 1240 Double_t dPos = TMath::Sqrt((vertexXPos - x0pos)*(vertexXPos - x0pos)
1241 +(vertexYPos - y0pos)*(vertexYPos - y0pos));
a0b94e5c 1242
4a6157dc 1243 Double_t rNeg = TMath::Sqrt(negtrackradius*negtrackradius -
1244 dNeg*dNeg/4.);
a0b94e5c 1245
4a6157dc 1246 Double_t rPos = TMath::Sqrt(postrackradius*postrackradius -
1247 dPos*dPos/4.);
a0b94e5c 1248
4a6157dc 1249 Double_t deltabetaNeg = 2*(pi + TMath::ATan2(-dNeg/2.,-rNeg));
1250 Double_t deltabetaPos = 2*(pi + TMath::ATan2(-dPos/2.,-rPos));
a0b94e5c 1251
4a6157dc 1252 Double_t deltaUNeg = negtrackradius*deltabetaNeg;
1253 Double_t deltaUPos = postrackradius*deltabetaPos;
a0b94e5c 1254
4a6157dc 1255 Double_t zphaseNeg = ntrack->GetZ() + deltaUNeg * ntrack->GetTgl();
1256 Double_t zphasePos = ptrack->GetZ() + deltaUPos * ptrack->GetTgl();
a0b94e5c 1257
87f6de3e 1258 Double_t convposz = (zphasePos*negtrackradius+zphaseNeg*postrackradius)/(negtrackradius+postrackradius);
a0b94e5c 1259
1260 return convposz;
1261}
5e55d806 1262
1263AliGammaConversionKFVector* AliV0Reader::GetBGGoodV0s(Int_t event){
1264
037dc2db 1265 return fBGEventHandler->GetBGGoodV0s(event,fESDEvent->GetPrimaryVertex()->GetZ(),CountESDTracks());
1266}
1267
1268Int_t AliV0Reader::CountESDTracks(){
1269 // see header file for documentation
1270 if(fNumberOfESDTracks == 0){ // count the good esd tracks
1271 for(Int_t iTracks = 0; iTracks < fESDEvent->GetNumberOfTracks(); iTracks++){
1272 AliESDtrack* curTrack = fESDEvent->GetTrack(iTracks);
1273 if(!curTrack){
1274 continue;
1275 }
1276 if(fEsdTrackCuts->AcceptTrack(curTrack) ){
1277 fNumberOfESDTracks++;
1278 }
1279 }
1280 }
1281
1282 return fNumberOfESDTracks;
1283}
1284
1285Bool_t AliV0Reader::CheckIfPi0IsMother(Int_t label){
1286 // see headerfile for documentation
1287 Bool_t iResult=kFALSE;
1288 // cout<<"Checking particle label, particle is: "<<fMCStack->Particle(TMath::Abs(label))->GetName()<<endl;
1289 if(fMCStack->Particle(TMath::Abs(label))->GetPdgCode() == 111){
1290 iResult=kTRUE;
1291 }
1292 return iResult;
5e55d806 1293}
48682642 1294
1295
1296Bool_t AliV0Reader::GetArmenterosQtAlfa(AliKFParticle* positiveKFParticle, AliKFParticle * negativeKFParticle, AliKFParticle * gammaKFCandidate, Double_t armenterosQtAlfa[2] ){
1297 //see header file for documentation
1298
1299 TVector3 momentumVectorPositiveKF(positiveKFParticle->GetPx(),positiveKFParticle->GetPy(),positiveKFParticle->GetPz());
1300 TVector3 momentumVectorNegativeKF(negativeKFParticle->GetPx(),negativeKFParticle->GetPy(),negativeKFParticle->GetPz());
1301 TVector3 vecV0(gammaKFCandidate->GetPx(),gammaKFCandidate->GetPy(),gammaKFCandidate->GetPz());
1302
1303 Float_t thetaV0pos=TMath::ACos(( momentumVectorPositiveKF* vecV0)/(momentumVectorPositiveKF.Mag() * vecV0.Mag()));
1304 Float_t thetaV0neg=TMath::ACos(( momentumVectorNegativeKF* vecV0)/(momentumVectorNegativeKF.Mag() * vecV0.Mag()));
1305
1306 Float_t alfa =((momentumVectorPositiveKF.Mag())*TMath::Cos(thetaV0pos)-(momentumVectorNegativeKF.Mag())*TMath::Cos(thetaV0neg))/
1307 ((momentumVectorPositiveKF.Mag())*TMath::Cos(thetaV0pos)+(momentumVectorNegativeKF.Mag())*TMath::Cos(thetaV0neg)) ;
1308
1309
1310 Float_t qt = momentumVectorPositiveKF.Mag()*TMath::Sin(thetaV0pos);
1311
1312 armenterosQtAlfa[0]=qt;
1313 armenterosQtAlfa[1]=alfa;
1314
1315 return 1;
1316
1317}
1318
1319