|
ATLAS Offline Software
|
Go to the documentation of this file.
29 using namespace TopParticleLevel;
58 muon->auxdecor<
bool>(
"hasRecoMuonHistoryInfo")=
false;
64 truthmu->
auxdecor<
bool>(
"hasTruthMuonHistoryInfo")=
false;
65 if(doPartonHistory) truthmu->
auxdecor<
bool>(
"hasTruthMuonPartonHistoryInfo")=
false;
73 m_target->
auxdecor<
bool>(
"hasRecoMuonHistoryInfo") = m_origin->
auxdecor<
bool>(
"hasRecoMuonHistoryInfo");
80 tm_target->
auxdecor<
bool>(
"hasTruthMuonHistoryInfo")= tm_origin->
auxdecor<
bool>(
"hasTruthMuonHistoryInfo");
81 tm_target->
auxdecor<
bool>(
"hasTruthMuonPartonHistoryInfo")= tm_origin->
auxdecor<
bool>(
"hasTruthMuonPartonHistoryInfo");
88 ATH_MSG_ERROR(
" top::truth::copyCommonMuonHistoryInfo called with an origin muon which has no truth info!");
89 throw std::runtime_error(
"Muon has no truth info in copyCommonMuonHistoryInfo");
122 if(!truthmu)
return 0;
123 if(!truthmu->
isMuon())
return 0;
131 if(
verbose)
ATH_MSG_INFO(
"getRecoMuonHistory:: ---------------entering in function-----------------");
141 ATH_MSG_INFO(
"getRecoMuonHistory::called on muon with pt="<<
muon->pt()<<
" origin="<<origin);
146 static int nWarnings=0;
149 ATH_MSG_WARNING(
"top::truth::getRecoMuonHistory : partonHistory can be checked only for pythia8 and herwigpp showering algorithms, SoftMuonAdditionalTruthInfoCheckPartonOrigin will be ignored for this sample");
152 doPartonHistory=
false;
155 if(!
muon->isAvailable<
bool>(
"hasRecoMuonHistoryInfo"))
159 else if(
muon->auxdecor<
bool>(
"hasRecoMuonHistoryInfo"))
164 muon->auxdecor<
bool>(
"hasRecoMuonHistoryInfo")=
true;
179 ATH_MSG_INFO(
"getRecoMuonHistory::---truth decay chain---");
217 if(!truthmu->
isAvailable<
bool>(
"hasTruthMuonHistoryInfo"))
221 else if(truthmu->
auxdecor<
bool>(
"hasTruthMuonHistoryInfo"))
223 if(
verbose)
ATH_MSG_INFO(
"getTruthMuonHistory:: -> we already ran on this truth muon, exiting");
226 truthmu->
auxdecor<
bool>(
"hasTruthMuonHistoryInfo")=
true;
235 if(initial_mu) truthmu_mother= initial_mu->
parent(0);
237 if(truthmu_mother && !
MC::isMuon(truthmu_mother))
240 if(!truthmu_mother->
isLepton()) truthmu_firstNonLeptonMother=truthmu_mother;
245 else if(truthmu_mother->
isW())
249 else if(truthmu_mother->
isZ())
257 else if(truthmu_mother->
isHiggs())
261 else if(truthmu_mother->
isBSM())
265 else if(truthmu_mother->
isTau())
272 truthmu_Bmother=truthmu_mother;
276 truthmu_Cmother=truthmu_mother;
283 ATH_MSG_INFO(
"getTruthMuonHistory::LepParticleOriginFlag="<<
static_cast<int>(lepParticleOriginFlag));
284 if(truthmu)
ATH_MSG_INFO(
"getTruthMuonHistory::-->truth muon "<<truthmu);
285 else ATH_MSG_INFO(
"getTruthMuonHistory::-->truth muon not found");
286 if(truthmu_mother)
ATH_MSG_INFO(
"getTruthMuonHistory::-->truth muon mother "<<truthmu_mother);
287 else ATH_MSG_INFO(
"getTruthMuonHistory::-->truth muon mother not found");
288 if(truthmu_firstNonLeptonMother)
ATH_MSG_INFO(
"getTruthMuonHistory::-->truthmu_firstNonLeptonMother "<<truthmu_firstNonLeptonMother);
289 else ATH_MSG_INFO(
"getTruthMuonHistory::-->truthmu_firstNonLeptonMother not found");
290 if(truthmu_Bmother)
ATH_MSG_INFO(
"getTruthMuonHistory::-->truth muon Bmother "<<truthmu_Bmother);
291 else ATH_MSG_INFO(
"getTruthMuonHistory::-->truth muon Bmother not found");
292 if(truthmu_Cmother)
ATH_MSG_INFO(
"getTruthMuonHistory::-->truth muon Cmother "<<truthmu_Cmother);
293 else ATH_MSG_INFO(
"getTruthMuonHistory::-->truth muon Cmother not found");
317 ATH_MSG_INFO(
"getTruthMuonPartonHistory:: -> called on empty truth muon");
321 if(!truthmu->
isAvailable<
bool>(
"hasTruthMuonPartonHistoryInfo"))
325 else if(truthmu->
auxdecor<
bool>(
"hasTruthMuonPartonHistoryInfo"))
327 if(
verbose)
ATH_MSG_INFO(
"getTruthMuonHistory:: -> we already ran on this truth muon, exiting");
330 truthmu->
auxdecor<
bool>(
"hasTruthMuonPartonHistoryInfo")=
true;
336 if(
verbose)
ATH_MSG_INFO(
"getTruthMuonPartonHistory:: -> no muon mother available, returning");
342 if(
verbose)
ATH_MSG_INFO(
"getTruthMuonPartonHistory:: -> muon from light hadron, will not fill info");
351 if(
p->isTop())
return 0;
352 if(
p->isHiggs())
return 10;
353 if(
p->isBSM())
return 15;
354 if(
p->isW() ||
p->isZ())
return 20;
355 if(
p->isPhoton())
return 25;
359 if(truthmu_mother->isTop())
366 else if(truthmu_mother->isHiggs())
371 else if(truthmu_mother->isBSM())
376 else if(truthmu_mother->isW() || truthmu_mother->isZ() || truthmu_mother->isPhoton() )
387 unsigned int bosonOrigin_priority=999;
389 if(initialStateBoson)
396 unsigned int parent_priority=get_priority(
parent);
397 if(parent_priority<bosonOrigin_priority)
399 bosonOrigin_priority=parent_priority;
404 if(bosonOrigin && bosonOrigin->
isTop())
412 else if(bosonOrigin && bosonOrigin->
isHiggs())
418 else if(bosonOrigin && bosonOrigin->
isBSM())
426 if(
verbose)
ATH_MSG_INFO(
"getTruthMuonPartonHistory:: -> muon from boson not from top or higgs");
430 else if(truthmu_Bmother || truthmu_Cmother)
434 bool isBHadronMother=truthmu_Bmother;
435 const xAOD::TruthParticle* hadronMother= isBHadronMother ? truthmu_Bmother : truthmu_Cmother;
440 ATH_MSG_INFO(
"getTruthMuonPartonHistory:: isBHadronmother="<<isBHadronMother<<
" Bmom="<<truthmu_Bmother<<
" Cmom="<<truthmu_Cmother<<
" hadMom="<<hadronMother<<
" firstHadMom="<<firstHadronMother);
441 ATH_MSG_INFO(
"getTruthMuonPartonHistory:: -> muon from hadron pdgId="<<(hadronMother ? hadronMother->
pdgId() : 0)<<
", first hadron in chain pdgId="<<(firstHadronMother ? firstHadronMother->
pdgId() : 0));
443 if(firstHadronMother)
482 unsigned int parton_ancestor_priority=999;
484 if(initial_hf_parton_parent)
486 for(
unsigned int ip=0;
ip<initial_hf_parton_parent->nParents();
ip++)
490 if(!parton_ancestor) parton_ancestor=
parent;
494 if(
priority < parton_ancestor_priority)
504 if(parton_ancestor && parton_ancestor->
isTop())
512 else if(parton_ancestor && parton_ancestor->
isHiggs())
517 else if(parton_ancestor && parton_ancestor->
isBSM())
522 else if(parton_ancestor && (parton_ancestor->
isW() || parton_ancestor->
isZ() || parton_ancestor->
isPhoton()))
531 unsigned int bosonOrigin_priority=999;
533 if(first_bosonMotherOfHfQuark)
535 for(
unsigned int ip=0;
ip<first_bosonMotherOfHfQuark->
nParents();
ip++)
547 if(bosonOrigin && bosonOrigin->
isTop())
549 if(
verbose)
ATH_MSG_INFO(
"getTruthMuonPartonHistory:: -> muon from HF from boson from top");
555 else if(bosonOrigin && bosonOrigin->
isHiggs())
557 if(
verbose)
ATH_MSG_INFO(
"getTruthMuonPartonHistory:: -> muon from HF from boson from higgs");
561 else if(bosonOrigin && bosonOrigin->
isBSM())
563 if(
verbose)
ATH_MSG_INFO(
"getTruthMuonPartonHistory:: -> muon from HF from boson from BSM");
580 if(
verbose)
ATH_MSG_INFO(
"getTruthMuonHistory::------> LepPartonOriginFlag="<<
static_cast<int>(lepPartonOriginFlag));
594 bool hasBHadronParent=
false;
599 if(
parent->isBottomHadron())
601 hasBHadronParent=
true;
623 throw std::runtime_error(
"getTruthMuonFromTauHistory called with a non-tau particle ID");
636 if(!tauMother->
isLepton()) truthmu_firstNonLeptonMother=tauMother;
654 if(tauMother->
isBSM())
660 truthmu_Bmother=tauMother;
665 truthmu_Cmother=tauMother;
668 bool hasBHadronParent=
false;
674 if(
parent->isBottomHadron())
676 hasBHadronParent=
true;
694 if(!truthParticle)
return 0;
700 if(
verbose)
ATH_MSG_INFO(
"getFirstHFHadronOfSameFlavour:: this can be called only on HF hadrons...");
707 if((niterations++)>100)
709 if(
verbose)
ATH_MSG_INFO(
"getFirstHFHadronOfSameFlavour:: too many iterations on particle "<<(truthParticle->
pdgId()));
716 if(
verbose)
ATH_MSG_INFO(
"getFirstHFHadronOfSameFlavour:: initial state particle not found");
722 bool hasSameFlavourParent=
false;
730 hasSameFlavourParent=
true;
736 if(!hasSameFlavourParent)
754 if(!truthParticle)
return 0;
761 if((niterations++)>100)
767 bool hasParentWithSamePdgId=
false;
773 hasParentWithSamePdgId=
true;
777 if(!hasParentWithSamePdgId)
break;
785 const std::string&
prefix ) {
787 if (!truthPart || !truthPart->
prodVtx()) {
788 os <<
prefix <<
"[" << (truthPart ? truthPart->
pdgId() :0x0) <<
" <- NULL]" <<
'\n';
796 if((niterations++)>30)
798 os<<
" STOP! too many iterations ";
812 if(!truthPart->
parent(
ip))
continue;
816 firstWithSamePdgId = truthPart->
parent(
ip);
820 firstNonParton = truthPart->
parent(
ip);
824 firstCorrectFlavorQuark = truthPart->
parent(
ip);
828 firstCorrectFlavorQuark = truthPart->
parent(
ip);
832 if(firstWithSamePdgId) truthPart=firstWithSamePdgId;
833 else if(firstNonParton) truthPart=firstNonParton;
834 else if(firstCorrectFlavorQuark) truthPart=firstCorrectFlavorQuark;
835 else truthPart=truthPart->
parent(0);
842 const std::vector<int>& parentPDGIds,
860 for (std::size_t motherIndex = 0;
861 motherIndex < numIncoming;
864 int motherPdgId = truthParticle->
pdgId();
870 while (truthParticle->
pdgId() == motherPdgId) {
873 motherPdgId = mother->
pdgId();
878 if (truthParticle->
pdgId() != motherPdgId) {
887 if (prevProdVtx == mother->
prodVtx()) {
892 prevProdVtx = prodVtx;
909 if (
std::find(parentPDGIds.begin(), parentPDGIds.end(), motherPdgId) != parentPDGIds.end()) {
915 if (!bOnlyDirect &&
isFrom(mother, parentPDGIds, bOnlyDirect)) {
943 for (std::size_t motherIndex = 0;
944 motherIndex < numIncoming;
947 int motherAbsPdgId = truthParticle->
absPdgId();
953 while (truthParticle->
absPdgId() == motherAbsPdgId) {
956 motherAbsPdgId = mother->
absPdgId();
961 if (truthParticle->
absPdgId() != motherAbsPdgId) {
970 if (prevProdVtx == mother->
prodVtx()) {
975 prevProdVtx = prodVtx;
994 if (motherAbsPdgId == 23 || motherAbsPdgId == 24) {
1050 return isFrom(truthParticle, {15, -15},
true);
1055 bool bTauIsHadron ) {
1077 for (std::size_t motherIndex = 0;
1078 motherIndex < numIncoming;
1080 int motherPdgId = truthParticle->
pdgId();
1087 while (truthParticle->
pdgId() == motherPdgId) {
1090 motherPdgId = mother->
pdgId();
1100 if (prevProdVtx == mother->
prodVtx()) {
1105 prevProdVtx = prodVtx;
1125 (bTauIsHadron &&
MC::isTau(motherPdgId)))) {
1131 if (!bOnlyDirect && !
isNotFromHadron(mother, bOnlyDirect, bTauIsHadron)) {
@ FromAntiTopViaLeptonicBoson
tipically means that the muon is coming from tbar->W->...->muon in some way (or any tbar->W/Z/gamma*...
bool isNotFromHadron(const xAOD::TruthParticle *truthParticle, bool bOnlyDirect, bool bTauIsHadron)
Check whether a given truth particle is not produced in the decay of physical hadrons or their descen...
const TruthParticle_v1 * parent(size_t i=0) const
Retrieve the i-th mother (TruthParticle) of this TruthParticle.
@ Unknown
BSMparticle->tau->muon.
@ FromAntiTopViaQuarkToHF
tipically means that the muon is coming from tbar->bbar->...->muon in some way (or any tbar->qbar->....
int absPdgId() const
Absolute PDG ID code (often useful)
const xAOD::TruthParticle * getFirstHFHadronOfSameFlavour(const xAOD::TruthParticle *truthParticle, bool verbose)
@ FromAntiTopViaHadronicBosonToHF
tipically means that the muon is coming from tbar->W->...->muon in some way (or any tbar->W/Z/gamma*...
TopConfig A simple configuration that is NOT a singleton.
bool isFrom(const xAOD::TruthParticle *truthParticle, const std::vector< int > &parentPDGIds, bool bOnlyDirect)
Function to determine whether the input particle was produced in the physical decay of a particle of ...
@ FromBtoTau
from B-hadron to tau to mu decay
@ FromLeptonicW
from W with leptonic decay (note: this will not work for Sherpa)
std::string find(const std::string &s)
return a remapped string
void copyCommonMuonHistoryInfo(const xAOD::IParticle *m_origin, const xAOD::IParticle *m_target)
@ FromHiggs
H->HF->muon, not sure if this can happen in some generators.
LepParticleOriginFlag
this enum defines a flag used to understand the particle origin of a lepton (tipically a soft muon),...
const xAOD::TruthParticle * getTruthMuonAssociatedToRecoMuon(const xAOD::Muon *muon)
bool isCharmHadron() const
Determine if the PID is that of a c-hadron.
Helper class to provide type-safe access to aux data.
@ FromLeptonicZToTau
from Z->tau->lep (note: this will not work for Sherpa)
@ MissingTruthInfo
e.g. this can mean the muon is coming from light hadrons and there is no truth history,...
@ FromHiggsViaHadronicBosonToHF
H->VV->muon.
@ FromTopViaLeptonicBoson
tipically means that the muon is coming from t->W->...->muon in some way (or any t->W/Z/gamma*/H->....
bool isW() const
Check if this particle is a W boson.
top::LepParticleOriginFlag getTruthMuonFromCharmHistory(const xAOD::TruthParticle *&truthmu_Bmother, const xAOD::TruthParticle *truthmu_Cmother, bool verbose)
@ FromLightHadron
often these muons are Unknown, but in some cases we have the truth record and we can verify they are ...
Class providing the definition of the 4-vector interface.
const TPLinks_t & outgoingParticleLinks() const
Get all the outgoing particles.
bool isBSM() const
Check if this is a BSM particle.
Decorator< T, ALLOC >::reference_type auxdecor(const std::string &name) const
Fetch an aux decoration, as a non-const reference.
bool isBottomHadron(const T &p)
@ FromTopViaHadronicBosonToHF
tipically means that the muon is coming from t->W->...->muon in some way (or any t->W/Z/gamma*/H->....
bool isSMLepton(const T &p)
bool isParton() const
Check if this particle is a parton.
bool isZ() const
Check if this particle is a Z boson.
top::LepParticleOriginFlag getTruthMuonFromTauHistory(const xAOD::TruthParticle *tau, const xAOD::TruthParticle *&truthmu_Bmother, const xAOD::TruthParticle *&truthmu_Cmother, const xAOD::TruthParticle *&truthmu_firstNonLeptonMother, bool verbose)
@ FromTau
from Tau leptonic (not coming from W or HF-hadron, so not sure this can really happen)
bool isLepton() const
Whether the particle is a lepton.
@ FromHiggsViaLeptonicBosonToHF
@ FromTopViaQuarkToHF
tipically means that the muon is coming from t->b->...->muon in some way (or any t->q->....
size_t nParents() const
Number of parents of this particle.
void initTruthMuonHistoryInfo(const xAOD::TruthParticle *truthmu, bool doPartonHistory)
bool isBottom(const T &p)
Class describing a truth particle in the MC record.
void initRecoMuonHistoryInfo(const xAOD::Muon *muon, bool doPartonHistory)
@ FromLeptonicBoson
general case of W/Z/gamma*/H->muon or W/Z/gamma*/H->tau->muon
@ MissingTruthInfo
no associated truth muon tipically this happens for muon from light-hadrons
bool hasProdVtx() const
Check for a production vertex on this particle.
@ Unknown
BSMparticle->HF->muon.
@ FromCtoTau
from C-hadron (with no B-hadron parent) to tau to mu decay
void getTruthMuonHistory(const xAOD::TruthParticle *truthmu, bool doPartonHistory, SampleXsection::showering shAlgo, bool verbose)
@ FromBtoC
from B-hadron to C-hadron to muon decay
@ FromBtoCtoTau
from B-hadron to C-hadron to tau to muon decay
bool isTau() const
Whether the particle is a tau (or antitau)
const TruthParticle_v1 * incomingParticle(size_t index) const
Get one of the incoming particles.
void getRecoMuonHistory(const xAOD::Muon *muon, bool doPartonHistory, SampleXsection::showering shAlgo, bool verbose)
const xAOD::TruthParticle * getInitialStateParticle(const xAOD::TruthParticle *truthParticle, bool verbose)
bool isBottomHadron() const
Determine if the PID is that of a b-hadron.
const TruthVertex_v1 * prodVtx() const
The production vertex of this particle.
bool isLightHadron() const
Determine if the PID is that of a light flavour (not b or c) hadron.
Class describing a truth vertex in the MC record.
@ FromBSMToHF
BSMparticle->V->HF->muon.
void initCommonMuonHistoryInfo(const xAOD::IParticle *muon, bool doPartonHistory)
const xAOD::TruthParticle * getTruthParticle(const xAOD::IParticle &p)
Return the truthParticle associated to the given IParticle (if any)
bool isHadron(const T &p)
@ FromHiggsToHF
H->VV->HF->muon.
bool isAvailable(const std::string &name, const std::string &clsname="") const
Check if a user property is available for reading or not.
@ FromLeptonicWToTau
from W->tau->lep (note: this will not work for Sherpa)
bool isLeptonFromTau(const xAOD::TruthParticle *truthParticle)
Function the check if a particle is a lepton which was produced in the decay of a tau lepton.
bool isPhoton() const
Whether the particle is a photon.
@ FromPhotonToTau
gamma*->muonmuon
bool isHiggs() const
Check if this particle is a Higgs boson.
@ FromBSMViaHadronicBosonToHF
BSMparticle->V->muon.
#define ATH_MSG_WARNING(x)
size_t nIncomingParticles() const
Get the number of incoming particles.
bool isDecayed(const T &p)
@ FromLeptonicZ
gamma*->tautau and tau->muon
bool isMuon() const
Whether the particle is a muon (or antimuon)
@ FromBSMToTau
BSMparticle->muon.
bool isCharmHadron(const T &p)
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
@ FromHFHadronOfUnkownOrigin
HF hadron->muon or HF hadron->tau->muon, we're not sure where the HF hadron is coming from (maybe a g...
void getTruthMuonPartonHistory(const xAOD::TruthParticle *truthmu, top::LepParticleOriginFlag lepParticleOriginFlag, const xAOD::TruthParticle *truthmu_Bmother, const xAOD::TruthParticle *truthmu_Cmother, const xAOD::TruthParticle *truthmu_firstNonLeptonMother, SampleXsection::showering shAlgo, bool verbose)
bool isFromWZDecay(const xAOD::TruthParticle *truthParticle, bool bOnlyDirect)
Function to determine whether a given truth particle is a result of a decay chain that started in the...
Class describing a TrackParticle.
@ FromHadronicBosonToHF
general case of W/Z/gamma*/H->HF hadrons->muon
@ FromC
from direct C-hadron (with no B-hadron parent) decay
@ FromBSMViaLeptonicBosonToHF
BSMparticle->muon.
int pdgId() const
PDG ID code.
void printDecayChain(const xAOD::TruthParticle *truthPart, std::ostream &os, const std::string &prefix)
Prints the decay chain leading up to a certain particle to a std::ostream.
LepPartonOriginFlag
this enum defines a flag used to understand the partonic origin of a lepton (tipically a soft muon),...
void copyTruthMuonHistoryInfo(const xAOD::TruthParticle *tm_origin, const xAOD::TruthParticle *tm_target)
@ FromHiggsToTau
Higgs->muon.
Base class for elements of a container that can have aux data.
bool isTop() const
Check if this particle is a top quark.
void copyRecoMuonHistoryInfo(const xAOD::Muon *m_origin, const xAOD::Muon *m_target)