24 #include "AliAODMCParticle.h"
25 #include "AliAODEvent.h"
26 #include "TClonesArray.h"
28 #include "AliESDtrack.h"
29 #include "TDatabasePDG.h"
32 #include "AliCFContainer.h"
34 #include "AliPIDResponse.h"
47 fPDGneutrDaughForMC(0),
48 fPDGneutrDaughPositive(0),
49 fPDGneutrDaughNegative(0),
51 fUseCutsForTMVA(kFALSE),
52 fCutOnMomConservation(0.00001)
75 fPDGneutrDaughForMC(0),
76 fPDGneutrDaughPositive(0),
77 fPDGneutrDaughNegative(0),
79 fUseCutsForTMVA(kFALSE),
80 fCutOnMomConservation(0.00001)
116 Bool_t bSignAssoc = kFALSE;
122 AliError(
"fRecoCandidate not found, problem in assignement\n");
135 AliDebug(3,Form(
"nentries = %d\n", nentries));
143 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));
146 if (mcLabel == -1)
return bSignAssoc;
161 AliDebug(3,
"No part candidate");
176 Bool_t bGenValues = kFALSE;
181 AliAODMCParticle* mcPartDaughter0 =
dynamic_cast<AliAODMCParticle*
>(
fmcArray->At(daughter0cascade));
182 AliAODMCParticle* mcPartDaughter1 =
dynamic_cast<AliAODMCParticle*
>(
fmcArray->At(daughter1cascade));
183 AliAODMCParticle* mcPartDaughterNeutrDaugh = NULL;
184 AliAODMCParticle* mcPartDaughterBachelor = NULL;
189 if (mcPartDaughter0->Charge()/3 == 0){
190 mcPartDaughterNeutrDaugh = mcPartDaughter0;
191 mcPartDaughterBachelor = mcPartDaughter1;
194 mcPartDaughterNeutrDaugh = mcPartDaughter1;
195 mcPartDaughterBachelor = mcPartDaughter0;
198 if (!mcPartDaughterNeutrDaugh || !mcPartDaughterBachelor)
return kFALSE;
201 Double_t vtx2daughter0[3] = {0,0,0};
202 Double_t vtx2daughter1[3] = {0,0,0};
206 Int_t daughter0 = mcPartDaughterNeutrDaugh->GetDaughter(0);
207 Int_t daughter1 = mcPartDaughterNeutrDaugh->GetDaughter(1);
209 AliAODMCParticle* mcPartNeutrDaughter0 =
dynamic_cast<AliAODMCParticle*
>(
fmcArray->At(daughter0));
210 AliAODMCParticle* mcPartNeutrDaughter1 =
dynamic_cast<AliAODMCParticle*
>(
fmcArray->At(daughter1));
212 if (!mcPartNeutrDaughter0 || !mcPartNeutrDaughter1)
return kFALSE;
215 mcPartNeutrDaughter0->XvYvZv(vtx2daughter0);
216 mcPartNeutrDaughter1->XvYvZv(vtx2daughter1);
217 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) {
218 AliError(
"Daughters have different secondary vertex, skipping the track");
225 AliAODMCParticle* positiveDaugh = mcPartNeutrDaughter0;
226 AliAODMCParticle* negativeDaugh = mcPartNeutrDaughter1;
227 if (mcPartNeutrDaughter0->GetPdgCode() < 0 && mcPartNeutrDaughter1->GetPdgCode() > 0){
229 positiveDaugh = mcPartNeutrDaughter1;
230 negativeDaugh = mcPartNeutrDaughter0;
234 Double_t px[2] = {positiveDaugh->Px(), negativeDaugh->Px()};
235 Double_t py[2] = {positiveDaugh->Py(), negativeDaugh->Py()};
236 Double_t pz[2] = {positiveDaugh->Pz(), negativeDaugh->Pz()};
243 Double_t cosThetaStarNeutrDaugh = 0.;
244 Double_t cosThetaStarNeutrDaughBar = 0.;
248 AliDebug(3, Form(
"Neutral Daughter, with pdgprong0 = %d, pdgprong1 = %d", mcPartDaughter0->GetPdgCode(), mcPartDaughter1->GetPdgCode()));
249 cosThetaStar = cosThetaStarNeutrDaugh;
252 AliDebug(3, Form(
"Neutral Daughter, with pdgprong0 = %d, pdgprong1 = %d",mcPartDaughter0->GetPdgCode(),mcPartDaughter1->GetPdgCode()));
253 cosThetaStar = cosThetaStarNeutrDaughBar;
256 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()));
260 if (cosThetaStar < -1 || cosThetaStar > 1) {
261 AliWarning(Form(
"Invalid value for cosine Theta star %f, returning", cosThetaStar));
266 Double_t vectorNeutrDaugh[2] = {0.,0.};
270 AliDebug(2,
"Error! the Neutral Daughter MC doesn't have correct daughters!!");
292 vectorMC[2] = cosThetaStar ;
293 vectorMC[3] = vectorNeutrDaugh[0];
294 vectorMC[4] = vectorNeutrDaugh[1];
295 vectorMC[5] = cT*1.E4 ;
297 vectorMC[7] = -100000.;
310 vectorMC[2] = cT*1.E4;
328 Bool_t bFillRecoValues = kFALSE;
332 AliAODRecoDecay* neutrDaugh = NULL;
348 Double_t dca = neutrDaugh->GetDCA();
364 pTneutrDaughPos = neutrDaugh->PtProng(0);
365 pTneutrDaughNeg = neutrDaugh->PtProng(1);
372 pTneutrDaughPos = neutrDaugh->PtProng(1);
373 pTneutrDaughNeg = neutrDaugh->PtProng(0);
385 vectorReco[2] = cosThetaStar;
386 vectorReco[3] = pTneutrDaughPos;
387 vectorReco[4] = pTneutrDaughNeg;
388 vectorReco[5] = cT*1.E4;
389 vectorReco[6] = dca*1.E4;
390 vectorReco[7] = d0xd0*1.E8;
391 vectorReco[8] = cosPointingAngle;
395 vectorReco[12] =
fFake;
396 vectorReco[13] = cosPointingAngleXY;
397 vectorReco[14] = normDecayLengthXY;
403 vectorReco[2] = cT*1.E4;
407 vectorReco[6] =
fFake;
412 bFillRecoValues = kTRUE;
414 return bFillRecoValues;
427 AliAODMCParticle* mcPartDaughter0 =
dynamic_cast<AliAODMCParticle*
>(
fmcArray->At(daughter0));
428 AliAODMCParticle* mcPartDaughter1 =
dynamic_cast<AliAODMCParticle*
>(
fmcArray->At(daughter1));
430 if (!mcPartDaughter0 || !mcPartDaughter1) {
431 AliDebug (2,
"Problems in the MC Daughters\n");
435 if(TMath::Abs(
fmcPartCandidate->GetPdgCode()) == 4122 && (daughter1 - daughter0 != 1)) {
436 AliDebug(2, Form(
"The MC particle doesn't have the correct daughters!!"));
441 TMath::Abs(mcPartDaughter1->GetPdgCode()) ==
fPDGbachelor) &&
442 !(TMath::Abs(mcPartDaughter0->GetPdgCode()) ==
fPDGbachelor &&
444 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()));
449 AliAODMCParticle* mcPartDaughterNeutrDaugh = NULL;
453 AliDebug(3, Form(
"Charge0 = %d, Charge1 = %d", mcPartDaughter0->Charge()/3, mcPartDaughter1->Charge()/3));
454 if (mcPartDaughter0->Charge()/3 != 0){
455 mcPartDaughterNeutrDaugh = mcPartDaughter1;
458 mcPartDaughterNeutrDaugh = mcPartDaughter0;
461 Double_t vectorNeutrDaugh[2] ={0., 0.};
465 AliDebug(2,
"Error! the NeutrDaugh MC doesn't have correct daughters!!");
481 Bool_t isHadronic = kFALSE;
482 AliDebug(2, Form(
"neutralDaugh = %p, pdg = %d", neutralDaugh, neutralDaugh->GetPdgCode()));
485 Int_t labelresonanceDaugh = neutralDaugh->GetDaughter(0);
486 AliAODMCParticle* resonanceDaugh =
dynamic_cast<AliAODMCParticle*
>(
fmcArray->At(labelresonanceDaugh));
487 if (!resonanceDaugh){
491 AliDebug(3, Form(
"The daughter of the resonant particle is a %d (we are looking for a %d)", resonanceDaugh->GetPdgCode(),
fPDGneutrDaugh));
496 neutralDaugh = resonanceDaugh;
501 Int_t daughterNeutrDaugh0 = neutralDaugh->GetDaughter(0);
502 Int_t daughterNeutrDaugh1 = neutralDaugh->GetDaughter(1);
504 AliDebug(2, Form(
"daughter0 = %d and daughter1 = %d", daughterNeutrDaugh0, daughterNeutrDaugh1));
505 if (daughterNeutrDaugh0 == 0 || daughterNeutrDaugh1 == 0) {
506 AliDebug(2,
"Error! the D0 MC doesn't have correct daughters!!");
510 Int_t numberOfExpectedDaughters = 2;
511 if (TMath::Abs(daughterNeutrDaugh1 - daughterNeutrDaugh0) != numberOfExpectedDaughters-1) {
512 AliDebug(2,
"The D0 MC doesn't come from a 2-prong decay, skipping!!");
516 AliAODMCParticle* mcPartDaughterNeutrDaugh0 =
dynamic_cast<AliAODMCParticle*
>(
fmcArray->At(daughterNeutrDaugh0));
517 AliAODMCParticle* mcPartDaughterNeutrDaugh1 =
dynamic_cast<AliAODMCParticle*
>(
fmcArray->At(daughterNeutrDaugh1));
518 if (!mcPartDaughterNeutrDaugh0 || !mcPartDaughterNeutrDaugh1) {
519 AliWarning(
"D0 MC analysis: At least one Daughter Particle not found in tree, skipping");
523 AliDebug(3, Form(
"Daughter 0 has pdg = %d, daughter 1 has pdg = %d", mcPartDaughterNeutrDaugh0->GetPdgCode(), mcPartDaughterNeutrDaugh1->GetPdgCode()));
528 AliDebug(2,
"The neutral particle (MC) doesn't come from the required decay, skipping!!");
532 Double_t sumPxDau = mcPartDaughterNeutrDaugh0->Px()+mcPartDaughterNeutrDaugh1->Px();
533 Double_t sumPyDau = mcPartDaughterNeutrDaugh0->Py()+mcPartDaughterNeutrDaugh1->Py();
534 Double_t sumPzDau = mcPartDaughterNeutrDaugh0->Pz()+mcPartDaughterNeutrDaugh1->Pz();
535 Double_t pxMother = neutralDaugh->Px();
536 Double_t pyMother = neutralDaugh->Py();
537 Double_t pzMother = neutralDaugh->Pz();
538 AliDebug(3, Form(
"pxMother = %f, pyMother = %f, pzMother = %f", pxMother, pyMother, pzMother));
539 AliDebug(3, Form(
"sumPxDau = %f, sumPyDau = %f, sumPzDau = %f", sumPxDau, sumPyDau, sumPzDau));
543 AliDebug(2,
"Momentum conservation violated, skipping!!");
550 if (mcPartDaughterNeutrDaugh0->GetPdgCode() > 0 ) {
551 pTNeutrDaughPositive = mcPartDaughterNeutrDaugh0->Pt();
552 pTNeutrDaughNegative = mcPartDaughterNeutrDaugh1->Pt();
555 pTNeutrDaughPositive = mcPartDaughterNeutrDaugh1->Pt();
556 pTNeutrDaughNegative = mcPartDaughterNeutrDaugh0->Pt();
561 vectorNeutrDaugh[0] = pTNeutrDaughPositive;
562 vectorNeutrDaugh[1] = pTNeutrDaughNegative;
576 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");
595 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");
611 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");
629 Int_t bachelorPosition = 2;
631 AliAODMCParticle* mcPartDaughter =
dynamic_cast<AliAODMCParticle*
>(
fmcArray->At(
fLabelArray[bachelorPosition]));
632 if(!mcPartDaughter)
return;
633 Int_t mother = mcPartDaughter->GetMother();
634 AliAODMCParticle* mcMother =
dynamic_cast<AliAODMCParticle*
>(
fmcArray->At(mother));
635 if(!mcMother)
return;
637 if (TMath::Abs(mcPartDaughter->GetPdgCode()) !=
fPDGbachelor || TMath::Abs(mcMother->GetPdgCode()) !=
fPDGcascade){
638 AliError(Form(
"Apparently the expected bachelor is not in the third position, causing an error (pdg expected = %d, actual = %d)!!",
fPDGbachelor, mcPartDaughter->GetPdgCode()));
639 AliError(
"This should be fixed when checking the MC part family in the CF task...");
668 AliAODRecoDecay* neutrDaugh=0;
674 neutrDaugh = cascade->
Getv0();
677 if (iProng==0) etaProng = neutrDaugh->EtaProng(0);
678 if (iProng==1) etaProng = neutrDaugh->EtaProng(1);
679 if (iProng==2) etaProng = cascade->EtaProng(ibachelor);
697 AliAODRecoDecay* neutrDaugh=0;
700 if (iProng == 0) ptProng = neutrDaugh->PtProng(0);
701 if (iProng == 1) ptProng = neutrDaugh->PtProng(1);
702 if (iProng == 2) ptProng = cascade->PtProng(1);
720 AliAODv0 * v0part = cascade->
Getv0();
721 AliAODTrack *bachelor = (AliAODTrack*)cascade->
GetBachelor();
722 Double_t bachelorEta = bachelor->Eta();
723 AliAODTrack *v0pos = (AliAODTrack*)v0part->GetDaughter(0);
724 AliAODTrack *v0neg = (AliAODTrack*)v0part->GetDaughter(1);
728 Bool_t onFlyV0 = v0part->GetOnFlyStatus();
731 nSigmaTPCpr = pidResponse->NumberOfSigmasTPC(bachelor,(
AliPID::kProton));
732 nSigmaTOFpr = pidResponse->NumberOfSigmasTOF(bachelor,(
AliPID::kProton));
734 Double_t invmassK0s = v0part->MassK0Short();
735 Double_t mK0SPDG = TDatabasePDG::Instance()->GetParticle(310)->Mass();
737 Bool_t cutsForTMVA = (TMath::Abs(bachelorEta) < 0.8 && TMath::Abs(v0posEta) < 0.8 && TMath::Abs(v0negEta) < 0.8) &&
738 ((nSigmaTOFpr < -800) || (TMath::Abs(nSigmaTOFpr) < 3)) &&
739 ((ptArm > 0.01 && ptArm < 0.07) || (ptArm > 0.105)) &&
740 ((TMath::Abs(invmassK0s - mK0SPDG)) < 0.01);
745 Bool_t cutsForInvMassTask = !(onFlyV0) &&
747 (TMath::Abs(nSigmaTPCpr) <= 3) &&
748 (v0part->Getd0Prong(0) < 20) &&
749 (v0part->Getd0Prong(1) < 20);
751 if (cutsForTMVA && cutsForInvMassTask) {
AliCFVertexingHF & operator=(const AliCFVertexingHF &c)
Bool_t GetRecoValuesFromCandidate(Double_t *) const
Int_t fPDGneutrDaughPositive
pdg code of the V0
Double_t GetPtProng(Int_t iProng) const
Class for HF corrections as a function of many variables and steps For D* and other cascades...
Double_t Ct(UInt_t pdg) const
Int_t MatchToMC(Int_t pdgabs, Int_t pdgabs2prong, Int_t *pdgDg, Int_t *pdgDg2prong, TClonesArray *mcArray, Bool_t isV0=kFALSE) const
Bool_t CheckMCChannelDecay() const
AliAODVertex * fPrimVtx
pdg code of the negative daughter of the V0
AliAODMCParticle * fmcPartCandidate
Reconstructed HF candidate.
Int_t fPDGbachelor
pdg code of the cascade
AliCFVertexingHFCascade & operator=(const AliCFVertexingHFCascade &other)
Double_t CosPointingAngleXY() const
Double_t Prodd0d0() const
void SetEtaAccCut(Float_t *etaAccCut)
void SetNProngs(Int_t nProngs)
void SetPtAccCut(Float_t *ptAccCut)
Float_t * fPtAccCut
centrality value
Double_t GetEtaProng(Int_t iProng) const
Float_t fFake
fakes selection: 0 –> all, 1 –> non-fake, 2 –> fake
Int_t fConfiguration
multiplicity of the event
Int_t fPDGneutrDaughForMC
pdg code of the V0
AliAODTrack * GetBachelor() const
slow configuration, all variables
Int_t fPDGneutrDaughNegative
pdg code of the positive daughter of the V0
Bool_t GetGeneratedValuesFromMCParticle(Double_t *)
Double_t CosV0PointingAngle() const
Bool_t fUseCutsForTMVA
primaryVertex
Int_t * fLabelArray
n. of prongs
Int_t fPDGneutrDaugh
pdg code of the bachelor
AliCFVertexingHFCascade()
AliAODRecoDecayHF * fRecoCandidate
mcArray candidate
Bool_t CheckAdditionalCuts(AliPIDResponse *pidResponse) const
Int_t fmcLabel
flag to keep only the charm particles that comes from beauty decays
Double_t fzPrimVertex
get Number of variables for the container from the channel decay
Int_t NumberOfFakeDaughters() const
Int_t fProngs
results of the MatchToMC()
AliAODVertex * GetPrimaryVtx() const
Float_t fCutOnMomConservation
void SetMCLabel(Int_t mcLabel)
AliAODRecoDecayHF2Prong * Get2Prong() const
Bool_t EvaluateIfCorrectNeutrDaugh(AliAODMCParticle *neutralDaugh, Double_t *VectorD0) const
Double_t fzMCVertex
Reco z primary vertex.
Double_t fMultiplicity
flag to remove events not geenrated with PYTHIA
Bool_t SetRecoCandidateParam(AliAODRecoDecayHF *recoCand)
Class for HF corrections as a function of many variables and step.