11#include "HepPDT/ParticleDataTable.hh"
20 template <
typename T, std::
size_t N>
21 void accumulateTo(
typename std::vector<std::array<T,N> >
::const_iterator src_begin,
23 std::array<T,N> &dest) {
24 for (
typename std::vector<std::array<T,N> >
::const_iterator src_iter = src_begin;
27 for (
unsigned int elm_i=0; elm_i<
dest.size(); ++elm_i) {
28 assert( elm_i < src_iter->
size() );
29 dest[elm_i] += (*src_iter)[elm_i];
34 template <
typename T,
bool LastRowOnly=false>
35 void accumulateToLastColumnRow(std::size_t n_rows, std::size_t n_cols, std::vector<T> &stat) {
38 auto stat_begin_iter =
stat.begin();
40 auto stat_total_row_begin_iter =
stat.begin() + (n_rows-1) * n_cols;
41 assert(
static_cast<std::size_t
>(stat_total_row_begin_iter - stat_begin_iter) <
stat.size());
43 for (std::size_t row_i = 0; row_i < n_rows-1; ++row_i) {
44 auto stat_end_iter = stat_begin_iter + n_cols - 1 ;
45 assert(
static_cast<std::size_t
>(stat_end_iter -
stat.begin()) <
stat.size());
46 auto stat_total_row_iter = stat_total_row_begin_iter;
47 if constexpr(!LastRowOnly) {
48 accumulateTo(stat_begin_iter, stat_end_iter, *stat_end_iter );
52 for (; stat_begin_iter != stat_end_iter; ++stat_begin_iter, ++stat_total_row_iter) {
53 assert(
static_cast<std::size_t
>(stat_begin_iter - stat.begin()) < stat.size());
54 assert(
static_cast<std::size_t
>(stat_total_row_iter - stat.begin()) < stat.size());
55 for (
unsigned int idx=0; idx < stat_total_row_iter->size(); ++idx) {
56 stat_total_row_iter->at(idx) += stat_begin_iter->at(idx);
61 else if constexpr(!LastRowOnly) {
62 auto stat_end_iter = stat_begin_iter + n_cols - 1 ;
63 accumulateTo(stat_begin_iter, stat_end_iter, *stat_end_iter );
68 void accumulateToLastRow(std::size_t n_rows, std::size_t n_cols, std::vector<T> &stat) {
69 accumulateToLastColumnRow<T,true>(n_rows, n_cols, stat);
72 template <
typename T, std::
size_t N>
73 void addStat(
const std::vector<std::array<T,N> > &src, std::vector<std::array<T,N> > &dest) {
74 assert(
src.size() ==
dest.size());
76 for (
const std::array<T,N> &src_elm : src) {
77 assert( idx <
dest.size());
78 std::array<T,N> &dest_elm =
dest[
idx];
80 for (
const T &val : src_elm) {
81 assert( val_i < dest_elm.size());
89 inline double sqr(
double a) {
return a*
a; }
91 inline std::array<float, 2>
computeRatio(
unsigned int numerator_counts,
unsigned int denominator_counts) {
92 double inv_denominator_counts = denominator_counts > 0 ? 1./denominator_counts : 0.;
93 return std::array<float, 2> {
94 static_cast<float>(numerator_counts * inv_denominator_counts),
95 static_cast<float>(sqrt( numerator_counts * (denominator_counts-numerator_counts)
96 * inv_denominator_counts *
sqr(inv_denominator_counts) ))
100 std::string hfill(
const std::string &
head,
const std::string &
tail, std::size_t
width) {
102 std::stringstream
out;
109 std::stringstream
out;
110 for (uint8_t val : counts) {
111 out <<
" " << std::setw(2) <<
static_cast<int>(
val);
119 inline MsgStream &
operator<<(MsgStream &out,
const ActsUtils::Stat &stat) {
125 ISvcLocator *pSvcLocator)
138 template <
bool IsDebug>
139 template <
class T_OutStream>
141 if constexpr(IsDebug) {
142 out <<
"Weighted measurement sum per truth particle without associated counts :" << m_measPerTruthParticleWithoutCounts << std::endl
143 << m_measPerTruthParticleWithoutCounts.histogramToString() << std::endl
144 <<
"Match probability of best match :" << m_bestMatchProb << std::endl
145 << m_bestMatchProb.histogramToString() << std::endl
146 <<
"Match probability of next-to-best match :" << m_nextToBestMatchProb << std::endl
147 << m_nextToBestMatchProb.histogramToString() << std::endl;
151 template <
bool IsDebug>
153 if constexpr(IsDebug) {
154 std::lock_guard<std::mutex>
lock(m_mutex);
155 m_measPerTruthParticleWithoutCounts.add(weighted_measurement_sum);
158 template <
bool IsDebug>
160 if constexpr(IsDebug) {
161 std::lock_guard<std::mutex>
lock(m_mutex);
162 m_bestMatchProb.add(best_match_prob[0]);
163 m_nextToBestMatchProb.add(best_match_prob[1]);
174 msg(MSG::INFO) <<
"Truth selection cuts: " << std::endl;
175 unsigned int cut_i=0;
176 std::size_t total = std::accumulate ( m_detailedStat.m_truthSelectionCuts.m_histogram.begin(),
177 m_detailedStat.m_truthSelectionCuts.m_histogram.end(), 0u);
178 msg() << std::setw(3) <<
"" <<
" " << std::setw(20) << total <<
" total" << std::endl;
179 if (m_detailedStat.m_truthSelectionCuts.m_histogram.at(cut_i) > 0) {
180 msg() << std::setw(3) <<
"" <<
" "
181 << std::setw(20) << (total - m_detailedStat.m_truthSelectionCuts.m_histogram.at(cut_i))
182 <<
" underflow" << std::endl;
184 total -= m_detailedStat.m_truthSelectionCuts.m_histogram.at(cut_i++);
186 total -= m_detailedStat.m_truthSelectionCuts.m_histogram.at(cut_i);
187 msg() << std::setw(3) << cut_i <<
" " << std::setw(20) << total <<
" " << name << std::endl;
190 total -= m_detailedStat.m_truthSelectionCuts.m_histogram.at(cut_i);
192 msg() << std::setw(3) <<
"" <<
" " << std::setw(20) << total <<
" overflow" << std::endl;
195 msg() << m_detailedStat.m_truthSelectionCuts.histogramToString();
200 return StatusCode::SUCCESS;
209 std::array<unsigned int,2> best_match_i{std::numeric_limits<unsigned int>::max(),std::numeric_limits<unsigned int>::max()};
210 std::array<float,2> best_match_prob {};
212 std::array<unsigned int,2> best_match_i_nonoise{std::numeric_limits<unsigned int>::max(),std::numeric_limits<unsigned int>::max()};
213 std::array<float,2> best_match_prob_nonoise{};
221 double total_sum_for_prob_nonoise=total_sum_for_prob;
222 total_sum_for_prob += noise_sum;
224 if (total_sum_for_prob>0.) {
228 unsigned int truth_i=0;
230 for (
const std::pair<const xAOD::TruthParticle *, HitCounterArray > &
234 float match_prob_nonoise = truth_sum_for_prob /total_sum_for_prob_nonoise;
235 float match_prob = truth_sum_for_prob /total_sum_for_prob;
236 if (match_prob>1 || match_prob<0.) {
237 ATH_MSG_ERROR(
"Negative or too large truth match \"probability\". This should not happen."
238 <<
" Track hits: " << dumpCounts(total_counts)
239 <<
" noise hits of those: " << dumpCounts(noise_counts)
240 <<
" truth hits: " << dumpCounts(hit_counts_for_associated_truth_particle.second));
242 if (match_prob>best_match_prob[1]) {
243 int dest_i=match_prob<best_match_prob[0];
244 best_match_i[1]=best_match_i[0];
245 best_match_prob[1]=best_match_prob[0];
246 best_match_prob[dest_i]=match_prob;
247 best_match_i[dest_i]=truth_i;
249 if (match_prob_nonoise>best_match_prob_nonoise[1]) {
250 int dest_i=match_prob_nonoise<best_match_prob_nonoise[0];
251 best_match_i_nonoise[1]=best_match_i_nonoise[0];
252 best_match_prob_nonoise[1]=best_match_prob_nonoise[0];
253 best_match_prob_nonoise[dest_i]=match_prob_nonoise;
254 best_match_i_nonoise[dest_i]=truth_i;
260 if (best_match_i_nonoise[0] != best_match_i[0]) {
275 float hit_efficiency = 0.;
276 std::unordered_map<const xAOD::TruthParticle *,HitCounterArray>::const_iterator
277 best_truth_particle_counts_iter = truth_particle_hit_counts.find( best_match );
279 if (best_truth_particle_counts_iter != truth_particle_hit_counts.end()) {
282 hit_efficiency = truth_sum > 0u ? (common_truth_sum/truth_sum) : 0.;
294 float hit_purity = common_truth_sum / total_sum;
300 float best_match_pt = best_match->
pt();
303 event_stat.
fill( eta_category_i, pdg_id_category_i, hit_efficiency, hit_purity, best_match_prob[0], best_match );
318 <<
". This should not happen." );
327 std::size_t n_tracks,
332 for(
const std::pair<const xAOD::TruthParticle * const,ActsTrk::HitCounterArray> &truth_particle : truth_particle_hit_counts) {
337 float truth_particle_pt = truth_particle.first->pt();
338 std::size_t eta_category_i =
getPtEtaStatCategory(truth_particle_pt, truth_particle.first->eta());
339 std::size_t pdg_id_category_i =
getPtPdgIdStatCategory(truth_particle_pt, truth_particle.first->pdg_id());
349 std::lock_guard<std::mutex>
lock(m_statMutex);
358 m_detailedStat += event_stat;
365 std::vector<float>::const_iterator pt_bin_iter = std::upper_bound(
m_statPtBins.begin(),
368 std::vector<float>::const_iterator eta_bin_iter = std::upper_bound(
m_statEtaBins.begin(),
372 +
static_cast<std::size_t
>(eta_bin_iter -
m_statEtaBins.begin());
375 std::vector<float>::const_iterator pt_bin_iter = std::upper_bound(
m_statPtBins.begin(),
378 int abs_pdg_id = std::min(std::abs(pdg_id),
s_pdgIdMax);
379 std::vector< int >::const_iterator iter = std::find(m_pdgId.begin(), m_pdgId.end(), abs_pdg_id);
380 if (iter == m_pdgId.end()){
381 if (m_pdgId.size() < m_pdgId.capacity()) {
382 std::lock_guard<std::mutex>
lock(m_statMutex);
384 iter = std::find(m_pdgId.begin(), m_pdgId.end(), abs_pdg_id);
385 if (iter == m_pdgId.end()){
386 m_pdgId.push_back(abs_pdg_id);
387 iter = m_pdgId.end()-1;
391 iter=m_pdgId.begin();
394 return (m_pdgId.capacity()) *
static_cast<std::size_t
>(pt_bin_iter -
m_statPtBins.begin())
395 + (iter - m_pdgId.begin());
399 if (!bin_edges.empty())
401 float last_eta = bin_edges[0];
402 for (
float eta : bin_edges)
406 ATH_MSG_FATAL(bin_label +
" bins for statistics counter not in ascending order.");
429 m_pdgId.reserve(max_pdg_id_slots);
430 m_pdgId.push_back(1000000000);
433 template <
bool DetailEnabled>
436 if constexpr(DetailEnabled) {
446 template <
bool DetailEnabled>
448 const std::vector<float> &statPtBins,
449 const std::vector<float> &statEtaBins,
450 std::vector< int > &pdgId,
452 bool pdgIdCategorisation,
453 bool useAbsEtaForStat) {
454 if constexpr(DetailEnabled) {
455 static constexpr bool rotate=
true;
456 std::vector<std::string> counter_labels { std::string(
"Truth particles"),
457 std::string(
"with asso. track"),
458 std::string(
"with >1 asso. tracks"),
459 std::string(
"total tracks")};
460 std::vector<std::string> pt_labels;
461 pt_labels.reserve(statPtBins.size() + 2);
462 unsigned int pt_precision=0;
463 for (
float pt : statPtBins) {
469 for (std::size_t bin_i = 0; bin_i < statPtBins.size() + 2; ++bin_i) {
474 std::vector<std::string> eta_labels;
475 eta_labels.reserve(statEtaBins.size() + 2);
476 for (std::size_t eta_bin_i = 0; eta_bin_i < statEtaBins.size() + 2; ++eta_bin_i) {
480 accumulateToLastColumnRow(statPtBins.size()+2,statEtaBins.size()+2,
m_statPerEta);
481 accumulateToLastColumnRow(statPtBins.size()+2,statEtaBins.size()+2,
m_counterPerEta);
483 if (statPtBins.empty() || printDetails) {
490 : std::string(
"eta") ),
491 !statPtBins.empty());
493 if (!statPtBins.empty()) {
494 parent.printData2D(pt_labels, eta_labels,
505 if (pdgIdCategorisation) {
506 std::vector<std::string> pdg_id_labels;
507 pdg_id_labels.reserve( pdgId.size());
508 pdg_id_labels.push_back(
"Other");
509 for (
unsigned int pdg_i=1; pdg_i < pdgId.size(); ++pdg_i) {
510 std::stringstream a_label;
511 a_label << HepPID::particleName(pdgId[pdg_i]) <<
" [" << pdgId[pdg_i] <<
"]";
512 pdg_id_labels.push_back( a_label.str() );
514 unsigned int max_pdg_id_slots=
m_statPerPdgId.size()/(statPtBins.size()+2);
517 accumulateToLastRow(statPtBins.size()+2,max_pdg_id_slots,
m_statPerPdgId);
520 if (statPtBins.empty() || printDetails) {
527 : std::string(
"eta")),
528 !statPtBins.empty());
530 if (!statPtBins.empty()) {
531 parent.printData2D(pt_labels, pdg_id_labels,
547 msg() << MSG::INFO << std::endl;
550 std::array<std::string, kNCounter> counter_labels { std::string(
"Number of tracks"),
551 std::string(
"Number of truth particles with hit counts"),
552 std::string(
"Associated truth particles without hit counts"),
553 std::string(
"Tracks without associated truth particle"),
554 std::string(
"Tracks without selected, associated truth particle"),
555 std::string(
"Best truth particle without noise correction mismatch")
557 msg() <<
makeTable( m_counter, counter_labels) << std::endl;
566 const std::vector<std::string> &col_category_labels,
567 std::vector<std::string> &counter_labels,
568 std::vector< std::array< ActsUtils::Stat, kNCategorisedStat> > &stat_per_category,
569 std::vector< std::array< std::size_t, kNCategorisedCounter> > &counts_per_category,
570 const std::string &top_left,
571 bool print_sub_categories)
const {
572 if (!row_category_labels.empty() && !col_category_labels.empty()) {
573 if (row_category_labels.size() * col_category_labels.size() > counts_per_category.size() ) {
574 ATH_MSG_ERROR(
"Mismatch between category labels and number of counters (logic error -> fix needed):"
575 << row_category_labels.size() <<
" * " << col_category_labels.size()
576 <<
" > " << counts_per_category.size() );
578 constexpr std::size_t stat_column_width=14*4 + 3*3+4 + 9;
579 assert( stat_per_category.size() == counts_per_category.size());
580 const unsigned int n_rows = row_category_labels.size();
581 const unsigned int n_cols = stat_per_category.size() / n_rows;
584 assert( stat_per_category.size() % n_rows == 0 );
585 for(
unsigned int row_i=(print_sub_categories ? 0 : n_rows-1); row_i<n_rows; ++row_i) {
587 std::vector<std::string> stat_labels { std::string(
"Hit Efficiency") };
589 .columnWidth(stat_column_width)
590 .labelPrefix(row_category_labels.at(row_i)+
" ")
591 .precision(std::vector<unsigned int>{3})
595 std::vector<std::string> stat_labels { std::string(
"Hit Purity") };
597 .columnWidth(stat_column_width)
598 .labelPrefix(row_category_labels.at(row_i)+
" ")
599 .precision(std::vector<unsigned int>{3})
603 std::vector<std::string> stat_labels { std::string(
"Match probability") };
605 .columnWidth(stat_column_width)
606 .labelPrefix(row_category_labels.at(row_i)+
" ")
607 .precision(std::vector<unsigned int>{3})
612 .labelPrefix(row_category_labels.at(row_i)+
" ")
617 std::vector< std::array< float, 2> > eff;
618 eff.reserve(m_pdgId.size());
619 for (
unsigned int category_i=0; category_i< col_category_labels.size(); ++category_i) {
623 std::vector<std::string> eff_labels { std::string(
"reco efficiency"),
624 std::string(
"stat. uncertainty") };
625 msg() <<
makeTable( eff, 0u, eff.begin()->size(),0u,1u, col_category_labels, eff_labels, top_left)
626 .labelPrefix(row_category_labels.at(row_i)+
" ")
627 .precision(std::vector<unsigned int>{3,3})
636 template <
typename T>
637 struct TablePlusData {
638 TablePlusData(std::vector<T> &&values,
639 const std::vector<std::string> &row_labels,
640 const std::vector<std::string> &col_labels,
641 const std::string &top_left_label)
642 : m_data(
std::move(values)),
651 TableUtils::Range<std::string> {col_labels.data(), col_labels.size()},
655 std::vector<T> m_data;
656 TableUtils::MultiColumnTable<T> m_assocTable;
657 TablePlusData &columnWidth(std::size_t value) { m_assocTable.columnWidth(value);
return *
this;}
658 TablePlusData &minLabelWidth(std::size_t value) { m_assocTable.minLabelWidth(value);
return *
this;}
659 TablePlusData &dumpHeader(
bool value=
true) { m_assocTable.dumpHeader(value);
return *
this;}
660 TablePlusData &dumpFooter(
bool value=
true) { m_assocTable.dumpFooter(value);
return *
this;}
661 TablePlusData &separateLastRow(
bool value=
true) { m_assocTable.separateLastRow(value);
return *
this;}
662 TablePlusData &labelPrefix(
const std::string& value) { m_assocTable.labelPrefix(value);
return *
this;}
663 TablePlusData &precision(std::vector<unsigned int> &&precision) { m_assocTable.precision(std::move(precision));
return *
this;}
666 template <
typename T>
667 inline MsgStream &
operator<<(MsgStream &out,
const TablePlusData<T> &table) {
672 template <
typename T>
673 inline std::ostream &
operator<<(std::ostream &out,
const TablePlusData<T> &table) {
678 template <
class T_Container,
class T_Function,
typename T=
double>
680 create2DTable(
const std::vector<std::string> &row_category_labels,
681 const std::vector<std::string> &col_category_labels,
682 const std::string &top_left_label,
683 T_Container container,
686 const unsigned int n_rows = row_category_labels.size();
687 const unsigned int n_cols = col_category_labels.size();
688 const unsigned int n_cols_total =
container.size() / n_rows;
690 values.reserve( n_rows * n_cols );
692 for (
unsigned int col_i=0; col_i< n_cols; ++col_i) {
693 for (
unsigned int row_i=0; row_i< n_rows; ++row_i) {
694 values.push_back( function(
container.at( row_i * n_cols_total + col_i )) );
699 for (
unsigned int row_i=0; row_i< n_rows; ++row_i) {
700 for (
unsigned int col_i=0; col_i< n_cols; ++col_i) {
701 values.push_back( function(
container.at( row_i * n_cols_total + col_i )) );
705 return TablePlusData<T>(std::move(values),
706 rotate ? col_category_labels : row_category_labels,
707 rotate ? row_category_labels : col_category_labels,
713 const std::vector<std::string> &col_category_labels,
714 const std::string &top_left_label,
715 std::vector< std::array< ActsUtils::Stat, kNCategorisedStat> > &stat_per_category,
716 std::vector< std::array< std::size_t, kNCategorisedCounter> > &counts_per_category,
719 if (!row_category_labels.empty() && !col_category_labels.empty()) {
720 if (row_category_labels.size() * col_category_labels.size() > counts_per_category.size() ) {
721 ATH_MSG_ERROR(
"Mismatch between category labels and number of counters (logic error -> fix needed):"
722 << row_category_labels.size() <<
" * " << col_category_labels.size()
723 <<
" > " << counts_per_category.size() );
725 std::vector<unsigned int> column_precision;
726 column_precision.resize(
rotate ? row_category_labels.size() : col_category_labels.size(), 3u);
727 assert( stat_per_category.size() == counts_per_category.size());
728 msg() <<
"Hit efficiency : contributing hits over all hits of best matching truth particle" << std::endl
729 << create2DTable( row_category_labels, col_category_labels, top_left_label, stat_per_category,
730 [](
const std::array< ActsUtils::Stat, kNCategorisedStat> &stat) {
735 .precision(std::vector<unsigned int>(column_precision))
737 msg() <<
"Hit purity : contributing hits of best matching truth particle over all hits on track" << std::endl
738 << create2DTable( row_category_labels, col_category_labels, top_left_label, stat_per_category,
739 [](
const std::array< ActsUtils::Stat, kNCategorisedStat> &stat) {
744 .precision(std::vector<unsigned int>(column_precision))
746 msg() <<
"Match probability : weighted common hit sum of best matching truth particle over total track weighted hit sum" << std::endl
747 << create2DTable( row_category_labels, col_category_labels, top_left_label, stat_per_category,
748 [](
const std::array< ActsUtils::Stat, kNCategorisedStat> &stat) {
753 .precision(std::vector<unsigned int>(column_precision))
757 msg() <<
"Reco efficiency : tracks with assoc. truth particle over all selected truth particles with assoc. measurements."
759 << create2DTable( row_category_labels, col_category_labels, top_left_label, counts_per_category,
760 [](
const std::array< std::size_t, kNCategorisedCounter> &counter) {
766 .precision(std::move(column_precision))
774 ATH_MSG_FATAL(
"There must be exactly one weight per measurement type. But got "
776 return StatusCode::FAILURE;
779 ATH_MSG_FATAL(
"There must be exactly one weight for computing the matching probability per measurement type. But got "
781 return StatusCode::FAILURE;
785 ATH_MSG_FATAL(
"Invalid weights (should be positive) or inconsistency of weights which are zero (match prob. weights, weights):"
787 return StatusCode::FAILURE;
790 return StatusCode::SUCCESS;
794 const std::vector<float> &
weights) {
795 assert(
weights.size() == counts.size());
797 for (
unsigned int count_i=0; count_i < counts.size(); ++count_i) {
798 sum += counts[count_i] *
weights[count_i];
804 const std::vector<float> &
weights) {
805 assert(
weights.size() == noise_counts.size());
807 for (
unsigned int count_i=0; count_i < noise_counts.size(); ++count_i) {
808 sum -=
weights[count_i] * noise_counts[count_i] - noise_counts[count_i];
Scalar eta() const
pseudorapidity method
#define ATH_CHECK
Evaluate an expression and check for errors.
virtual void lock()=0
Interface to allow an object to lock itself when made const in SG.
size_t size() const
Number of registered mappings.
void rotate(double angler, GeoTrf::Vector2D &vector)
TableUtils::StatTable< T > makeTable(const std::array< T, N > &counter, const std::array< std::string, N > &label)
Container for hit counts per track Contains hit counts per associated truth particle and the total hi...
const container & countsPerTruthParticle() const
vector with counts per associated truth particle (read only)
HitCounterArray & noiseCounts()
Noise hit counts per track.
HitCounterArray & totalCounts()
Total hit counts per track.
void checkBinOrder(const std::vector< float > &bin_edges, const std::string &bin_label) const
check that bins are in increasing order.
static constexpr unsigned int s_NMeasurementTypes
static constexpr int s_pdgIdMax
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
SG::ReadHandleKey< TruthParticleHitCounts > m_truthHitCounts
TruthMatchResult analyseTrackTruth(const TruthParticleHitCounts &truth_particle_hit_counts, const HitCountsPerTrack &track_hit_counts, EventStat &event_stat) const
DebugCounter< TrackFindingValidationDebugHists > m_debugCounter
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
StatusCode checkMatchWeights()
EventStatBase< TrackFindingValidationDetailedStat > EventStat
static double noiseCorrection(const ActsTrk::HitCounterArray &noise_counts, const std::vector< float > &weights)
std::size_t getPtPdgIdStatCategory(float pt, int pdg_id) const
Return the category based on the PDG ID.
static double weightedCountSum(const ActsTrk::HitCounterArray &counts, const std::vector< float > &weights)
@ NoAssociatedTruthParticle
@ TruthParticleNoNoiseMismatch
@ MissingTruthParticleHitCounts
@ NoSelectedTruthParticle
Property< std::vector< float > > m_statPtBins
Property< bool > m_showRawCounts
void postProcessEventStat(const TruthParticleHitCounts &truth_particle_hit_counts, std::size_t n_tracks, EventStat &event_stat) const
Gaudi::Property< std::vector< float > > m_weightsForProb
void printStatTables() const
std::size_t getPtEtaStatCategory(float pt, float eta) const
Return the category based on the provided eta value.
TrackTruthMatchingBaseAlg(const std::string &name, ISvcLocator *pSvcLocator)
Property< bool > m_computeTrackRecoEfficiency
Property< bool > m_pdgIdCategorisation
@ kNParticleWithAssociatedTrack
Property< std::vector< float > > m_statEtaBins
Property< bool > m_printDetails
virtual StatusCode initialize() override
Gaudi::Property< std::vector< float > > m_weights
virtual StatusCode finalize() override
ToolHandle< IAthSelectionTool > m_truthSelectionTool
void add(double val)
Gather statistics and fill the histogram if not disabled.
bool msgLvl(const MSG::Level lvl) const
An algorithm that can be simultaneously executed in multiple threads.
int pdg_id() const
PDG ID code.
virtual double pt() const override final
The transverse momentum ( ) of the particle.
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
std::string tail(std::string s, const std::string &pattern)
tail of a string
std::string head(std::string s, const std::string &pattern)
head of a string
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
std::unordered_map< const xAOD::TruthParticle *, HitCounterArray > TruthParticleHitCounts
constexpr bool TrackFindingValidationDetailedStat
std::ostream & operator<<(std::ostream &ostr, const DetectorType type)
constexpr bool TrackFindingValidationDebugHists
void dumpStat(T_Stream &out, const Stat &stat)
Dump the given statistics object to the given output stream.
const SG::AuxVectorData * container() const
Return the container holding this element.
float computeRatio(std::size_t numerator, std::size_t denominator)
std::size_t maxLabelWidth(const T_Collection &col)
std::string makeEtaBinLabel(const std::vector< float > &eta_bins, std::size_t eta_bin_i, bool abs_eta=false)
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)
TruthParticle_v1 TruthParticle
Typedef to implementation.
void incrementTotal(unsigned int eta_category_i, unsigned int pdg_id_category_i)
BaseStat< DetailEnabled > & operator+=(const BaseStat< DetailEnabled > &event_stat)
StatArrayVec m_statPerPdgId
CounterArrayVec m_counterPerPdgId
StatArrayVec m_statPerEta
ActsUtils::StatHist m_truthSelectionCuts
CounterArrayVec m_counterPerEta
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)
void fillMeasForTruthParticleWithoutCount(double weighted_measurement_sum) const
void dumpStatistics(T_OutStream &out) const
void fillTruthMatchProb(const std::array< float, 2 > &best_match_prob) const
unsigned int m_nTruthParticleWithoutAssociatedCounts
static constexpr bool doDetail
unsigned int m_nTracksWithoutAssociatedTruthParticle
unsigned int m_nTruthCuts
unsigned int m_nTracksWithoutSelectedTruthParticle
void fill(unsigned int eta_category_i, unsigned int pdg_id_category_i, float hit_efficiency, float hit_purity, float match_prob, const xAOD::TruthParticle *best_match)
unsigned int m_nTruthParticleNonoiseMismatches
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