Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-07 08:28:05

0001 // SPDX-License-Identifier: LGPL-3.0-or-later
0002 // Copyright (C) 2023 - 2026, Joe Osborn, Dmitry Romanov, Wouter Deconinck
0003 
0004 #pragma once
0005 
0006 #include <cstddef>
0007 #include <cmath>
0008 #include <ios>
0009 #include <istream>
0010 #include <limits>
0011 #include <numbers>
0012 #include <ostream>
0013 #include <string>
0014 #include <utility>
0015 
0016 #include <Acts/Definitions/Units.hpp>
0017 #include <Acts/Seeding/SeedConfirmationRangeConfig.hpp>
0018 namespace eicrecon {
0019 
0020 /// Unified configuration for TrackSeeding algorithm.
0021 /// Supports both Acts::SeedFinderOrthogonal and Acts Seeding2 API
0022 ///
0023 /// The algorithm selects the appropriate implementation based on seedingMethod configuration:
0024 /// - SeedingMethod::Auto: Seeding2 when available, otherwise Orthogonal
0025 /// - SeedingMethod::Seeding2: Forces Seeding2
0026 /// - SeedingMethod::Orthogonal: Forces Orthogonal
0027 ///
0028 /// Most parameters work for both implementations. Some parameters are specific to one implementation
0029 /// and are documented accordingly.
0030 struct TrackSeedingConfig {
0031 
0032   //////////////////////////////////////////////////////////////////////////
0033   /// METHOD SELECTION
0034 
0035   enum class SeedingMethod {
0036     /// Automatic selection based on Acts version
0037     Auto,
0038 
0039     /// Force Seeding2 method (modern triplet seeding with KD-tree)
0040     Seeding2,
0041 
0042     /// Force Orthogonal method (legacy orthogonal seeding)
0043     Orthogonal
0044   };
0045 
0046   /// Seeding method to use (auto, seeding2, or orthogonal)
0047 #if Acts_VERSION_MAJOR <= 46
0048   SeedingMethod seedingMethod = SeedingMethod::Orthogonal;
0049 #else
0050   SeedingMethod seedingMethod = SeedingMethod::Seeding2;
0051 #endif
0052 
0053   //////////////////////////////////////////////////////////////////////////
0054   /// GEOMETRY / ACCEPTANCE PARAMETERS
0055 
0056   /// Maximum r of measurements used for seeding
0057   float rMax = 440. * Acts::UnitConstants::mm;
0058   /// Minimum r of measurements used for seeding
0059   float rMin = 33. * Acts::UnitConstants::mm;
0060   /// Maximum z of measurements used for seeding
0061   float zMax = 1700. * Acts::UnitConstants::mm;
0062   /// Minimum z of measurements used for seeding
0063   float zMin = -1500. * Acts::UnitConstants::mm;
0064   /// Minimum phi for seeding (Seeding2 only)
0065   float phiMin = -std::numbers::pi_v<float>;
0066   /// Maximum phi for seeding (Seeding2 only)
0067   float phiMax = std::numbers::pi_v<float>;
0068 
0069   //////////////////////////////////////////////////////////////////////////
0070   /// DOUBLET PARAMETERS
0071 
0072   /// Generic minimum radial distance between doublet space points.
0073   /// Used by Seeding2 and Orthogonal seed-filters and as initial construction-time
0074   /// value for specialized top/bottom doublet windows.
0075   float deltaRMin = 10. * Acts::UnitConstants::mm;
0076 
0077   /// Minimum radial distance for top (outer) space point doublets.
0078   /// Allows independent tuning of top doublet constraints.
0079   /// Initialized from deltaRMin at construction time.
0080   /// If deltaRMin is overridden via parameters, set this explicitly as needed.
0081   float deltaRMinTopSP = deltaRMin;
0082 
0083   /// Maximum radial distance for top (outer) space point doublets.
0084   /// Allows independent tuning of top doublet constraints.
0085   float deltaRMaxTopSP = 450. * Acts::UnitConstants::mm;
0086 
0087   /// Minimum radial distance for bottom (inner) space point doublets.
0088   /// Allows independent tuning of bottom doublet constraints.
0089   /// Initialized from deltaRMin at construction time.
0090   /// If deltaRMin is overridden via parameters, set this explicitly as needed.
0091   float deltaRMinBottomSP = deltaRMin;
0092 
0093   /// Maximum radial distance for bottom (inner) space point doublets.
0094   /// Allows independent tuning of bottom doublet constraints.
0095   float deltaRMaxBottomSP = 200. * Acts::UnitConstants::mm;
0096 
0097   /// Minimum z-distance between doublet space points (Seeding2 only)
0098   /// Note: Cannot use infinity due to JANA2 parameter bug that converts inf->0
0099   float deltaZMin = -std::numeric_limits<float>::max();
0100   /// Maximum z-distance between doublet space points (Seeding2 only)
0101   /// Note: Cannot use infinity due to JANA2 parameter bug that converts inf->0
0102   float deltaZMax = std::numeric_limits<float>::max();
0103 
0104   /// Maximum impact parameter allowed for doublet/seed candidates
0105   float impactMax = 3. * Acts::UnitConstants::mm;
0106 
0107   /// Enable interaction-point cut on doublet compatibility (Seeding2 only)
0108   bool interactionPointCut = false;
0109 
0110   /// Minimum z of collision region
0111   float collisionRegionMin = -250. * Acts::UnitConstants::mm;
0112   /// Maximum z of collision region
0113   float collisionRegionMax = 250. * Acts::UnitConstants::mm;
0114 
0115   /// Maximum cotTheta for doublet/seed candidates (equivalent to eta = 4)
0116   float cotThetaMax = 1.0 / tan(2. * atan(exp(-4.0)));
0117 
0118   /// Shrink the phi range for middle space points
0119   float deltaPhiMax = 0.085;
0120 
0121   /// Helix cut tolerance for doublet compatibility (Seeding2 only)
0122   float helixCutTolerance = 1.0;
0123 
0124   //////////////////////////////////////////////////////////////////////////
0125   /// TRIPLET PARAMETERS
0126 
0127   /// Minimum pT for seeding (GeV)
0128   float minPt = (100. * Acts::UnitConstants::MeV) / (1.0 / tan(2. * atan(exp(-4.0))));
0129   /// Number of sigmas of scattering angle to consider
0130   float sigmaScattering = 5.0;
0131   /// Average radiation lengths per seed
0132   float radLengthPerSeed = 0.1;
0133   /// Tolerance parameter for strip module compatibility (Seeding2 only)
0134   float toleranceParam = 1.1 * Acts::UnitConstants::mm;
0135 
0136   //////////////////////////////////////////////////////////////////////////
0137   /// MIDDLE SPACE POINT REGION
0138 
0139   /// Minimum r for middle space point
0140   float rMinMiddle = 20. * Acts::UnitConstants::mm;
0141   /// Maximum r for middle space point
0142   float rMaxMiddle = 400. * Acts::UnitConstants::mm;
0143 
0144   /// Use variable middle SP r range derived from SP extent (Seeding2 only)
0145   bool useVariableMiddleSPRange = false;
0146   float deltaRMiddleMinSPRange  = 10. * Acts::UnitConstants::mm;
0147   float deltaRMiddleMaxSPRange  = 10. * Acts::UnitConstants::mm;
0148 
0149   /// Min/max z for middle space points (Seeding2 only)
0150   std::pair<float, float> zOutermostLayers{-1500. * Acts::UnitConstants::mm,
0151                                            1700. * Acts::UnitConstants::mm};
0152 
0153   //////////////////////////////////////////////////////////////////////////
0154   /// SEED FILTER PARAMETERS
0155 
0156   float deltaInvHelixDiameter = 0.00003 * 1. / Acts::UnitConstants::mm;
0157   float compatSeedWeight      = 200.;
0158   float impactWeightFactor    = 1.;
0159   float zOriginWeightFactor   = 1.;
0160   unsigned int maxSeedsPerSpM = 0;
0161   std::size_t compatSeedLimit = 2;
0162   float seedWeightIncrement   = 0;
0163 
0164   /// Enable quality seed confirmation
0165   bool seedConfirmation = false;
0166 
0167   ///////////////////////////////////////
0168   /// CENTRAL SEED FILTER PARAMETERS
0169   float zMinSeedConfCentral            = -250. * Acts::UnitConstants::mm;
0170   float zMaxSeedConfCentral            = 250. * Acts::UnitConstants::mm;
0171   float rMaxSeedConfCentral            = 140. * Acts::UnitConstants::mm;
0172   std::size_t nTopForLargeRCentral     = 1;
0173   std::size_t nTopForSmallRCentral     = 2;
0174   float seedConfMinBottomRadiusCentral = 60.0 * Acts::UnitConstants::mm;
0175   float seedConfMaxZOriginCentral      = 150.0 * Acts::UnitConstants::mm;
0176   float minImpactSeedConfCentral       = 1.0 * Acts::UnitConstants::mm;
0177 
0178   ///////////////////////////////////////
0179   /// FORWARD / BACKWARD SEED FILTER PARAMETERS
0180   float zMinSeedConfForward            = -3000. * Acts::UnitConstants::mm;
0181   float zMaxSeedConfForward            = 3000. * Acts::UnitConstants::mm;
0182   float rMaxSeedConfForward            = 140. * Acts::UnitConstants::mm;
0183   std::size_t nTopForLargeRForward     = 1;
0184   std::size_t nTopForSmallRForward     = 2;
0185   float seedConfMinBottomRadiusForward = 60.0 * Acts::UnitConstants::mm;
0186   float seedConfMaxZOriginForward      = 150.0 * Acts::UnitConstants::mm;
0187   float minImpactSeedConfForward       = 1.0 * Acts::UnitConstants::mm;
0188 
0189   //////////////////////////////////////////////////////////////////////////
0190   /// PHYSICS / FIELD PARAMETERS
0191 
0192   /// Magnetic field in z (GeV/[e*mm] = T in Acts units)
0193   /// Magnetic field  Z component (for helix-based cuts) [Acts units]
0194   float bFieldInZ = 1.7 * Acts::UnitConstants::T;
0195   /// Beam position x offset
0196   float beamPosX = 0.;
0197   /// Beam position y offset
0198   float beamPosY = 0.;
0199 
0200   //////////////////////////////////////////////////////////////////////////
0201   /// TRACK PARAMETER ESTIMATION COVARIANCE
0202 
0203   float locaError   = std::sqrt(1.5) * Acts::UnitConstants::mm;
0204   float locbError   = std::sqrt(1.5) * Acts::UnitConstants::mm;
0205   float phiError    = std::sqrt(0.02) * Acts::UnitConstants::rad;
0206   float thetaError  = std::sqrt(0.002) * Acts::UnitConstants::rad;
0207   float qOverPError = std::sqrt(0.025) / Acts::UnitConstants::GeV;
0208   float timeError =
0209       std::sqrt(0.1 * Acts::UnitConstants::mm / Acts::UnitConstants::ns) * Acts::UnitConstants::ns;
0210   // FIXME timeError is currently set to 0.0183 = 5.5 ns in these units since:
0211   // Acts::UnitConstants::mm = 1
0212   // Acts::UnitConstants::ns = 299.792458
0213 };
0214 
0215 inline std::istream& operator>>(std::istream& in,
0216                                 TrackSeedingConfig::SeedingMethod& seedingMethod) {
0217   std::string s;
0218   in >> s;
0219   if (s == "auto") {
0220     seedingMethod = TrackSeedingConfig::SeedingMethod::Auto;
0221   } else if (s == "seeding2") {
0222     seedingMethod = TrackSeedingConfig::SeedingMethod::Seeding2;
0223   } else if (s == "orthogonal") {
0224     seedingMethod = TrackSeedingConfig::SeedingMethod::Orthogonal;
0225   } else {
0226     in.setstate(std::ios::failbit); // Set the fail bit if the input is not valid
0227   }
0228   return in;
0229 }
0230 
0231 inline std::ostream& operator<<(std::ostream& out,
0232                                 const TrackSeedingConfig::SeedingMethod& seedingMethod) {
0233   switch (seedingMethod) {
0234   case TrackSeedingConfig::SeedingMethod::Auto:
0235     out << "auto";
0236     break;
0237   case TrackSeedingConfig::SeedingMethod::Seeding2:
0238     out << "seeding2";
0239     break;
0240   case TrackSeedingConfig::SeedingMethod::Orthogonal:
0241     out << "orthogonal";
0242     break;
0243   default:
0244     out.setstate(std::ios::failbit);
0245   }
0246   return out;
0247 }
0248 
0249 } // namespace eicrecon