39 return StatusCode::SUCCESS;
51 assert(truthPart !=
nullptr);
52 assert(truthMuon != truthPart);
53 ATH_CHECK(truthPartToMuonMap.insert(std::make_pair(truthPart, truthMuon)).second);
59 using enum xAOD::Muon::TrackParticleType;
61 Link_t& truthLink = truthLinkDecor(*muon);
65 if (idTrack !=
nullptr) {
67 truth = truthPartToMuonMap.insert(std::make_pair(truth, truth)).first->second;
68 truthLink = createLink(truth);
69 if (truth !=
nullptr ){
73 std::vector<std::pair<const xAOD::TruthParticle*, unsigned>> counts{};
74 for (
unsigned seg =0 ; seg < muon->nMuonSegments(); ++ seg) {
76 auto itr = std::ranges::find_if(counts, [truth](
const auto& known){
77 return known.first == truth;
79 if(itr != counts.end()) {
82 counts.emplace_back(std::make_pair(truth , 1));
88 const auto* truth = std::ranges::max_element(counts, [](
const auto&
a,
const auto& b){
89 return a.second < b.second;
91 truthLink = createLink(truth);
94 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
ElementLink< xAOD::TruthParticleContainer > Link_t
Handle class for reading from StoreGate.
Handle class for adding a decoration to an object.
ElementLink implementation for ROOT usage.
SG::ReadHandleKey< xAOD::MuonContainer > m_muonKey
the actual muon container that we want to decorate
SG::ReadHandleKeyArray< xAOD::TrackParticleContainer > m_trkKeys
Additional track container dependencies.
virtual StatusCode execute(const EventContext &ctx) const override final
virtual StatusCode initialize() override final
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_truthKey
Declare the dependency on the truth particle container.
SG::ReadHandleKey< xAOD::MuonSegmentContainer > m_segmentKey
Declare the dependency on the reconstructed segment container to establish the reco -> truth link fro...
SG::WriteDecorHandleKey< xAOD::MuonContainer > m_truthPartLinkKey
Explicitly declare the truth particle link decoration.
SG::ReadDecorHandleKeyArray< SG::AuxVectorBase > m_decorKeys
Collector of all the decoration dependencies what are implicitly needed.
Property holding a SG store/key/clid from which a ReadHandle is made.
Auxiliary class to instantiate WriteDecorHandles.The handles can be created in an empty state.
This header ties the generic definitions in this package.
const xAOD::TruthParticle * getTruthMatchedParticle(const xAOD::MuonSegment &segment)
Returns the particle truth-matched to the segment.
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
const xAOD::TruthParticle * getTruthParticle(const xAOD::IParticle &p)
Return the truthParticle associated to the given IParticle (if any).
TrackParticle_v1 TrackParticle
Reference the current persistent version:
TruthParticle_v1 TruthParticle
Typedef to implementation.
Muon_v1 Muon
Reference the current persistent version:
MuonContainer_v1 MuonContainer
Definition of the current "Muon container version".
TruthParticleContainer_v1 TruthParticleContainer
Declare the latest version of the truth particle container.