Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:23:16

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 "Acts/Seeding/CompositeSpacePointLineFitter.hpp"
0010 
0011 namespace Acts::Experimental {
0012 
0013 CompositeSpacePointLineFitter::CompositeSpacePointLineFitter(
0014     const Config& cfg, std::unique_ptr<const Logger> logger)
0015     : m_cfg{cfg}, m_logger{std::move(logger)} {
0016   std::ranges::sort(m_cfg.parsToUse);
0017 }
0018 
0019 detail::FastStrawLineFitter::Config
0020 CompositeSpacePointLineFitter::fastFitterCfg() const {
0021   detail::FastStrawLineFitter::Config fastCfg{};
0022   fastCfg.maxIter = m_cfg.maxIter;
0023   fastCfg.precCutOff = m_cfg.precCutOff;
0024   return fastCfg;
0025 }
0026 
0027 std::vector<CompositeSpacePointLineFitter::FitParIndex>
0028 CompositeSpacePointLineFitter::extractFitablePars(
0029     const DoFcounts& hitCounts) const {
0030   if (!m_cfg.parsToUse.empty()) {
0031     return m_cfg.parsToUse;
0032   }
0033   std::vector<FitParIndex> pars{};
0034   using enum FitParIndex;
0035   if (hitCounts.nonBending > 1) {
0036     pars.insert(pars.end(), {x0, phi});
0037   }
0038   // Measurements in the bending direction
0039   if (hitCounts.bending > 1) {
0040     pars.insert(pars.end(), {y0, theta});
0041   }
0042   // Time measurements
0043   if (m_cfg.fitT0 && (hitCounts.time + hitCounts.straw) > 1) {
0044     pars.push_back(t0);
0045   }
0046   std::ranges::sort(pars);
0047   return pars;
0048 }
0049 
0050 bool CompositeSpacePointLineFitter::withinRange(
0051     const double parValue, const FitParIndex fitPar) const {
0052   const auto p = toUnderlying(fitPar);
0053   /// The parameter is unbound
0054   if (m_cfg.ranges[p][0] >= m_cfg.ranges[p][1]) {
0055     return true;
0056   }
0057   if (parValue < m_cfg.ranges[p][0] || parValue > m_cfg.ranges[p][1]) {
0058     ACTS_VERBOSE(__func__ << "() " << __LINE__ << ": The parameter "
0059                           << detail::CompSpacePointAuxiliaries::parName(fitPar)
0060                           << " " << parValue << " is out range ["
0061                           << m_cfg.ranges[p][0] << ";" << m_cfg.ranges[p][1]
0062                           << "]");
0063     return false;
0064   }
0065   return true;
0066 }
0067 bool CompositeSpacePointLineFitter::withinRange(
0068     const ParamVec_t& pars, const std::vector<FitParIndex>& parsToUse) const {
0069   return std::ranges::all_of(parsToUse, [&](const FitParIndex par) {
0070     return withinRange(pars[toUnderlying(par)], par);
0071   });
0072 }
0073 
0074 void CompositeSpacePointLineFitter::FitParameters::print(
0075     std::ostream& ostr) const {
0076   using namespace Acts::UnitLiterals;
0077   using enum FitParIndex;
0078   ostr << "parameters converged: " << (converged ? "yes" : "no") << ", ";
0079   ostr << "# iterations: " << nIter << ", ";
0080   ostr << "chi2: " << chi2 << ", ";
0081   ostr << "parameters - ";
0082   ostr << std::format("theta: {:.3f}, ",
0083                       parameters[toUnderlying(theta)] / 1._degree);
0084   ostr << std::format("phi: {:.3f}, ",
0085                       parameters[toUnderlying(phi)] / 1._degree);
0086   ostr << std::format("y0: {:.3f}, ", parameters[toUnderlying(y0)]);
0087   ostr << std::format("x0: {:.3f}, ", parameters[toUnderlying(x0)]);
0088   ostr << std::format("t0: {:.3f}, ", parameters[toUnderlying(t0)] / 1._ns);
0089   ostr << "covariance - \n" << covariance << ",\n";
0090 }
0091 }  // namespace Acts::Experimental