25 #include "TParticle.h" 26 #include "TClonesArray.h" 27 #include "AliAODMCParticle.h" 33 #include "AliAODMCHeader.h" 34 #include "AliAODEvent.h" 36 #include "AliESDtrackCuts.h" 37 #include "AliESDtrack.h" 46 fmcPartCandidate(0x0),
51 fFillFromGenerated(0),
54 fKeepDfromBOnly(kFALSE),
63 fRejectIfNoQuark(kFALSE),
142 TObject::operator=(c);
271 AliError(Form(
"Dynamic cast failed, fNdaughters will remain set to %d",
fNDaughters));
285 if (mcPart->GetPdgCode() == 4) cquarks++;
286 if (mcPart->GetPdgCode() == -4) cquarks++;
289 AliWarning(
"Particle not found in tree, skipping\n");
305 AliDebug(3, Form(
"pdgGranma = %d", pdgGranma));
307 if (pdgGranma == -99999){
308 AliDebug(2,
"This particle does not have a quark in his genealogy\n");
311 if (pdgGranma == -9999){
312 AliDebug(2,
"This particle come from a B decay channel but according to the settings of the task, we keep only the prompt charm particles\n");
316 if (pdgGranma == -999){
317 AliDebug(2,
"This particle come from a prompt charm particles but according to the settings of the task, we want only the ones coming from B\n");
322 AliDebug(3,
"CheckMCDaughters false");
326 AliDebug(3,
"CheckMCChannelDecay false");
343 Int_t abspdgGranma =0;
345 Bool_t isQuarkFound=kFALSE;
348 AliDebug(2,Form(
"mother at step %d = %d", istep, mother));
349 AliAODMCParticle* mcGranma =
dynamic_cast<AliAODMCParticle*
>(
fmcArray->At(mother));
351 pdgGranma = mcGranma->GetPdgCode();
352 AliDebug(2,Form(
"Pdg mother at step %d = %d", istep, pdgGranma));
353 abspdgGranma = TMath::Abs(pdgGranma);
354 if ((abspdgGranma > 500 && abspdgGranma < 600) || (abspdgGranma > 5000 && abspdgGranma < 6000)){
357 if(abspdgGranma==4 || abspdgGranma==5) isQuarkFound=kTRUE;
358 mother = mcGranma->GetMother();
359 AliDebug(3, Form(
"mother = %d", mother));
361 AliError(
"Failed casting the mother particle!");
389 AliAODMCParticle *mcPartDaughter;
390 Bool_t checkDaughters = kFALSE;
394 AliDebug(3,Form(
"label0 = %d, label1 = %d", label0, label1));
395 if (label1<=0 || label0 <= 0){
396 AliDebug(2, Form(
"The MC particle doesn't have correct daughters, skipping!!"));
397 return checkDaughters;
401 return checkDaughters;
405 AliDebug(3, Form(
"fLabelArray[%d] = %d", iProng,
fLabelArray[iProng]));
407 AliDebug(3, Form(
"Entries in MC array = %d (fast = %d)",
fmcArray->GetEntries(),
fmcArray->GetEntriesFast()));
409 AliDebug(3, Form(
"fLabelArray[%d] = %d", iProng,
fLabelArray[iProng]));
411 if (!mcPartDaughter) {
412 AliWarning(
"At least one Daughter Particle not found in tree, skipping");
413 return checkDaughters;
417 checkDaughters = kTRUE;
418 return checkDaughters;
428 Bool_t mcContainerFilled = kFALSE;
431 for (
Int_t iVar = 0; iVar<
fNVar; iVar++) vectorMC[iVar]= 9999.;
435 containerInputMC[iVar] = vectorMC[iVar];
437 mcContainerFilled = kTRUE;
440 AliDebug(3,
"We could not fill the array for the container");
444 return mcContainerFilled;
454 Bool_t recoContainerFilled = kFALSE;
459 vectorValues[iVar]= 9999.;
460 vectorReco[iVar]=9999.;
467 containerInput[iVar] = vectorValues[iVar];
469 recoContainerFilled = kTRUE;
477 containerInput[iVar] = vectorReco[iVar];
479 recoContainerFilled = kTRUE;
483 delete [] vectorValues;
484 delete [] vectorReco;
488 return recoContainerFilled;
498 Bool_t bMCAccStep = kFALSE;
500 AliAODMCParticle *mcPartDaughter;
503 if (label1<=0 || label0 <= 0){
504 AliDebug(2, Form(
"The MC particle doesn't have correct daughters, skipping!!"));
514 if (!mcPartDaughter) {
515 AliWarning(
"At least one Daughter Particle not found in tree, skipping");
518 Double_t eta = mcPartDaughter->Eta();
524 AliDebug(3,Form(
"At least one daughter has eta or pt outside the required range (|eta| = %f, pt = %f, should be |eta| < %f, pt > %f \n", TMath::Abs(eta), pt,
fEtaAccCut[iProng],
fPtAccCut[iProng]));
538 Bool_t bRefitStep = kFALSE;
543 if (label1<=0 || label0 <= 0){
544 AliDebug(2, Form(
"The MC particle doesn't have correct daughters, skipping!!"));
552 Int_t foundDaughters = 0;
560 for(
Int_t iaod =0; iaod<aodEvent->GetNumberOfTracks(); iaod++){
561 AliAODTrack *track = (AliAODTrack*)aodEvent->GetTrack(iaod);
562 if(track->GetStatus()&AliESDtrack::kITSpureSA)
continue;
563 Bool_t foundTrack = kFALSE;
566 AliDebug(3,Form(
"fLabelArray[%d] = %d, track->GetLabel() = %d",ilabel,
fLabelArray[ilabel],TMath::Abs(track->GetLabel())));
570 if (TMath::Abs(track->GetLabel()) == temp[ilabel]) {
579 AliDebug(4,Form(
"daughter %d \n",foundDaughters));
580 if(trackCuts[prongindex]->GetRequireTPCRefit()){
581 if(track->GetStatus()&AliESDtrack::kTPCrefit) {
585 AliDebug(3,
"Refit cut not passed , missing TPC refit\n");
592 if (trackCuts[prongindex]->GetRequireITSRefit()) {
593 if(track->GetStatus()&AliESDtrack::kITSrefit){
597 AliDebug(3,
"Refit cut not passed , missing ITS refit\n");
604 if (foundDaughters == fProngs){
611 if (foundDaughters== fProngs)
return bRefitStep;
623 Bool_t bRecoStep = kFALSE;
627 AliDebug(2,
"No MC particle found");
633 AliWarning(
"Could not find associated MC in AOD MC tree");
640 if (pdgGranma == -99999){
641 AliDebug(2,
"This particle does not have a quark in his genealogy\n");
644 if (pdgGranma == -9999){
645 AliDebug(2,
"This particle come from a B decay channel but according to the settings of the task, we keep only prompt charm particles\n");
649 if (pdgGranma == -999){
650 AliDebug(2,
"This particle come from a prompt charm particle but according to the settings of the task, we want only the ones coming from B\n");
693 Bool_t bRecoAccStep = kFALSE;
695 Float_t etaCutMin=0, ptCutMin=0, etaCutMax=0, ptCutMax=0;
697 Float_t etaProng=0., ptProng=0.;
701 trackCuts[iProng]->GetEtaRange(etaCutMin, etaCutMax);
702 trackCuts[iProng]->GetPtRange(ptCutMin, ptCutMax);
706 Bool_t acceptanceProng = (etaProng>etaCutMin && etaProng<etaCutMax && ptProng>ptCutMin && ptProng<ptCutMax);
707 if (!acceptanceProng) {
708 AliDebug(2,
"At least one reconstructed prong isn't in the acceptance\n");
748 AliDebug(2,
"No MC particle found");
754 AliWarning(
"Could not find associated MC in AOD MC tree");
761 AliDebug(2,
"candidate is particle, I ask for antiparticle only");
768 AliDebug(2,
"candidate is antiparticle, I ask for particle only");
784 Bool_t bLabelArray = kFALSE;
788 AliAODMCParticle *mcPartDaughter;
791 AliDebug(2, Form(
"label0 = %d, label1 = %d", label0, label1));
792 if (label1<=0 || label0 <= 0){
793 AliDebug(2, Form(
"The MC particle doesn't have correct daughters, skipping!!"));
798 AliAODMCParticle* tmp0 =
dynamic_cast<AliAODMCParticle*
>(
fmcArray->At(label0));
799 AliAODMCParticle* tmp1 =
dynamic_cast<AliAODMCParticle*
>(
fmcArray->At(label1));
800 AliDebug(2, Form(
"label0 = %d (pdg = %d), label1 = %d (pdg = %d)", label0, tmp0->GetPdgCode(), label1, tmp1->GetPdgCode()));
802 if (label1 - label0 ==
fProngs-1){
804 mcPartDaughter =
dynamic_cast<AliAODMCParticle*
>(
fmcArray->At(label0+iProng));
809 AliError(
"Failed casting the daughter particle, returning a NULL label array");
819 AliDebug(3,
"In the resonance decay channel");
821 Int_t foundDaughters = 0;
823 Int_t iLabelDau = labelFirstDau+iDau;
824 AliAODMCParticle*
part =
dynamic_cast<AliAODMCParticle*
>(
fmcArray->At(iLabelDau));
826 AliError(
"Wrong particle type in fmcArray");
831 Int_t pdgCode=TMath::Abs(part->GetPdgCode());
832 AliDebug(3, Form(
"Prong %d had pdg = %d", iDau, pdgCode));
833 if(pdgCode==211 || pdgCode==321 || pdgCode==2212){
836 AliDebug(3, Form(
"part found at %d has label = %d", iLabelDau, part->GetLabel()));
837 AliDebug(3, Form(
"fLabelArray[%d] = %d", foundDaughters,
fLabelArray[foundDaughters]));
841 AliError(
"Error while casting particle! returning a NULL array");
848 else if (pdgCode==311) {
849 AliDebug(3, Form(
"K0S case, foundDaughters = %d", foundDaughters));
850 if (part->GetNDaughters()!=1) {
855 Int_t labelK0Dau = part->GetDaughter(0);
856 AliAODMCParticle* partK0S =
dynamic_cast<AliAODMCParticle*
>(
fmcArray->At(labelK0Dau));
858 AliError(
"Error while casting particle! returning a NULL array");
863 Int_t nDauRes = partK0S->GetNDaughters();
864 AliDebug(3, Form(
"nDauRes = %d", nDauRes));
865 if (nDauRes!=2 || partK0S->GetPdgCode() != 310) {
866 AliDebug(2,
"No K0S on no 2-body decay");
871 Int_t labelFirstDauRes = partK0S->GetDaughter(0);
872 AliDebug(2, Form(
"Found K0S (%d)", labelK0Dau));
873 for(
Int_t iDauRes=0; iDauRes<nDauRes; iDauRes++){
874 Int_t iLabelDauRes = labelFirstDauRes+iDauRes;
875 AliAODMCParticle* dauRes =
dynamic_cast<AliAODMCParticle*
>(
fmcArray->At(iLabelDauRes));
876 AliDebug(3, Form(
"daughter = %d, pointer = %p, with label = %d", iLabelDauRes, dauRes, dauRes->GetLabel()));
878 AliDebug(3, Form(
"PDG code = %d", dauRes->GetPdgCode()));
879 if (TMath::Abs(dauRes->GetPdgCode())!=211) {
880 AliDebug(2,
"K0S doesn't decay in 2 charged pions!");
887 AliDebug(3, Form(
"Setting fLabelArray[%d] = %d (before it was %d)", foundDaughters, iLabelDauRes, dauRes->GetLabel()));
892 AliError(
"Error while casting resonant daughter! returning a NULL array");
901 Int_t nDauRes=part->GetNDaughters();
902 AliDebug(3, Form(
"nDauRes = %d", nDauRes));
904 AliDebug(3, Form(
"nDauRes = %d, different from 2", nDauRes));
905 Int_t labelFirstDauResTest = part->GetDaughter(0);
906 for(
Int_t iDauRes=0; iDauRes<nDauRes; iDauRes++){
907 Int_t iLabelDauResTest = labelFirstDauResTest+iDauRes;
908 AliAODMCParticle* dauRes =
dynamic_cast<AliAODMCParticle*
>(
fmcArray->At(iLabelDauResTest));
910 AliDebug(3, Form(
"pdg of daugh %d = %d", iDauRes, dauRes->GetPdgCode()));
917 Int_t labelFirstDauRes = part->GetDaughter(0);
918 for(
Int_t iDauRes=0; iDauRes<nDauRes; iDauRes++){
919 Int_t iLabelDauRes = labelFirstDauRes+iDauRes;
920 AliAODMCParticle* dauRes =
dynamic_cast<AliAODMCParticle*
>(
fmcArray->At(iLabelDauRes));
926 AliError(
"Error while casting resonant daughter! returning a NULL array");
934 if (foundDaughters != fProngs){
935 AliDebug(3, Form(
"foundDaughters (%d) != fProngs (%d)", foundDaughters, fProngs));
947 AliDebug(3,
"Setting AccCuts");
Bool_t fFillFromGenerated
MC z primary vertex.
AliCFVertexingHF & operator=(const AliCFVertexingHF &c)
Double_t GetPtCand() const
Bool_t CheckMCDaughters() const
Bool_t FillUnfoldingMatrix(UInt_t pdg, Double_t fill[4]) const
Int_t MCcquarkCounting(AliAODMCParticle *mcPart) const
Bool_t FillRecoContainer(Double_t *containerInput)
virtual void SetPtAccCut(Float_t *ptAccCut)
AliAODMCParticle * fmcPartCandidate
Reconstructed HF candidate.
virtual Bool_t SetLabelArray()
Bool_t fKeepDfromBOnly
flag for the feed down from b quark decay.
virtual ~AliCFVertexingHF()
virtual Bool_t GetRecoValuesFromCandidate(Double_t *) const
TString part
use mixed event to constrain combinatorial background
Float_t * fPtAccCut
centrality value
virtual Double_t GetPtProng(Int_t iProng) const
virtual Bool_t CheckMCChannelDecay() const
Float_t fFake
fakes selection: 0 –> all, 1 –> non-fake, 2 –> fake
Int_t fConfiguration
multiplicity of the event
UShort_t fOriginDselection
flag to indicate whether data container should be filled
Int_t CheckOrigin() const
void SetDselection(UShort_t originDselection)
virtual Bool_t GetGeneratedValuesFromMCParticle(Double_t *)
Int_t * fLabelArray
n. of prongs
void SetMCCandidateParam(Int_t label)
Bool_t CheckMCPartFamily(AliAODMCParticle *, TClonesArray *) const
AliAODRecoDecayHF * fRecoCandidate
mcArray candidate
Int_t CheckReflexion(Char_t isSign)
Bool_t MCAcceptanceStep() const
Bool_t RecoAcceptStep(AliESDtrackCuts **trackCuts) 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 fProngs
results of the MatchToMC()
Double_t GetYCand(UInt_t pdg) const
Bool_t MCRefitStep(AliAODEvent *aodEvent, AliESDtrackCuts **trackCuts) const
Double_t fzMCVertex
Reco z primary vertex.
Bool_t fKeepDfromB
flag to select D0 origins. 0 Only from charm 1 only from beauty 2 both from charm and beauty ...
Double_t fMultiplicity
flag to remove events not geenrated with PYTHIA
virtual void SetEtaAccCut(Float_t *etaAccCut)
Bool_t FillMCContainer(Double_t *containerInputMC)
Bool_t fRejectIfNoQuark
variable to indicate whether the D0 was a fake or not: 0 –> fake, 1 –> MC, 2 –> non-fake ...
virtual Double_t GetEtaProng(Int_t iProng) const
Class for HF corrections as a function of many variables and step.