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)
52 // standard constructor
55 fPtAccCut = new Float_t[fProngs];
56 fEtaAccCut = new Float_t[fProngs];
57 // element 0 in the cut arrays corresponds to the soft pion!!!!!!!! Careful when setting the values...
60 for(Int_t iP=1; iP<fProngs; iP++){
68 //_____________________________________
69 AliCFVertexingHFCascade& AliCFVertexingHFCascade::operator=(const AliCFVertexingHFCascade& c)
75 AliCFVertexingHF::operator=(c);
81 //__________________________________________
82 Bool_t AliCFVertexingHFCascade::SetRecoCandidateParam(AliAODRecoDecayHF *recoCand)
84 // set the AliAODRecoDecay candidate
86 Bool_t bSignAssoc = kFALSE;
88 fRecoCandidate = recoCand;
89 AliAODRecoCascadeHF* cascade = (AliAODRecoCascadeHF*)recoCand;
91 if (!fRecoCandidate) {
92 AliError("fRecoCandidate not found, problem in assignement\n");
96 if ( fRecoCandidate->GetPrimaryVtx()) AliDebug(3,"fReco Candidate has a pointer to PrimVtx\n");
98 //Int_t pdgCand = 413;
100 Int_t pdgDgCascade[2] = {fPDGneutrDaugh, fPDGbachelor};
101 Int_t pdgDgNeutrDaugh[2] = {fPDGneutrDaughPositive, fPDGneutrDaughNegative};
103 Int_t nentries = fmcArray->GetEntriesFast();
105 AliDebug(3,Form("nentries = %d\n", nentries));
107 Bool_t isV0 = kFALSE;
108 if (fPDGcascade == 4122) {
110 pdgDgCascade[0] = fPDGbachelor;
111 pdgDgCascade[1] = fPDGneutrDaugh;
113 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));
114 Int_t mcLabel = cascade->MatchToMC(fPDGcascade, fPDGneutrDaugh, pdgDgCascade, pdgDgNeutrDaugh, fmcArray, isV0);
116 if (mcLabel == -1) return bSignAssoc;
118 if (fRecoCandidate->NumberOfFakeDaughters()>0){
119 fFake = 0; // fake candidate
120 if (fFakeSelection == 1) return bSignAssoc;
122 if (fRecoCandidate->NumberOfFakeDaughters()==0){
123 fFake = 2; // non-fake candidate
124 if (fFakeSelection == 2) return bSignAssoc;
128 fmcPartCandidate = dynamic_cast<AliAODMCParticle*>(fmcArray->At(fmcLabel));
130 if (!fmcPartCandidate){
131 AliDebug(3,"No part candidate");
139 //______________________________________________
140 Bool_t AliCFVertexingHFCascade::GetGeneratedValuesFromMCParticle(Double_t* vectorMC)
143 // collecting all the necessary info (pt, y, cosThetaStar, ptPi, ptKa, cT) from MC particle
146 Bool_t bGenValues = kFALSE;
148 Int_t daughter0cascade = fmcPartCandidate->GetDaughter(0);
149 Int_t daughter1cascade = fmcPartCandidate->GetDaughter(1);
151 AliAODMCParticle* mcPartDaughter0 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter0cascade));
152 AliAODMCParticle* mcPartDaughter1 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter1cascade));
153 AliAODMCParticle* mcPartDaughterNeutrDaugh = NULL;
154 AliAODMCParticle* mcPartDaughterBachelor = NULL;
156 // the Neutral Particle (e.g. D0 for D*, K0S for Lc...)
157 // for D* the D0 (the neutral) is the first daughter, while for Lc the V0 is the second, so we check the
158 // charge of the daughters to decide which is which
159 if (mcPartDaughter0->Charge()/3 == 0){
160 mcPartDaughterNeutrDaugh = mcPartDaughter0;
161 mcPartDaughterBachelor = mcPartDaughter1;
164 mcPartDaughterNeutrDaugh = mcPartDaughter1;
165 mcPartDaughterBachelor = mcPartDaughter0;
168 if (!mcPartDaughterNeutrDaugh || !mcPartDaughterBachelor) return kFALSE;
170 Double_t vtx1[3] = {0,0,0}; // primary vertex
171 Double_t vtx2daughter0[3] = {0,0,0}; // secondary vertex from daughter 0
172 Double_t vtx2daughter1[3] = {0,0,0}; // secondary vertex from daughter 1
173 fmcPartCandidate->XvYvZv(vtx1); // cm
175 //Daughters of the neutral particle of the cascade
176 Int_t daughter0 = mcPartDaughterNeutrDaugh->GetDaughter(0); // this is the positive
177 Int_t daughter1 = mcPartDaughterNeutrDaugh->GetDaughter(1); // this is the negative
179 AliAODMCParticle* mcPartNeutrDaughter0 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter0));
180 AliAODMCParticle* mcPartNeutrDaughter1 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter1));
182 if (!mcPartNeutrDaughter0 || !mcPartNeutrDaughter1) return kFALSE;
184 // getting vertex from daughters
185 mcPartNeutrDaughter0->XvYvZv(vtx2daughter0); // cm
186 mcPartNeutrDaughter1->XvYvZv(vtx2daughter1); //cm
187 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) {
188 AliError("Daughters have different secondary vertex, skipping the track");
194 // always instantiate the AliAODRecoDecay with the positive daughter first, the negative second
195 AliAODMCParticle* positiveDaugh = mcPartNeutrDaughter0;
196 AliAODMCParticle* negativeDaugh = mcPartNeutrDaughter1;
197 if (mcPartNeutrDaughter0->GetPdgCode() < 0 && mcPartNeutrDaughter1->GetPdgCode() > 0){
198 // inverting in case the positive daughter is the second one
199 positiveDaugh = mcPartNeutrDaughter1;
200 negativeDaugh = mcPartNeutrDaughter0;
203 // getting the momentum from the daughters
204 Double_t px[2] = {positiveDaugh->Px(), negativeDaugh->Px()};
205 Double_t py[2] = {positiveDaugh->Py(), negativeDaugh->Py()};
206 Double_t pz[2] = {positiveDaugh->Pz(), negativeDaugh->Pz()};
208 Double_t d0[2] = {0.,0.};
210 AliAODRecoDecayHF* decay = new AliAODRecoDecayHF(vtx1, vtx2daughter0, nprongs, charge, px, py, pz, d0);
212 Double_t cosThetaStar = 0.;
213 Double_t cosThetaStarNeutrDaugh = 0.;
214 Double_t cosThetaStarNeutrDaughBar = 0.;
215 cosThetaStarNeutrDaugh = decay->CosThetaStar(1, fPDGneutrDaugh, fPDGneutrDaughPositive, fPDGneutrDaughNegative);
216 cosThetaStarNeutrDaughBar = decay->CosThetaStar(0, fPDGneutrDaugh, fPDGneutrDaughNegative, fPDGneutrDaughPositive);
217 if (mcPartDaughterNeutrDaugh->GetPdgCode() == fPDGneutrDaughForMC){ // neutral particle
218 AliDebug(3, Form("Neutral Daughter, with pdgprong0 = %d, pdgprong1 = %d", mcPartDaughter0->GetPdgCode(), mcPartDaughter1->GetPdgCode()));
219 cosThetaStar = cosThetaStarNeutrDaugh;
221 else if (mcPartDaughterNeutrDaugh->GetPdgCode() == -fPDGneutrDaughForMC){ // neutral particle bar
222 AliDebug(3, Form("Neutral Daughter, with pdgprong0 = %d, pdgprong1 = %d",mcPartDaughter0->GetPdgCode(),mcPartDaughter1->GetPdgCode()));
223 cosThetaStar = cosThetaStarNeutrDaughBar;
226 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()));
230 if (cosThetaStar < -1 || cosThetaStar > 1) {
231 AliWarning(Form("Invalid value for cosine Theta star %f, returning", cosThetaStar));
236 Double_t vectorNeutrDaugh[2] = {0.,0.};
238 // evaluate the correct cascade
239 if (!EvaluateIfCorrectNeutrDaugh(mcPartDaughterNeutrDaugh, vectorNeutrDaugh)) {
240 AliDebug(2, "Error! the Neutral Daughter MC doesn't have correct daughters!!");
246 Double_t cT = decay->Ct(fPDGneutrDaugh);
247 // // get the pT of the daughters
248 // Double_t pTNeutrDaugh= 0.;
249 // Double_t pTBachelor = 0.;
251 // if (TMath::Abs(fmcPartCandidate->GetPdgCode()) == fPDGcascade) {
252 // pTNeutrDaugh = mcPartDaughterNeutrDaugh->Pt();
253 // pTBachelor = mcPartDaughterBachelor->Pt();
256 AliDebug(3, Form("The candidate has pt = %f, y = %f", fmcPartCandidate->Pt(), fmcPartCandidate->Y()));
258 switch (fConfiguration){
259 case AliCFTaskVertexingHF::kSnail:
260 vectorMC[0] = fmcPartCandidate->Pt();
261 vectorMC[1] = fmcPartCandidate->Y() ;
262 vectorMC[2] = cosThetaStar ;
263 vectorMC[3] = vectorNeutrDaugh[0];
264 vectorMC[4] = vectorNeutrDaugh[1];
265 vectorMC[5] = cT*1.E4 ; // in micron
266 vectorMC[6] = 0.; // dummy value, meaningless in MC
267 vectorMC[7] = -100000.; // dummy value, meaningless in MC, in micron^2
268 vectorMC[8] = 1.01; // dummy value, meaningless in MC
269 vectorMC[9] = fmcPartCandidate->Phi();
270 vectorMC[10] = fzMCVertex; // z of reconstructed of primary vertex
271 vectorMC[11] = fCentValue; // reconstructed centrality
272 vectorMC[12] = 1.; // always filling with 1 at MC level
273 vectorMC[13] = 1.01; // dummy value for cosPointingXY multiplicity
274 vectorMC[14] = 0.; // dummy value for NormalizedDecayLengthXY multiplicity
275 vectorMC[15] = fMultiplicity; // reconstructed multiplicity
277 case AliCFTaskVertexingHF::kCheetah:
278 vectorMC[0] = fmcPartCandidate->Pt();
279 vectorMC[1] = fmcPartCandidate->Y() ;
280 vectorMC[2] = cT*1.E4; // in micron
281 vectorMC[3] = fmcPartCandidate->Phi();
282 vectorMC[4] = fzMCVertex;
283 vectorMC[5] = fCentValue; // dummy value for dca, meaningless in MC
284 vectorMC[6] = 1. ; // fake: always filling with 1 at MC level
285 vectorMC[7] = fMultiplicity; // dummy value for d0pi, meaningless in MC, in micron
293 //____________________________________________
294 Bool_t AliCFVertexingHFCascade::GetRecoValuesFromCandidate(Double_t *vectorReco) const
296 // read the variables for the container
298 Bool_t bFillRecoValues = kFALSE;
300 //Get the cascade and the neutral particle from it
301 AliAODRecoCascadeHF* cascade = (AliAODRecoCascadeHF*)fRecoCandidate;
302 AliAODRecoDecay* neutrDaugh = NULL;
303 if (fPDGcascade == 413) neutrDaugh = cascade->Get2Prong();
304 else if (fPDGcascade == 4122) neutrDaugh = cascade->Getv0();
309 //if (cascade->GetPrimaryVtx())printf("cascade has primary vtx\n");
310 //if (fRecoCandidate->GetPrimaryVtx())printf("fRecoCandidateDstar has primary vtx\n");
312 Double_t pt = cascade->Pt();
313 Double_t rapidity = cascade->Y(fPDGcascade);
314 // Double_t invMass = 0.;
315 Double_t cosThetaStar = 9999.;
316 Double_t pTneutrDaughPos = 0.;
317 Double_t pTneutrDaughNeg = 0.;
318 Double_t dca = neutrDaugh->GetDCA();
319 // Double_t d0neutrDaughPos = 0.;
320 // Double_t d0neutrDaughNeg = 0.;
321 Double_t d0xd0 = neutrDaugh->Prodd0d0();
322 Double_t cosPointingAngle = neutrDaugh->CosPointingAngle(fPrimVtx);
323 Double_t phi = cascade->Phi();
324 Double_t cosPointingAngleXY = neutrDaugh->CosPointingAngleXY(fPrimVtx);
325 Double_t normDecayLengthXY = neutrDaugh->NormalizedDecayLengthXY(fPrimVtx);
327 Int_t pdgCode = fmcPartCandidate->GetPdgCode();
329 // UInt_t pdgDaughCascade[2] = { static_cast<UInt_t>(fPDGbachelor), static_cast<UInt_t>(fPDGneutrDaugh) }; // bachelor is first daughter of cascade
330 // UInt_t pdgDaughBarCascade[2] = { static_cast<UInt_t>(fPDGneutrDaugh), static_cast<UInt_t>(fPDGbachelor) }; // bachelor is second daughter in case of a cascade-bar
333 cosThetaStar = neutrDaugh->CosThetaStar(1, fPDGneutrDaugh, fPDGneutrDaughPositive, fPDGneutrDaughNegative);
334 pTneutrDaughPos = neutrDaugh->PtProng(0);
335 pTneutrDaughNeg = neutrDaugh->PtProng(1);
336 // d0neutrDaughPos = neutrDaugh->Getd0Prong(0);
337 // d0neutrDaughNeg = neutrDaugh->Getd0Prong(1);
338 // invMass = neutrDaugh->InvMass(2, pdgDaughCascade);
341 cosThetaStar = neutrDaugh->CosThetaStar(0, fPDGneutrDaugh, fPDGneutrDaughPositive, fPDGneutrDaughNegative);
342 pTneutrDaughPos = neutrDaugh->PtProng(1);
343 pTneutrDaughNeg = neutrDaugh->PtProng(0);
344 // d0neutrDaughPos = neutrDaugh->Getd0Prong(1);
345 // d0neutrDaughNeg = neutrDaugh->Getd0Prong(0);
346 // invMass = neutrDaugh->InvMass(2, pdgDaughBarCascade);
349 Double_t cT = neutrDaugh->Ct(fPDGneutrDaugh, fPrimVtx);
351 switch (fConfiguration){
352 case AliCFTaskVertexingHF::kSnail:
354 vectorReco[1] = rapidity;
355 vectorReco[2] = cosThetaStar;
356 vectorReco[3] = pTneutrDaughPos;
357 vectorReco[4] = pTneutrDaughNeg;
358 vectorReco[5] = cT*1.E4; // in micron
359 vectorReco[6] = dca*1.E4; // in micron
360 vectorReco[7] = d0xd0*1.E8; // in micron^2
361 vectorReco[8] = cosPointingAngle; // in micron
363 vectorReco[10] = fzPrimVertex; // z of reconstructed of primary vertex
364 vectorReco[11] = fCentValue;
365 vectorReco[12] = fFake; // whether the reconstructed candidate was a fake (fFake = 0) or not (fFake = 2)
366 vectorReco[13] = cosPointingAngleXY;
367 vectorReco[14] = normDecayLengthXY; // in cm
368 vectorReco[15] = fMultiplicity; // reconstructed multiplicity
370 case AliCFTaskVertexingHF::kCheetah:
372 vectorReco[1] = rapidity;
373 vectorReco[2] = cT*1.E4; // in micron
375 vectorReco[4] = fzPrimVertex;
376 vectorReco[5] = fCentValue;
377 vectorReco[6] = fFake;
378 vectorReco[7] = fMultiplicity;
382 bFillRecoValues = kTRUE;
384 return bFillRecoValues;
388 //_____________________________________________________________
389 Bool_t AliCFVertexingHFCascade::CheckMCChannelDecay() const
391 // check the required decay channel
393 Bool_t checkCD = kFALSE;
395 Int_t daughter0 = fmcPartCandidate->GetDaughter(0);
396 Int_t daughter1 = fmcPartCandidate->GetDaughter(1);
397 AliAODMCParticle* mcPartDaughter0 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter0));
398 AliAODMCParticle* mcPartDaughter1 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter1));
400 if (!mcPartDaughter0 || !mcPartDaughter1) {
401 AliDebug (2,"Problems in the MC Daughters\n");
405 if (!(TMath::Abs(mcPartDaughter0->GetPdgCode()) == fPDGneutrDaughForMC &&
406 TMath::Abs(mcPartDaughter1->GetPdgCode()) == fPDGbachelor) &&
407 !(TMath::Abs(mcPartDaughter0->GetPdgCode()) == fPDGbachelor &&
408 TMath::Abs(mcPartDaughter1->GetPdgCode()) == fPDGneutrDaughForMC)) {
409 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()));
413 // the Neutral Particle (e.g. D0 for D*, K0S for Lc...)
414 AliAODMCParticle* mcPartDaughterNeutrDaugh = NULL;
416 // for D* the D0 (the neutral) is the first daughter, while for Lc the V0 is the second, so we check the
417 // charge of teh daughters to decide which is which
418 AliDebug(3, Form("Charge0 = %d, Charge1 = %d", mcPartDaughter0->Charge()/3, mcPartDaughter1->Charge()/3));
419 if (mcPartDaughter0->Charge()/3 != 0){
420 mcPartDaughterNeutrDaugh = mcPartDaughter1;
423 mcPartDaughterNeutrDaugh = mcPartDaughter0;
426 Double_t vectorNeutrDaugh[2] ={0., 0.};
428 // We are looking at a cascade ...evaluate the correct cascade
429 if (!EvaluateIfCorrectNeutrDaugh(mcPartDaughterNeutrDaugh, vectorNeutrDaugh)) {
430 AliDebug(2, "Error! the NeutrDaugh MC doesn't have correct daughters!!");
439 //__________________________________________
440 Bool_t AliCFVertexingHFCascade::EvaluateIfCorrectNeutrDaugh(AliAODMCParticle* neutralDaugh, Double_t* vectorNeutrDaugh)const
443 // check wether D0 is decaing into kpi
446 Bool_t isHadronic = kFALSE;
447 AliDebug(2, Form("neutralDaugh = %p, pdg = %d", neutralDaugh, neutralDaugh->GetPdgCode()));
449 if (fPDGcascade == 4122) {
450 Int_t labelresonanceDaugh = neutralDaugh->GetDaughter(0);
451 AliAODMCParticle* resonanceDaugh = dynamic_cast<AliAODMCParticle*>(fmcArray->At(labelresonanceDaugh));
452 if (!resonanceDaugh){
456 AliDebug(3, Form("The daughter of the resonant particle is a %d (we are looking for a %d)", resonanceDaugh->GetPdgCode(), fPDGneutrDaugh));
457 if (TMath::Abs(resonanceDaugh->GetPdgCode()) != fPDGneutrDaugh){
461 neutralDaugh = resonanceDaugh;
466 Int_t daughterNeutrDaugh0 = neutralDaugh->GetDaughter(0);
467 Int_t daughterNeutrDaugh1 = neutralDaugh->GetDaughter(1);
469 AliDebug(2, Form("daughter0 = %d and daughter1 = %d", daughterNeutrDaugh0, daughterNeutrDaugh1));
470 if (daughterNeutrDaugh0 == 0 || daughterNeutrDaugh1 == 0) {
471 AliDebug(2, "Error! the D0 MC doesn't have correct daughters!!");
475 Int_t numberOfExpectedDaughters = 2;
476 if (TMath::Abs(daughterNeutrDaugh1 - daughterNeutrDaugh0) != numberOfExpectedDaughters-1) { // should be everytime true - see PDGdatabooklet
477 AliDebug(2, "The D0 MC doesn't come from a 2-prong decay, skipping!!");
481 AliAODMCParticle* mcPartDaughterNeutrDaugh0 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughterNeutrDaugh0));
482 AliAODMCParticle* mcPartDaughterNeutrDaugh1 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughterNeutrDaugh1));
483 if (!mcPartDaughterNeutrDaugh0 || !mcPartDaughterNeutrDaugh1) {
484 AliWarning("D0 MC analysis: At least one Daughter Particle not found in tree, skipping");
488 AliDebug(3, Form("Daughter 0 has pdg = %d, daughter 1 has pdg = %d", mcPartDaughterNeutrDaugh0->GetPdgCode(), mcPartDaughterNeutrDaugh1->GetPdgCode()));
489 if (!(TMath::Abs(mcPartDaughterNeutrDaugh0->GetPdgCode()) == fPDGneutrDaughPositive &&
490 TMath::Abs(mcPartDaughterNeutrDaugh1->GetPdgCode()) == fPDGneutrDaughNegative) &&
491 !(TMath::Abs(mcPartDaughterNeutrDaugh0->GetPdgCode()) == fPDGneutrDaughNegative &&
492 TMath::Abs(mcPartDaughterNeutrDaugh1->GetPdgCode()) == fPDGneutrDaughPositive)) {
493 AliDebug(2, "The neutral particle (MC) doesn't come from the required decay, skipping!!");
497 Double_t sumPxDau = mcPartDaughterNeutrDaugh0->Px()+mcPartDaughterNeutrDaugh1->Px();
498 Double_t sumPyDau = mcPartDaughterNeutrDaugh0->Py()+mcPartDaughterNeutrDaugh1->Py();
499 Double_t sumPzDau = mcPartDaughterNeutrDaugh0->Pz()+mcPartDaughterNeutrDaugh1->Pz();
500 Double_t pxMother = neutralDaugh->Px();
501 Double_t pyMother = neutralDaugh->Py();
502 Double_t pzMother = neutralDaugh->Pz();
503 AliDebug(3, Form("pxMother = %f, pyMother = %f, pzMother = %f", pxMother, pyMother, pzMother));
504 AliDebug(3, Form("sumPxDau = %f, sumPyDau = %f, sumPzDau = %f", sumPxDau, sumPyDau, sumPzDau));
505 if(TMath::Abs(pxMother-sumPxDau)/(TMath::Abs(pxMother)+1.e-13)>0.00001 ||
506 TMath::Abs(pyMother-sumPyDau)/(TMath::Abs(pyMother)+1.e-13)>0.00001 ||
507 TMath::Abs(pzMother-sumPzDau)/(TMath::Abs(pzMother)+1.e-13)>0.00001){
508 AliDebug(2, "Momentum conservation violated, skipping!!");
512 Double_t pTNeutrDaughPositive = 0;
513 Double_t pTNeutrDaughNegative = 0;
515 if (mcPartDaughterNeutrDaugh0->GetPdgCode() > 0 ) {
516 pTNeutrDaughPositive = mcPartDaughterNeutrDaugh0->Pt();
517 pTNeutrDaughNegative = mcPartDaughterNeutrDaugh1->Pt();
520 pTNeutrDaughPositive = mcPartDaughterNeutrDaugh1->Pt();
521 pTNeutrDaughNegative = mcPartDaughterNeutrDaugh0->Pt();
526 vectorNeutrDaugh[0] = pTNeutrDaughPositive;
527 vectorNeutrDaugh[1] = pTNeutrDaughNegative;
533 //___________________________________________________________
535 void AliCFVertexingHFCascade::SetPtAccCut(Float_t* ptAccCut)
538 // setting the pt cut to be used in the Acceptance steps (MC+Reco)
541 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");
543 for (Int_t iP=0; iP<fProngs; iP++){
544 fPtAccCut[iP]=ptAccCut[iP];
552 //___________________________________________________________
554 void AliCFVertexingHFCascade::SetEtaAccCut(Float_t* etaAccCut)
557 // setting the eta cut to be used in the Acceptance steps (MC+Reco)
560 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");
562 for (Int_t iP=0; iP<fProngs; iP++){
563 fEtaAccCut[iP] = etaAccCut[iP];
568 //___________________________________________________________
570 void AliCFVertexingHFCascade::SetAccCut(Float_t* ptAccCut, Float_t* etaAccCut)
573 // setting the pt and eta cut to be used in the Acceptance steps (MC+Reco)
576 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");
578 for (Int_t iP=0; iP<fProngs; iP++){
579 fPtAccCut[iP]=ptAccCut[iP];
580 fEtaAccCut[iP]=etaAccCut[iP];
586 //___________________________________________________________
588 void AliCFVertexingHFCascade::SetAccCut()
591 // setting the pt and eta cut to be used in the Acceptance steps (MC+Reco)
594 Int_t bachelorPosition = 2;
595 if (fPDGcascade == 4122) bachelorPosition = 0;
596 AliAODMCParticle* mcPartDaughter = dynamic_cast<AliAODMCParticle*>(fmcArray->At(fLabelArray[bachelorPosition])); // should be the soft pion...
597 if(!mcPartDaughter) return;
598 Int_t mother = mcPartDaughter->GetMother();
599 AliAODMCParticle* mcMother = dynamic_cast<AliAODMCParticle*>(fmcArray->At(mother));
600 if(!mcMother) return;
602 if (TMath::Abs(mcPartDaughter->GetPdgCode()) != fPDGbachelor || TMath::Abs(mcMother->GetPdgCode()) != fPDGcascade){
603 AliFatal("Apparently the soft pion is not in the third position, causing a crash!!");
606 for (Int_t iP=0; iP<fProngs-1; iP++){
610 fPtAccCut[2]=0.06; // soft pion
611 fEtaAccCut[2]=0.9; // soft pion
616 //_____________________________________________________________
617 Double_t AliCFVertexingHFCascade::GetEtaProng(Int_t iProng) const
620 // getting eta of the prong - overload the mother class method
625 AliAODRecoCascadeHF* cascade = (AliAODRecoCascadeHF*)fRecoCandidate;
627 Double_t etaProng =-9999;
628 AliAODRecoDecay* neutrDaugh=0;
629 if (fPDGcascade == 413) neutrDaugh = cascade->Get2Prong();
630 else if (fPDGcascade == 4122) neutrDaugh = cascade->Getv0();
631 if (iProng==0) etaProng = neutrDaugh->EtaProng(0);
632 if (iProng==1) etaProng = neutrDaugh->EtaProng(1);
633 if (iProng==2) etaProng = cascade->EtaProng(1);
640 //_____________________________________________________________
641 Double_t AliCFVertexingHFCascade::GetPtProng(Int_t iProng) const
644 // getting pt of the prong
649 AliAODRecoCascadeHF* cascade = (AliAODRecoCascadeHF*)fRecoCandidate;
650 Double_t ptProng= -9999;
651 AliAODRecoDecay* neutrDaugh=0;
652 if (fPDGcascade == 413) neutrDaugh = cascade->Get2Prong();
653 else if (fPDGcascade == 4122) neutrDaugh = cascade->Getv0();
654 if (iProng == 0) ptProng = neutrDaugh->PtProng(0);
655 if (iProng == 1) ptProng = neutrDaugh->PtProng(1);
656 if (iProng == 2) ptProng = cascade->PtProng(1);
658 // Double_t ptProng = fRecoCandidate->PtProng(iProng);
665 //_____________________________________________________________
666 Bool_t AliCFVertexingHFCascade::CheckAdditionalCuts(AliPIDResponse* pidResponse) const {
668 // function to check whether the candidate passes the additional cuts defined in the task to get the
669 // invariant mass spectra; these cuts are NOT pt-dependent
671 if (fPDGcascade == 4122){
672 // the method is implemented only in this case so far
673 AliAODRecoCascadeHF* cascade = (AliAODRecoCascadeHF*)fRecoCandidate;
674 AliAODv0 * v0part = cascade->Getv0();
675 AliAODTrack *bachelor = (AliAODTrack*)cascade->GetBachelor();
677 Bool_t onFlyV0 = v0part->GetOnFlyStatus(); // on-the-flight V0s
678 Double_t nSigmaTPCpr=-999.;
679 Double_t nSigmaTOFpr=-999.;
680 nSigmaTPCpr = pidResponse->NumberOfSigmasTPC(bachelor,(AliPID::kProton));
681 nSigmaTOFpr = pidResponse->NumberOfSigmasTOF(bachelor,(AliPID::kProton));
682 Double_t ptArm = v0part->PtArmV0();
683 Double_t invmassK0s = v0part->MassK0Short();
684 Double_t mK0SPDG = TDatabasePDG::Instance()->GetParticle(310)->Mass();
686 Bool_t cutsForTMVA = ((nSigmaTOFpr > -800) && (nSigmaTOFpr < 3)) &&
687 ((ptArm > 0.07) && (ptArm < 0.105)) &&
688 ((TMath::Abs(invmassK0s - mK0SPDG)) < 0.01);
690 if (!fUseCutsForTMVA) cutsForTMVA = kTRUE;
692 Bool_t cutsForInvMassTask = !(onFlyV0) &&
693 (cascade->CosV0PointingAngle()>0.99) &&
694 (TMath::Abs(nSigmaTPCpr) <= 3) &&
695 (v0part->Getd0Prong(0) < 20) &&
696 (v0part->Getd0Prong(1) < 20);
698 if (cutsForTMVA && cutsForInvMassTask) {