1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: Ana Marin, Kathrin Koch, Kenneth Aamodt *
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 **************************************************************************/
16 ////////////////////////////////////////////////
17 //---------------------------------------------
18 // Class used to do analysis on conversion pairs
19 //---------------------------------------------
20 ////////////////////////////////////////////////
22 // --- ROOT system ---
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"
34 #include "AliMCEventHandler.h"
35 #include "AliESDpid.h"
36 #include "AliGammaConversionBGHandler.h"
37 #include "AliESDtrackCuts.h"
50 AliV0Reader::AliV0Reader() :
54 fMCEvent(NULL), // for CF
61 fCurrentV0IndexNumber(0),
63 fCurrentNegativeKFParticle(NULL),
64 fCurrentPositiveKFParticle(NULL),
65 fCurrentMotherKFCandidate(NULL),
66 fCurrentNegativeESDTrack(NULL),
67 fCurrentPositiveESDTrack(NULL),
68 fNegativeTrackLorentzVector(NULL),
69 fPositiveTrackLorentzVector(NULL),
70 fMotherCandidateLorentzVector(NULL),
76 fNegativeMCParticle(NULL),
77 fPositiveMCParticle(NULL),
78 fMotherMCParticle(NULL),
79 fMotherCandidateKFMass(0),
80 fMotherCandidateKFWidth(0),
81 fUseKFParticle(kTRUE),
84 fMaxR(10000),// 100 meter(outside of ALICE)
90 fChi2CutConversion(0.),
92 fPIDProbabilityCutNegativeParticle(0),
93 fPIDProbabilityCutPositiveParticle(0),
94 fDodEdxSigmaCut(kFALSE),
95 fPIDnSigmaAboveElectronLine(100),
96 fPIDnSigmaBelowElectronLine(-100),
97 fPIDnSigmaAbovePionLine(-100),
98 fPIDMinPnSigmaAbovePionLine(100),
103 fUseImprovedVertex(kFALSE),
104 fUseOwnXYZCalculation(kFALSE),
106 fUseOnFlyV0Finder(kTRUE),
107 fUpdateV0AlreadyCalled(kFALSE),
108 fCurrentEventGoodV0s(NULL),
109 // fPreviousEventGoodV0s(),
110 fCalculateBackground(kFALSE),
111 fBGEventHandler(NULL),
112 fBGEventInitialized(kFALSE),
114 fNumberOfESDTracks(0)
116 fESDpid = new AliESDpid;
120 AliV0Reader::AliV0Reader(const AliV0Reader & original) :
122 fMCStack(original.fMCStack),
123 fMCTruth(original.fMCTruth),
124 fMCEvent(original.fMCEvent), // for CF
125 fChain(original.fChain),
126 fESDHandler(original.fESDHandler),
127 fESDEvent(original.fESDEvent),
128 fCFManager(original.fCFManager),
129 fESDpid(original.fESDpid),
130 fHistograms(original.fHistograms),
131 fCurrentV0IndexNumber(original.fCurrentV0IndexNumber),
132 fCurrentV0(original.fCurrentV0),
133 fCurrentNegativeKFParticle(original.fCurrentNegativeKFParticle),
134 fCurrentPositiveKFParticle(original.fCurrentPositiveKFParticle),
135 fCurrentMotherKFCandidate(original.fCurrentMotherKFCandidate),
136 fCurrentNegativeESDTrack(original.fCurrentNegativeESDTrack),
137 fCurrentPositiveESDTrack(original.fCurrentPositiveESDTrack),
138 fNegativeTrackLorentzVector(original.fNegativeTrackLorentzVector),
139 fPositiveTrackLorentzVector(original.fPositiveTrackLorentzVector),
140 fMotherCandidateLorentzVector(original.fMotherCandidateLorentzVector),
141 fCurrentXValue(original.fCurrentXValue),
142 fCurrentYValue(original.fCurrentYValue),
143 fCurrentZValue(original.fCurrentZValue),
144 fPositiveTrackPID(original.fPositiveTrackPID),
145 fNegativeTrackPID(original.fNegativeTrackPID),
146 fNegativeMCParticle(original.fNegativeMCParticle),
147 fPositiveMCParticle(original.fPositiveMCParticle),
148 fMotherMCParticle(original.fMotherMCParticle),
149 fMotherCandidateKFMass(original.fMotherCandidateKFMass),
150 fMotherCandidateKFWidth(original.fMotherCandidateKFWidth),
151 fUseKFParticle(kTRUE),
152 fUseESDTrack(kFALSE),
154 fMaxR(original.fMaxR),
155 fEtaCut(original.fEtaCut),
156 fPtCut(original.fPtCut),
157 fMaxZ(original.fMaxZ),
158 fLineCutZRSlope(original.fLineCutZRSlope),
159 fLineCutZValue(original.fLineCutZValue),
160 fChi2CutConversion(original.fChi2CutConversion),
161 fChi2CutMeson(original.fChi2CutMeson),
162 fPIDProbabilityCutNegativeParticle(original.fPIDProbabilityCutNegativeParticle),
163 fPIDProbabilityCutPositiveParticle(original.fPIDProbabilityCutPositiveParticle),
164 fDodEdxSigmaCut(original.fDodEdxSigmaCut),
165 fPIDnSigmaAboveElectronLine(original.fPIDnSigmaAboveElectronLine),
166 fPIDnSigmaBelowElectronLine(original.fPIDnSigmaBelowElectronLine),
167 fPIDnSigmaAbovePionLine(original.fPIDnSigmaAbovePionLine),
168 fPIDMinPnSigmaAbovePionLine(original.fPIDMinPnSigmaAbovePionLine),
169 fXVertexCut(original.fXVertexCut),
170 fYVertexCut(original.fYVertexCut),
171 fZVertexCut(original.fZVertexCut),
172 fNSigmaMass(original.fNSigmaMass),
173 fUseImprovedVertex(original.fUseImprovedVertex),
174 fUseOwnXYZCalculation(original.fUseOwnXYZCalculation),
175 fDoCF(original.fDoCF),
176 fUseOnFlyV0Finder(original.fUseOnFlyV0Finder),
177 fUpdateV0AlreadyCalled(original.fUpdateV0AlreadyCalled),
178 fCurrentEventGoodV0s(original.fCurrentEventGoodV0s),
179 // fPreviousEventGoodV0s(original.fPreviousEventGoodV0s),
180 fCalculateBackground(original.fCalculateBackground),
181 fBGEventHandler(original.fBGEventHandler),
182 fBGEventInitialized(original.fBGEventInitialized),
183 fEsdTrackCuts(original.fEsdTrackCuts),
184 fNumberOfESDTracks(original.fNumberOfESDTracks)
190 AliV0Reader & AliV0Reader::operator = (const AliV0Reader & /*source*/)
192 // assignment operator
195 AliV0Reader::~AliV0Reader()
202 void AliV0Reader::Initialize(){
203 //see header file for documentation
205 fUpdateV0AlreadyCalled = kFALSE;
206 // Get the input handler from the manager
207 fESDHandler = (AliESDInputHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
208 if(fESDHandler == NULL){
212 // Get pointer to esd event from input handler
213 fESDEvent = fESDHandler->GetEvent();
214 if(fESDEvent == NULL){
218 //Get pointer to MCTruth
219 fMCTruth = (AliMCEventHandler*)((AliAnalysisManager::GetAnalysisManager())->GetMCtruthEventHandler());
220 if(fMCTruth == NULL){
225 //Get pointer to the mc stack
227 fMCStack = fMCTruth->MCEvent()->Stack();
228 if(fMCStack == NULL){
231 // Better parameters for MonteCarlo from A. Kalweit 2010/01/8
232 fESDpid->GetTPCResponse().SetBetheBlochParameters( 2.15898e+00/50.,
239 // Better parameters for data from A. Kalweit 2010/01/8
240 fESDpid->GetTPCResponse().SetBetheBlochParameters(0.0283086,
248 //Get pointer to the mc event
250 fMCEvent = fMCTruth->MCEvent();
251 if(fMCEvent == NULL){
257 AliKFParticle::SetField(fESDEvent->GetMagneticField());
259 // fCurrentEventGoodV0s = new TClonesArray("TClonesArray", 0);
260 fCurrentEventGoodV0s = new TClonesArray("AliKFParticle", 0);
262 if(fCalculateBackground == kTRUE){
263 if(fBGEventInitialized == kFALSE){
266 Double_t *zBinLimitsArray = new Double_t[8];
267 zBinLimitsArray[0] = -50.00;
268 zBinLimitsArray[1] = -4.07;
269 zBinLimitsArray[2] = -2.17;
270 zBinLimitsArray[3] = -0.69;
271 zBinLimitsArray[4] = 0.69;
272 zBinLimitsArray[5] = 2.17;
273 zBinLimitsArray[6] = 4.11;
274 zBinLimitsArray[7] = 50.00;
276 Double_t *multiplicityBinLimitsArray= new Double_t[5];
277 multiplicityBinLimitsArray[0] = 0;
278 multiplicityBinLimitsArray[1] = 8.5;
279 multiplicityBinLimitsArray[2] = 16.5;
280 multiplicityBinLimitsArray[3] = 27.5;
281 multiplicityBinLimitsArray[4] = 41.5;
283 fBGEventHandler = new AliGammaConversionBGHandler(8,4,10);
286 // ---------------------------------
287 Double_t *zBinLimitsArray = new Double_t[1];
288 zBinLimitsArray[0] = 999999.00;
290 Double_t *multiplicityBinLimitsArray= new Double_t[1];
291 multiplicityBinLimitsArray[0] = 99999999.00;
292 fBGEventHandler = new AliGammaConversionBGHandler(1,1,10);
293 // ---------------------------------
295 fBGEventHandler->Initialize(zBinLimitsArray, multiplicityBinLimitsArray);
296 fBGEventInitialized = kTRUE;
301 AliESDv0* AliV0Reader::GetV0(Int_t index){
302 //see header file for documentation
303 fCurrentV0 = fESDEvent->GetV0(index);
304 UpdateV0Information();
308 Bool_t AliV0Reader::CheckForPrimaryVertex(){
309 //see headerfile for documentation
310 return fESDEvent->GetPrimaryVertex()->GetNContributors()>0;
314 Bool_t AliV0Reader::CheckV0FinderStatus(Int_t index){
315 // see headerfile for documentation
316 if(fUseOnFlyV0Finder){
317 if(!GetV0(index)->GetOnFlyStatus()){
321 if(!fUseOnFlyV0Finder){
322 if(GetV0(index)->GetOnFlyStatus()){
331 Bool_t AliV0Reader::NextV0(){
332 //see header file for documentation
334 Bool_t iResult=kFALSE;
335 while(fCurrentV0IndexNumber<fESDEvent->GetNumberOfV0s()){
336 fCurrentV0 = fESDEvent->GetV0(fCurrentV0IndexNumber);
338 fUpdateV0AlreadyCalled=kFALSE;
340 if(fHistograms != NULL){
341 fHistograms->FillHistogram("ESD_AllV0s_InvMass",GetMotherCandidateMass());
344 // moved it up here so that the correction framework can access pt and eta information
345 if(UpdateV0Information() == kFALSE){
346 fCurrentV0IndexNumber++;
350 Double_t containerInput[3];
352 containerInput[0] = GetMotherCandidatePt();
353 containerInput[1] = GetMotherCandidateEta();
354 containerInput[2] = GetMotherCandidateMass();
358 containerInput[0] = GetMotherCandidatePt();
359 containerInput[1] = GetMotherCandidateEta();
360 containerInput[2] = GetMotherCandidateMass();
362 fCFManager->GetParticleContainer()->Fill(containerInput,kStepLikeSign); // for CF
363 fCFManager->GetParticleContainer()->Fill(containerInput,kStepTPCRefit); // for CF
364 fCFManager->GetParticleContainer()->Fill(containerInput,kStepKinks); // for CF
368 //checks if on the fly mode is set
369 if ( !CheckV0FinderStatus(fCurrentV0IndexNumber) ){
370 if(fHistograms != NULL){
371 fHistograms->FillHistogram("ESD_CutGetOnFly_InvMass",GetMotherCandidateMass());
373 fCurrentV0IndexNumber++;
377 fCFManager->GetParticleContainer()->Fill(containerInput,kStepGetOnFly); // for CF
380 if(fHistograms != NULL){
381 fHistograms->FillHistogram("ESD_AllV0sCurrentFinder_InvMass",GetMotherCandidateMass());
384 if(fCurrentNegativeESDTrack->GetSign() == fCurrentPositiveESDTrack->GetSign()){ // avoid like sign
386 if(fHistograms != NULL ){
387 fHistograms->FillHistogram("ESD_CutLikeSign_InvMass",GetMotherCandidateMass());
388 // to avoid filling the other cut histograms. So in this case fUpdateV0AlreadyCalled also serves as a flag for the histogram filling
389 // it will anyway be set to true at the end of the UpdateV0Information function, and there are no return until the end
390 // fUpdateV0AlreadyCalled = kTRUE;
392 fCurrentV0IndexNumber++;
396 fCFManager->GetParticleContainer()->Fill(containerInput,kStepLikeSign); // for CF
400 if( !(fCurrentNegativeESDTrack->GetStatus() & AliESDtrack::kTPCrefit) ||
401 !(fCurrentPositiveESDTrack->GetStatus() & AliESDtrack::kTPCrefit) ){
402 // if( !(fCurrentNegativeESDTrack->GetStatus() & AliESDtrack::kITSrefit) ||
403 // !(fCurrentPositiveESDTrack->GetStatus() & AliESDtrack::kITSrefit) ){
405 if(fHistograms != NULL){
406 fHistograms->FillHistogram("ESD_CutRefit_InvMass",GetMotherCandidateMass());
407 // to avoid filling the other cut histograms. So in this case fUpdateV0AlreadyCalled also serves as a flag for the histogram filling
408 // it will anyway be set to true at the end of the UpdateV0Information function, and there are no return until the end
409 //fUpdateV0AlreadyCalled = kTRUE;
411 fCurrentV0IndexNumber++;
415 fCFManager->GetParticleContainer()->Fill(containerInput,kStepTPCRefit); // for CF
420 if( fCurrentNegativeESDTrack->GetKinkIndex(0) > 0 ||
421 fCurrentPositiveESDTrack->GetKinkIndex(0) > 0) {
423 if(fHistograms != NULL ){
424 fHistograms->FillHistogram("ESD_CutKink_InvMass",GetMotherCandidateMass());
425 // to avoid filling the other cut histograms. So in this case fUpdateV0AlreadyCalled also serves as a flag for the histogram filling
426 // it will anyway be set to true at the end of the UpdateV0Information function, and there are no return until the end
427 //fUpdateV0AlreadyCalled = kTRUE;
429 fCurrentV0IndexNumber++;
434 fCFManager->GetParticleContainer()->Fill(containerInput,kStepKinks); // for CF
438 if(fDodEdxSigmaCut == kTRUE){
439 if( fESDpid->NumberOfSigmasTPC(fCurrentPositiveESDTrack,AliPID::kElectron)<fPIDnSigmaBelowElectronLine ||
440 fESDpid->NumberOfSigmasTPC(fCurrentPositiveESDTrack,AliPID::kElectron)>fPIDnSigmaAboveElectronLine ||
441 fESDpid->NumberOfSigmasTPC(fCurrentNegativeESDTrack,AliPID::kElectron)<fPIDnSigmaBelowElectronLine ||
442 fESDpid->NumberOfSigmasTPC(fCurrentNegativeESDTrack,AliPID::kElectron)>fPIDnSigmaAboveElectronLine ){
444 if(fHistograms != NULL ){
445 fHistograms->FillHistogram("ESD_CutdEdxSigmaElectronLine_InvMass",GetMotherCandidateMass());
446 // to avoid filling the other cut histograms. So in this case fUpdateV0AlreadyCalled also serves as a flag for the histogram filling
447 // it will anyway be set to true at the end of the UpdateV0Information function, and there are no return until the end
448 //fUpdateV0AlreadyCalled = kTRUE;
450 fCurrentV0IndexNumber++;
454 fCFManager->GetParticleContainer()->Fill(containerInput,kStepdEdx_electronselection); // for CF
457 if( fCurrentPositiveESDTrack->P()>fPIDMinPnSigmaAbovePionLine){
458 if(fESDpid->NumberOfSigmasTPC(fCurrentPositiveESDTrack,AliPID::kElectron)>fPIDnSigmaBelowElectronLine &&
459 fESDpid->NumberOfSigmasTPC(fCurrentPositiveESDTrack,AliPID::kElectron)<fPIDnSigmaAboveElectronLine&&
460 fESDpid->NumberOfSigmasTPC(fCurrentPositiveESDTrack,AliPID::kPion)<fPIDnSigmaAbovePionLine){
462 if(fHistograms != NULL){
463 fHistograms->FillHistogram("ESD_CutdEdxSigmaPionLine_InvMass",GetMotherCandidateMass());
464 // to avoid filling the other cut histograms. So in this case fUpdateV0AlreadyCalled also serves as a flag for the histogram filling
465 // it will anyway be set to true at the end of the UpdateV0Information function, and there are no return until the end
466 //fUpdateV0AlreadyCalled = kTRUE;
468 fCurrentV0IndexNumber++;
473 if( fCurrentNegativeESDTrack->P()>fPIDMinPnSigmaAbovePionLine){
474 if(fESDpid->NumberOfSigmasTPC(fCurrentNegativeESDTrack,AliPID::kElectron)>fPIDnSigmaBelowElectronLine &&
475 fESDpid->NumberOfSigmasTPC(fCurrentNegativeESDTrack,AliPID::kElectron)<fPIDnSigmaAboveElectronLine&&
476 fESDpid->NumberOfSigmasTPC(fCurrentNegativeESDTrack,AliPID::kPion)<fPIDnSigmaAbovePionLine){
478 if(fHistograms != NULL){
479 fHistograms->FillHistogram("ESD_CutdEdxSigmaPionLine_InvMass",GetMotherCandidateMass());
480 // to avoid filling the other cut histograms. So in this case fUpdateV0AlreadyCalled also serves as a flag for the histogram filling
481 // it will anyway be set to true at the end of the UpdateV0Information function, and there are no return until the end
482 //fUpdateV0AlreadyCalled = kTRUE;
484 fCurrentV0IndexNumber++;
489 fCFManager->GetParticleContainer()->Fill(containerInput,kStepdEdx_pionrejection); // for CF
494 //checks if we have a prim vertex
495 if(fESDEvent->GetPrimaryVertex()->GetNContributors()<=0) {
496 if(fHistograms != NULL){
497 fHistograms->FillHistogram("ESD_CutNContributors_InvMass",GetMotherCandidateMass());
499 fCurrentV0IndexNumber++;
503 fCFManager->GetParticleContainer()->Fill(containerInput,kStepNContributors); // for CF
506 //Check the pid probability
507 if(CheckPIDProbability(fPIDProbabilityCutNegativeParticle,fPIDProbabilityCutPositiveParticle)==kFALSE){
508 if(fHistograms != NULL){
509 fHistograms->FillHistogram("ESD_CutPIDProb_InvMass",GetMotherCandidateMass());
511 fCurrentV0IndexNumber++;
515 fCFManager->GetParticleContainer()->Fill(containerInput,kStepTPCPID); // for CF
518 if(GetXYRadius()>fMaxR){ // cuts on distance from collision point
519 if(fHistograms != NULL){
520 fHistograms->FillHistogram("ESD_CutR_InvMass",GetMotherCandidateMass());
522 fCurrentV0IndexNumber++;
526 fCFManager->GetParticleContainer()->Fill(containerInput,kStepR); // for CF
530 if((TMath::Abs(fCurrentZValue)*fLineCutZRSlope)-fLineCutZValue > GetXYRadius() ){ // cuts out regions where we do not reconstruct
531 if(fHistograms != NULL){
532 fHistograms->FillHistogram("ESD_CutLine_InvMass",GetMotherCandidateMass());
534 fCurrentV0IndexNumber++;
538 fCFManager->GetParticleContainer()->Fill(containerInput,kStepLine); // for CF
541 if(TMath::Abs(fCurrentZValue) > fMaxZ ){ // cuts out regions where we do not reconstruct
542 if(fHistograms != NULL){
543 fHistograms->FillHistogram("ESD_CutZ_InvMass",GetMotherCandidateMass());
545 fCurrentV0IndexNumber++;
549 fCFManager->GetParticleContainer()->Fill(containerInput,kStepZ); // for CF
552 /* Moved further up so corr framework can work
553 if(UpdateV0Information() == kFALSE){
554 fCurrentV0IndexNumber++;
561 if(fCurrentMotherKFCandidate->GetNDF()<=0){
562 if(fHistograms != NULL){
563 fHistograms->FillHistogram("ESD_CutNDF_InvMass",GetMotherCandidateMass());
565 fCurrentV0IndexNumber++;
569 fCFManager->GetParticleContainer()->Fill(containerInput,kStepNDF); // for CF
572 Double_t chi2V0 = fCurrentMotherKFCandidate->GetChi2()/fCurrentMotherKFCandidate->GetNDF();
573 if(chi2V0 > fChi2CutConversion || chi2V0 <=0){
574 if(fHistograms != NULL){
575 fHistograms->FillHistogram("ESD_CutChi2_InvMass",GetMotherCandidateMass());
577 fCurrentV0IndexNumber++;
581 fCFManager->GetParticleContainer()->Fill(containerInput,kStepChi2); // for CF
584 if(TMath::Abs(fMotherCandidateLorentzVector->Eta())> fEtaCut){
585 if(fHistograms != NULL){
586 fHistograms->FillHistogram("ESD_CutEta_InvMass",GetMotherCandidateMass());
588 fCurrentV0IndexNumber++;
592 fCFManager->GetParticleContainer()->Fill(containerInput,kStepEta); // for CF
595 if(fMotherCandidateLorentzVector->Pt()<fPtCut){
596 if(fHistograms != NULL){
597 fHistograms->FillHistogram("ESD_CutPt_InvMass",GetMotherCandidateMass());
599 fCurrentV0IndexNumber++;
603 fCFManager->GetParticleContainer()->Fill(containerInput,kStepPt); // for CF
607 else if(fUseESDTrack){
611 if(fHistograms != NULL){
612 fHistograms->FillHistogram("ESD_GoodV0s_InvMass",GetMotherCandidateMass());
615 // fCurrentEventGoodV0s.push_back(*fCurrentMotherKFCandidate);
617 new((*fCurrentEventGoodV0s)[fCurrentEventGoodV0s->GetEntriesFast()]) AliKFParticle(*fCurrentMotherKFCandidate);
619 iResult=kTRUE;//means we have a v0 who survived all the cuts applied
621 fCurrentV0IndexNumber++;
628 Bool_t AliV0Reader::UpdateV0Information(){
629 //see header file for documentation
631 Bool_t iResult=kTRUE; // for taking out not refitted, kinks and like sign tracks
633 Bool_t switchTracks = kFALSE;
635 fCurrentNegativeESDTrack = fESDEvent->GetTrack(fCurrentV0->GetNindex());
636 fCurrentPositiveESDTrack = fESDEvent->GetTrack(fCurrentV0->GetPindex());
638 if(fCurrentPositiveESDTrack->GetSign() == -1 && fCurrentNegativeESDTrack->GetSign() == 1){ // switch wrong signed tracks
639 fCurrentNegativeESDTrack = fESDEvent->GetTrack(fCurrentV0->GetPindex());
640 fCurrentPositiveESDTrack = fESDEvent->GetTrack(fCurrentV0->GetNindex());
641 switchTracks = kTRUE;
644 if(fCurrentNegativeKFParticle != NULL){
645 delete fCurrentNegativeKFParticle;
647 if(switchTracks == kFALSE){
648 fCurrentNegativeKFParticle = new AliKFParticle(*(fCurrentV0->GetParamN()),fNegativeTrackPID);
651 fCurrentNegativeKFParticle = new AliKFParticle(*(fCurrentV0->GetParamP()),fNegativeTrackPID);
654 if(fCurrentPositiveKFParticle != NULL){
655 delete fCurrentPositiveKFParticle;
657 if(switchTracks == kFALSE){
658 fCurrentPositiveKFParticle = new AliKFParticle(*(fCurrentV0->GetParamP()),fPositiveTrackPID);
661 fCurrentPositiveKFParticle = new AliKFParticle(*(fCurrentV0->GetParamN()),fPositiveTrackPID);
664 if(fCurrentMotherKFCandidate != NULL){
665 delete fCurrentMotherKFCandidate;
667 fCurrentMotherKFCandidate = new AliKFParticle(*fCurrentNegativeKFParticle,*fCurrentPositiveKFParticle);
670 if(fPositiveTrackPID==-11 && fNegativeTrackPID==11){
671 fCurrentMotherKFCandidate->SetMassConstraint(0,fNSigmaMass);
674 if(fUseImprovedVertex == kTRUE){
675 AliKFVertex primaryVertexImproved(*GetPrimaryVertex());
676 primaryVertexImproved+=*fCurrentMotherKFCandidate;
677 fCurrentMotherKFCandidate->SetProductionVertex(primaryVertexImproved);
680 fCurrentMotherKFCandidate->GetMass(fMotherCandidateKFMass,fMotherCandidateKFWidth);
682 if(fNegativeTrackLorentzVector != NULL){
683 delete fNegativeTrackLorentzVector;
686 fNegativeTrackLorentzVector = new TLorentzVector(fCurrentNegativeKFParticle->Px(),fCurrentNegativeKFParticle->Py(),fCurrentNegativeKFParticle->Pz());
688 else if(fUseESDTrack){
689 fNegativeTrackLorentzVector = new TLorentzVector(fCurrentNegativeESDTrack->Px(),fCurrentNegativeESDTrack->Py(),fCurrentNegativeESDTrack->Pz());
692 if(fPositiveTrackLorentzVector != NULL){
693 delete fPositiveTrackLorentzVector;
696 fPositiveTrackLorentzVector = new TLorentzVector(fCurrentPositiveKFParticle->Px(),fCurrentPositiveKFParticle->Py(),fCurrentPositiveKFParticle->Pz());
698 else if(fUseESDTrack){
699 fPositiveTrackLorentzVector = new TLorentzVector(fCurrentPositiveESDTrack->Px(),fCurrentPositiveESDTrack->Py(),fCurrentPositiveESDTrack->Pz());
702 if(fMotherCandidateLorentzVector != NULL){
703 delete fMotherCandidateLorentzVector;
706 fMotherCandidateLorentzVector = new TLorentzVector(*fNegativeTrackLorentzVector + *fPositiveTrackLorentzVector);
708 else if(fUseESDTrack){
709 fMotherCandidateLorentzVector = new TLorentzVector(*fNegativeTrackLorentzVector + *fPositiveTrackLorentzVector);
712 if(fPositiveTrackPID==-11 && fNegativeTrackPID==11){
713 fMotherCandidateLorentzVector->SetXYZM(fMotherCandidateLorentzVector->Px() ,fMotherCandidateLorentzVector->Py(),fMotherCandidateLorentzVector->Pz(),0.);
718 fMotherMCParticle= NULL;
719 fNegativeMCParticle = fMCStack->Particle(TMath::Abs(fESDEvent->GetTrack(fCurrentV0->GetNindex())->GetLabel()));
720 fPositiveMCParticle = fMCStack->Particle(TMath::Abs(fESDEvent->GetTrack(fCurrentV0->GetPindex())->GetLabel()));
721 if(fPositiveMCParticle->GetMother(0)>-1){
722 fMotherMCParticle = fMCStack->Particle(fPositiveMCParticle->GetMother(0));
728 // Double_t containerInput[3];
730 // containerInput[0] = GetMotherCandidatePt();
731 // containerInput[1] = GetMotherCandidateEta();
732 // containerInput[2] = GetMotherCandidateMass();
734 // fCFManager->GetParticleContainer()->Fill(containerInput,kStepLikeSign); // for CF
735 // fCFManager->GetParticleContainer()->Fill(containerInput,kStepTPCRefit); // for CF
736 // fCFManager->GetParticleContainer()->Fill(containerInput,kStepKinks); // for CF
740 if(fUseOwnXYZCalculation == kFALSE){
741 fCurrentV0->GetXYZ(fCurrentXValue,fCurrentYValue,fCurrentZValue);
747 GetConvPosXY(GetPositiveESDTrack(),GetNegativeESDTrack(),GetMagneticField(),convpos);
748 fCurrentXValue = convpos[0];
749 fCurrentYValue = convpos[1];
750 fCurrentZValue = GetConvPosZ(GetPositiveESDTrack(),GetNegativeESDTrack(),GetMagneticField());
753 if(fCurrentNegativeESDTrack->GetSign() == fCurrentPositiveESDTrack->GetSign()){ // avoid like sign
755 if(fHistograms != NULL && fUpdateV0AlreadyCalled == kFALSE && doFillHistos == kTRUE){
756 fHistograms->FillHistogram("ESD_CutLikeSign_InvMass",GetMotherCandidateMass());
757 // to avoid filling the other cut histograms. So in this case fUpdateV0AlreadyCalled also serves as a flag for the histogram filling
758 // it will anyway be set to true at the end of the UpdateV0Information function, and there are no return until the end
759 fUpdateV0AlreadyCalled = kTRUE;
763 if( !(fCurrentNegativeESDTrack->GetStatus() & AliESDtrack::kTPCrefit) ||
764 !(fCurrentPositiveESDTrack->GetStatus() & AliESDtrack::kTPCrefit) ){
765 // if( !(fCurrentNegativeESDTrack->GetStatus() & AliESDtrack::kITSrefit) ||
766 // !(fCurrentPositiveESDTrack->GetStatus() & AliESDtrack::kITSrefit) ){
768 if(fHistograms != NULL && fUpdateV0AlreadyCalled == kFALSE && doFillHistos == kTRUE){
769 fHistograms->FillHistogram("ESD_CutRefit_InvMass",GetMotherCandidateMass());
770 // to avoid filling the other cut histograms. So in this case fUpdateV0AlreadyCalled also serves as a flag for the histogram filling
771 // it will anyway be set to true at the end of the UpdateV0Information function, and there are no return until the end
772 fUpdateV0AlreadyCalled = kTRUE;
776 if( fCurrentNegativeESDTrack->GetKinkIndex(0) > 0 ||
777 fCurrentPositiveESDTrack->GetKinkIndex(0) > 0) {
780 if(fHistograms != NULL && fUpdateV0AlreadyCalled == kFALSE && doFillHistos == kTRUE ){
781 fHistograms->FillHistogram("ESD_CutKink_InvMass",GetMotherCandidateMass());
782 // to avoid filling the other cut histograms. So in this case fUpdateV0AlreadyCalled also serves as a flag for the histogram filling
783 // it will anyway be set to true at the end of the UpdateV0Information function, and there are no return until the end
784 fUpdateV0AlreadyCalled = kTRUE;
788 if(fDodEdxSigmaCut == kTRUE){
790 if( fESDpid->NumberOfSigmasTPC(fCurrentPositiveESDTrack,AliPID::kElectron)<fPIDnSigmaBelowElectronLine ||
791 fESDpid->NumberOfSigmasTPC(fCurrentPositiveESDTrack,AliPID::kElectron)>fPIDnSigmaAboveElectronLine ||
792 fESDpid->NumberOfSigmasTPC(fCurrentNegativeESDTrack,AliPID::kElectron)<fPIDnSigmaBelowElectronLine ||
793 fESDpid->NumberOfSigmasTPC(fCurrentNegativeESDTrack,AliPID::kElectron)>fPIDnSigmaAboveElectronLine ){
795 if(fHistograms != NULL && fUpdateV0AlreadyCalled == kFALSE && doFillHistos == kTRUE){
796 fHistograms->FillHistogram("ESD_CutdEdxSigmaElectronLine_InvMass",GetMotherCandidateMass());
797 // to avoid filling the other cut histograms. So in this case fUpdateV0AlreadyCalled also serves as a flag for the histogram filling
798 // it will anyway be set to true at the end of the UpdateV0Information function, and there are no return until the end
799 fUpdateV0AlreadyCalled = kTRUE;
802 if( fCurrentPositiveESDTrack->P()>fPIDMinPnSigmaAbovePionLine){
803 if(fESDpid->NumberOfSigmasTPC(fCurrentPositiveESDTrack,AliPID::kElectron)>fPIDnSigmaBelowElectronLine &&
804 fESDpid->NumberOfSigmasTPC(fCurrentPositiveESDTrack,AliPID::kElectron)<fPIDnSigmaAboveElectronLine&&
805 fESDpid->NumberOfSigmasTPC(fCurrentPositiveESDTrack,AliPID::kPion)<fPIDnSigmaAbovePionLine){
807 if(fHistograms != NULL && fUpdateV0AlreadyCalled == kFALSE && doFillHistos == kTRUE){
808 fHistograms->FillHistogram("ESD_CutdEdxSigmaPionLine_InvMass",GetMotherCandidateMass());
809 // to avoid filling the other cut histograms. So in this case fUpdateV0AlreadyCalled also serves as a flag for the histogram filling
810 // it will anyway be set to true at the end of the UpdateV0Information function, and there are no return until the end
811 fUpdateV0AlreadyCalled = kTRUE;
816 if( fCurrentNegativeESDTrack->P()>fPIDMinPnSigmaAbovePionLine){
817 if(fESDpid->NumberOfSigmasTPC(fCurrentNegativeESDTrack,AliPID::kElectron)>fPIDnSigmaBelowElectronLine &&
818 fESDpid->NumberOfSigmasTPC(fCurrentNegativeESDTrack,AliPID::kElectron)<fPIDnSigmaAboveElectronLine&&
819 fESDpid->NumberOfSigmasTPC(fCurrentNegativeESDTrack,AliPID::kPion)<fPIDnSigmaAbovePionLine){
821 if(fHistograms != NULL && fUpdateV0AlreadyCalled == kFALSE && doFillHistos == kTRUE ){
822 fHistograms->FillHistogram("ESD_CutdEdxSigmaPionLine_InvMass",GetMotherCandidateMass());
823 // to avoid filling the other cut histograms. So in this case fUpdateV0AlreadyCalled also serves as a flag for the histogram filling
824 // it will anyway be set to true at the end of the UpdateV0Information function, and there are no return until the end
825 fUpdateV0AlreadyCalled = kTRUE;
831 fUpdateV0AlreadyCalled = kTRUE;
838 Bool_t AliV0Reader::HasSameMCMother(){
839 //see header file for documentation
841 Bool_t iResult = kFALSE;
843 if(fNegativeMCParticle != NULL && fPositiveMCParticle != NULL){
844 if(fNegativeMCParticle->GetMother(0) == fPositiveMCParticle->GetMother(0))
845 if(fMotherMCParticle){
853 Bool_t AliV0Reader::CheckPIDProbability(Double_t negProbCut, Double_t posProbCut){
854 //see header file for documentation
856 Bool_t iResult=kFALSE;
858 Double_t *posProbArray = new Double_t[10];
859 Double_t *negProbArray = new Double_t[10];
860 AliESDtrack* negTrack = fESDEvent->GetTrack(fCurrentV0->GetNindex());
861 AliESDtrack* posTrack = fESDEvent->GetTrack(fCurrentV0->GetPindex());
863 negTrack->GetTPCpid(negProbArray);
864 posTrack->GetTPCpid(posProbArray);
866 // if(negProbArray != NULL && posProbArray != NULL){ // this is not allowed anymore for some reason(RC19)
867 if(negProbArray && posProbArray){
868 if(negProbArray[GetSpeciesIndex(-1)]>=negProbCut && posProbArray[GetSpeciesIndex(1)]>=posProbCut){
872 delete [] posProbArray;
873 delete [] negProbArray;
877 void AliV0Reader::GetPIDProbability(Double_t &negPIDProb,Double_t & posPIDProb){
878 // see header file for documentation
880 Double_t *posProbArray = new Double_t[10];
881 Double_t *negProbArray = new Double_t[10];
882 AliESDtrack* negTrack = fESDEvent->GetTrack(fCurrentV0->GetNindex());
883 AliESDtrack* posTrack = fESDEvent->GetTrack(fCurrentV0->GetPindex());
885 negTrack->GetTPCpid(negProbArray);
886 posTrack->GetTPCpid(posProbArray);
888 // if(negProbArray!=NULL && posProbArray!=NULL){ // this is not allowed anymore for some reason(RC19)
889 if(negProbArray && posProbArray){
890 negPIDProb = negProbArray[GetSpeciesIndex(-1)];
891 posPIDProb = posProbArray[GetSpeciesIndex(1)];
893 delete [] posProbArray;
894 delete [] negProbArray;
897 void AliV0Reader::UpdateEventByEventData(){
898 //see header file for documentation
899 if(fCurrentEventGoodV0s->GetEntriesFast() >0 ){
900 if(fCalculateBackground){
901 fBGEventHandler->AddEvent(fCurrentEventGoodV0s,fESDEvent->GetPrimaryVertex()->GetZ(),CountESDTracks());
902 //filling z and multiplicity histograms
903 fHistograms->FillHistogram("ESD_Z_distribution",fESDEvent->GetPrimaryVertex()->GetZ());
904 fHistograms->FillHistogram("ESD_multiplicity_distribution",CountESDTracks());
905 fHistograms->FillHistogram("ESD_ZvsMultiplicity",fESDEvent->GetPrimaryVertex()->GetZ(),CountESDTracks());
908 fCurrentEventGoodV0s->Delete();
909 fCurrentV0IndexNumber=0;
910 fNumberOfESDTracks=0;
911 // fBGEventHandler->PrintBGArray(); // for debugging
915 Double_t AliV0Reader::GetNegativeTrackPhi() const{
916 //see header file for documentation
919 if(fNegativeTrackLorentzVector->Phi()> TMath::Pi()){
920 offset = -2*TMath::Pi();
922 return fNegativeTrackLorentzVector->Phi()+offset;
925 Double_t AliV0Reader::GetPositiveTrackPhi() const{
926 //see header file for documentation
929 if(fPositiveTrackLorentzVector->Phi()> TMath::Pi()){
930 offset = -2*TMath::Pi();
932 return fPositiveTrackLorentzVector->Phi()+offset;
935 Double_t AliV0Reader::GetMotherCandidatePhi() const{
936 //see header file for documentation
939 if(fMotherCandidateLorentzVector->Phi()> TMath::Pi()){
940 offset = -2*TMath::Pi();
942 return fMotherCandidateLorentzVector->Phi()+offset;
946 Double_t AliV0Reader::GetMotherCandidateRapidity() const{
947 //see header file for documentation
950 if(fMotherCandidateLorentzVector->Energy() - fMotherCandidateLorentzVector->Pz() == 0 || fMotherCandidateLorentzVector->Energy() + fMotherCandidateLorentzVector->Pz() == 0) rapidity=0;
951 else rapidity = 0.5*(TMath::Log((fMotherCandidateLorentzVector->Energy() + fMotherCandidateLorentzVector->Pz()) / (fMotherCandidateLorentzVector->Energy()-fMotherCandidateLorentzVector->Pz())));
960 Int_t AliV0Reader::GetSpeciesIndex(Int_t chargeOfTrack){
961 //see header file for documentation
963 Int_t iResult = 10; // Unknown particle
965 if(chargeOfTrack==-1){ //negative track
966 switch(abs(fNegativeTrackPID)){
995 //Put in here for kSPECIES::kEleCon ????
998 else if(chargeOfTrack==1){ //positive track
999 switch(abs(fPositiveTrackPID)){
1021 case 2112: //neutron
1028 //Put in here for kSPECIES::kEleCon ????
1032 //Wrong parameter.. Print warning
1037 Bool_t AliV0Reader::GetHelixCenter(AliESDtrack* track, Double_t b,Int_t charge, Double_t center[2]){
1038 // see header file for documentation
1040 Double_t pi = 3.14159265358979323846;
1043 track->GetHelixParameters(helix,b);
1045 Double_t xpos = helix[5];
1046 Double_t ypos = helix[0];
1047 Double_t radius = TMath::Abs(1./helix[4]);
1048 Double_t phi = helix[2];
1055 Double_t xpoint = radius * TMath::Cos(phi);
1056 Double_t ypoint = radius * TMath::Sin(phi);
1067 center[0] = xpos + xpoint;
1068 center[1] = ypos + ypoint;
1073 Bool_t AliV0Reader::GetConvPosXY(AliESDtrack* ptrack, AliESDtrack* ntrack, Double_t b, Double_t convpos[2]){
1074 //see header file for documentation
1076 Double_t helixcenterpos[2];
1077 GetHelixCenter(ptrack,b,ptrack->Charge(),helixcenterpos);
1079 Double_t helixcenterneg[2];
1080 GetHelixCenter(ntrack,b,ntrack->Charge(),helixcenterneg);
1082 Double_t poshelix[6];
1083 ptrack->GetHelixParameters(poshelix,b);
1084 Double_t posradius = TMath::Abs(1./poshelix[4]);
1086 Double_t neghelix[6];
1087 ntrack->GetHelixParameters(neghelix,b);
1088 Double_t negradius = TMath::Abs(1./neghelix[4]);
1090 Double_t xpos = helixcenterpos[0];
1091 Double_t ypos = helixcenterpos[1];
1092 Double_t xneg = helixcenterneg[0];
1093 Double_t yneg = helixcenterneg[1];
1095 convpos[0] = (xpos*negradius + xneg*posradius)/(negradius+posradius);
1096 convpos[1] = (ypos*negradius+ yneg*posradius)/(negradius+posradius);
1103 Double_t AliV0Reader::GetConvPosZ(AliESDtrack* ptrack,AliESDtrack* ntrack, Double_t b){
1104 //see header file for documentation
1106 Double_t helixpos[6];
1107 ptrack->GetHelixParameters(helixpos,b);
1109 Double_t helixneg[6];
1110 ntrack->GetHelixParameters(helixneg,b);
1112 Double_t negtrackradius = TMath::Abs(1./helixneg[4]);
1113 Double_t postrackradius = TMath::Abs(1./helixpos[4]);
1115 Double_t pi = 3.14159265358979323846;
1117 Double_t convpos[2];
1118 GetConvPosXY(ptrack,ntrack,b,convpos);
1120 Double_t convposx = convpos[0];
1121 Double_t convposy = convpos[1];
1123 Double_t helixcenterpos[2];
1124 GetHelixCenter(ptrack,b,ptrack->Charge(),helixcenterpos);
1126 Double_t helixcenterneg[2];
1127 GetHelixCenter(ntrack,b,ntrack->Charge(),helixcenterneg);
1129 Double_t xpos = helixcenterpos[0];
1130 Double_t ypos = helixcenterpos[1];
1131 Double_t xneg = helixcenterneg[0];
1132 Double_t yneg = helixcenterneg[1];
1134 Double_t deltaXPos = convposx - xpos;
1135 Double_t deltaYPos = convposy - ypos;
1137 Double_t deltaXNeg = convposx - xneg;
1138 Double_t deltaYNeg = convposy - yneg;
1140 Double_t alphaPos = pi + TMath::ATan2(-deltaYPos,-deltaXPos);
1141 Double_t alphaNeg = pi + TMath::ATan2(-deltaYNeg,-deltaXNeg);
1143 Double_t vertexXNeg = xneg + TMath::Abs(negtrackradius)*
1144 TMath::Cos(alphaNeg);
1145 Double_t vertexYNeg = yneg + TMath::Abs(negtrackradius)*
1146 TMath::Sin(alphaNeg);
1148 Double_t vertexXPos = xpos + TMath::Abs(postrackradius)*
1149 TMath::Cos(alphaPos);
1150 Double_t vertexYPos = ypos + TMath::Abs(postrackradius)*
1151 TMath::Sin(alphaPos);
1153 Double_t x0neg = helixneg[5];
1154 Double_t y0neg = helixneg[0];
1156 Double_t x0pos = helixpos[5];
1157 Double_t y0pos = helixpos[0];
1159 Double_t dNeg = TMath::Sqrt((vertexXNeg - x0neg)*(vertexXNeg - x0neg)
1160 +(vertexYNeg - y0neg)*(vertexYNeg - y0neg));
1162 Double_t dPos = TMath::Sqrt((vertexXPos - x0pos)*(vertexXPos - x0pos)
1163 +(vertexYPos - y0pos)*(vertexYPos - y0pos));
1165 Double_t rNeg = TMath::Sqrt(negtrackradius*negtrackradius -
1168 Double_t rPos = TMath::Sqrt(postrackradius*postrackradius -
1171 Double_t deltabetaNeg = 2*(pi + TMath::ATan2(-dNeg/2.,-rNeg));
1172 Double_t deltabetaPos = 2*(pi + TMath::ATan2(-dPos/2.,-rPos));
1174 Double_t deltaUNeg = negtrackradius*deltabetaNeg;
1175 Double_t deltaUPos = postrackradius*deltabetaPos;
1177 Double_t zphaseNeg = ntrack->GetZ() + deltaUNeg * ntrack->GetTgl();
1178 Double_t zphasePos = ptrack->GetZ() + deltaUPos * ptrack->GetTgl();
1180 Double_t convposz = (zphasePos*negtrackradius+zphaseNeg*postrackradius)/(negtrackradius+postrackradius);
1185 AliGammaConversionKFVector* AliV0Reader::GetBGGoodV0s(Int_t event){
1187 return fBGEventHandler->GetBGGoodV0s(event,fESDEvent->GetPrimaryVertex()->GetZ(),CountESDTracks());
1190 Int_t AliV0Reader::CountESDTracks(){
1191 // see header file for documentation
1192 if(fNumberOfESDTracks == 0){ // count the good esd tracks
1193 for(Int_t iTracks = 0; iTracks < fESDEvent->GetNumberOfTracks(); iTracks++){
1194 AliESDtrack* curTrack = fESDEvent->GetTrack(iTracks);
1198 if(fEsdTrackCuts->AcceptTrack(curTrack) ){
1199 fNumberOfESDTracks++;
1204 return fNumberOfESDTracks;
1207 Bool_t AliV0Reader::CheckIfPi0IsMother(Int_t label){
1208 // see headerfile for documentation
1209 Bool_t iResult=kFALSE;
1210 // cout<<"Checking particle label, particle is: "<<fMCStack->Particle(TMath::Abs(label))->GetName()<<endl;
1211 if(fMCStack->Particle(TMath::Abs(label))->GetPdgCode() == 111){