1 /**************************************************************************
2 * Copyright(c) 1998-2011, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 // Class for HF corrections as a function of many variables and steps
18 // For D* and other cascades
20 // Author : A.Grelli a.grelli@uu.nl UTECHT
21 //-----------------------------------------------------------------------
23 #include "AliAODRecoDecayHF2Prong.h"
24 #include "AliAODMCParticle.h"
25 #include "AliAODEvent.h"
26 #include "TClonesArray.h"
27 #include "AliCFVertexingHF.h"
28 #include "AliESDtrack.h"
29 #include "TDatabasePDG.h"
30 #include "AliAODRecoCascadeHF.h"
31 #include "AliCFVertexingHFCascade.h"
32 #include "AliCFContainer.h"
33 #include "AliCFTaskVertexingHF.h"
34 #include "AliPIDResponse.h"
37 ClassImp(AliCFVertexingHFCascade)
40 //_________________________________________
41 AliCFVertexingHFCascade::AliCFVertexingHFCascade(TClonesArray *mcArray, UShort_t originDselection):
42 AliCFVertexingHF(mcArray, originDselection),
46 fPDGneutrDaughForMC(0),
47 fPDGneutrDaughPositive(0),
48 fPDGneutrDaughNegative(0),
50 fUseCutsForTMVA(kFALSE),
51 fCutOnMomConservation(0.00001)
53 // standard constructor
56 fPtAccCut = new Float_t[fProngs];
57 fEtaAccCut = new Float_t[fProngs];
58 // element 0 in the cut arrays corresponds to the soft pion!!!!!!!! Careful when setting the values...
61 for(Int_t iP=1; iP<fProngs; iP++){
69 //_____________________________________
70 AliCFVertexingHFCascade& AliCFVertexingHFCascade::operator=(const AliCFVertexingHFCascade& c)
76 AliCFVertexingHF::operator=(c);
82 //__________________________________________
83 Bool_t AliCFVertexingHFCascade::SetRecoCandidateParam(AliAODRecoDecayHF *recoCand)
85 // set the AliAODRecoDecay candidate
87 Bool_t bSignAssoc = kFALSE;
89 fRecoCandidate = recoCand;
90 AliAODRecoCascadeHF* cascade = (AliAODRecoCascadeHF*)recoCand;
92 if (!fRecoCandidate) {
93 AliError("fRecoCandidate not found, problem in assignement\n");
97 if ( fRecoCandidate->GetPrimaryVtx()) AliDebug(3,"fReco Candidate has a pointer to PrimVtx\n");
99 //Int_t pdgCand = 413;
101 Int_t pdgDgCascade[2] = {fPDGneutrDaugh, fPDGbachelor};
102 Int_t pdgDgNeutrDaugh[2] = {fPDGneutrDaughPositive, fPDGneutrDaughNegative};
104 Int_t nentries = fmcArray->GetEntriesFast();
106 AliDebug(3,Form("nentries = %d\n", nentries));
108 Bool_t isV0 = kFALSE;
109 if (fPDGcascade == 4122) {
111 pdgDgCascade[0] = fPDGbachelor;
112 pdgDgCascade[1] = fPDGneutrDaugh;
114 AliDebug(3, Form("calling MatchToMC with: fPDGcascade = %d, fPDGneutrDaugh = %d, pdgDgCascade[0] = %d, pdgDgCascade[1] = %d, pdgDgNeutrDaugh[0] = %d, pdgDgNeutrDaugh[1] = %d, fmcArray = %p", fPDGcascade, fPDGneutrDaugh, pdgDgCascade[0], pdgDgCascade[1], pdgDgNeutrDaugh[0], pdgDgNeutrDaugh[1], fmcArray));
115 Int_t mcLabel = cascade->MatchToMC(fPDGcascade, fPDGneutrDaugh, pdgDgCascade, pdgDgNeutrDaugh, fmcArray, isV0);
117 if (mcLabel == -1) return bSignAssoc;
119 if (fRecoCandidate->NumberOfFakeDaughters()>0){
120 fFake = 0; // fake candidate
121 if (fFakeSelection == 1) return bSignAssoc;
123 if (fRecoCandidate->NumberOfFakeDaughters()==0){
124 fFake = 2; // non-fake candidate
125 if (fFakeSelection == 2) return bSignAssoc;
129 fmcPartCandidate = dynamic_cast<AliAODMCParticle*>(fmcArray->At(fmcLabel));
131 if (!fmcPartCandidate){
132 AliDebug(3,"No part candidate");
140 //______________________________________________
141 Bool_t AliCFVertexingHFCascade::GetGeneratedValuesFromMCParticle(Double_t* vectorMC)
144 // collecting all the necessary info (pt, y, cosThetaStar, ptPi, ptKa, cT) from MC particle
147 Bool_t bGenValues = kFALSE;
149 Int_t daughter0cascade = fmcPartCandidate->GetDaughter(0);
150 Int_t daughter1cascade = fmcPartCandidate->GetDaughter(1);
152 AliAODMCParticle* mcPartDaughter0 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter0cascade));
153 AliAODMCParticle* mcPartDaughter1 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter1cascade));
154 AliAODMCParticle* mcPartDaughterNeutrDaugh = NULL;
155 AliAODMCParticle* mcPartDaughterBachelor = NULL;
157 // the Neutral Particle (e.g. D0 for D*, K0S for Lc...)
158 // for D* the D0 (the neutral) is the first daughter, while for Lc the V0 is the second, so we check the
159 // charge of the daughters to decide which is which
160 if (mcPartDaughter0->Charge()/3 == 0){
161 mcPartDaughterNeutrDaugh = mcPartDaughter0;
162 mcPartDaughterBachelor = mcPartDaughter1;
165 mcPartDaughterNeutrDaugh = mcPartDaughter1;
166 mcPartDaughterBachelor = mcPartDaughter0;
169 if (!mcPartDaughterNeutrDaugh || !mcPartDaughterBachelor) return kFALSE;
171 Double_t vtx1[3] = {0,0,0}; // primary vertex
172 Double_t vtx2daughter0[3] = {0,0,0}; // secondary vertex from daughter 0
173 Double_t vtx2daughter1[3] = {0,0,0}; // secondary vertex from daughter 1
174 fmcPartCandidate->XvYvZv(vtx1); // cm
176 //Daughters of the neutral particle of the cascade
177 Int_t daughter0 = mcPartDaughterNeutrDaugh->GetDaughter(0); // this is the positive
178 Int_t daughter1 = mcPartDaughterNeutrDaugh->GetDaughter(1); // this is the negative
180 AliAODMCParticle* mcPartNeutrDaughter0 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter0));
181 AliAODMCParticle* mcPartNeutrDaughter1 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter1));
183 if (!mcPartNeutrDaughter0 || !mcPartNeutrDaughter1) return kFALSE;
185 // getting vertex from daughters
186 mcPartNeutrDaughter0->XvYvZv(vtx2daughter0); // cm
187 mcPartNeutrDaughter1->XvYvZv(vtx2daughter1); //cm
188 if (TMath::Abs(vtx2daughter0[0] - vtx2daughter1[0])>1E-5 || TMath::Abs(vtx2daughter0[1]- vtx2daughter1[1])>1E-5 || TMath::Abs(vtx2daughter0[2] - vtx2daughter1[2])>1E-5) {
189 AliError("Daughters have different secondary vertex, skipping the track");
195 // always instantiate the AliAODRecoDecay with the positive daughter first, the negative second
196 AliAODMCParticle* positiveDaugh = mcPartNeutrDaughter0;
197 AliAODMCParticle* negativeDaugh = mcPartNeutrDaughter1;
198 if (mcPartNeutrDaughter0->GetPdgCode() < 0 && mcPartNeutrDaughter1->GetPdgCode() > 0){
199 // inverting in case the positive daughter is the second one
200 positiveDaugh = mcPartNeutrDaughter1;
201 negativeDaugh = mcPartNeutrDaughter0;
204 // getting the momentum from the daughters
205 Double_t px[2] = {positiveDaugh->Px(), negativeDaugh->Px()};
206 Double_t py[2] = {positiveDaugh->Py(), negativeDaugh->Py()};
207 Double_t pz[2] = {positiveDaugh->Pz(), negativeDaugh->Pz()};
209 Double_t d0[2] = {0.,0.};
211 AliAODRecoDecayHF* decay = new AliAODRecoDecayHF(vtx1, vtx2daughter0, nprongs, charge, px, py, pz, d0);
213 Double_t cosThetaStar = 0.;
214 Double_t cosThetaStarNeutrDaugh = 0.;
215 Double_t cosThetaStarNeutrDaughBar = 0.;
216 cosThetaStarNeutrDaugh = decay->CosThetaStar(1, fPDGneutrDaugh, fPDGneutrDaughPositive, fPDGneutrDaughNegative);
217 cosThetaStarNeutrDaughBar = decay->CosThetaStar(0, fPDGneutrDaugh, fPDGneutrDaughNegative, fPDGneutrDaughPositive);
218 if (mcPartDaughterNeutrDaugh->GetPdgCode() == fPDGneutrDaughForMC){ // neutral particle
219 AliDebug(3, Form("Neutral Daughter, with pdgprong0 = %d, pdgprong1 = %d", mcPartDaughter0->GetPdgCode(), mcPartDaughter1->GetPdgCode()));
220 cosThetaStar = cosThetaStarNeutrDaugh;
222 else if (mcPartDaughterNeutrDaugh->GetPdgCode() == -fPDGneutrDaughForMC){ // neutral particle bar
223 AliDebug(3, Form("Neutral Daughter, with pdgprong0 = %d, pdgprong1 = %d",mcPartDaughter0->GetPdgCode(),mcPartDaughter1->GetPdgCode()));
224 cosThetaStar = cosThetaStarNeutrDaughBar;
227 AliWarning(Form("There are problems!! particle was expected to be either with pdg = %d or its antiparticle with pdg = %d, while we have a %d, check...", fPDGneutrDaughForMC, -fPDGneutrDaughForMC, mcPartDaughterNeutrDaugh->GetPdgCode()));
231 if (cosThetaStar < -1 || cosThetaStar > 1) {
232 AliWarning(Form("Invalid value for cosine Theta star %f, returning", cosThetaStar));
237 Double_t vectorNeutrDaugh[2] = {0.,0.};
239 // evaluate the correct cascade
240 if (!EvaluateIfCorrectNeutrDaugh(mcPartDaughterNeutrDaugh, vectorNeutrDaugh)) {
241 AliDebug(2, "Error! the Neutral Daughter MC doesn't have correct daughters!!");
247 Double_t cT = decay->Ct(fPDGneutrDaugh);
248 // // get the pT of the daughters
249 // Double_t pTNeutrDaugh= 0.;
250 // Double_t pTBachelor = 0.;
252 // if (TMath::Abs(fmcPartCandidate->GetPdgCode()) == fPDGcascade) {
253 // pTNeutrDaugh = mcPartDaughterNeutrDaugh->Pt();
254 // pTBachelor = mcPartDaughterBachelor->Pt();
257 AliDebug(3, Form("The candidate has pt = %f, y = %f", fmcPartCandidate->Pt(), fmcPartCandidate->Y()));
259 switch (fConfiguration){
260 case AliCFTaskVertexingHF::kSnail:
261 vectorMC[0] = fmcPartCandidate->Pt();
262 vectorMC[1] = fmcPartCandidate->Y() ;
263 vectorMC[2] = cosThetaStar ;
264 vectorMC[3] = vectorNeutrDaugh[0];
265 vectorMC[4] = vectorNeutrDaugh[1];
266 vectorMC[5] = cT*1.E4 ; // in micron
267 vectorMC[6] = 0.; // dummy value, meaningless in MC
268 vectorMC[7] = -100000.; // dummy value, meaningless in MC, in micron^2
269 vectorMC[8] = 1.01; // dummy value, meaningless in MC
270 vectorMC[9] = fmcPartCandidate->Phi();
271 vectorMC[10] = fzMCVertex; // z of reconstructed of primary vertex
272 vectorMC[11] = fCentValue; // reconstructed centrality
273 vectorMC[12] = 1.; // always filling with 1 at MC level
274 vectorMC[13] = 1.01; // dummy value for cosPointingXY multiplicity
275 vectorMC[14] = 0.; // dummy value for NormalizedDecayLengthXY multiplicity
276 vectorMC[15] = fMultiplicity; // reconstructed multiplicity
278 case AliCFTaskVertexingHF::kCheetah:
279 vectorMC[0] = fmcPartCandidate->Pt();
280 vectorMC[1] = fmcPartCandidate->Y() ;
281 vectorMC[2] = cT*1.E4; // in micron
282 vectorMC[3] = fmcPartCandidate->Phi();
283 vectorMC[4] = fzMCVertex;
284 vectorMC[5] = fCentValue; // dummy value for dca, meaningless in MC
285 vectorMC[6] = 1. ; // fake: always filling with 1 at MC level
286 vectorMC[7] = fMultiplicity; // dummy value for d0pi, meaningless in MC, in micron
294 //____________________________________________
295 Bool_t AliCFVertexingHFCascade::GetRecoValuesFromCandidate(Double_t *vectorReco) const
297 // read the variables for the container
299 Bool_t bFillRecoValues = kFALSE;
301 //Get the cascade and the neutral particle from it
302 AliAODRecoCascadeHF* cascade = (AliAODRecoCascadeHF*)fRecoCandidate;
303 AliAODRecoDecay* neutrDaugh = NULL;
304 if (fPDGcascade == 413) neutrDaugh = cascade->Get2Prong();
305 else if (fPDGcascade == 4122) neutrDaugh = cascade->Getv0();
310 //if (cascade->GetPrimaryVtx())printf("cascade has primary vtx\n");
311 //if (fRecoCandidate->GetPrimaryVtx())printf("fRecoCandidateDstar has primary vtx\n");
313 Double_t pt = cascade->Pt();
314 Double_t rapidity = cascade->Y(fPDGcascade);
315 // Double_t invMass = 0.;
316 Double_t cosThetaStar = 9999.;
317 Double_t pTneutrDaughPos = 0.;
318 Double_t pTneutrDaughNeg = 0.;
319 Double_t dca = neutrDaugh->GetDCA();
320 // Double_t d0neutrDaughPos = 0.;
321 // Double_t d0neutrDaughNeg = 0.;
322 Double_t d0xd0 = neutrDaugh->Prodd0d0();
323 Double_t cosPointingAngle = neutrDaugh->CosPointingAngle(fPrimVtx);
324 Double_t phi = cascade->Phi();
325 Double_t cosPointingAngleXY = neutrDaugh->CosPointingAngleXY(fPrimVtx);
326 Double_t normDecayLengthXY = neutrDaugh->NormalizedDecayLengthXY(fPrimVtx);
328 Int_t pdgCode = fmcPartCandidate->GetPdgCode();
330 // UInt_t pdgDaughCascade[2] = { static_cast<UInt_t>(fPDGbachelor), static_cast<UInt_t>(fPDGneutrDaugh) }; // bachelor is first daughter of cascade
331 // UInt_t pdgDaughBarCascade[2] = { static_cast<UInt_t>(fPDGneutrDaugh), static_cast<UInt_t>(fPDGbachelor) }; // bachelor is second daughter in case of a cascade-bar
334 cosThetaStar = neutrDaugh->CosThetaStar(1, fPDGneutrDaugh, fPDGneutrDaughPositive, fPDGneutrDaughNegative);
335 pTneutrDaughPos = neutrDaugh->PtProng(0);
336 pTneutrDaughNeg = neutrDaugh->PtProng(1);
337 // d0neutrDaughPos = neutrDaugh->Getd0Prong(0);
338 // d0neutrDaughNeg = neutrDaugh->Getd0Prong(1);
339 // invMass = neutrDaugh->InvMass(2, pdgDaughCascade);
342 cosThetaStar = neutrDaugh->CosThetaStar(0, fPDGneutrDaugh, fPDGneutrDaughPositive, fPDGneutrDaughNegative);
343 pTneutrDaughPos = neutrDaugh->PtProng(1);
344 pTneutrDaughNeg = neutrDaugh->PtProng(0);
345 // d0neutrDaughPos = neutrDaugh->Getd0Prong(1);
346 // d0neutrDaughNeg = neutrDaugh->Getd0Prong(0);
347 // invMass = neutrDaugh->InvMass(2, pdgDaughBarCascade);
350 Double_t cT = neutrDaugh->Ct(fPDGneutrDaugh, fPrimVtx);
352 switch (fConfiguration){
353 case AliCFTaskVertexingHF::kSnail:
355 vectorReco[1] = rapidity;
356 vectorReco[2] = cosThetaStar;
357 vectorReco[3] = pTneutrDaughPos;
358 vectorReco[4] = pTneutrDaughNeg;
359 vectorReco[5] = cT*1.E4; // in micron
360 vectorReco[6] = dca*1.E4; // in micron
361 vectorReco[7] = d0xd0*1.E8; // in micron^2
362 vectorReco[8] = cosPointingAngle; // in micron
364 vectorReco[10] = fzPrimVertex; // z of reconstructed of primary vertex
365 vectorReco[11] = fCentValue;
366 vectorReco[12] = fFake; // whether the reconstructed candidate was a fake (fFake = 0) or not (fFake = 2)
367 vectorReco[13] = cosPointingAngleXY;
368 vectorReco[14] = normDecayLengthXY; // in cm
369 vectorReco[15] = fMultiplicity; // reconstructed multiplicity
371 case AliCFTaskVertexingHF::kCheetah:
373 vectorReco[1] = rapidity;
374 vectorReco[2] = cT*1.E4; // in micron
376 vectorReco[4] = fzPrimVertex;
377 vectorReco[5] = fCentValue;
378 vectorReco[6] = fFake;
379 vectorReco[7] = fMultiplicity;
383 bFillRecoValues = kTRUE;
385 return bFillRecoValues;
389 //_____________________________________________________________
390 Bool_t AliCFVertexingHFCascade::CheckMCChannelDecay() const
392 // check the required decay channel
394 Bool_t checkCD = kFALSE;
396 Int_t daughter0 = fmcPartCandidate->GetDaughter(0);
397 Int_t daughter1 = fmcPartCandidate->GetDaughter(1);
398 AliAODMCParticle* mcPartDaughter0 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter0));
399 AliAODMCParticle* mcPartDaughter1 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter1));
401 if (!mcPartDaughter0 || !mcPartDaughter1) {
402 AliDebug (2,"Problems in the MC Daughters\n");
406 if (!(TMath::Abs(mcPartDaughter0->GetPdgCode()) == fPDGneutrDaughForMC &&
407 TMath::Abs(mcPartDaughter1->GetPdgCode()) == fPDGbachelor) &&
408 !(TMath::Abs(mcPartDaughter0->GetPdgCode()) == fPDGbachelor &&
409 TMath::Abs(mcPartDaughter1->GetPdgCode()) == fPDGneutrDaughForMC)) {
410 AliDebug(2, Form("The cascade MC doesn't come from a the decay under study, skipping!! (Pdg codes of daughters = %d, %d)", mcPartDaughter0->GetPdgCode(), mcPartDaughter1->GetPdgCode()));
414 // the Neutral Particle (e.g. D0 for D*, K0S for Lc...)
415 AliAODMCParticle* mcPartDaughterNeutrDaugh = NULL;
417 // for D* the D0 (the neutral) is the first daughter, while for Lc the V0 is the second, so we check the
418 // charge of teh daughters to decide which is which
419 AliDebug(3, Form("Charge0 = %d, Charge1 = %d", mcPartDaughter0->Charge()/3, mcPartDaughter1->Charge()/3));
420 if (mcPartDaughter0->Charge()/3 != 0){
421 mcPartDaughterNeutrDaugh = mcPartDaughter1;
424 mcPartDaughterNeutrDaugh = mcPartDaughter0;
427 Double_t vectorNeutrDaugh[2] ={0., 0.};
429 // We are looking at a cascade ...evaluate the correct cascade
430 if (!EvaluateIfCorrectNeutrDaugh(mcPartDaughterNeutrDaugh, vectorNeutrDaugh)) {
431 AliDebug(2, "Error! the NeutrDaugh MC doesn't have correct daughters!!");
440 //__________________________________________
441 Bool_t AliCFVertexingHFCascade::EvaluateIfCorrectNeutrDaugh(AliAODMCParticle* neutralDaugh, Double_t* vectorNeutrDaugh)const
444 // check wether D0 is decaing into kpi
447 Bool_t isHadronic = kFALSE;
448 AliDebug(2, Form("neutralDaugh = %p, pdg = %d", neutralDaugh, neutralDaugh->GetPdgCode()));
450 if (fPDGcascade == 4122) {
451 Int_t labelresonanceDaugh = neutralDaugh->GetDaughter(0);
452 AliAODMCParticle* resonanceDaugh = dynamic_cast<AliAODMCParticle*>(fmcArray->At(labelresonanceDaugh));
453 if (!resonanceDaugh){
457 AliDebug(3, Form("The daughter of the resonant particle is a %d (we are looking for a %d)", resonanceDaugh->GetPdgCode(), fPDGneutrDaugh));
458 if (TMath::Abs(resonanceDaugh->GetPdgCode()) != fPDGneutrDaugh){
462 neutralDaugh = resonanceDaugh;
467 Int_t daughterNeutrDaugh0 = neutralDaugh->GetDaughter(0);
468 Int_t daughterNeutrDaugh1 = neutralDaugh->GetDaughter(1);
470 AliDebug(2, Form("daughter0 = %d and daughter1 = %d", daughterNeutrDaugh0, daughterNeutrDaugh1));
471 if (daughterNeutrDaugh0 == 0 || daughterNeutrDaugh1 == 0) {
472 AliDebug(2, "Error! the D0 MC doesn't have correct daughters!!");
476 Int_t numberOfExpectedDaughters = 2;
477 if (TMath::Abs(daughterNeutrDaugh1 - daughterNeutrDaugh0) != numberOfExpectedDaughters-1) { // should be everytime true - see PDGdatabooklet
478 AliDebug(2, "The D0 MC doesn't come from a 2-prong decay, skipping!!");
482 AliAODMCParticle* mcPartDaughterNeutrDaugh0 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughterNeutrDaugh0));
483 AliAODMCParticle* mcPartDaughterNeutrDaugh1 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughterNeutrDaugh1));
484 if (!mcPartDaughterNeutrDaugh0 || !mcPartDaughterNeutrDaugh1) {
485 AliWarning("D0 MC analysis: At least one Daughter Particle not found in tree, skipping");
489 AliDebug(3, Form("Daughter 0 has pdg = %d, daughter 1 has pdg = %d", mcPartDaughterNeutrDaugh0->GetPdgCode(), mcPartDaughterNeutrDaugh1->GetPdgCode()));
490 if (!(TMath::Abs(mcPartDaughterNeutrDaugh0->GetPdgCode()) == fPDGneutrDaughPositive &&
491 TMath::Abs(mcPartDaughterNeutrDaugh1->GetPdgCode()) == fPDGneutrDaughNegative) &&
492 !(TMath::Abs(mcPartDaughterNeutrDaugh0->GetPdgCode()) == fPDGneutrDaughNegative &&
493 TMath::Abs(mcPartDaughterNeutrDaugh1->GetPdgCode()) == fPDGneutrDaughPositive)) {
494 AliDebug(2, "The neutral particle (MC) doesn't come from the required decay, skipping!!");
498 Double_t sumPxDau = mcPartDaughterNeutrDaugh0->Px()+mcPartDaughterNeutrDaugh1->Px();
499 Double_t sumPyDau = mcPartDaughterNeutrDaugh0->Py()+mcPartDaughterNeutrDaugh1->Py();
500 Double_t sumPzDau = mcPartDaughterNeutrDaugh0->Pz()+mcPartDaughterNeutrDaugh1->Pz();
501 Double_t pxMother = neutralDaugh->Px();
502 Double_t pyMother = neutralDaugh->Py();
503 Double_t pzMother = neutralDaugh->Pz();
504 AliDebug(3, Form("pxMother = %f, pyMother = %f, pzMother = %f", pxMother, pyMother, pzMother));
505 AliDebug(3, Form("sumPxDau = %f, sumPyDau = %f, sumPzDau = %f", sumPxDau, sumPyDau, sumPzDau));
506 if(TMath::Abs(pxMother-sumPxDau)/(TMath::Abs(pxMother)+1.e-13)>fCutOnMomConservation ||
507 TMath::Abs(pyMother-sumPyDau)/(TMath::Abs(pyMother)+1.e-13)>fCutOnMomConservation ||
508 TMath::Abs(pzMother-sumPzDau)/(TMath::Abs(pzMother)+1.e-13)>fCutOnMomConservation){
509 AliDebug(2, "Momentum conservation violated, skipping!!");
513 Double_t pTNeutrDaughPositive = 0;
514 Double_t pTNeutrDaughNegative = 0;
516 if (mcPartDaughterNeutrDaugh0->GetPdgCode() > 0 ) {
517 pTNeutrDaughPositive = mcPartDaughterNeutrDaugh0->Pt();
518 pTNeutrDaughNegative = mcPartDaughterNeutrDaugh1->Pt();
521 pTNeutrDaughPositive = mcPartDaughterNeutrDaugh1->Pt();
522 pTNeutrDaughNegative = mcPartDaughterNeutrDaugh0->Pt();
527 vectorNeutrDaugh[0] = pTNeutrDaughPositive;
528 vectorNeutrDaugh[1] = pTNeutrDaughNegative;
534 //___________________________________________________________
536 void AliCFVertexingHFCascade::SetPtAccCut(Float_t* ptAccCut)
539 // setting the pt cut to be used in the Acceptance steps (MC+Reco)
542 AliDebug(3, "The 3rd element of the pt cut array will correspond to the cut applied to the soft pion - please check that it is correct");
544 for (Int_t iP=0; iP<fProngs; iP++){
545 fPtAccCut[iP]=ptAccCut[iP];
553 //___________________________________________________________
555 void AliCFVertexingHFCascade::SetEtaAccCut(Float_t* etaAccCut)
558 // setting the eta cut to be used in the Acceptance steps (MC+Reco)
561 AliDebug(3, "The 3rd element of the eta cut array will correspond to the cut applied to the soft pion - please check that it is correct");
563 for (Int_t iP=0; iP<fProngs; iP++){
564 fEtaAccCut[iP] = etaAccCut[iP];
569 //___________________________________________________________
571 void AliCFVertexingHFCascade::SetAccCut(Float_t* ptAccCut, Float_t* etaAccCut)
574 // setting the pt and eta cut to be used in the Acceptance steps (MC+Reco)
577 AliDebug(3, "The 3rd element of the pt and cut array will correspond to the cut applied to the soft pion - please check that they are correct");
579 for (Int_t iP=0; iP<fProngs; iP++){
580 fPtAccCut[iP]=ptAccCut[iP];
581 fEtaAccCut[iP]=etaAccCut[iP];
587 //___________________________________________________________
589 void AliCFVertexingHFCascade::SetAccCut()
592 // setting the pt and eta cut to be used in the Acceptance steps (MC+Reco)
595 Int_t bachelorPosition = 2;
596 if (fPDGcascade == 4122) bachelorPosition = 0;
597 AliAODMCParticle* mcPartDaughter = dynamic_cast<AliAODMCParticle*>(fmcArray->At(fLabelArray[bachelorPosition])); // should be the soft pion...
598 if(!mcPartDaughter) return;
599 Int_t mother = mcPartDaughter->GetMother();
600 AliAODMCParticle* mcMother = dynamic_cast<AliAODMCParticle*>(fmcArray->At(mother));
601 if(!mcMother) return;
603 if (TMath::Abs(mcPartDaughter->GetPdgCode()) != fPDGbachelor || TMath::Abs(mcMother->GetPdgCode()) != fPDGcascade){
604 AliFatal("Apparently the soft pion is not in the third position, causing a crash!!");
607 for (Int_t iP=0; iP<fProngs-1; iP++){
612 if (fPDGcascade != 4122){
613 fPtAccCut[2]=0.06; // soft pion
614 fEtaAccCut[2]=0.9; // soft pion
620 //_____________________________________________________________
621 Double_t AliCFVertexingHFCascade::GetEtaProng(Int_t iProng) const
624 // getting eta of the prong - overload the mother class method
629 AliAODRecoCascadeHF* cascade = (AliAODRecoCascadeHF*)fRecoCandidate;
631 Double_t etaProng =-9999;
632 AliAODRecoDecay* neutrDaugh=0;
633 if (fPDGcascade == 413) neutrDaugh = cascade->Get2Prong();
634 else if (fPDGcascade == 4122) neutrDaugh = cascade->Getv0();
635 if (iProng==0) etaProng = neutrDaugh->EtaProng(0);
636 if (iProng==1) etaProng = neutrDaugh->EtaProng(1);
637 if (iProng==2) etaProng = cascade->EtaProng(1);
644 //_____________________________________________________________
645 Double_t AliCFVertexingHFCascade::GetPtProng(Int_t iProng) const
648 // getting pt of the prong
653 AliAODRecoCascadeHF* cascade = (AliAODRecoCascadeHF*)fRecoCandidate;
654 Double_t ptProng= -9999;
655 AliAODRecoDecay* neutrDaugh=0;
656 if (fPDGcascade == 413) neutrDaugh = cascade->Get2Prong();
657 else if (fPDGcascade == 4122) neutrDaugh = cascade->Getv0();
658 if (iProng == 0) ptProng = neutrDaugh->PtProng(0);
659 if (iProng == 1) ptProng = neutrDaugh->PtProng(1);
660 if (iProng == 2) ptProng = cascade->PtProng(1);
662 // Double_t ptProng = fRecoCandidate->PtProng(iProng);
669 //_____________________________________________________________
670 Bool_t AliCFVertexingHFCascade::CheckAdditionalCuts(AliPIDResponse* pidResponse) const {
672 // function to check whether the candidate passes the additional cuts defined in the task to get the
673 // invariant mass spectra; these cuts are NOT pt-dependent
675 if (fPDGcascade == 4122){
676 // the method is implemented only in this case so far
677 AliAODRecoCascadeHF* cascade = (AliAODRecoCascadeHF*)fRecoCandidate;
678 AliAODv0 * v0part = cascade->Getv0();
679 AliAODTrack *bachelor = (AliAODTrack*)cascade->GetBachelor();
681 Bool_t onFlyV0 = v0part->GetOnFlyStatus(); // on-the-flight V0s
682 Double_t nSigmaTPCpr=-999.;
683 Double_t nSigmaTOFpr=-999.;
684 nSigmaTPCpr = pidResponse->NumberOfSigmasTPC(bachelor,(AliPID::kProton));
685 nSigmaTOFpr = pidResponse->NumberOfSigmasTOF(bachelor,(AliPID::kProton));
686 Double_t ptArm = v0part->PtArmV0();
687 Double_t invmassK0s = v0part->MassK0Short();
688 Double_t mK0SPDG = TDatabasePDG::Instance()->GetParticle(310)->Mass();
690 Bool_t cutsForTMVA = ((nSigmaTOFpr > -800) && (nSigmaTOFpr < 3)) &&
691 ((ptArm > 0.07) && (ptArm < 0.105)) &&
692 ((TMath::Abs(invmassK0s - mK0SPDG)) < 0.01);
694 if (!fUseCutsForTMVA) cutsForTMVA = kTRUE;
696 Bool_t cutsForInvMassTask = !(onFlyV0) &&
697 (cascade->CosV0PointingAngle()>0.99) &&
698 (TMath::Abs(nSigmaTPCpr) <= 3) &&
699 (v0part->Getd0Prong(0) < 20) &&
700 (v0part->Getd0Prong(1) < 20);
702 if (cutsForTMVA && cutsForInvMassTask) {