ATLAS Offline Software
Classes | Public Types | Public Member Functions | Public Attributes | List of all members
ActsTrk::TrackTruthMatchingBaseAlg::BaseStat< DetailEnabled > Struct Template Reference
Inheritance diagram for ActsTrk::TrackTruthMatchingBaseAlg::BaseStat< DetailEnabled >:
Collaboration diagram for ActsTrk::TrackTruthMatchingBaseAlg::BaseStat< DetailEnabled >:

Classes

struct  Empty
 

Public Types

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

 BaseStat ()=default
 
 BaseStat ([[maybe_unused]] const IAthSelectionTool &truth_selection_tool, [[maybe_unused]] std::size_t per_eta_size, [[maybe_unused]] std::size_t per_pdg_size)
 
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

ActsUtils::StatHist m_truthSelectionCuts
 
CounterArrayVec m_counterPerEta
 
CounterArrayVec m_counterPerPdgId
 
StatArrayVec m_statPerEta
 
StatArrayVec m_statPerPdgId
 

Detailed Description

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

Definition at line 47 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

Definition at line 345 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

Definition at line 348 of file TrackTruthMatchingBaseAlg.h.

Constructor & Destructor Documentation

◆ BaseStat() [1/2]

template<bool DetailEnabled>
ActsTrk::TrackTruthMatchingBaseAlg::BaseStat< DetailEnabled >::BaseStat ( )
default

◆ BaseStat() [2/2]

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

Definition at line 266 of file TrackTruthMatchingBaseAlg.h.

269  : m_truthSelectionCuts(truth_selection_tool.nCuts()+1, -0.5,truth_selection_tool.nCuts()+.5)
270  {
271  if constexpr(DetailEnabled) {
272  m_counterPerEta.resize(per_eta_size);
273  m_counterPerPdgId.resize( per_pdg_size);
274  m_statPerEta.resize( per_eta_size );
275  m_statPerPdgId.resize( per_pdg_size );
276  }
277 
278  }

Member Function Documentation

◆ fill()

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 
)
inline

Definition at line 295 of file TrackTruthMatchingBaseAlg.h.

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

◆ 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 
)
inline

Definition at line 315 of file TrackTruthMatchingBaseAlg.h.

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

◆ operator+=()

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

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
inline

Definition at line 334 of file TrackTruthMatchingBaseAlg.h.

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

◆ perPdgIdSize()

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

Definition at line 338 of file TrackTruthMatchingBaseAlg.h.

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

◆ 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 
)

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 
)
inline

Definition at line 279 of file TrackTruthMatchingBaseAlg.h.

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

Member Data Documentation

◆ m_counterPerEta

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

Definition at line 351 of file TrackTruthMatchingBaseAlg.h.

◆ m_counterPerPdgId

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

Definition at line 352 of file TrackTruthMatchingBaseAlg.h.

◆ m_statPerEta

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

Definition at line 353 of file TrackTruthMatchingBaseAlg.h.

◆ m_statPerPdgId

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

Definition at line 354 of file TrackTruthMatchingBaseAlg.h.

◆ m_truthSelectionCuts

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

Definition at line 342 of file TrackTruthMatchingBaseAlg.h.


The documentation for this struct was generated from the following files:
rotate
void rotate(double angler, GeoTrf::Vector2D &vector)
Definition: TRTDetectorFactory_Full.cxx:63
ActsTrk::TrackTruthMatchingBaseAlg::kHitEfficiency
@ kHitEfficiency
Definition: TrackTruthMatchingBaseAlg.h:252
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:254
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:77
ActsTrk::TrackTruthMatchingBaseAlg::BaseStat::m_truthSelectionCuts
ActsUtils::StatHist m_truthSelectionCuts
Definition: TrackTruthMatchingBaseAlg.h:342
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
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ActsTrk::TrackTruthMatchingBaseAlg::BaseStat::m_counterPerPdgId
CounterArrayVec m_counterPerPdgId
Definition: TrackTruthMatchingBaseAlg.h:352
ActsTrk::TrackTruthMatchingBaseAlg::kHitPurity
@ kHitPurity
Definition: TrackTruthMatchingBaseAlg.h:253
ActsTrk::TrackTruthMatchingBaseAlg::kNTotalTracks
@ kNTotalTracks
Definition: TrackTruthMatchingBaseAlg.h:248
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::BaseStat::m_statPerPdgId
StatArrayVec m_statPerPdgId
Definition: TrackTruthMatchingBaseAlg.h:354
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:245
ActsTrk::TrackTruthMatchingBaseAlg::BaseStat::m_counterPerEta
CounterArrayVec m_counterPerEta
Definition: TrackTruthMatchingBaseAlg.h:351
ActsTrk::TrackTruthMatchingBaseAlg::BaseStat::m_statPerEta
StatArrayVec m_statPerEta
Definition: TrackTruthMatchingBaseAlg.h:353