Back to home page

EIC code displayed by LXR

 
 

    


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

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/TrackFinding/SeedingOrthogonalAlgorithm.hpp"
0010 
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/EventData/Seed.hpp"
0013 #include "Acts/Seeding/SeedFilter.hpp"
0014 #include "ActsExamples/EventData/SimSeed.hpp"
0015 
0016 #include <ostream>
0017 #include <stdexcept>
0018 #include <utility>
0019 
0020 namespace ActsExamples {
0021 
0022 SeedingOrthogonalAlgorithm::SeedingOrthogonalAlgorithm(
0023     SeedingOrthogonalAlgorithm::Config cfg, Acts::Logging::Level lvl)
0024     : IAlgorithm("SeedingAlgorithm", lvl), m_cfg(std::move(cfg)) {
0025   m_cfg.seedFinderConfig = m_cfg.seedFinderConfig.calculateDerivedQuantities();
0026   m_cfg.seedFinderOptions = m_cfg.seedFinderOptions.calculateDerivedQuantities(
0027       m_cfg.seedFinderConfig);
0028 
0029   printOptions();
0030   printConfig<SimSpacePoint>();
0031 
0032   if (m_cfg.inputSpacePoints.empty()) {
0033     throw std::invalid_argument("Missing space point input collections");
0034   }
0035 
0036   for (const auto &spName : m_cfg.inputSpacePoints) {
0037     if (spName.empty()) {
0038       throw std::invalid_argument("Invalid space point input collection");
0039     }
0040 
0041     auto &handle = m_inputSpacePoints.emplace_back(
0042         std::make_unique<ReadDataHandle<SimSpacePointContainer>>(
0043             this,
0044             "InputSpacePoints#" + std::to_string(m_inputSpacePoints.size())));
0045     handle->initialize(spName);
0046   }
0047 
0048   if (m_cfg.outputSeeds.empty()) {
0049     throw std::invalid_argument("Missing seeds output collection");
0050   }
0051 
0052   m_outputSeeds.initialize(m_cfg.outputSeeds);
0053 
0054   if (m_cfg.seedFilterConfig.maxSeedsPerSpM !=
0055       m_cfg.seedFinderConfig.maxSeedsPerSpM) {
0056     throw std::invalid_argument("Inconsistent config maxSeedsPerSpM");
0057   }
0058 
0059   // construct seed filter
0060   m_cfg.seedFinderConfig.seedFilter =
0061       std::make_unique<Acts::SeedFilter<proxy_type>>(
0062           m_cfg.seedFilterConfig, logger().cloneWithSuffix("Filter"));
0063 
0064   m_finder = std::make_unique<Acts::SeedFinderOrthogonal<proxy_type>>(
0065       m_cfg.seedFinderConfig, logger().cloneWithSuffix("Finder"));
0066 }
0067 
0068 ProcessCode SeedingOrthogonalAlgorithm::execute(
0069     const AlgorithmContext &ctx) const {
0070   std::vector<const SimSpacePoint *> spacePoints;
0071 
0072   for (const auto &isp : m_inputSpacePoints) {
0073     for (const auto &spacePoint : (*isp)(ctx)) {
0074       spacePoints.push_back(&spacePoint);
0075     }
0076   }
0077 
0078   // Config
0079   Acts::SpacePointContainerConfig spConfig;
0080 
0081   // Options
0082   Acts::SpacePointContainerOptions spOptions;
0083   spOptions.beamPos = {0., 0.};
0084 
0085   SpacePointContainer container(spacePoints);
0086   Acts::SpacePointContainer<decltype(container), Acts::detail::RefHolder>
0087       spContainer(spConfig, spOptions, container);
0088 
0089   ACTS_DEBUG("About to process " << spContainer.size() << " space points ...");
0090 
0091   std::vector<Acts::Seed<proxy_type>> seeds =
0092       m_finder->createSeeds(m_cfg.seedFinderOptions, spContainer);
0093 
0094   ACTS_DEBUG("Created " << seeds.size() << " track seeds from "
0095                         << spacePoints.size() << " space points");
0096 
0097   // need to convert here from seed of proxies to seed of sps
0098   SimSeedContainer seedsToAdd;
0099   seedsToAdd.reserve(seeds.size());
0100 
0101   for (const auto &seed : seeds) {
0102     const auto &sps = seed.sp();
0103     seedsToAdd.emplace_back(*sps[0]->externalSpacePoint(),
0104                             *sps[1]->externalSpacePoint(),
0105                             *sps[2]->externalSpacePoint());
0106     seedsToAdd.back().setVertexZ(seed.z());
0107     seedsToAdd.back().setQuality(seed.seedQuality());
0108   }
0109 
0110   m_outputSeeds(ctx, std::move(seedsToAdd));
0111 
0112   return ProcessCode::SUCCESS;
0113 }
0114 
0115 void SeedingOrthogonalAlgorithm::printOptions() const {
0116   ACTS_DEBUG("SeedFinderOptions");
0117   ACTS_DEBUG("beamPos           " << m_cfg.seedFinderOptions.beamPos);
0118   // field induction
0119   ACTS_DEBUG("bFieldInZ         " << m_cfg.seedFinderOptions.bFieldInZ);
0120   // derived quantities
0121   ACTS_DEBUG("pTPerHelixRadius  " << m_cfg.seedFinderOptions.pTPerHelixRadius);
0122   ACTS_DEBUG("minHelixDiameter2 " << m_cfg.seedFinderOptions.minHelixDiameter2);
0123   ACTS_DEBUG("pT2perRadius      " << m_cfg.seedFinderOptions.pT2perRadius);
0124   ACTS_DEBUG("sigmapT2perRadius " << m_cfg.seedFinderOptions.sigmapT2perRadius);
0125   ACTS_DEBUG("...\n");
0126 }
0127 
0128 template <typename sp>
0129 void SeedingOrthogonalAlgorithm::printConfig() const {
0130   ACTS_DEBUG("SeedFinderOrthogonalConfig");
0131   ACTS_DEBUG("minPt                 " << m_cfg.seedFinderConfig.minPt);
0132   ACTS_DEBUG("deltaRMinTopSP        " << m_cfg.seedFinderConfig.deltaRMinTopSP);
0133   ACTS_DEBUG("deltaRMaxTopSP        " << m_cfg.seedFinderConfig.deltaRMaxTopSP);
0134   ACTS_DEBUG("deltaRMinBottomSP     "
0135              << m_cfg.seedFinderConfig.deltaRMinBottomSP);
0136   ACTS_DEBUG("deltaRMaxBottomSP     "
0137              << m_cfg.seedFinderConfig.deltaRMaxBottomSP);
0138   ACTS_DEBUG("impactMax             " << m_cfg.seedFinderConfig.impactMax);
0139   ACTS_DEBUG("maxPtScattering       "
0140              << m_cfg.seedFinderConfig.maxPtScattering);
0141   ACTS_DEBUG("collisionRegionMin    "
0142              << m_cfg.seedFinderConfig.collisionRegionMin);
0143   ACTS_DEBUG("collisionRegionMax    "
0144              << m_cfg.seedFinderConfig.collisionRegionMax);
0145   ACTS_DEBUG("zMin                  " << m_cfg.seedFinderConfig.zMin);
0146   ACTS_DEBUG("zMax                  " << m_cfg.seedFinderConfig.zMax);
0147   ACTS_DEBUG("rMax                  " << m_cfg.seedFinderConfig.rMax);
0148   ACTS_DEBUG("rMin                  " << m_cfg.seedFinderConfig.rMin);
0149   ACTS_DEBUG("highland              " << m_cfg.seedFinderConfig.highland);
0150   ACTS_DEBUG("maxScatteringAngle2   "
0151              << m_cfg.seedFinderConfig.maxScatteringAngle2);
0152   ACTS_DEBUG("...\n");
0153 }
0154 
0155 }  // namespace ActsExamples