26 return StatusCode::SUCCESS;
36 ATH_CHECK(muonTruthContainer.
record(std::make_unique<xAOD::TruthParticleContainer>(),
37 std::make_unique<xAOD::TruthParticleAuxContainer>()));
47 xAOD::TruthParticle* truthParticle = muonTruthContainer->push_back(std::make_unique<xAOD::TruthParticle>());
48 truthParticle->
setPdgId(truth->pdgId());
50 truthParticle->
setStatus(truth->status());
51 truthParticle->
setPx(truth->px());
52 truthParticle->
setPy(truth->py());
53 truthParticle->
setPz(truth->pz());
54 truthParticle->
setE(truth->e());
55 truthParticle->
setM(truth->m());
56 if (truth->hasProdVtx()) truthParticle->
setProdVtxLink(truth->prodVtxLink());
58 TruthLink_t itruthLink(*truthContainer, truth->index());
60 truthLink(*truthParticle) = itruthLink;
61 ATH_MSG_DEBUG(
"Found stable muon: " << truth->pt() <<
" eta " << truth->eta() <<
" phi " << truth->phi() <<
" mass "
62 << truth->m() <<
" unique ID " <<
HepMC::uniqueID(truth) <<
" HepMC::uniqueID(truthParticle) "
65 int iType{0}, iOrigin{0};
70 std::pair<MCTruthPartClassifier::ParticleType, MCTruthPartClassifier::ParticleOrigin> truthClass =
72 iType = truthClass.first;
73 iOrigin = truthClass.second;
76 truthOrigin(*truthParticle) = iOrigin;
77 truthType(*truthParticle) = iType;
79 ATH_MSG_DEBUG(
"good muon with type " << iType <<
" and origin" << iOrigin);
82 ATH_MSG_DEBUG(
"Registered " << muonTruthContainer->size() <<
" truth muons ");
84 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
ATLAS-specific HepMC functions.
Handle class for adding a decoration to an object.
ElementLink< xAOD::TruthParticleContainer > TruthLink_t
ElementLink implementation for ROOT usage.
bool toPersistent()
Dummy function provinding the offline interface.
SG::WriteDecorHandleKey< xAOD::TruthParticleContainer > m_truthOriginKey
Gaudi::Property< float > m_pt
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
ToolHandle< IMCTruthClassifier > m_truthClassifier
SG::WriteDecorHandleKey< xAOD::TruthParticleContainer > m_truthLinkKey
virtual StatusCode execute(const EventContext &ctx) const override
Gaudi::Property< std::set< int > > m_pdgIds
SG::WriteHandleKey< xAOD::TruthParticleContainer > m_outTruthMuonKey
virtual StatusCode initialize() override
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_truthRecordKey
SG::WriteDecorHandleKey< xAOD::TruthParticleContainer > m_truthTypeKey
Handle class for adding a decoration to an object.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
void setPy(float value)
Set the y component of the particle's momentum.
void setUid(int value)
Set unique ID.
void setM(float value)
Also store the mass.
void setE(float value)
Set the energy of the particle.
void setPz(float value)
Set the z component of the particle's momentum.
void setStatus(int value)
Set status code.
void setPdgId(int pid)
Set PDG ID code.
void setPx(float value)
Set the x component of the particle's momentum.
void setProdVtxLink(const ElementLink< TruthVertexContainer > &link)
Set the production vertex of the particle.
bool isStable(const T &p)
Identify if the particle is stable, i.e. has not decayed.
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
TruthParticle_v1 TruthParticle
Typedef to implementation.
TruthParticleContainer_v1 TruthParticleContainer
Declare the latest version of the truth particle container.