9#include <unordered_map>
25 float_decor_names[
kHitPurity]=
"truthHitPurity";
53 std::unordered_map<const ActsTrk::TrackContainerBase *, const ActsTrk::TrackToTruthParticleAssociation *> truth_association_map;
57 if (!track_to_truth_handle.
isValid()) {
58 ATH_MSG_ERROR(
"No track to truth particle association for key " << truth_association_key.key() );
59 return StatusCode::FAILURE;
61 truth_association_map.insert(std::make_pair( track_to_truth_handle->sourceContainer(), track_to_truth_handle.
cptr() ));
65 if (!track_particle_handle.
isValid()) {
66 ATH_MSG_ERROR(
"No track particle container for key " << track_particle_handle.
key() );
67 return StatusCode::FAILURE;
69 std::vector< SG::WriteDecorHandle<xAOD::TrackParticleContainer,float > >
71 std::vector< SG::WriteDecorHandle<xAOD::TrackParticleContainer,int > >
79 track_particle_handle->size());
81 std::pair<const ActsTrk::TrackContainerBase *, const ActsTrk::TrackToTruthParticleAssociation *>
82 the_track_truth_association{
nullptr,
nullptr};
88 unsigned int classification = 0;
91 std::optional<ActsTrk::TrackContainer::ConstTrackProxy> optional_track =
getActsTrack(*track_particle);
92 if (optional_track.has_value()) {
94 if (track_container != the_track_truth_association.first && track_container ) {
95 std::unordered_map<const ActsTrk::TrackContainerBase *, const ActsTrk::TrackToTruthParticleAssociation *>::const_iterator
96 truth_association_map_iter = truth_association_map.find( track_container );
97 if (truth_association_map_iter != truth_association_map.end()) {
98 the_track_truth_association = *truth_association_map_iter;
101 if (the_track_truth_association.second) {
103 (*the_track_truth_association.second).at(optional_track.value().index()),
109 if (truth_particle) {
110 if (!ref_truth_link.
isValid()) {
113 if (!truth_particle_container) {
114 ATH_MSG_ERROR(
"Valid truth particle not part of a xAOD::TruthParticleContainer");
124 type = truthClass.first;
125 origin = truthClass.second;
139 truthClass_decor(*track_particle) = classification;
142 track_particle_handle->size(),
144 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
virtual StatusCode execute(const EventContext &ctx) const override
SG::ReadHandleKeyArray< TrackToTruthParticleAssociation > m_trackToTruth
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_trkParticleName
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_truthClassDecor
std::vector< SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > > m_floatDecor
virtual StatusCode finalize() override
virtual StatusCode initialize() override
std::vector< SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > > m_intDecor
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_linkDecor
ToolHandle< IMCTruthClassifier > m_truthClassifier
const IAthSelectionTool & truthSelectionTool() const
std::size_t perEtaSize() const
TruthMatchResult analyseTrackTruth(const TruthParticleHitCounts &truth_particle_hit_counts, const HitCountsPerTrack &track_hit_counts, EventStat &event_stat) const
const TruthParticleHitCounts & getTruthParticleHitCounts(const EventContext &ctx) const
EventStatBase< TrackFindingValidationDetailedStat > EventStat
std::size_t perPdgIdSize() const
void postProcessEventStat(const TruthParticleHitCounts &truth_particle_hit_counts, std::size_t n_tracks, EventStat &event_stat) const
virtual StatusCode initialize() override
virtual StatusCode finalize() override
ElementLink implementation for ROOT usage.
BaseConstPointer getStorableObjectPointer() const
Retrieve storable object pointer.
bool isValid() const
Check if the element can be found.
Property holding a SG store/key/clid from which a ReadHandle is made.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
virtual const std::string & key() const override final
Return the StoreGate ID for the referenced object.
Handle class for adding a decoration to an object.
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
std::unordered_map< const xAOD::TruthParticle *, HitCounterArray > TruthParticleHitCounts
void createDecoratorKeys(T_Parent &parent, const SG::ReadHandleKey< T_Cont > &container_key, const std::string &prefix, const std::vector< std::string > &decor_names, std::vector< SG::WriteDecorHandleKey< T_Cont > > &decor_out)
Acts::TrackContainer< TrackBackend, TrackStateBackend, Acts::detail::ValueHolder > TrackContainerBase
std::vector< SG::WriteDecorHandle< T_Cont, T > > createDecorators(const std::vector< SG::WriteDecorHandleKey< T_Cont > > &keys, const EventContext &ctx)
std::optional< ActsTrk::TrackContainer::ConstTrackProxy > getActsTrack(const xAOD::TrackParticle &trkPart)
Return the proxy to the Acts track from which the track particle was made frome.
std::tuple< unsigned int, T > defOrigOfParticle(T thePart)
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
TrackParticle_v1 TrackParticle
Reference the current persistent version:
TruthParticle_v1 TruthParticle
Typedef to implementation.
TruthParticleContainer_v1 TruthParticleContainer
Declare the latest version of the truth particle container.
Match result returned by analyseTrackTruth.
float m_hitPurity
fraction of hits originting from best match over total reco hits
float m_matchProbability
the matching probability based on weighted hit sums
float m_hitEfficiency
fraction of hits originting from best match over total best match hits
const xAOD::TruthParticle * m_truthParticle
best matching truth particle or nullptr