Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:12:25

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