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)
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!!");
288 Int_t localmult = -1;
297 vectorMC[2] = cosThetaStar ;
298 vectorMC[3] = vectorNeutrDaugh[0];
299 vectorMC[4] = vectorNeutrDaugh[1];
300 vectorMC[5] = cT*1.E4 ;
302 vectorMC[7] = -100000.;
315 vectorMC[2] = cT*1.E4;
333 vectorMC[4] = localmult;
347 Bool_t bFillRecoValues = kFALSE;
351 AliAODRecoDecay* neutrDaugh = NULL;
367 Double_t dca = neutrDaugh->GetDCA();
383 pTneutrDaughPos = neutrDaugh->PtProng(0);
384 pTneutrDaughNeg = neutrDaugh->PtProng(1);
391 pTneutrDaughPos = neutrDaugh->PtProng(1);
392 pTneutrDaughNeg = neutrDaugh->PtProng(0);
400 Int_t localmult = -1;
409 vectorReco[2] = cosThetaStar;
410 vectorReco[3] = pTneutrDaughPos;
411 vectorReco[4] = pTneutrDaughNeg;
412 vectorReco[5] = cT*1.E4;
413 vectorReco[6] = dca*1.E4;
414 vectorReco[7] = d0xd0*1.E8;
415 vectorReco[8] = cosPointingAngle;
419 vectorReco[12] =
fFake;
420 vectorReco[13] = cosPointingAngleXY;
421 vectorReco[14] = normDecayLengthXY;
427 vectorReco[2] = cT*1.E4;
431 vectorReco[6] =
fFake;
445 vectorReco[4] = localmult;
450 bFillRecoValues = kTRUE;
452 return bFillRecoValues;
465 AliAODMCParticle* mcPartDaughter0 =
dynamic_cast<AliAODMCParticle*
>(
fmcArray->At(daughter0));
466 AliAODMCParticle* mcPartDaughter1 =
dynamic_cast<AliAODMCParticle*
>(
fmcArray->At(daughter1));
468 if (!mcPartDaughter0 || !mcPartDaughter1) {
469 AliDebug (2,
"Problems in the MC Daughters\n");
473 if(TMath::Abs(
fmcPartCandidate->GetPdgCode()) == 4122 && (daughter1 - daughter0 != 1)) {
474 AliDebug(2, Form(
"The MC particle doesn't have the correct daughters!!"));
479 TMath::Abs(mcPartDaughter1->GetPdgCode()) ==
fPDGbachelor) &&
480 !(TMath::Abs(mcPartDaughter0->GetPdgCode()) ==
fPDGbachelor &&
482 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()));
487 AliAODMCParticle* mcPartDaughterNeutrDaugh = NULL;
491 AliDebug(3, Form(
"Charge0 = %d, Charge1 = %d", mcPartDaughter0->Charge()/3, mcPartDaughter1->Charge()/3));
492 if (mcPartDaughter0->Charge()/3 != 0){
493 mcPartDaughterNeutrDaugh = mcPartDaughter1;
496 mcPartDaughterNeutrDaugh = mcPartDaughter0;
499 Double_t vectorNeutrDaugh[2] ={0., 0.};
503 AliDebug(2,
"Error! the NeutrDaugh MC doesn't have correct daughters!!");
519 Bool_t isHadronic = kFALSE;
520 AliDebug(2, Form(
"neutralDaugh = %p, pdg = %d", neutralDaugh, neutralDaugh->GetPdgCode()));
523 Int_t labelresonanceDaugh = neutralDaugh->GetDaughter(0);
524 AliAODMCParticle* resonanceDaugh =
dynamic_cast<AliAODMCParticle*
>(
fmcArray->At(labelresonanceDaugh));
525 if (!resonanceDaugh){
529 AliDebug(3, Form(
"The daughter of the resonant particle is a %d (we are looking for a %d)", resonanceDaugh->GetPdgCode(),
fPDGneutrDaugh));
534 neutralDaugh = resonanceDaugh;
539 Int_t daughterNeutrDaugh0 = neutralDaugh->GetDaughter(0);
540 Int_t daughterNeutrDaugh1 = neutralDaugh->GetDaughter(1);
542 AliDebug(2, Form(
"daughter0 = %d and daughter1 = %d", daughterNeutrDaugh0, daughterNeutrDaugh1));
543 if (daughterNeutrDaugh0 == 0 || daughterNeutrDaugh1 == 0) {
544 AliDebug(2,
"Error! the D0 MC doesn't have correct daughters!!");
548 Int_t numberOfExpectedDaughters = 2;
549 if (TMath::Abs(daughterNeutrDaugh1 - daughterNeutrDaugh0) != numberOfExpectedDaughters-1) {
550 AliDebug(2,
"The D0 MC doesn't come from a 2-prong decay, skipping!!");
554 AliAODMCParticle* mcPartDaughterNeutrDaugh0 =
dynamic_cast<AliAODMCParticle*
>(
fmcArray->At(daughterNeutrDaugh0));
555 AliAODMCParticle* mcPartDaughterNeutrDaugh1 =
dynamic_cast<AliAODMCParticle*
>(
fmcArray->At(daughterNeutrDaugh1));
556 if (!mcPartDaughterNeutrDaugh0 || !mcPartDaughterNeutrDaugh1) {
557 AliWarning(
"D0 MC analysis: At least one Daughter Particle not found in tree, skipping");
561 AliDebug(3, Form(
"Daughter 0 has pdg = %d, daughter 1 has pdg = %d", mcPartDaughterNeutrDaugh0->GetPdgCode(), mcPartDaughterNeutrDaugh1->GetPdgCode()));
566 AliDebug(2,
"The neutral particle (MC) doesn't come from the required decay, skipping!!");
570 Double_t sumPxDau = mcPartDaughterNeutrDaugh0->Px()+mcPartDaughterNeutrDaugh1->Px();
571 Double_t sumPyDau = mcPartDaughterNeutrDaugh0->Py()+mcPartDaughterNeutrDaugh1->Py();
572 Double_t sumPzDau = mcPartDaughterNeutrDaugh0->Pz()+mcPartDaughterNeutrDaugh1->Pz();
573 Double_t pxMother = neutralDaugh->Px();
574 Double_t pyMother = neutralDaugh->Py();
575 Double_t pzMother = neutralDaugh->Pz();
576 AliDebug(3, Form(
"pxMother = %f, pyMother = %f, pzMother = %f", pxMother, pyMother, pzMother));
577 AliDebug(3, Form(
"sumPxDau = %f, sumPyDau = %f, sumPzDau = %f", sumPxDau, sumPyDau, sumPzDau));
581 AliDebug(2,
"Momentum conservation violated, skipping!!");
588 if (mcPartDaughterNeutrDaugh0->GetPdgCode() > 0 ) {
589 pTNeutrDaughPositive = mcPartDaughterNeutrDaugh0->Pt();
590 pTNeutrDaughNegative = mcPartDaughterNeutrDaugh1->Pt();
593 pTNeutrDaughPositive = mcPartDaughterNeutrDaugh1->Pt();
594 pTNeutrDaughNegative = mcPartDaughterNeutrDaugh0->Pt();
599 vectorNeutrDaugh[0] = pTNeutrDaughPositive;
600 vectorNeutrDaugh[1] = pTNeutrDaughNegative;
614 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");
633 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");
649 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");
667 Int_t bachelorPosition = 2;
669 AliAODMCParticle* mcPartDaughter =
dynamic_cast<AliAODMCParticle*
>(
fmcArray->At(
fLabelArray[bachelorPosition]));
670 if(!mcPartDaughter)
return;
671 Int_t mother = mcPartDaughter->GetMother();
672 AliAODMCParticle* mcMother =
dynamic_cast<AliAODMCParticle*
>(
fmcArray->At(mother));
673 if(!mcMother)
return;
675 if (TMath::Abs(mcPartDaughter->GetPdgCode()) !=
fPDGbachelor || TMath::Abs(mcMother->GetPdgCode()) !=
fPDGcascade){
676 AliError(Form(
"Apparently the expected bachelor is not in the third position, causing an error (pdg expected = %d, actual = %d)!!",
fPDGbachelor, mcPartDaughter->GetPdgCode()));
677 AliError(
"This should be fixed when checking the MC part family in the CF task...");
706 AliAODRecoDecay* neutrDaugh=0;
712 neutrDaugh = cascade->
Getv0();
715 if (iProng==0) etaProng = neutrDaugh->EtaProng(0);
716 if (iProng==1) etaProng = neutrDaugh->EtaProng(1);
717 if (iProng==2) etaProng = cascade->EtaProng(ibachelor);
735 AliAODRecoDecay* neutrDaugh=0;
738 if (iProng == 0) ptProng = neutrDaugh->PtProng(0);
739 if (iProng == 1) ptProng = neutrDaugh->PtProng(1);
740 if (iProng == 2) ptProng = cascade->PtProng(1);
758 AliAODv0 * v0part = cascade->
Getv0();
759 AliAODTrack *bachelor = (AliAODTrack*)cascade->
GetBachelor();
760 Double_t bachelorEta = bachelor->Eta();
761 AliAODTrack *v0pos = (AliAODTrack*)v0part->GetDaughter(0);
762 AliAODTrack *v0neg = (AliAODTrack*)v0part->GetDaughter(1);
766 Bool_t onFlyV0 = v0part->GetOnFlyStatus();
769 nSigmaTPCpr = pidResponse->NumberOfSigmasTPC(bachelor,(
AliPID::kProton));
770 nSigmaTOFpr = pidResponse->NumberOfSigmasTOF(bachelor,(
AliPID::kProton));
772 Double_t invmassK0s = v0part->MassK0Short();
773 Double_t mK0SPDG = TDatabasePDG::Instance()->GetParticle(310)->Mass();
775 Bool_t cutsForTMVA = (TMath::Abs(bachelorEta) < 0.8 && TMath::Abs(v0posEta) < 0.8 && TMath::Abs(v0negEta) < 0.8) &&
776 ((nSigmaTOFpr < -800) || (TMath::Abs(nSigmaTOFpr) < 3)) &&
777 ((ptArm > 0.01 && ptArm < 0.07) || (ptArm > 0.105)) &&
778 ((TMath::Abs(invmassK0s - mK0SPDG)) < 0.01);
783 Bool_t cutsForInvMassTask = !(onFlyV0) &&
785 (TMath::Abs(nSigmaTPCpr) <= 3) &&
786 (v0part->Getd0Prong(0) < 20) &&
787 (v0part->Getd0Prong(1) < 20);
789 if (cutsForTMVA && cutsForInvMassTask) {
fast configuration, only a subset of variables
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 ComputeLocalMultiplicity(Double_t etaD, Double_t phiD, Double_t R) 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
array of tracks
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
Double_t fq2
multiplicity of the event
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.
super fast configuration, only (pt,y,centrality)