Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-11 07:49:55

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/Algebra.hpp"
0012 #include "Acts/Definitions/Units.hpp"
0013 #include "Acts/Material/Interactions.hpp"
0014 #include "Acts/Seeding/SeedConfirmationRangeConfig.hpp"
0015 #include "Acts/Utilities/Delegate.hpp"
0016 
0017 #include <limits>
0018 #include <memory>
0019 #include <numbers>
0020 #include <vector>
0021 
0022 namespace Acts {
0023 
0024 // forward declaration to avoid cyclic dependence
0025 template <typename T>
0026 class SeedFilter;
0027 
0028 /// @brief Structure that holds configuration parameters for the seed finder algorithm
0029 template <typename SpacePoint>
0030 struct SeedFinderConfig {
0031   std::shared_ptr<SeedFilter<SpacePoint>> seedFilter;
0032 
0033   /// Seeding parameters used in the space-point grid creation and bin finding
0034 
0035   /// Geometry Settings + Detector ROI
0036   /// (r, z, phi) range for limiting location of all measurements and grid
0037   /// creation
0038   float phiMin = -std::numbers::pi_v<float>;
0039   float phiMax = std::numbers::pi_v<float>;
0040   float zMin = -2800 * UnitConstants::mm;
0041   float zMax = 2800 * UnitConstants::mm;
0042   float rMax = 600 * UnitConstants::mm;
0043   /// WARNING: if rMin is smaller than impactMax, the bin size will be 2*pi,
0044   /// which will make seeding very slow!
0045   float rMin = 33 * UnitConstants::mm;
0046 
0047   /// Vector containing the z-bin edges for non equidistant binning in z
0048   std::vector<float> zBinEdges;
0049 
0050   /// Order of z bins to loop over when searching for SPs
0051   std::vector<std::size_t> zBinsCustomLooping = {};
0052 
0053   /// Radial bin size used in space-point grid
0054   float binSizeR = 1. * UnitConstants::mm;
0055 
0056   /// Seeding parameters used to define the region of interest for middle
0057   /// space-point
0058 
0059   /// Radial range for middle space-point
0060   /// The range can be defined manually with (rMinMiddle, rMaxMiddle). If
0061   /// useVariableMiddleSPRange is set to false and the vector rRangeMiddleSP is
0062   /// empty, we use (rMinMiddle, rMaxMiddle) to cut the middle space-points
0063   float rMinMiddle = 60.f * UnitConstants::mm;
0064   float rMaxMiddle = 120.f * UnitConstants::mm;
0065   /// If useVariableMiddleSPRange is set to false, the vector rRangeMiddleSP can
0066   /// be used to define a fixed r range for each z bin: {{rMin, rMax}, ...}
0067   bool useVariableMiddleSPRange = false;
0068   /// Range defined in vector for each z bin
0069   std::vector<std::vector<float>> rRangeMiddleSP;
0070   /// If useVariableMiddleSPRange is true, the radial range will be calculated
0071   /// based on the maximum and minimum r values of the space-points in the event
0072   /// and a deltaR (deltaRMiddleMinSPRange, deltaRMiddleMaxSPRange)
0073   float deltaRMiddleMinSPRange = 10. * UnitConstants::mm;
0074   float deltaRMiddleMaxSPRange = 10. * UnitConstants::mm;
0075 
0076   /// Seeding parameters used to define the cuts on space-point doublets
0077 
0078   /// Minimum radial distance between two doublet components (prefer
0079   /// deltaRMinTopSP and deltaRMinBottomSP to set separate values for outer and
0080   /// inner space-points)
0081   float deltaRMin = 5 * UnitConstants::mm;
0082   /// Maximum radial distance between two doublet components (prefer
0083   /// deltaRMaxTopSP and deltaRMacBottomSP to set separate values for outer and
0084   /// inner space-points)
0085   float deltaRMax = 270 * UnitConstants::mm;
0086   /// Minimum radial distance between middle-outer doublet components
0087   float deltaRMinTopSP = std::numeric_limits<float>::quiet_NaN();
0088   /// Maximum radial distance between middle-outer doublet components
0089   float deltaRMaxTopSP = std::numeric_limits<float>::quiet_NaN();
0090   /// Minimum radial distance between inner-middle doublet components
0091   float deltaRMinBottomSP = std::numeric_limits<float>::quiet_NaN();
0092   /// Maximum radial distance between inner-middle doublet components
0093   float deltaRMaxBottomSP = std::numeric_limits<float>::quiet_NaN();
0094 
0095   /// Maximum value of z-distance between space-points in doublet
0096   float deltaZMax = std::numeric_limits<float>::infinity() * UnitConstants::mm;
0097 
0098   /// Maximum allowed cotTheta between two space-points in doublet, used to
0099   /// check if forward angle is within bounds
0100   float cotThetaMax = 10.01788;  // equivalent to eta = 3 (pseudorapidity)
0101 
0102   /// Limiting location of collision region in z-axis used to check if doublet
0103   /// origin is within reasonable bounds
0104   float collisionRegionMin = -150 * UnitConstants::mm;
0105   float collisionRegionMax = +150 * UnitConstants::mm;
0106 
0107   /// Enable cut on the compatibility between interaction point and doublet,
0108   /// this is an useful approximation to speed up the seeding
0109   bool interactionPointCut = false;
0110 
0111   /// Seeding parameters used to define the cuts on space-point triplets
0112 
0113   /// Minimum transverse momentum (pT) used to check the r-z slope compatibility
0114   /// of triplets with maximum multiple scattering effect (produced by the
0115   /// minimum allowed pT particle) + a certain uncertainty term. Check the
0116   /// documentation for more information
0117   /// https://acts.readthedocs.io/en/latest/core/reconstruction/pattern_recognition/seeding.html
0118   float minPt = 400. * UnitConstants::MeV;
0119   /// Number of sigmas of scattering angle to be considered in the minimum pT
0120   /// scattering term
0121   float sigmaScattering = 5;
0122   /// Term that accounts for the thickness of scattering medium in radiation
0123   /// lengths in the Lynch & Dahl correction to the Highland equation default is
0124   /// 5%
0125   /// TODO: necessary to make amount of material dependent on detector region?
0126   float radLengthPerSeed = 0.05;
0127   /// Maximum transverse momentum for scattering calculation
0128   float maxPtScattering = 10 * UnitConstants::GeV;
0129   /// Maximum value of impact parameter estimation of the seed candidates
0130   float impactMax = 20. * UnitConstants::mm;
0131   /// Parameter which can loosen the tolerance of the track seed to form a
0132   /// helix. This is useful for e.g. misaligned seeding.
0133   float helixCutTolerance = 1.;
0134 
0135   /// Seeding parameters used for quality seed confirmation
0136 
0137   /// Enable quality seed confirmation, this is different than default seeding
0138   /// confirmation because it can also be defined for different (r, z) regions
0139   /// of the detector (e.g. forward or central region) by SeedConfirmationRange.
0140   /// Seeds are classified as "high-quality" seeds and normal quality seeds.
0141   /// Normal quality seeds are only selected if no other "high-quality" seeds
0142   /// has been found for that inner-middle doublet.
0143   bool seedConfirmation = false;
0144   /// Contains parameters for central seed confirmation
0145   SeedConfirmationRangeConfig centralSeedConfirmationRange;
0146   /// Contains parameters for forward seed confirmation
0147   SeedConfirmationRangeConfig forwardSeedConfirmationRange;
0148   /// Maximum number (minus one) of accepted seeds per middle space-point
0149   unsigned int maxSeedsPerSpM = 5;
0150 
0151   /// Other parameters
0152 
0153   /// Alignment uncertainties, used for uncertainties in the
0154   /// non-measurement-plane of the modules
0155   /// which otherwise would be 0
0156   /// will be added to spacepoint measurement uncertainties (and therefore also
0157   /// multiplied by sigmaError)
0158   /// FIXME: call align1 and align2
0159   float zAlign = 0 * UnitConstants::mm;
0160   float rAlign = 0 * UnitConstants::mm;
0161   /// used for measurement (+alignment) uncertainties.
0162   /// find seeds within 5sigma error ellipse
0163   float sigmaError = 5;
0164 
0165   /// derived values, set on SeedFinder construction
0166   float highland = 0;
0167   float maxScatteringAngle2 = 0;
0168 
0169   /// only for Cuda plugin
0170   int maxBlockSize = 1024;
0171   int nTrplPerSpBLimit = 100;
0172   int nAvgTrplPerSpBLimit = 2;
0173 
0174   /// Delegates for accessors to detailed information on double measurement that
0175   /// produced the space point.
0176   /// This is mainly referring to space points produced when combining
0177   /// measurement from strips on back-to-back modules.
0178   /// Enables setting of the following delegates.
0179   bool useDetailedDoubleMeasurementInfo = false;
0180 
0181   Delegate<bool(const SpacePoint&)> spacePointSelector{
0182       DelegateFuncTag<voidSpacePointSelector>{}};
0183 
0184   static bool voidSpacePointSelector(const SpacePoint& /*sp*/) { return true; }
0185 
0186   /// Tolerance parameter used to check the compatibility of space-point
0187   /// coordinates in xyz. This is only used in a detector specific check for
0188   /// strip modules
0189   float toleranceParam = 1.1 * UnitConstants::mm;
0190 
0191   // Delegate to apply experiment specific cuts during doublet finding
0192   Delegate<bool(float /*bottomRadius*/, float /*cotTheta*/)> experimentCuts{
0193       DelegateFuncTag<&noopExperimentCuts>{}};
0194 
0195   bool isInInternalUnits = true;
0196   //[[deprecated("SeedFinderConfig uses internal units")]]
0197   SeedFinderConfig toInternalUnits() const { return *this; }
0198 
0199   SeedFinderConfig calculateDerivedQuantities() const {
0200     SeedFinderConfig config = *this;
0201     config.highland = approximateHighlandScattering(config.radLengthPerSeed);
0202     const float maxScatteringAngle = config.highland / minPt;
0203     config.maxScatteringAngle2 = maxScatteringAngle * maxScatteringAngle;
0204     return config;
0205   }
0206 };
0207 
0208 struct SeedFinderOptions {
0209   // location of beam in x,y plane.
0210   // used as offset for Space Points
0211   Vector2 beamPos{0 * UnitConstants::mm, 0 * UnitConstants::mm};
0212   // field induction
0213   float bFieldInZ = 2 * UnitConstants::T;
0214 
0215   // derived quantities
0216   float pTPerHelixRadius = std::numeric_limits<float>::quiet_NaN();
0217   float minHelixDiameter2 = std::numeric_limits<float>::quiet_NaN();
0218   float pT2perRadius = std::numeric_limits<float>::quiet_NaN();
0219   float sigmapT2perRadius = std::numeric_limits<float>::quiet_NaN();
0220   float multipleScattering2 = std::numeric_limits<float>::quiet_NaN();
0221 
0222   bool isInInternalUnits = true;
0223   //[[deprecated("SeedFinderOptions uses internal units")]]
0224   SeedFinderOptions toInternalUnits() const { return *this; }
0225 
0226   template <typename Config>
0227   SeedFinderOptions calculateDerivedQuantities(const Config& config) const {
0228     using namespace UnitLiterals;
0229 
0230     SeedFinderOptions options = *this;
0231     // bFieldInZ is in (pT/radius) natively, no need for conversion
0232     options.pTPerHelixRadius = options.bFieldInZ;
0233     options.minHelixDiameter2 =
0234         std::pow(config.minPt * 2 / options.pTPerHelixRadius, 2) *
0235         config.helixCutTolerance;
0236     options.pT2perRadius =
0237         std::pow(config.highland / options.pTPerHelixRadius, 2);
0238     options.sigmapT2perRadius =
0239         options.pT2perRadius * std::pow(2 * config.sigmaScattering, 2);
0240     options.multipleScattering2 =
0241         config.maxScatteringAngle2 * std::pow(config.sigmaScattering, 2);
0242     return options;
0243   }
0244 };
0245 
0246 }  // namespace Acts