9#include <unordered_map>
23 float_decor_names[
kHitPurity]=
"truthHitPurity";
27 std::vector<std::string> link_decor_names;
28 link_decor_names.push_back(
"truthParticleLink");
44 std::unordered_map<const ActsTrk::TrackContainerBase *, const ActsTrk::TrackToTruthParticleAssociation *> truth_association_map;
48 if (!track_to_truth_handle.
isValid()) {
49 ATH_MSG_ERROR(
"No track to truth particle association for key " << truth_association_key.key() );
50 return StatusCode::FAILURE;
52 truth_association_map.insert(std::make_pair( track_to_truth_handle->sourceContainer(), track_to_truth_handle.
cptr() ));
56 if (!track_particle_handle.
isValid()) {
57 ATH_MSG_ERROR(
"No track particle container for key " << track_particle_handle.
key() );
58 return StatusCode::FAILURE;
60 std::vector< SG::WriteDecorHandle<xAOD::TrackParticleContainer,float > >
68 track_particle_handle->size());
72 std::pair<const ActsTrk::TrackContainerBase *, const ActsTrk::TrackToTruthParticleAssociation *>
73 the_track_truth_association{
nullptr,
nullptr};
77 static_assert( std::is_same<ElementLink<ActsTrk::TrackContainer>::ElementConstReference,
78 std::optional<ActsTrk::TrackContainer::ConstTrackProxy> >::value);
82 std::optional<ActsTrk::TrackContainer::ConstTrackProxy> optional_track = *link_to_track;
83 if (optional_track.has_value()) {
85 if (track_container != the_track_truth_association.first && track_container ) {
86 std::unordered_map<const ActsTrk::TrackContainerBase *, const ActsTrk::TrackToTruthParticleAssociation *>::const_iterator
87 truth_association_map_iter = truth_association_map.find( track_container );
88 if (truth_association_map_iter != truth_association_map.end()) {
89 the_track_truth_association = *truth_association_map_iter;
92 if (the_track_truth_association.second) {
94 (*the_track_truth_association.second).at(optional_track.value().index()),
100 if (truth_particle) {
101 if (!ref_truth_link.
isValid()) {
104 if (!truth_particle_container) {
105 ATH_MSG_ERROR(
"Valid truth particle not part of a xAOD::TruthParticleContainer");
125 track_particle_handle->size(),
127 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
std::vector< SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > > m_linkDecor
virtual StatusCode execute(const EventContext &ctx) const override
SG::ReadHandleKeyArray< TrackToTruthParticleAssociation > m_trackToTruth
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_trkParticleName
std::vector< SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > > m_floatDecor
virtual StatusCode finalize() override
virtual StatusCode initialize() override
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
Return a pointer to the currently-referenced container object.
bool isValid() const
Test to see if the link can be dereferenced.
SG::ConstAccessor< T, ALLOC > ConstAccessor
const SG::AuxVectorData * container() const
Return the container holding this element.
size_t index() const
Return the index of this element within its container.
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...
Acts::TrackContainer< TrackBackend, TrackStateBackend, Acts::detail::ValueHolder > TrackContainerBase
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)
std::vector< SG::WriteDecorHandle< T_Cont, T > > createDecorators(const std::vector< SG::WriteDecorHandleKey< T_Cont > > &keys, const EventContext &ctx)
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