Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-09 08:20:15

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 #include "ActsExamples/Validation/DuplicationPlotTool.hpp"
0010 
0011 #include "Acts/Utilities/VectorHelpers.hpp"
0012 
0013 #include <format>
0014 
0015 using Acts::VectorHelpers::eta;
0016 using Acts::VectorHelpers::perp;
0017 using Acts::VectorHelpers::phi;
0018 
0019 using namespace Acts::Experimental;
0020 
0021 namespace ActsExamples {
0022 
0023 namespace {
0024 
0025 ProfileHistogram1 makeProfile(const DuplicationPlotTool::Config& cfg,
0026                               const std::string& name, const std::string& title,
0027                               const AxisVariant& ax) {
0028   const auto& yAxis = cfg.varBinning.at("Num");
0029   Acts::Range1D<double> yRange{yAxis.bin(0).lower(),
0030                                yAxis.bin(yAxis.size() - 1).upper()};
0031   return ProfileHistogram1(name, title, {ax}, yAxis.metadata(), yRange);
0032 }
0033 
0034 }  // namespace
0035 
0036 DuplicationPlotTool::DuplicationPlotTool(const DuplicationPlotTool::Config& cfg,
0037                                          Acts::Logging::Level lvl)
0038     : m_cfg(cfg), m_logger(Acts::getDefaultLogger("DuplicationPlotTool", lvl)) {
0039   ACTS_DEBUG("Initialize the histograms for duplication ratio plots");
0040 
0041   std::string dupTitle =
0042       std::format("Number of duplicated {}s candidates", m_cfg.label);
0043 
0044   m_profiles.insert(
0045       {"nDuplicated_vs_pT", makeProfile(m_cfg, "nDuplicated_vs_pT", dupTitle,
0046                                         m_cfg.varBinning.at("Pt"))});
0047   m_profiles.insert(
0048       {"nDuplicated_vs_eta", makeProfile(m_cfg, "nDuplicated_vs_eta", dupTitle,
0049                                          m_cfg.varBinning.at("Eta"))});
0050   m_profiles.insert(
0051       {"nDuplicated_vs_phi", makeProfile(m_cfg, "nDuplicated_vs_phi", dupTitle,
0052                                          m_cfg.varBinning.at("Phi"))});
0053 
0054   m_efficiencies.insert(
0055       {"duplicationRatio_vs_pT",
0056        Efficiency1("duplicationRatio_vs_pT", "Duplication ratio",
0057                    std::array{m_cfg.recoVarBinning.at("Pt")})});
0058   m_efficiencies.insert(
0059       {"duplicationRatio_vs_eta",
0060        Efficiency1("duplicationRatio_vs_eta", "Duplication ratio",
0061                    std::array{m_cfg.recoVarBinning.at("Eta")})});
0062   m_efficiencies.insert(
0063       {"duplicationRatio_vs_phi",
0064        Efficiency1("duplicationRatio_vs_phi", "Duplication ratio",
0065                    std::array{m_cfg.recoVarBinning.at("Phi")})});
0066 }
0067 
0068 void DuplicationPlotTool::fill(
0069     const Acts::BoundTrackParameters& fittedParameters, bool status) {
0070   const auto momentum = fittedParameters.momentum();
0071   const double fit_phi = phi(momentum);
0072   const double fit_eta = eta(momentum);
0073   const double fit_pT = perp(momentum);
0074 
0075   m_efficiencies.at("duplicationRatio_vs_pT").fill({fit_pT}, status);
0076   m_efficiencies.at("duplicationRatio_vs_eta").fill({fit_eta}, status);
0077   m_efficiencies.at("duplicationRatio_vs_phi").fill({fit_phi}, status);
0078 }
0079 
0080 void DuplicationPlotTool::fill(const SimParticleState& truthParticle,
0081                                std::size_t nMatchedTracks) {
0082   const auto t_phi = phi(truthParticle.direction());
0083   const auto t_eta = eta(truthParticle.direction());
0084   const auto t_pT = truthParticle.transverseMomentum();
0085 
0086   const auto nDuplicatedTracks = nMatchedTracks == 0 ? 0 : nMatchedTracks - 1;
0087 
0088   m_profiles.at("nDuplicated_vs_pT")
0089       .fill({t_pT}, static_cast<double>(nDuplicatedTracks));
0090   m_profiles.at("nDuplicated_vs_eta")
0091       .fill({t_eta}, static_cast<double>(nDuplicatedTracks));
0092   m_profiles.at("nDuplicated_vs_phi")
0093       .fill({t_phi}, static_cast<double>(nDuplicatedTracks));
0094 }
0095 
0096 }  // namespace ActsExamples