2   Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
 
    5 #include "ActsInterop/TableUtils.h"
 
   10   template <typename row_t,
 
   13   StatusCode ActsInspectTruthContentAlg::printStatTables(const std::string& objectCollectionName,
 
   14                              const stat_t& stat) const
 
   16     constexpr std::size_t NROW = static_cast<std::size_t>(row_t::kNStat);
 
   17     constexpr std::size_t NCOL = static_cast<std::size_t>(coll_t::nTypes);
 
   18     constexpr std::size_t TOTROW = static_cast<std::size_t>(row_t::kNTotal);
 
   19     static_assert( std::same_as<stat_t,
 
   21            std::array<std::size_t, NCOL>, NROW>> );
 
   23     // labels have to follow the enum
 
   24     std::array<std::string, NROW> stat_labels;
 
   25     for (std::size_t i(0); i<NROW; ++i) {
 
   26       stat_labels[i] = to_label(static_cast<row_t>(i));
 
   29     std::array<std::string, NROW - 1> ratio_labels {};
 
   30     for (std::size_t i(1); i< stat_labels.size(); ++i) {
 
   31       ratio_labels[i-1] = stat_labels[i] + " / total";
 
   34     std::size_t max_label_width = TableUtils::maxLabelWidth(ratio_labels);
 
   36     std::array<std::string, NCOL> categories {};
 
   37     for (std::size_t i(0); i<categories.size(); ++i) {
 
   38       categories[i] = to_string( static_cast<coll_t>(i) );
 
   41     std::stringstream table_out;
 
   42     table_out << makeTable(stat,
 
   47       .minLabelWidth(max_label_width);
 
   51       std::array<float, NCOL>,
 
   52       NROW - 1> ratioStat {};
 
   55     for (std::size_t i(1); i<NROW; ++i) {
 
   56       for (std::size_t j(0); j<NCOL; ++j) {
 
   57     if (stat[TOTROW][j] == 0) ratioStat[i-1][j] = 0;
 
   58     else ratioStat[i-1][j] = stat[i][j] * 1. / stat[TOTROW][j];
 
   62     table_out << makeTable(ratioStat,
 
   67       .minLabelWidth(max_label_width);
 
   69     ATH_MSG_INFO(objectCollectionName << " statistics:" << std::endl
 
   72     return StatusCode::SUCCESS;
 
   75   // -------------------------------------------------------------------- //
 
   77   template <typename stat_t>
 
   78   StatusCode ActsInspectTruthContentAlg::copyStatTable(const stat_t& contextual,
 
   79                                stat_t& global) const {
 
   80     std::lock_guard<std::mutex> lock(m_mutex);
 
   81     for (std::size_t i(0); i<contextual.size(); ++i) {
 
   82       for (std::size_t j(0); j<contextual[i].size(); ++j) {
 
   83     global[i][j] += contextual[i][j];
 
   86     return StatusCode::SUCCESS;
 
   89   // -------------------------------------------------------------------- //
 
   91   inline std::string ActsInspectTruthContentAlg::to_string(xAOD::UncalibMeasType type) const {
 
   93     case (xAOD::UncalibMeasType::Other):
 
   95     case (xAOD::UncalibMeasType::PixelClusterType):
 
   97     case (xAOD::UncalibMeasType::StripClusterType):
 
   99     case (xAOD::UncalibMeasType::MdtDriftCircleType):
 
  101     case (xAOD::UncalibMeasType::RpcStripType):
 
  103     case (xAOD::UncalibMeasType::TgcStripType):
 
  105     case (xAOD::UncalibMeasType::MMClusterType):
 
  107     case (xAOD::UncalibMeasType::sTgcStripType):
 
  109     case (xAOD::UncalibMeasType::HGTDClusterType):
 
  116   inline std::string ActsInspectTruthContentAlg::to_string(ActsInspectTruthContentAlg::SeedType type) const {
 
  118     case (ActsInspectTruthContentAlg::SeedType::PPP):
 
  120     case (ActsInspectTruthContentAlg::SeedType::SSS):
 
  122     case (ActsInspectTruthContentAlg::SeedType::PPS):
 
  124     case (ActsInspectTruthContentAlg::SeedType::PSS):
 
  126     case (ActsInspectTruthContentAlg::SeedType::Others):
 
  134   inline std::string ActsInspectTruthContentAlg::to_string(ActsInspectTruthContentAlg::TrackType type) const {
 
  136     case (ActsInspectTruthContentAlg::TrackType::Main):
 
  144   inline std::string ActsInspectTruthContentAlg::to_label(ActsInspectTruthContentAlg::EStatClusters type) const {
 
  146     case (ActsInspectTruthContentAlg::EStatClusters::kNTotal):
 
  147       return "Total number of Clusters";
 
  148     case (ActsInspectTruthContentAlg::EStatClusters::kNClustersFromPrimaries):
 
  149       return "Clusters with barcode < 200k";
 
  150     case (ActsInspectTruthContentAlg::EStatClusters::kNClustersWithNoBarcode):
 
  151       return "Clusters with no barcode";
 
  152     case (ActsInspectTruthContentAlg::EStatClusters::kNClustersWith1Contribution):
 
  153       return "Clusters with 1 contribution";
 
  154     case (ActsInspectTruthContentAlg::EStatClusters::kNClustersWith1ValidContribution):
 
  155       return "Clusters with 1 contribution (all < 200k)";
 
  156     case (ActsInspectTruthContentAlg::EStatClusters::kNClustersWith2Contribution):
 
  157       return "Clusters with 2 contributions";
 
  158     case (ActsInspectTruthContentAlg::EStatClusters::kNClustersWith2ValidContribution):
 
  159       return "Clusters with 2 contributions (all < 200k)";
 
  160     case (ActsInspectTruthContentAlg::EStatClusters::kNClustersWith3Contribution):
 
  161       return "Clusters with 3+ contributions";
 
  162     case (ActsInspectTruthContentAlg::EStatClusters::kNClustersWith3ValidContribution):
 
  163       return "Clusters with 3+ contributions (all < 200k)";
 
  164     case (ActsInspectTruthContentAlg::EStatClusters::kNClustersWith200kBarcode):
 
  165       return "Clusters with barcode >= 200k";
 
  171   inline std::string ActsInspectTruthContentAlg::to_label(ActsInspectTruthContentAlg::EStatSeeds type) const {
 
  173     case (ActsInspectTruthContentAlg::EStatSeeds::kNTotal):
 
  174       return "Total number of Seeds";
 
  175     case (ActsInspectTruthContentAlg::EStatSeeds::nKSeedsWith0Matches):
 
  176       return "Seeds with 0 clusters with barcode < 200k";
 
  177     case (ActsInspectTruthContentAlg::EStatSeeds::nKSeedsWith1Matches):
 
  178       return "Seeds with 1 clusters with barcode < 200k";
 
  179     case (ActsInspectTruthContentAlg::EStatSeeds::nKSeedsWith2Matches):
 
  180       return "Seeds with 2 clusters with barcode < 200k";
 
  181     case (ActsInspectTruthContentAlg::EStatSeeds::nKSeedsWith3Matches):
 
  182       return "Seeds with 3 clusters with barcode < 200k";
 
  183     case (ActsInspectTruthContentAlg::EStatSeeds::nKSeedsWith4Matches):
 
  184       return "Seeds with 4 clusters with barcode < 200k";
 
  185     case (ActsInspectTruthContentAlg::EStatSeeds::nKSeedsWith5Matches):
 
  186       return "Seeds with 5 clusters with barcode < 200k";
 
  187     case (ActsInspectTruthContentAlg::EStatSeeds::nKSeedsWith6Matches):
 
  188       return "Seeds with 6 clusters with barcode < 200k";
 
  189     case (ActsInspectTruthContentAlg::EStatSeeds::nKSeedsSame2Matches):
 
  190       return "Seeds with 2 clusters with barcode < 200k (all same)";
 
  191     case (ActsInspectTruthContentAlg::EStatSeeds::nKSeedsSame3Matches):
 
  192       return "Seeds with 3 clusters with barcode < 200k (all same)";
 
  193     case (ActsInspectTruthContentAlg::EStatSeeds::nKSeedsSame4Matches):
 
  194       return "Seeds with 4 clusters with barcode < 200k (all same)";
 
  195     case (ActsInspectTruthContentAlg::EStatSeeds::nKSeedsSame5Matches):
 
  196       return "Seeds with 5 clusters with barcode < 200k (all same)";
 
  197     case (ActsInspectTruthContentAlg::EStatSeeds::nKSeedsSame6Matches):
 
  198       return "Seeds with 6 clusters with barcode < 200k (all same)";
 
  205   inline std::string ActsInspectTruthContentAlg::to_label(ActsInspectTruthContentAlg::EStatTracks type) const {
 
  207     case (ActsInspectTruthContentAlg::EStatTracks::kNTotal):
 
  208       return "Total number of Tracks";
 
  209     case (ActsInspectTruthContentAlg::EStatTracks::kNFullMatch):
 
  210       return "Tracks with only clusters with barcodes <200k";
 
  211     case (ActsInspectTruthContentAlg::EStatTracks::kNPerfectMatch):
 
  212       return "Tracks with only clusters with barcodes <200k (all same)";
 
  213     case (ActsInspectTruthContentAlg::EStatTracks::kNTracks0Holes):
 
  214       return "Tracks with 0 holes";
 
  215     case (ActsInspectTruthContentAlg::EStatTracks::kNTracks1Holes):
 
  216       return "Tracks with 1 holes";
 
  217     case (ActsInspectTruthContentAlg::EStatTracks::kNTracks2Holes):
 
  218       return "Tracks with 2 holes";
 
  219     case (ActsInspectTruthContentAlg::EStatTracks::kNTracks3Holes):
 
  220       return "Tracks with 3+ holes";
 
  221     case (ActsInspectTruthContentAlg::EStatTracks::kNTracks0Outliers):
 
  222       return "Tracks with 0 outliers";
 
  223     case (ActsInspectTruthContentAlg::EStatTracks::kNTracks1Outliers):
 
  224       return "Tracks with 1 outliers";
 
  225     case (ActsInspectTruthContentAlg::EStatTracks::kNTracks2Outliers):
 
  226       return "Tracks with 2 outliers";
 
  227     case (ActsInspectTruthContentAlg::EStatTracks::kNTracks3Outliers):
 
  228       return "Tracks with 3+ outliers";