Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-09 08:21:44

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 // GCC 15 reports the axis metadata strings of the default `ResPlotTool::Config`
0010 // as maybe-uninitialized while copying them into the binning map. The pragma
0011 // has to cover the includes because the warning is reported at the inlined
0012 // `std::string` destructor in `<string>`.
0013 #if defined(__GNUC__) && !defined(__clang__)
0014 #pragma GCC diagnostic push
0015 #pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
0016 #endif
0017 
0018 #include <boost/test/unit_test.hpp>
0019 
0020 #include "Acts/Definitions/TrackParametrization.hpp"
0021 #include "Acts/Definitions/Units.hpp"
0022 #include "Acts/EventData/BoundTrackParameters.hpp"
0023 #include "Acts/Surfaces/PerigeeSurface.hpp"
0024 #include "ActsExamples/Validation/ResPlotTool.hpp"
0025 
0026 #include <memory>
0027 #include <numbers>
0028 
0029 #if defined(__GNUC__) && !defined(__clang__)
0030 #pragma GCC diagnostic pop
0031 #endif
0032 
0033 using namespace Acts;
0034 using namespace ActsExamples;
0035 
0036 namespace {
0037 
0038 /// The number of entries in the in-range bins of @p histogram, i.e. excluding
0039 /// the under- and overflow bins.
0040 double inRangeEntries(const ResPlotTool::Histogram1& histogram) {
0041   double sum = 0;
0042   for (int i = 0; i < histogram.histogram().axis(0).size(); ++i) {
0043     sum += histogram.binContent({i});
0044   }
0045   return sum;
0046 }
0047 
0048 /// The default config with the perigee parameter names filled in, which the
0049 /// tool leaves to its caller.
0050 ResPlotTool::Config makeConfig() {
0051   ResPlotTool::Config cfg;
0052   cfg.paramNames = {"d0", "z0", "phi", "theta", "qop", "t"};
0053   return cfg;
0054 }
0055 
0056 BoundTrackParameters makeParameters(
0057     const std::shared_ptr<const Surface>& surface, double phi) {
0058   BoundVector parameters = BoundVector::Zero();
0059   parameters[eBoundPhi] = phi;
0060   parameters[eBoundTheta] = std::numbers::pi / 2;
0061   parameters[eBoundQOverP] = 1. / (1. * UnitConstants::GeV);
0062 
0063   return BoundTrackParameters(surface, parameters,
0064                               BoundMatrix::Identity() * 1e-4,
0065                               ParticleHypothesis::pion());
0066 }
0067 
0068 }  // namespace
0069 
0070 BOOST_AUTO_TEST_SUITE(ValidationResPlotTool)
0071 
0072 // a track pointing along -x has truth and reco phi on opposite sides of the
0073 // wrap, where the naive difference is almost a full turn
0074 BOOST_AUTO_TEST_CASE(PhiResidualWrapsAround) {
0075   ResPlotTool tool(makeConfig(), Acts::Logging::INFO);
0076 
0077   const auto surface = Surface::makeShared<PerigeeSurface>(Vector3::Zero());
0078   const double delta = 0.00105;
0079   tool.fill(makeParameters(surface, std::numbers::pi - delta),
0080             makeParameters(surface, -std::numbers::pi + delta));
0081 
0082   // without the wrap the residual is `-2 pi + 2 delta` and lands in underflow
0083   const ResPlotTool::Histogram1& residual = tool.res().at("phi");
0084   BOOST_CHECK_EQUAL(inRangeEntries(residual), 1.);
0085 
0086   const int bin = residual.histogram().axis(0).index(2 * delta);
0087   BOOST_CHECK_EQUAL(residual.binContent({bin}), 1.);
0088 }
0089 
0090 // the same fill away from the wrap must be untouched by it
0091 BOOST_AUTO_TEST_CASE(PhiResidualAwayFromTheWrap) {
0092   ResPlotTool tool(makeConfig(), Acts::Logging::INFO);
0093 
0094   const auto surface = Surface::makeShared<PerigeeSurface>(Vector3::Zero());
0095   const double delta = 0.00105;
0096   tool.fill(makeParameters(surface, 0.), makeParameters(surface, delta));
0097 
0098   const ResPlotTool::Histogram1& residual = tool.res().at("phi");
0099   const int bin = residual.histogram().axis(0).index(delta);
0100   BOOST_CHECK_EQUAL(residual.binContent({bin}), 1.);
0101 }
0102 
0103 BOOST_AUTO_TEST_SUITE_END()