Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-12 07:51:39

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 #pragma once
0010 
0011 #include "Acts/Definitions/Direction.hpp"
0012 #include "Acts/EventData/SpacePointContainer2.hpp"
0013 #include "Acts/Seeding/SeedFinderUtils.hpp"
0014 #include "Acts/Utilities/Delegate.hpp"
0015 
0016 #include <vector>
0017 
0018 namespace Acts::Experimental {
0019 
0020 class DoubletSeedFinder {
0021  public:
0022   struct Config {
0023     /// Direction of the doublet candidate space points. Either forward, also
0024     /// called top doublet, or backward, also called bottom doublet.
0025     Direction candidateDirection = Direction::Forward();
0026 
0027     /// Minimum radial distance between two doublet components
0028     float deltaRMin = 5 * Acts::UnitConstants::mm;
0029     /// Maximum radial distance between two doublet components
0030     float deltaRMax = 270 * Acts::UnitConstants::mm;
0031 
0032     /// Minimal z distance between two doublet components
0033     float deltaZMin = -std::numeric_limits<float>::infinity();
0034     /// Maximum z distance between two doublet components
0035     float deltaZMax = std::numeric_limits<float>::infinity();
0036 
0037     /// Maximum value of impact parameter estimation of the seed candidates
0038     float impactMax = 20 * UnitConstants::mm;
0039 
0040     /// Enable cut on the compatibility between interaction point and doublet,
0041     /// this is an useful approximation to speed up the seeding
0042     bool interactionPointCut = false;
0043 
0044     /// Limiting location of collision region in z-axis used to check if doublet
0045     /// origin is within reasonable bounds
0046     float collisionRegionMin = -150 * UnitConstants::mm;
0047     float collisionRegionMax = +150 * UnitConstants::mm;
0048 
0049     /// Maximum allowed cotTheta between two space-points in doublet, used to
0050     /// check if forward angle is within bounds
0051     float cotThetaMax = 10.01788;  // equivalent to eta = 3 (pseudorapidity)
0052 
0053     /// Minimum transverse momentum (pT) used to check the r-z slope
0054     /// compatibility of triplets with maximum multiple scattering effect
0055     /// (produced by the minimum allowed pT particle) + a certain uncertainty
0056     /// term. Check the documentation for more information
0057     /// https://acts.readthedocs.io/en/latest/core/reconstruction/pattern_recognition/seeding.html
0058     float minPt = 400 * UnitConstants::MeV;
0059     /// Parameter which can loosen the tolerance of the track seed to form a
0060     /// helix. This is useful for e.g. misaligned seeding.
0061     float helixCutTolerance = 1;
0062 
0063     /// Delegate to apply experiment specific cuts during doublet finding
0064     Delegate<bool(float /*bottomRadius*/, float /*cotTheta*/)> experimentCuts;
0065   };
0066 
0067   struct DerivedConfig : public Config {
0068     DerivedConfig(const Config& cfg, float bFieldInZ);
0069 
0070     float bFieldInZ = 0;
0071     float minHelixDiameter2 = std::numeric_limits<float>::quiet_NaN();
0072   };
0073 
0074   struct DoubletsForMiddleSp {
0075     std::vector<SpacePointIndex2> spacePoints;
0076     /// contains parameters required to calculate a circle with linear equation
0077     std::vector<LinCircle> linCircles;
0078     std::vector<float> cotTheta;
0079 
0080     [[nodiscard]] bool empty() const { return spacePoints.empty(); }
0081 
0082     [[nodiscard]] std::size_t size() const { return spacePoints.size(); }
0083 
0084     void clear() {
0085       spacePoints.clear();
0086       linCircles.clear();
0087       cotTheta.clear();
0088     }
0089 
0090     void emplace_back(SpacePointIndex2 sp, const LinCircle& linCircle) {
0091       spacePoints.emplace_back(sp);
0092       linCircles.emplace_back(linCircle);
0093       cotTheta.emplace_back(linCircle.cotTheta);
0094     }
0095   };
0096 
0097   struct MiddleSpInfo {
0098     /// minus one over radius of middle SP
0099     float uIP{};
0100     /// square of uIP
0101     float uIP2{};
0102     /// ratio between middle SP x position and radius
0103     float cosPhiM{};
0104     /// ratio between middle SP y position and radius
0105     float sinPhiM{};
0106   };
0107 
0108   static MiddleSpInfo computeMiddleSpInfo(const ConstSpacePointProxy2& spM);
0109 
0110   explicit DoubletSeedFinder(const DerivedConfig& cfg);
0111 
0112   const DerivedConfig& config() const { return m_cfg; }
0113 
0114   /// Creates compatible dublets by applying a series of cuts that can be
0115   /// tested with only two SPs.
0116   ///
0117   /// @param spacePoints Space point container
0118   /// @param middleSp Space point candidate to be used as middle SP in a seed
0119   /// @param middleSpInfo Information about the middle space point
0120   /// @param candidateSps Group of space points to be used as candidates for
0121   ///                     middle SP in a seed
0122   /// @param compatibleDoublets Output container for compatible doublets
0123   void createDoublets(const SpacePointContainer2& spacePoints,
0124                       const ConstSpacePointProxy2& middleSp,
0125                       const MiddleSpInfo& middleSpInfo,
0126                       std::span<const SpacePointIndex2> candidateSps,
0127                       DoubletsForMiddleSp& compatibleDoublets) const;
0128 
0129   /// Creates compatible dublets by applying a series of cuts that can be
0130   /// tested with only two SPs. Input space points need to be sorted by radius.
0131   ///
0132   /// @param spacePoints Space point container
0133   /// @param middleSp Space point candidate to be used as middle SP in a seed
0134   /// @param middleSpInfo Information about the middle space point
0135   /// @param candidateSps Group of space points to be used as candidates for
0136   ///                     middle SP in a seed
0137   /// @param candidateOffset Offset in the candidateSps span to start from
0138   /// @param compatibleDoublets Output container for compatible doublets
0139   void createSortedDoublets(const SpacePointContainer2& spacePoints,
0140                             const ConstSpacePointProxy2& middleSp,
0141                             const MiddleSpInfo& middleSpInfo,
0142                             std::span<const SpacePointIndex2> candidateSps,
0143                             std::size_t& candidateOffset,
0144                             DoubletsForMiddleSp& compatibleDoublets) const;
0145 
0146  private:
0147   DerivedConfig m_cfg;
0148 };
0149 
0150 }  // namespace Acts::Experimental