|  | ATLAS Offline Software
    | 
 
 
 
Go to the documentation of this file.
    5 #ifndef ACTSTRK_TRACKTRUTHMATCHINGBASEALG_H 
    6 #define ACTSTRK_TRACKTRUTHMATCHINGBASEALG_H 1 
   12 #include "Gaudi/Property.h" 
   31 #include <type_traits> 
   46      template <
bool DetailEnabled>
 
   49      template <
bool DetailEnabled>
 
   54                                ISvcLocator *pSvcLocator);
 
   62         if (!truth_particle_hit_counts_handle.
isValid()) {
 
   64            std::runtime_error(
"Failed to get truth particle hit count map");
 
   66         return *truth_particle_hit_counts_handle;
 
   72         return m_detailedStat.perEtaSize();
 
   75         return m_detailedStat.perPdgIdSize();
 
   78      template <
bool DetailEnabled>
 
   80         static constexpr 
bool doDetail = DetailEnabled;
 
   83                   std::size_t per_eta_size,
 
   84                   std::size_t per_pdg_size,
 
   85                   [[maybe_unused]] std::size_t track_to_truth_size)
 
   86            : 
BaseStat<DetailEnabled>(truth_selection_tool, per_eta_size, per_pdg_size),
 
   89            if constexpr(DetailEnabled) {
 
   94         void fill([[maybe_unused]] 
unsigned int eta_category_i,
 
   95                   [[maybe_unused]] 
unsigned int pdg_id_category_i,
 
   96                   [[maybe_unused]] 
float hit_efficiency,
 
   97                   [[maybe_unused]] 
float hit_purity,
 
   98                   [[maybe_unused]] 
float match_prob,
 
  105            if constexpr(DetailEnabled) {
 
  118                                                    std::unordered_set<const xAOD::TruthParticle *>,
 
  148                                std::size_t n_tracks,
 
  153         {
this, 
"TruthParticleHitCounts",
"", 
"Map from truth particle to hit counts." };
 
  156         {
this, 
"MatchWeights", {}, 
"Weights applied to the counts per measurement type for weighted sums" 
  157                                   " which are used compute the match probability." };
 
  159         {
this, 
"CountWeights", {}, 
"Weights applied to the counts per measurement type for weighted sums" 
  160                                    " which are used to compute hit efficiencies and purities." };
 
  163      template <
class Base>
 
  165         template <
class OWNER>
 
  171         std::size_t 
size()
 const {
return 0
u; }
 
  173         auto operator[](std::size_t ) { 
throw std::out_of_range(
"DummyProperty");}
 
  176         template <
class... 
Args>
 
  177         decltype( std::declval<Base>()( std::declval<Args&&>()... ) ) operator()( 
Args&&... 
args ) 
const 
  178            noexcept( noexcept( std::declval<
Base>()( std::declval<
Args&&>()... ) ) ) {
 
  179            return value()( std::forward<Args>( 
args )... );
 
  183      template <
class Base>
 
  187         {
this, 
"StatisticEtaBins", {-4, -2.6, -2, 0, 2., 2.6, 4}, 
"Gather statistics separately for these eta bins."};
 
  189         {
this, 
"StatisticPtBins", {1.e3,2.5e3,10
e3, 100
e3}, 
"Gather statistics separately for these pt bins."};
 
  191         {
this, 
"PdgIdCategorisation", 
false, 
"Categorise by pdg id."};
 
  193         {
this, 
"ShowRawCounts", 
false, 
"Show all counters."};
 
  195         {
this, 
"ShowDetailedTables", 
false, 
"Show more details; stat. uncert., RMS, entries"};
 
  197         {
this, 
"ComputeTrackRecoEfficiency", 
true, 
"Compute and print track reconstruction efficiency."};
 
  199     ToolHandle<IAthSelectionTool> 
m_truthSelectionTool{
this, 
"TruthSelectionTool",
"AthTruthSelectionTool", 
"Truth selection tool (for efficiencies and resolutions)"};
 
  203      template <
bool IsDebug>
 
  206            template <
typename... T_Args>
 
  209         mutable typename std::conditional<
IsDebug,
 
  212         mutable typename std::conditional<
IsDebug,
 
  215         mutable typename std::conditional<
IsDebug,
 
  218         mutable typename std::conditional<
IsDebug,
 
  222         template <
class T_OutStream>
 
  262      template <
bool DetailEnabled>
 
  266                     [[maybe_unused]] std::size_t per_eta_size,
 
  267                     [[maybe_unused]] std::size_t per_pdg_size)
 
  270            if constexpr(DetailEnabled) {
 
  279                    [[maybe_unused]] std::size_t per_eta_size,
 
  280                    [[maybe_unused]] std::size_t per_pdg_size)
 
  283            if constexpr(DetailEnabled) {
 
  294         void fill([[maybe_unused]] 
unsigned int eta_category_i,
 
  295                   [[maybe_unused]] 
unsigned int pdg_id_category_i,
 
  296                   [[maybe_unused]] 
float hit_efficiency,
 
  297                   [[maybe_unused]] 
float hit_purity,
 
  298                   [[maybe_unused]] 
float match_prob) {
 
  315                             [[maybe_unused]] 
unsigned int pdg_id_category_i) {
 
  316            if constexpr(DetailEnabled) {
 
  325                              const std::vector<float> &statPtBins,
 
  326                              const std::vector<float> &statEtaBins,
 
  327                              std::vector< int > &
pdgId,
 
  329                              bool pdgIdCategorisation,
 
  330                              bool useAbsEtaForStat);
 
  345                                                   std::vector< std::array< std::size_t, kNCategorisedCounter> >,
 
  348                                                std::vector< std::array<ActsUtils::Stat, kNCategorisedStat> >,
 
  365      void checkBinOrder( 
const std::vector<float> &bin_edges, 
const std::string &bin_label) 
const;
 
  380      void printCategories(
const std::vector<std::string> &pt_category_labels,
 
  381                           const std::vector<std::string> &eta_category_labels,
 
  382                           std::vector<std::string> &counter_labels,
 
  383                           std::vector< std::array< ActsUtils::Stat, kNCategorisedStat> > &stat_per_category,
 
  384                           std::vector< std::array< std::size_t, kNCategorisedCounter> >  &counts_per_category,
 
  385                           const std::string &top_left_label,
 
  386                           bool print_sub_categories) 
const;
 
  387      void printData2D(
const std::vector<std::string> &row_category_labels,
 
  388                       const std::vector<std::string> &col_category_labels,
 
  389                       const std::string &top_left_label,
 
  390                       std::vector< std::array< ActsUtils::Stat, kNCategorisedStat> > &stat_per_category,
 
  391                       std::vector< std::array< std::size_t, kNCategorisedCounter> >  &counts_per_category,
 
  397                                      const std::vector<float> &
weights);
 
  399                                     const std::vector<float> &
weights);
 
  
Property holding a SG store/key/clid from which a ReadHandle is made.
void postProcessEventStat(const TruthParticleHitCounts &truth_particle_hit_counts, std::size_t n_tracks, EventStat &event_stat) const
unsigned int m_nTruthCuts
@ kNParticleWithMultipleAssociatedTracks
std::size_t perEtaSize() const
void fill([[maybe_unused]] unsigned int eta_category_i, [[maybe_unused]] unsigned int pdg_id_category_i, [[maybe_unused]] float hit_efficiency, [[maybe_unused]] float hit_purity, [[maybe_unused]] float match_prob)
Match result returned by analyseTrackTruth.
void rotate(double angler, GeoTrf::Vector2D &vector)
Gaudi::Property< std::vector< float > > m_weightsForProb
Container for hit counts per track Contains hit counts per associated truth particle and the total hi...
std::conditional< DetailEnabled, std::unordered_set< const xAOD::TruthParticle * >, typename BaseStat< DetailEnabled >::Empty >::type TruthParticleSet
std::vector< int > m_pdgId ATLAS_THREAD_SAFE
BaseStat< DetailEnabled > & operator+=(const BaseStat< DetailEnabled > &event_stat)
Scalar eta() const
pseudorapidity method
unsigned int m_nTracksWithoutAssociatedTruthParticle
void printData2D(const std::vector< std::string > &row_category_labels, const std::vector< std::string > &col_category_labels, const std::string &top_left_label, std::vector< std::array< ActsUtils::Stat, kNCategorisedStat > > &stat_per_category, std::vector< std::array< std::size_t, kNCategorisedCounter > > &counts_per_category, bool rotate) const
virtual StatusCode initialize() override
auto operator[](std::size_t)
Property< bool > m_printDetails
Extend Stat helper by an equidistant binned histogram.
EventStatBase(const IAthSelectionTool &truth_selection_tool, std::size_t per_eta_size, std::size_t per_pdg_size, [[maybe_unused]] std::size_t track_to_truth_size)
const std::string & key() const
Return the StoreGate ID for the referenced object.
bool const RAWDATA *ch2 const
std::conditional< DetailEnabled, std::vector< std::array< ActsUtils::Stat, kNCategorisedStat > >, Empty >::type StatArrayVec
const IAthSelectionTool & truthSelectionTool() const
Support class for PropertyMgr.
@ u
Enums for curvilinear frames.
ActsUtils::StatHist m_truthSelectionCuts
An algorithm that can be simultaneously executed in multiple threads.
float m_hitEfficiency
fraction of hits originting from best match over total best match hits
static double weightedCountSum(const ActsTrk::HitCounterArray &counts, const std::vector< float > &weights)
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
std::size_t getPtPdgIdStatCategory(float pt, int pdg_id) const
Return the category based on the PDG ID.
void fillTruthMatchProb(const std::array< float, 2 > &best_match_prob) const
@ NoAssociatedTruthParticle
void fill([[maybe_unused]] unsigned int eta_category_i, [[maybe_unused]] unsigned int pdg_id_category_i, [[maybe_unused]] float hit_efficiency, [[maybe_unused]] float hit_purity, [[maybe_unused]] float match_prob, [[maybe_unused]] const xAOD::TruthParticle *best_match)
unsigned int m_nTruthParticleWithoutAssociatedCounts
Property< std::vector< float > > m_statEtaBins
void printStatTables() const
constexpr static unsigned int s_NMeasurementTypes
void reset(const IAthSelectionTool &truth_selection_tool, [[maybe_unused]] std::size_t per_eta_size, [[maybe_unused]] std::size_t per_pdg_size)
::StatusCode StatusCode
StatusCode definition for legacy code.
Class describing a truth particle in the MC record.
TruthParticleSet m_truthParticlesWithAssociatedTrack
std::size_t getPtEtaStatCategory(float pt, float eta) const
Return the category based on the provided eta value.
@ TruthParticleNoNoiseMismatch
void checkBinOrder(const std::vector< float > &bin_edges, const std::string &bin_label) const
check that bins are in increasing order.
CounterArrayVec m_counterPerPdgId
Property< std::vector< float > > m_statPtBins
unsigned int m_nTruthParticleNonoiseMismatches
void fillMeasForTruthParticleWithoutCount(double weighted_measurement_sum) const
virtual bool isValid() override final
Can the handle be successfully dereferenced?
Property holding a SG store/key/clid from which a WriteHandle is made.
std::size_t perEtaSize() const
Property< bool > m_computeTrackRecoEfficiency
constexpr bool TrackFindingValidationDebugHists
float m_hitPurity
fraction of hits originting from best match over total reco hits
DummyProperty(OWNER *, std::string, Base &&, std::string)
unsigned int m_nTracksWithoutSelectedTruthParticle
StatusCode checkMatchWeights()
std::unordered_map< const xAOD::TruthParticle *, HitCounterArray > TruthParticleHitCounts
void printStatTables(const TrackTruthMatchingBaseAlg &parent, const std::vector< float > &statPtBins, const std::vector< float > &statEtaBins, std::vector< int > &pdgId, bool printDetails, bool pdgIdCategorisation, bool useAbsEtaForStat)
@ kNParticleWithAssociatedTrack
constexpr bool TrackFindingValidationDetailedStat
constexpr static int s_pdgIdMax
StatArrayVec m_statPerPdgId
void setBinning(unsigned int n_bins, float xmin, float xmax)
Define histogramm bins and enable histogramming.
ToolHandle< IAthSelectionTool > m_truthSelectionTool
Property< bool > m_showRawCounts
@ MissingTruthParticleHitCounts
static constexpr bool doDetail
TrackTruthMatchingBaseAlg(const std::string &name, ISvcLocator *pSvcLocator)
std::size_t perPdgIdSize() const
void printCategories(const std::vector< std::string > &pt_category_labels, const std::vector< std::string > &eta_category_labels, std::vector< std::string > &counter_labels, std::vector< std::array< ActsUtils::Stat, kNCategorisedStat > > &stat_per_category, std::vector< std::array< std::size_t, kNCategorisedCounter > > &counts_per_category, const std::string &top_left_label, bool print_sub_categories) const
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
std::conditional< DetailEnabled, std::vector< std::array< std::size_t, kNCategorisedCounter > >, Empty >::type CounterArrayVec
SG::ReadHandleKey< TruthParticleHitCounts > m_truthHitCounts
std::mutex m_statMutex ATLAS_THREAD_SAFE
Gaudi::Property< std::vector< float > > m_weights
DebugCounter< TrackFindingValidationDebugHists > m_debugCounter
TruthMatchResult analyseTrackTruth(const TruthParticleHitCounts &truth_particle_hit_counts, const HitCountsPerTrack &track_hit_counts, EventStat &event_stat) const
static double noiseCorrection(const ActsTrk::HitCounterArray &noise_counts, const std::vector< float > &weights)
CounterArrayVec m_counterPerEta
void dumpStatistics(T_OutStream &out) const
StatArrayVec m_statPerEta
BaseStat([[maybe_unused]] const IAthSelectionTool &truth_selection_tool, [[maybe_unused]] std::size_t per_eta_size, [[maybe_unused]] std::size_t per_pdg_size)
float m_matchProbability
the matching probability based on weighted hit sums
@ NoSelectedTruthParticle
BaseStat< TrackFindingValidationDetailedStat > m_detailedStat ATLAS_THREAD_SAFE
const xAOD::TruthParticle * m_truthParticle
best matching truth particle or nullptr
std::conditional< IsDebug, std::mutex, Empty >::type m_mutex ATLAS_THREAD_SAFE
const TruthParticleHitCounts & getTruthParticleHitCounts(const EventContext &ctx) const
void incrementTotal([[maybe_unused]] unsigned int eta_category_i, [[maybe_unused]] unsigned int pdg_id_category_i)
std::size_t perPdgIdSize() const
Property< bool > m_pdgIdCategorisation
virtual StatusCode finalize() override