ATLAS Offline Software
Public Types | Public Member Functions | Public Attributes | Static Public Attributes | List of all members
ActsTrk::TrackTruthMatchingBaseAlg::EventStatBase< DetailEnabled > Struct Template Reference

#include <TrackTruthMatchingBaseAlg.h>

Inheritance diagram for ActsTrk::TrackTruthMatchingBaseAlg::EventStatBase< DetailEnabled >:
Collaboration diagram for ActsTrk::TrackTruthMatchingBaseAlg::EventStatBase< DetailEnabled >:

Public Types

using TruthParticleSet = std::conditional< DetailEnabled, std::unordered_set< const xAOD::TruthParticle * >, typename BaseStat< DetailEnabled >::Empty >::type
 
using CounterArrayVec = std::conditional< DetailEnabled, std::vector< std::array< std::size_t, kNCategorisedCounter > >, Empty >::type
 
using StatArrayVec = std::conditional< DetailEnabled, std::vector< std::array< ActsUtils::Stat, kNCategorisedStat > >, Empty >::type
 

Public Member Functions

 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)
 
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)
 
void reset (const IAthSelectionTool &truth_selection_tool, [[maybe_unused]] std::size_t per_eta_size, [[maybe_unused]] std::size_t per_pdg_size)
 
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)
 
void incrementTotal ([[maybe_unused]] unsigned int eta_category_i, [[maybe_unused]] unsigned int pdg_id_category_i)
 
BaseStat< DetailEnabled > & operator+= (const BaseStat< DetailEnabled > &event_stat)
 
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)
 
std::size_t perEtaSize () const
 
std::size_t perPdgIdSize () const
 

Public Attributes

TruthParticleSet m_truthParticlesWithAssociatedTrack
 
unsigned int m_nTruthParticleWithoutAssociatedCounts =0u
 
unsigned int m_nTracksWithoutAssociatedTruthParticle =0u
 
unsigned int m_nTracksWithoutSelectedTruthParticle =0u
 
unsigned int m_nTruthParticleNonoiseMismatches =0u
 
unsigned int m_nTruthCuts
 
ActsUtils::StatHist m_truthSelectionCuts
 
CounterArrayVec m_counterPerEta
 
CounterArrayVec m_counterPerPdgId
 
StatArrayVec m_statPerEta
 
StatArrayVec m_statPerPdgId
 

Static Public Attributes

static constexpr bool doDetail = DetailEnabled
 

Detailed Description

template<bool DetailEnabled>
struct ActsTrk::TrackTruthMatchingBaseAlg::EventStatBase< DetailEnabled >

Definition at line 79 of file TrackTruthMatchingBaseAlg.h.

Member Typedef Documentation

◆ CounterArrayVec

template<bool DetailEnabled>
using ActsTrk::TrackTruthMatchingBaseAlg::BaseStat< DetailEnabled >::CounterArrayVec = std::conditional< DetailEnabled, std::vector< std::array< std::size_t, kNCategorisedCounter> >, Empty >::type
inherited

Definition at line 347 of file TrackTruthMatchingBaseAlg.h.

◆ StatArrayVec

template<bool DetailEnabled>
using ActsTrk::TrackTruthMatchingBaseAlg::BaseStat< DetailEnabled >::StatArrayVec = std::conditional< DetailEnabled, std::vector< std::array<ActsUtils::Stat, kNCategorisedStat> >, Empty >::type
inherited

Definition at line 350 of file TrackTruthMatchingBaseAlg.h.

◆ TruthParticleSet

template<bool DetailEnabled>
using ActsTrk::TrackTruthMatchingBaseAlg::EventStatBase< DetailEnabled >::TruthParticleSet = std::conditional< DetailEnabled, std::unordered_set<const xAOD::TruthParticle *>, typename BaseStat<DetailEnabled>::Empty >::type

Definition at line 117 of file TrackTruthMatchingBaseAlg.h.

Constructor & Destructor Documentation

◆ EventStatBase()

template<bool DetailEnabled>
ActsTrk::TrackTruthMatchingBaseAlg::EventStatBase< DetailEnabled >::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 
)
inline

Definition at line 82 of file TrackTruthMatchingBaseAlg.h.

86  : BaseStat<DetailEnabled>(truth_selection_tool, per_eta_size, per_pdg_size),
87  m_nTruthCuts(truth_selection_tool.nCuts())
88  {
89  if constexpr(DetailEnabled) {
90  m_truthParticlesWithAssociatedTrack.reserve(track_to_truth_size);
91  }
92 
93  };

Member Function Documentation

◆ fill() [1/2]

template<bool DetailEnabled>
void ActsTrk::TrackTruthMatchingBaseAlg::BaseStat< DetailEnabled >::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 
)
inlineinherited

Definition at line 297 of file TrackTruthMatchingBaseAlg.h.

301  {
302  if (DetailEnabled) {
303  assert( eta_category_i <m_statPerEta.size());
304  m_statPerEta[eta_category_i][kHitEfficiency].add( hit_efficiency);
305  m_statPerEta[eta_category_i][kHitPurity].add( hit_purity);
306  m_statPerEta[eta_category_i][kMatchProbability].add( match_prob);
307  assert( pdg_id_category_i <m_statPerPdgId.size());
308  m_statPerPdgId[pdg_id_category_i][kHitEfficiency].add( hit_efficiency);
309  m_statPerPdgId[pdg_id_category_i][kHitPurity].add( hit_purity);
310  m_statPerPdgId[pdg_id_category_i][kMatchProbability].add( match_prob);
311  assert( eta_category_i < m_counterPerEta.size());
312  assert( pdg_id_category_i <m_counterPerPdgId.size());
313  ++m_counterPerEta[eta_category_i][kNTotalTracks];
314  ++m_counterPerPdgId[pdg_id_category_i][kNTotalTracks];
315  }
316  }

◆ fill() [2/2]

template<bool DetailEnabled>
void ActsTrk::TrackTruthMatchingBaseAlg::EventStatBase< DetailEnabled >::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 
)
inline

Definition at line 94 of file TrackTruthMatchingBaseAlg.h.

99  {
100  BaseStat<DetailEnabled>::fill(eta_category_i,
101  pdg_id_category_i,
102  hit_efficiency,
103  hit_purity,
104  match_prob);
105  if constexpr(DetailEnabled) {
106  if (!m_truthParticlesWithAssociatedTrack.insert(best_match).second) {
107  // truth particle already had a best match
109  ++this->m_counterPerPdgId[pdg_id_category_i][kNParticleWithMultipleAssociatedTracks];
110  }
111  else {
112  ++this->m_counterPerEta[eta_category_i][kNParticleWithAssociatedTrack];
113  ++this->m_counterPerPdgId[pdg_id_category_i][kNParticleWithAssociatedTrack];
114  }
115  }
116  }

◆ incrementTotal()

template<bool DetailEnabled>
void ActsTrk::TrackTruthMatchingBaseAlg::BaseStat< DetailEnabled >::incrementTotal ( [[maybe_unused] ] unsigned int  eta_category_i,
[[maybe_unused] ] unsigned int  pdg_id_category_i 
)
inlineinherited

Definition at line 317 of file TrackTruthMatchingBaseAlg.h.

318  {
319  if constexpr(DetailEnabled) {
320  ++m_counterPerEta[eta_category_i][kNTotalParticles];
321  ++m_counterPerPdgId[pdg_id_category_i][kNTotalParticles];
322  }
323  }

◆ operator+=()

template<bool DetailEnabled>
TrackTruthMatchingBaseAlg::BaseStat< DetailEnabled > & ActsTrk::TrackTruthMatchingBaseAlg::BaseStat< DetailEnabled >::operator+= ( const BaseStat< DetailEnabled > &  event_stat)
inlineinherited

Definition at line 440 of file TrackTruthMatchingBaseAlg.cxx.

440  {
441  if constexpr(DetailEnabled) {
442  addStat(event_stat.m_counterPerEta,m_counterPerEta);
443  addStat(event_stat.m_statPerEta, m_statPerEta);
444  addStat(event_stat.m_counterPerPdgId,m_counterPerPdgId);
445  addStat(event_stat.m_statPerPdgId, m_statPerPdgId);
446  }
447  m_truthSelectionCuts += event_stat.m_truthSelectionCuts;
448  return *this;
449  }

◆ perEtaSize()

template<bool DetailEnabled>
std::size_t ActsTrk::TrackTruthMatchingBaseAlg::BaseStat< DetailEnabled >::perEtaSize ( ) const
inlineinherited

Definition at line 336 of file TrackTruthMatchingBaseAlg.h.

336  {
337  if constexpr(DetailEnabled) { return m_counterPerEta.size(); }
338  else { return 0u; }
339  }

◆ perPdgIdSize()

template<bool DetailEnabled>
std::size_t ActsTrk::TrackTruthMatchingBaseAlg::BaseStat< DetailEnabled >::perPdgIdSize ( ) const
inlineinherited

Definition at line 340 of file TrackTruthMatchingBaseAlg.h.

340  {
341  if constexpr(DetailEnabled) { return m_counterPerPdgId.size(); }
342  else { return 0u; }
343  }

◆ printStatTables()

template<bool DetailEnabled>
void ActsTrk::TrackTruthMatchingBaseAlg::BaseStat< DetailEnabled >::printStatTables ( const TrackTruthMatchingBaseAlg parent,
const std::vector< float > &  statPtBins,
const std::vector< float > &  statEtaBins,
std::vector< int > &  pdgId,
bool  printDetails,
bool  pdgIdCategorisation,
bool  useAbsEtaForStat 
)
inherited

Definition at line 452 of file TrackTruthMatchingBaseAlg.cxx.

458  {
459  if constexpr(DetailEnabled) {
460  static constexpr bool rotate=true;// row : eta/PDG ID; column: pt
461  std::vector<std::string> counter_labels { std::string("Truth particles"),
462  std::string("with asso. track"),
463  std::string("with >1 asso. tracks"),
464  std::string("total tracks")};
465  std::vector<std::string> pt_labels;
466  pt_labels.reserve(statPtBins.size() + 2);
467  unsigned int pt_precision=0;
468  for (float pt : statPtBins) {
469  if (pt<1.) {
470  pt_precision=1;
471  break;
472  }
473  }
474  for (std::size_t bin_i = 0; bin_i < statPtBins.size() + 2; ++bin_i) {
475  pt_labels.push_back(TableUtils::makeBinLabel("pt",statPtBins, bin_i, true, pt_precision));
476  }
477  // statistics eta-bins
478  {
479  std::vector<std::string> eta_labels;
480  eta_labels.reserve(statEtaBins.size() + 2);
481  for (std::size_t eta_bin_i = 0; eta_bin_i < statEtaBins.size() + 2; ++eta_bin_i) {
482  eta_labels.push_back(TableUtils::makeEtaBinLabel(statEtaBins, eta_bin_i, useAbsEtaForStat));
483  }
484 
485  accumulateToLastColumnRow(statPtBins.size()+2,statEtaBins.size()+2, m_statPerEta);
486  accumulateToLastColumnRow(statPtBins.size()+2,statEtaBins.size()+2, m_counterPerEta);
487 
488  if (statPtBins.empty() || printDetails) {
489  parent.printCategories(pt_labels, eta_labels, counter_labels, m_statPerEta, m_counterPerEta,
490  (!statPtBins.empty()
491  ? hfill("pt ",
492  "eta",
493  TableUtils::maxLabelWidth(pt_labels)
494  +TableUtils::maxLabelWidth(eta_labels))
495  : std::string("eta") ),
496  !statPtBins.empty());
497  }
498  if (!statPtBins.empty()) {
499  parent.printData2D(pt_labels, eta_labels,
500  rotate
501  ? hfill("eta","\\ pt", TableUtils::maxLabelWidth(eta_labels))
502  : hfill("pt","\\ eta", TableUtils::maxLabelWidth(pt_labels)),
503  m_statPerEta,
505  rotate);
506  }
507  }
508 
509  // statistics in PDG ID bins.
510  if (pdgIdCategorisation) {
511  std::vector<std::string> pdg_id_labels;
512  pdg_id_labels.reserve( pdgId.size());
513  pdg_id_labels.push_back("Other");
514  for (unsigned int pdg_i=1; pdg_i < pdgId.size(); ++pdg_i) {
515  std::stringstream a_label;
516  a_label << HepPID::particleName(pdgId[pdg_i]) << " [" << pdgId[pdg_i] << "]";
517  pdg_id_labels.push_back( a_label.str() );
518  }
519  unsigned int max_pdg_id_slots=m_statPerPdgId.size()/(statPtBins.size()+2);
520  assert( m_statPerPdgId.size() % (statPtBins.size()+2) == 0 );
521  // also the unused columns are projected, but that does not harm :
522  accumulateToLastRow(statPtBins.size()+2,max_pdg_id_slots, m_statPerPdgId);
523  accumulateToLastRow(statPtBins.size()+2,max_pdg_id_slots, m_counterPerPdgId);
524 
525  if (statPtBins.empty() || printDetails) {
526  parent.printCategories(pt_labels, pdg_id_labels, counter_labels, m_statPerPdgId, m_counterPerPdgId,
527  (!statPtBins.empty()
528  ? hfill("pt ",
529  "PDG-id",
530  TableUtils::maxLabelWidth(pt_labels)
531  +TableUtils::maxLabelWidth(pdg_id_labels))
532  : std::string("eta")),
533  !statPtBins.empty());
534  }
535  if (!statPtBins.empty()) {
536  parent.printData2D(pt_labels, pdg_id_labels,
537  rotate
538  ? hfill("PDG ID","\\ pt", TableUtils::maxLabelWidth(pdg_id_labels))
539  : hfill("pt","\\ PDG ID", TableUtils::maxLabelWidth(pt_labels)),
542  rotate);
543  }
544  }
545  }
546  }

◆ reset()

template<bool DetailEnabled>
void ActsTrk::TrackTruthMatchingBaseAlg::BaseStat< DetailEnabled >::reset ( const IAthSelectionTool truth_selection_tool,
[[maybe_unused] ] std::size_t  per_eta_size,
[[maybe_unused] ] std::size_t  per_pdg_size 
)
inlineinherited

Definition at line 281 of file TrackTruthMatchingBaseAlg.h.

284  {
285  m_truthSelectionCuts.setBinning(truth_selection_tool.nCuts()+1, -0.5,truth_selection_tool.nCuts()+.5);
286  if constexpr(DetailEnabled) {
287  m_counterPerEta.clear();
288  m_counterPerPdgId.clear();
289  m_statPerEta.clear();
290  m_statPerPdgId.clear();
291  m_counterPerEta.resize(per_eta_size);
292  m_counterPerPdgId.resize( per_pdg_size);
293  m_statPerEta.resize( per_eta_size );
294  m_statPerPdgId.resize( per_pdg_size );
295  }
296  }

Member Data Documentation

◆ doDetail

template<bool DetailEnabled>
constexpr bool ActsTrk::TrackTruthMatchingBaseAlg::EventStatBase< DetailEnabled >::doDetail = DetailEnabled
staticconstexpr

Definition at line 80 of file TrackTruthMatchingBaseAlg.h.

◆ m_counterPerEta

template<bool DetailEnabled>
CounterArrayVec ActsTrk::TrackTruthMatchingBaseAlg::BaseStat< DetailEnabled >::m_counterPerEta
inherited

Definition at line 353 of file TrackTruthMatchingBaseAlg.h.

◆ m_counterPerPdgId

template<bool DetailEnabled>
CounterArrayVec ActsTrk::TrackTruthMatchingBaseAlg::BaseStat< DetailEnabled >::m_counterPerPdgId
inherited

Definition at line 354 of file TrackTruthMatchingBaseAlg.h.

◆ m_nTracksWithoutAssociatedTruthParticle

template<bool DetailEnabled>
unsigned int ActsTrk::TrackTruthMatchingBaseAlg::EventStatBase< DetailEnabled >::m_nTracksWithoutAssociatedTruthParticle =0u

Definition at line 123 of file TrackTruthMatchingBaseAlg.h.

◆ m_nTracksWithoutSelectedTruthParticle

template<bool DetailEnabled>
unsigned int ActsTrk::TrackTruthMatchingBaseAlg::EventStatBase< DetailEnabled >::m_nTracksWithoutSelectedTruthParticle =0u

Definition at line 124 of file TrackTruthMatchingBaseAlg.h.

◆ m_nTruthCuts

template<bool DetailEnabled>
unsigned int ActsTrk::TrackTruthMatchingBaseAlg::EventStatBase< DetailEnabled >::m_nTruthCuts

Definition at line 127 of file TrackTruthMatchingBaseAlg.h.

◆ m_nTruthParticleNonoiseMismatches

template<bool DetailEnabled>
unsigned int ActsTrk::TrackTruthMatchingBaseAlg::EventStatBase< DetailEnabled >::m_nTruthParticleNonoiseMismatches =0u

Definition at line 125 of file TrackTruthMatchingBaseAlg.h.

◆ m_nTruthParticleWithoutAssociatedCounts

template<bool DetailEnabled>
unsigned int ActsTrk::TrackTruthMatchingBaseAlg::EventStatBase< DetailEnabled >::m_nTruthParticleWithoutAssociatedCounts =0u

Definition at line 122 of file TrackTruthMatchingBaseAlg.h.

◆ m_statPerEta

template<bool DetailEnabled>
StatArrayVec ActsTrk::TrackTruthMatchingBaseAlg::BaseStat< DetailEnabled >::m_statPerEta
inherited

Definition at line 355 of file TrackTruthMatchingBaseAlg.h.

◆ m_statPerPdgId

template<bool DetailEnabled>
StatArrayVec ActsTrk::TrackTruthMatchingBaseAlg::BaseStat< DetailEnabled >::m_statPerPdgId
inherited

Definition at line 356 of file TrackTruthMatchingBaseAlg.h.

◆ m_truthParticlesWithAssociatedTrack

template<bool DetailEnabled>
TruthParticleSet ActsTrk::TrackTruthMatchingBaseAlg::EventStatBase< DetailEnabled >::m_truthParticlesWithAssociatedTrack

Definition at line 120 of file TrackTruthMatchingBaseAlg.h.

◆ m_truthSelectionCuts

template<bool DetailEnabled>
ActsUtils::StatHist ActsTrk::TrackTruthMatchingBaseAlg::BaseStat< DetailEnabled >::m_truthSelectionCuts
inherited

Definition at line 344 of file TrackTruthMatchingBaseAlg.h.


The documentation for this struct was generated from the following file:
ActsTrk::TrackTruthMatchingBaseAlg::EventStatBase::m_nTruthCuts
unsigned int m_nTruthCuts
Definition: TrackTruthMatchingBaseAlg.h:127
ActsTrk::TrackTruthMatchingBaseAlg::kNParticleWithMultipleAssociatedTracks
@ kNParticleWithMultipleAssociatedTracks
Definition: TrackTruthMatchingBaseAlg.h:249
ActsTrk::TrackTruthMatchingBaseAlg::BaseStat::fill
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)
Definition: TrackTruthMatchingBaseAlg.h:297
rotate
void rotate(double angler, GeoTrf::Vector2D &vector)
Definition: TRTDetectorFactory_Full.cxx:63
ActsTrk::TrackTruthMatchingBaseAlg::kHitEfficiency
@ kHitEfficiency
Definition: TrackTruthMatchingBaseAlg.h:254
IAthSelectionTool::nCuts
virtual unsigned int nCuts() const =0
return the number of cuts.
test_pyathena.pt
pt
Definition: test_pyathena.py:11
ActsTrk::TrackTruthMatchingBaseAlg::kMatchProbability
@ kMatchProbability
Definition: TrackTruthMatchingBaseAlg.h:256
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:83
PowhegPy8EG_H2a.pdgId
dictionary pdgId
Definition: PowhegPy8EG_H2a.py:128
ActsTrk::TrackTruthMatchingBaseAlg::BaseStat::m_truthSelectionCuts
ActsUtils::StatHist m_truthSelectionCuts
Definition: TrackTruthMatchingBaseAlg.h:344
G4StepHelper::particleName
std::string particleName(const G4Step *theStep)
TODO.
Definition: StepHelper.cxx:24
TableUtils::maxLabelWidth
std::size_t maxLabelWidth(const T_Collection &col)
Definition: TableUtils.h:288
TableUtils::makeBinLabel
std::string makeBinLabel(const std::string &variable_name, const std::vector< float > &bins, std::size_t bin_i, bool abs_value=false, int precision=1)
Definition: TableUtils.h:483
ActsTrk::TrackTruthMatchingBaseAlg::EventStatBase::m_truthParticlesWithAssociatedTrack
TruthParticleSet m_truthParticlesWithAssociatedTrack
Definition: TrackTruthMatchingBaseAlg.h:120
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ActsTrk::TrackTruthMatchingBaseAlg::BaseStat::m_counterPerPdgId
CounterArrayVec m_counterPerPdgId
Definition: TrackTruthMatchingBaseAlg.h:354
ActsTrk::TrackTruthMatchingBaseAlg::kHitPurity
@ kHitPurity
Definition: TrackTruthMatchingBaseAlg.h:255
ActsTrk::TrackTruthMatchingBaseAlg::kNTotalTracks
@ kNTotalTracks
Definition: TrackTruthMatchingBaseAlg.h:250
TableUtils::makeEtaBinLabel
std::string makeEtaBinLabel(const std::vector< float > &eta_bins, std::size_t eta_bin_i, bool abs_eta=false)
Definition: TableUtils.h:512
ActsTrk::TrackTruthMatchingBaseAlg::kNParticleWithAssociatedTrack
@ kNParticleWithAssociatedTrack
Definition: TrackTruthMatchingBaseAlg.h:248
ActsTrk::TrackTruthMatchingBaseAlg::BaseStat::m_statPerPdgId
StatArrayVec m_statPerPdgId
Definition: TrackTruthMatchingBaseAlg.h:356
ActsUtils::StatHist::setBinning
void setBinning(unsigned int n_bins, float xmin, float xmax)
Define histogramm bins and enable histogramming.
Definition: StatUtils.h:98
ActsTrk::TrackTruthMatchingBaseAlg::kNTotalParticles
@ kNTotalParticles
Definition: TrackTruthMatchingBaseAlg.h:247
ActsTrk::TrackTruthMatchingBaseAlg::BaseStat::m_counterPerEta
CounterArrayVec m_counterPerEta
Definition: TrackTruthMatchingBaseAlg.h:353
ActsTrk::TrackTruthMatchingBaseAlg::BaseStat::m_statPerEta
StatArrayVec m_statPerEta
Definition: TrackTruthMatchingBaseAlg.h:355