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;
334 Bool_t bFillRecoValues = kFALSE;
338 AliAODRecoDecay* neutrDaugh = NULL;
354 Double_t dca = neutrDaugh->GetDCA();
370 pTneutrDaughPos = neutrDaugh->PtProng(0);
371 pTneutrDaughNeg = neutrDaugh->PtProng(1);
378 pTneutrDaughPos = neutrDaugh->PtProng(1);
379 pTneutrDaughNeg = neutrDaugh->PtProng(0);
391 vectorReco[2] = cosThetaStar;
392 vectorReco[3] = pTneutrDaughPos;
393 vectorReco[4] = pTneutrDaughNeg;
394 vectorReco[5] = cT*1.E4;
395 vectorReco[6] = dca*1.E4;
396 vectorReco[7] = d0xd0*1.E8;
397 vectorReco[8] = cosPointingAngle;
401 vectorReco[12] =
fFake;
402 vectorReco[13] = cosPointingAngleXY;
403 vectorReco[14] = normDecayLengthXY;
409 vectorReco[2] = cT*1.E4;
413 vectorReco[6] =
fFake;
424 bFillRecoValues = kTRUE;
426 return bFillRecoValues;
439 AliAODMCParticle* mcPartDaughter0 =
dynamic_cast<AliAODMCParticle*
>(
fmcArray->At(daughter0));
440 AliAODMCParticle* mcPartDaughter1 =
dynamic_cast<AliAODMCParticle*
>(
fmcArray->At(daughter1));
442 if (!mcPartDaughter0 || !mcPartDaughter1) {
443 AliDebug (2,
"Problems in the MC Daughters\n");
447 if(TMath::Abs(
fmcPartCandidate->GetPdgCode()) == 4122 && (daughter1 - daughter0 != 1)) {
448 AliDebug(2, Form(
"The MC particle doesn't have the correct daughters!!"));
453 TMath::Abs(mcPartDaughter1->GetPdgCode()) ==
fPDGbachelor) &&
454 !(TMath::Abs(mcPartDaughter0->GetPdgCode()) ==
fPDGbachelor &&
456 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()));
461 AliAODMCParticle* mcPartDaughterNeutrDaugh = NULL;
465 AliDebug(3, Form(
"Charge0 = %d, Charge1 = %d", mcPartDaughter0->Charge()/3, mcPartDaughter1->Charge()/3));
466 if (mcPartDaughter0->Charge()/3 != 0){
467 mcPartDaughterNeutrDaugh = mcPartDaughter1;
470 mcPartDaughterNeutrDaugh = mcPartDaughter0;
473 Double_t vectorNeutrDaugh[2] ={0., 0.};
477 AliDebug(2,
"Error! the NeutrDaugh MC doesn't have correct daughters!!");
493 Bool_t isHadronic = kFALSE;
494 AliDebug(2, Form(
"neutralDaugh = %p, pdg = %d", neutralDaugh, neutralDaugh->GetPdgCode()));
497 Int_t labelresonanceDaugh = neutralDaugh->GetDaughter(0);
498 AliAODMCParticle* resonanceDaugh =
dynamic_cast<AliAODMCParticle*
>(
fmcArray->At(labelresonanceDaugh));
499 if (!resonanceDaugh){
503 AliDebug(3, Form(
"The daughter of the resonant particle is a %d (we are looking for a %d)", resonanceDaugh->GetPdgCode(),
fPDGneutrDaugh));
508 neutralDaugh = resonanceDaugh;
513 Int_t daughterNeutrDaugh0 = neutralDaugh->GetDaughter(0);
514 Int_t daughterNeutrDaugh1 = neutralDaugh->GetDaughter(1);
516 AliDebug(2, Form(
"daughter0 = %d and daughter1 = %d", daughterNeutrDaugh0, daughterNeutrDaugh1));
517 if (daughterNeutrDaugh0 == 0 || daughterNeutrDaugh1 == 0) {
518 AliDebug(2,
"Error! the D0 MC doesn't have correct daughters!!");
522 Int_t numberOfExpectedDaughters = 2;
523 if (TMath::Abs(daughterNeutrDaugh1 - daughterNeutrDaugh0) != numberOfExpectedDaughters-1) {
524 AliDebug(2,
"The D0 MC doesn't come from a 2-prong decay, skipping!!");
528 AliAODMCParticle* mcPartDaughterNeutrDaugh0 =
dynamic_cast<AliAODMCParticle*
>(
fmcArray->At(daughterNeutrDaugh0));
529 AliAODMCParticle* mcPartDaughterNeutrDaugh1 =
dynamic_cast<AliAODMCParticle*
>(
fmcArray->At(daughterNeutrDaugh1));
530 if (!mcPartDaughterNeutrDaugh0 || !mcPartDaughterNeutrDaugh1) {
531 AliWarning(
"D0 MC analysis: At least one Daughter Particle not found in tree, skipping");
535 AliDebug(3, Form(
"Daughter 0 has pdg = %d, daughter 1 has pdg = %d", mcPartDaughterNeutrDaugh0->GetPdgCode(), mcPartDaughterNeutrDaugh1->GetPdgCode()));
540 AliDebug(2,
"The neutral particle (MC) doesn't come from the required decay, skipping!!");
544 Double_t sumPxDau = mcPartDaughterNeutrDaugh0->Px()+mcPartDaughterNeutrDaugh1->Px();
545 Double_t sumPyDau = mcPartDaughterNeutrDaugh0->Py()+mcPartDaughterNeutrDaugh1->Py();
546 Double_t sumPzDau = mcPartDaughterNeutrDaugh0->Pz()+mcPartDaughterNeutrDaugh1->Pz();
547 Double_t pxMother = neutralDaugh->Px();
548 Double_t pyMother = neutralDaugh->Py();
549 Double_t pzMother = neutralDaugh->Pz();
550 AliDebug(3, Form(
"pxMother = %f, pyMother = %f, pzMother = %f", pxMother, pyMother, pzMother));
551 AliDebug(3, Form(
"sumPxDau = %f, sumPyDau = %f, sumPzDau = %f", sumPxDau, sumPyDau, sumPzDau));
555 AliDebug(2,
"Momentum conservation violated, skipping!!");
562 if (mcPartDaughterNeutrDaugh0->GetPdgCode() > 0 ) {
563 pTNeutrDaughPositive = mcPartDaughterNeutrDaugh0->Pt();
564 pTNeutrDaughNegative = mcPartDaughterNeutrDaugh1->Pt();
567 pTNeutrDaughPositive = mcPartDaughterNeutrDaugh1->Pt();
568 pTNeutrDaughNegative = mcPartDaughterNeutrDaugh0->Pt();
573 vectorNeutrDaugh[0] = pTNeutrDaughPositive;
574 vectorNeutrDaugh[1] = pTNeutrDaughNegative;
588 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");
607 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");
623 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");
641 Int_t bachelorPosition = 2;
643 AliAODMCParticle* mcPartDaughter =
dynamic_cast<AliAODMCParticle*
>(
fmcArray->At(
fLabelArray[bachelorPosition]));
644 if(!mcPartDaughter)
return;
645 Int_t mother = mcPartDaughter->GetMother();
646 AliAODMCParticle* mcMother =
dynamic_cast<AliAODMCParticle*
>(
fmcArray->At(mother));
647 if(!mcMother)
return;
649 if (TMath::Abs(mcPartDaughter->GetPdgCode()) !=
fPDGbachelor || TMath::Abs(mcMother->GetPdgCode()) !=
fPDGcascade){
650 AliError(Form(
"Apparently the expected bachelor is not in the third position, causing an error (pdg expected = %d, actual = %d)!!",
fPDGbachelor, mcPartDaughter->GetPdgCode()));
651 AliError(
"This should be fixed when checking the MC part family in the CF task...");
680 AliAODRecoDecay* neutrDaugh=0;
686 neutrDaugh = cascade->
Getv0();
689 if (iProng==0) etaProng = neutrDaugh->EtaProng(0);
690 if (iProng==1) etaProng = neutrDaugh->EtaProng(1);
691 if (iProng==2) etaProng = cascade->EtaProng(ibachelor);
709 AliAODRecoDecay* neutrDaugh=0;
712 if (iProng == 0) ptProng = neutrDaugh->PtProng(0);
713 if (iProng == 1) ptProng = neutrDaugh->PtProng(1);
714 if (iProng == 2) ptProng = cascade->PtProng(1);
732 AliAODv0 * v0part = cascade->
Getv0();
733 AliAODTrack *bachelor = (AliAODTrack*)cascade->
GetBachelor();
734 Double_t bachelorEta = bachelor->Eta();
735 AliAODTrack *v0pos = (AliAODTrack*)v0part->GetDaughter(0);
736 AliAODTrack *v0neg = (AliAODTrack*)v0part->GetDaughter(1);
740 Bool_t onFlyV0 = v0part->GetOnFlyStatus();
743 nSigmaTPCpr = pidResponse->NumberOfSigmasTPC(bachelor,(
AliPID::kProton));
744 nSigmaTOFpr = pidResponse->NumberOfSigmasTOF(bachelor,(
AliPID::kProton));
746 Double_t invmassK0s = v0part->MassK0Short();
747 Double_t mK0SPDG = TDatabasePDG::Instance()->GetParticle(310)->Mass();
749 Bool_t cutsForTMVA = (TMath::Abs(bachelorEta) < 0.8 && TMath::Abs(v0posEta) < 0.8 && TMath::Abs(v0negEta) < 0.8) &&
750 ((nSigmaTOFpr < -800) || (TMath::Abs(nSigmaTOFpr) < 3)) &&
751 ((ptArm > 0.01 && ptArm < 0.07) || (ptArm > 0.105)) &&
752 ((TMath::Abs(invmassK0s - mK0SPDG)) < 0.01);
757 Bool_t cutsForInvMassTask = !(onFlyV0) &&
759 (TMath::Abs(nSigmaTPCpr) <= 3) &&
760 (v0part->Getd0Prong(0) < 20) &&
761 (v0part->Getd0Prong(1) < 20);
763 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
fast configuration, only a subset of variables
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.