Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-07 08:11:11

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2018 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 http://mozilla.org/MPL/2.0/.
0008 
0009 ///////////////////////////////////////////////////////////////////
0010 // AtlasSeedFinder.hpp Acts project
0011 ///////////////////////////////////////////////////////////////////
0012 
0013 #pragma once
0014 #include "Acts/Seeding/LegacyInternalSeed.hpp"
0015 #include "Acts/Seeding/SPForSeed.hpp"
0016 
0017 #include <list>
0018 #include <map>
0019 #include <set>
0020 #include <string>
0021 #include <utility>
0022 #include <vector>
0023 
0024 namespace Acts::Legacy {
0025 template <typename SpacePoint>
0026 class AtlasSeedFinder {
0027   struct Config {
0028     // UNIT AS RETURNED BY m_fieldService->getField() default value in ATLAS
0029     // was
0030     // 5. Unit is kilo-Tesla
0031     //  double bFieldInZ = 5.;
0032     double bFieldInZ = 0.00208;
0033 
0034     double SCT_rMin = 200.;
0035 
0036     double beamPosX = 0;
0037     double beamPosY = 0;
0038     double beamPosZ = 0;
0039     double beamTiltX = 0;
0040     double beamTiltY = 0;
0041   };
0042   ///////////////////////////////////////////////////////////////////
0043   // Public methods:
0044   ///////////////////////////////////////////////////////////////////
0045 
0046  public:
0047   ///////////////////////////////////////////////////////////////////
0048   // Standard tool methods
0049   ///////////////////////////////////////////////////////////////////
0050 
0051   AtlasSeedFinder();
0052   virtual ~AtlasSeedFinder() {
0053     if (r_index != nullptr) {
0054       delete[] r_index;
0055     }
0056     if (r_map != nullptr) {
0057       delete[] r_map;
0058     }
0059     if (r_Sorted != nullptr) {
0060       delete[] r_Sorted;
0061     }
0062 
0063     // Delete seeds
0064     //
0065     for (i_seed = l_seeds.begin(); i_seed != l_seeds.end(); ++i_seed) {
0066       delete *i_seed;
0067     }
0068     // Delete space points for reconstruction
0069     //
0070     i_spforseed = l_spforseed.begin();
0071     for (; i_spforseed != l_spforseed.end(); ++i_spforseed) {
0072       delete *i_spforseed;
0073     }
0074     if (m_seedOutput != nullptr) {
0075       delete m_seedOutput;
0076     }
0077 
0078     if (m_SP != nullptr) {
0079       delete[] m_SP;
0080     }
0081     if (m_R != nullptr) {
0082       delete[] m_R;
0083     }
0084     if (m_Tz != nullptr) {
0085       delete[] m_Tz;
0086     }
0087     if (m_Er != nullptr) {
0088       delete[] m_Er;
0089     }
0090     if (m_U != nullptr) {
0091       delete[] m_U;
0092     }
0093     if (m_V != nullptr) {
0094       delete[] m_V;
0095     }
0096     if (m_Zo != nullptr) {
0097       delete[] m_Zo;
0098     }
0099     if (m_OneSeeds != nullptr) {
0100       delete[] m_OneSeeds;
0101     }
0102   }
0103 
0104   ///////////////////////////////////////////////////////////////////
0105   // Methods to initialize tool for new event or region
0106   ///////////////////////////////////////////////////////////////////
0107 
0108   template <class RandIter>
0109   void newEvent(int /*iteration*/, RandIter /*spBegin*/, RandIter /*spEnd*/);
0110 
0111   //////////////////////////////////////////////////////////////////
0112   // Method to initialize seeds production
0113   //////////////////////////////////////////////////////////////////
0114   void find3Sp();
0115 
0116   ///////////////////////////////////////////////////////////////////
0117   // Iterator through seeds pseudo collection produced accordingly
0118   // methods find
0119   ///////////////////////////////////////////////////////////////////
0120 
0121   const Seed<SpacePoint>* next();
0122 
0123   ///////////////////////////////////////////////////////////////////
0124   // Configuration
0125   ///////////////////////////////////////////////////////////////////
0126 
0127   const Config m_config;
0128 
0129  protected:
0130   /**    @name Disallow default instantiation, copy, assignment */
0131   //@{
0132   AtlasSeedFinder(const AtlasSeedFinder<SpacePoint>&) = delete;
0133   AtlasSeedFinder<SpacePoint>& operator=(const AtlasSeedFinder<SpacePoint>&) =
0134       delete;
0135   //@}
0136   ///////////////////////////////////////////////////////////////////
0137   // Protected data and methods
0138   ///////////////////////////////////////////////////////////////////
0139 
0140   bool m_endlist = false;
0141   bool m_checketa = false;
0142   bool m_isvertex = false;
0143   int m_nprint = 0;
0144   int m_nlist = 0;
0145   int m_maxsize = 0;
0146   int m_state = 0;
0147   // event number since tool init
0148   int m_iteration = 0;
0149   float m_etamin = 0, m_etamax = 0;
0150   float m_drmin = 0, m_drminv = 0;
0151   float m_drmax = 0;
0152   float m_dzdrmin0 = 0;
0153   float m_dzdrmax0 = 0;
0154   float m_dzdrmin = 0;
0155   float m_dzdrmax = 0;
0156   float m_zmin = 0;
0157   float m_zmax = 0;
0158   float m_zminU = 0;
0159   float m_zmaxU = 0;
0160   float m_zminB = 0;
0161   float m_zmaxB = 0;
0162   float m_ftrig = 0;
0163   float m_ftrigW = 0;
0164   // maximum radius of outermost detector element
0165   float r_rmax = 0;
0166   // size of one r-slice
0167   float r_rstep = 0;
0168 
0169   float m_dzver = 0;
0170   float m_dzdrver = 0;
0171   float m_diver = 0;
0172   float m_diverpps = 0;
0173   float m_diversss = 0;
0174   float m_divermax = 0;
0175   float m_dazmax = 0;
0176   float m_ptmin = 0;
0177   float m_ipt = 0;
0178   float m_ipt2 = 0;
0179   float m_COF = 0;
0180   float m_K = 0;
0181   float m_ipt2K = 0;
0182   float m_ipt2C = 0;
0183   float m_COFK = 0;
0184   float m_umax = 0;
0185   // number of r-slices
0186   int r_size = 0;
0187   int r_first = 0;
0188   int rf_size = 0;
0189   int rfz_size = 0;
0190   std::list<SPForSeed<SpacePoint>*>* r_Sorted = nullptr;
0191   std::list<SPForSeed<SpacePoint>*> rfz_Sorted[583];
0192   std::list<SPForSeed<SpacePoint>*> l_spforseed;
0193   typename std::list<SPForSeed<SpacePoint>*>::iterator i_spforseed;
0194   typename std::list<SPForSeed<SpacePoint>*>::iterator m_rMin;
0195 
0196   int m_nsaz = 0, m_nsazv = 0;
0197   int m_fNmax = 0, m_fvNmax = 0;
0198   int m_fNmin = 0, m_fvNmin = 0;
0199   int m_zMin = 0;
0200   // m_nr: number of bins used in r_Sorted; r_index: index of all used bins in
0201   // r_Sorted; r_map is number of SP in each bin in r_Sorted
0202   int m_nr = 0;
0203   int* r_index = nullptr;
0204   int* r_map = nullptr;
0205   int m_nrfz = 0, rfz_index[583] = {}, rfz_map[583] = {};
0206   int rfz_b[583] = {}, rfz_t[593] = {}, rfz_ib[583][9] = {},
0207       rfz_it[583][9] = {};
0208   float m_sF = 0;
0209 
0210   ///////////////////////////////////////////////////////////////////
0211   // Tables for 3 space points seeds search
0212   ///////////////////////////////////////////////////////////////////
0213 
0214   int m_maxsizeSP = 0;
0215   SPForSeed<SpacePoint>** m_SP = nullptr;
0216   float* m_Zo = nullptr;
0217   float* m_Tz = nullptr;
0218   float* m_R = nullptr;
0219   float* m_U = nullptr;
0220   float* m_V = nullptr;
0221   float* m_Er = nullptr;
0222 
0223   Seed<SpacePoint>* m_seedOutput = nullptr;
0224 
0225   std::list<InternalSeed<SpacePoint>*> l_seeds;
0226   typename std::list<InternalSeed<SpacePoint>*>::iterator i_seed;
0227   typename std::list<InternalSeed<SpacePoint>*>::iterator i_seede;
0228 
0229   std::multimap<float, InternalSeed<SpacePoint>*> m_seeds;
0230   typename std::multimap<float, InternalSeed<SpacePoint>*>::iterator m_seed;
0231 
0232   std::multimap<float, InternalSeed<SpacePoint>*> m_mapOneSeeds;
0233   InternalSeed<SpacePoint>* m_OneSeeds = nullptr;
0234   int m_maxOneSize = 0;
0235   int m_nOneSeeds = 0;
0236   int m_fillOneSeeds = 0;
0237   std::vector<std::pair<float, SPForSeed<SpacePoint>*>> m_CmSp;
0238 
0239   ///////////////////////////////////////////////////////////////////
0240   // Beam geometry
0241   ///////////////////////////////////////////////////////////////////
0242 
0243   float m_xbeam = 0;  // x-center of beam-axis
0244   float m_ybeam = 0;  // y-center of beam-axis
0245   float m_zbeam = 0;  // z-center of beam-axis
0246 
0247   ///////////////////////////////////////////////////////////////////
0248   // Protected methods
0249   ///////////////////////////////////////////////////////////////////
0250 
0251   void buildFrameWork();
0252   void buildBeamFrameWork();
0253 
0254   SPForSeed<SpacePoint>* newSpacePoint(SpacePoint* const& /*sp*/);
0255 
0256   void newOneSeed(SPForSeed<SpacePoint>*& /*p1*/,
0257                   SPForSeed<SpacePoint>*& /*p2*/,
0258                   SPForSeed<SpacePoint>*& /*p3*/, float /*z*/, float /*q*/);
0259 
0260   void newOneSeedWithCurvaturesComparison(SPForSeed<SpacePoint>*& /*SPb*/,
0261                                           SPForSeed<SpacePoint>*& /*SP0*/,
0262                                           float /*Zob*/);
0263 
0264   void fillSeeds();
0265   void fillLists();
0266   void erase();
0267   void production3Sp();
0268   void production3Sp(
0269       typename std::list<SPForSeed<SpacePoint>*>::iterator* /*rb*/,
0270       typename std::list<SPForSeed<SpacePoint>*>::iterator* /*rbe*/,
0271       typename std::list<SPForSeed<SpacePoint>*>::iterator* /*rt*/,
0272       typename std::list<SPForSeed<SpacePoint>*>::iterator* /*rte*/, int /*NB*/,
0273       int /*NT*/, int& /*nseed*/);
0274 
0275   void findNext();
0276   bool isZCompatible(float& /*Zv*/);
0277   void convertToBeamFrameWork(SpacePoint* const& /*sp*/, float* /*r*/);
0278 };
0279 
0280 ///////////////////////////////////////////////////////////////////
0281 // Inline methods
0282 ///////////////////////////////////////////////////////////////////
0283 
0284 template <typename SpacePoint>
0285 inline const Seed<SpacePoint>* AtlasSeedFinder<SpacePoint>::next() {
0286   do {
0287     if (i_seed == i_seede) {
0288       findNext();
0289       if (i_seed == i_seede) {
0290         return nullptr;
0291       }
0292     }
0293     ++i_seed;
0294   } while (!(*m_seed++).second->set3(*m_seedOutput));
0295   return (m_seedOutput);
0296 }
0297 
0298 template <typename SpacePoint>
0299 inline bool AtlasSeedFinder<SpacePoint>::isZCompatible(float& Zv) {
0300   if (Zv < m_zminU || Zv > m_zmaxU) {
0301     return false;
0302   } else {
0303     return true;
0304   }
0305 }
0306 
0307 ///////////////////////////////////////////////////////////////////
0308 // New space point for seeds
0309 ///////////////////////////////////////////////////////////////////
0310 
0311 template <typename SpacePoint>
0312 inline SPForSeed<SpacePoint>* AtlasSeedFinder<SpacePoint>::newSpacePoint(
0313     SpacePoint* const& sp) {
0314   SPForSeed<SpacePoint>* sps = nullptr;
0315 
0316   float r[3];
0317   convertToBeamFrameWork(sp, r);
0318 
0319   if (m_checketa) {
0320     // filter SP outside of eta-range
0321     float z = (fabs(r[2]) + m_zmax);
0322     float x = r[0] * m_dzdrmin;
0323     float y = r[1] * m_dzdrmin;
0324     if ((z * z) < (x * x + y * y)) {
0325       return nullptr;
0326     }
0327   }
0328 
0329   if (i_spforseed != l_spforseed.end()) {
0330     sps = (*i_spforseed++);
0331     sps->set(sp, r);
0332   } else {
0333     l_spforseed.push_back((sps = new SPForSeed<SpacePoint>(sp, r)));
0334     i_spforseed = l_spforseed.end();
0335   }
0336 
0337   return sps;
0338 }
0339 
0340 ///////////////////////////////////////////////////////////////////
0341 // Object-function for curvature seeds comparison
0342 ///////////////////////////////////////////////////////////////////
0343 
0344 class comCurvature {
0345  public:
0346   template <typename SpacePoint>
0347   bool operator()(
0348       const std::pair<float, Acts::Legacy::SPForSeed<SpacePoint>*>& i1,
0349       const std::pair<float, Acts::Legacy::SPForSeed<SpacePoint>*>& i2) {
0350     return i1.first < i2.first;
0351   }
0352 };
0353 }  // namespace Acts::Legacy
0354 #include "Acts/Seeding/AtlasSeedFinder.ipp"