ATLAS Offline Software
FPGATrackSimRegionMap.h
Go to the documentation of this file.
1 // Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2 
40 #ifndef FPGATrackSimREGIONMAP_H
41 #define FPGATrackSimREGIONMAP_H
42 
44 
45 #include <vector>
46 #include <map>
47 #include <fstream>
48 
49 class FPGATrackSimHit;
50 
51 
53 {
54  int phi_min{}; // minimum phi ID
55  int phi_max{}; // maximum phi ID
56  int eta_min{}; // minimum eta ID
57  int eta_max{}; // minimum eta ID
58 };
59 
60 
62 {
63  public:
64 
66  // Constructors/Initialization
67 
68  FPGATrackSimRegionMap(FPGATrackSimPlaneMap const * pmap, std::string const & filepath);
69 
70  void loadModuleIDLUT(std::string const & filepath);
71 
72  void loadRadiiFile(std::string const& radii_file);
73 
75  // Simple Getters/Setters
76 
77  const FPGATrackSimPlaneMap* getPlaneMap() const { return m_pmap; }
78 
79  int getNRegions() const { return m_nregions; }
80 
81  bool isModuleIDLUTloaded() const { return !m_global_local_map.empty(); }
82 
84  // Main Interface Functions
85 
86  const FPGATrackSimRegionBoundaries & getRegionBoundaries(int region, int layer, int section) const
87  { return m_map.at(region).at(layer).at(section); }
88 
89  bool isInRegion(uint32_t region, const FPGATrackSimHit &hit) const;
90  bool isInRegion(uint32_t region, uint32_t plane, uint32_t section, int eta, int phi) const;
91 
92  // Returns a list of regions that hit belongs to
93  std::vector<uint32_t> getRegions(const FPGATrackSimHit &hit) const;
94 
95  uint32_t getUnmappedID(uint32_t region, const FPGATrackSimHit &hit) const;
96 
97  // These require the module LUT file to be loaded
98  uint32_t getLocalID(uint32_t region, uint32_t layer, uint32_t globalModuleID) const;
99  uint32_t getGlobalID(uint32_t region, uint32_t layer, uint32_t localModuleID) const;
100 
101  // These require the radii file to be loaded.
102  double getAvgRadius(unsigned region, unsigned layer) const;
103  const std::vector<double>& getAvgRadii(unsigned region) const { return m_radii_map.at(region); };
104 
105  private:
106 
107  const FPGATrackSimPlaneMap *m_pmap = nullptr;
108  int m_nregions = 0;
109 
110  std::vector<std::vector<std::vector<FPGATrackSimRegionBoundaries>>> m_map;
111  // Index by region, logical layer, section
112 
113  std::vector<std::vector<std::map<uint32_t, uint32_t>>> m_global_local_map;
114  // Index by region, logical layer, globalID. Returns a local id.
115 
116  std::vector<std::vector<double>> m_radii_map;
117  // Index by region, logical layer. Assume we DON'T have separate radii per section.
118 
120  // Helper Functions
121 
122  void allocateMap(std::ifstream & fin);
123  void readRegion(std::ifstream & fin, int expected_region);
124 };
125 
126 #endif // FPGATrackSimREGIONMAP_H
FPGATrackSimRegionMap::m_global_local_map
std::vector< std::vector< std::map< uint32_t, uint32_t > > > m_global_local_map
Definition: FPGATrackSimRegionMap.h:113
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
FPGATrackSimRegionBoundaries
Definition: FPGATrackSimRegionMap.h:53
FPGATrackSimPlaneMap.h
Maps physical layers to logical layers.
FPGATrackSimRegionBoundaries::eta_max
int eta_max
Definition: FPGATrackSimRegionMap.h:57
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
FPGATrackSimRegionMap::getRegionBoundaries
const FPGATrackSimRegionBoundaries & getRegionBoundaries(int region, int layer, int section) const
Definition: FPGATrackSimRegionMap.h:86
FPGATrackSimRegionMap::readRegion
void readRegion(std::ifstream &fin, int expected_region)
Definition: FPGATrackSimRegionMap.cxx:75
FPGATrackSimHit
Definition: FPGATrackSimHit.h:41
FPGATrackSimRegionBoundaries::phi_max
int phi_max
Definition: FPGATrackSimRegionMap.h:55
FPGATrackSimRegionMap::FPGATrackSimRegionMap
FPGATrackSimRegionMap(FPGATrackSimPlaneMap const *pmap, std::string const &filepath)
Definition: FPGATrackSimRegionMap.cxx:29
FPGATrackSimRegionMap::getGlobalID
uint32_t getGlobalID(uint32_t region, uint32_t layer, uint32_t localModuleID) const
Definition: FPGATrackSimRegionMap.cxx:334
FPGATrackSimRegionBoundaries::eta_min
int eta_min
Definition: FPGATrackSimRegionMap.h:56
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
FPGATrackSimRegionMap::getLocalID
uint32_t getLocalID(uint32_t region, uint32_t layer, uint32_t globalModuleID) const
Definition: FPGATrackSimRegionMap.cxx:325
FPGATrackSimRegionMap::isInRegion
bool isInRegion(uint32_t region, const FPGATrackSimHit &hit) const
Definition: FPGATrackSimRegionMap.cxx:217
FPGATrackSimRegionMap::getRegions
std::vector< uint32_t > getRegions(const FPGATrackSimHit &hit) const
Definition: FPGATrackSimRegionMap.cxx:259
FPGATrackSimRegionMap::m_pmap
const FPGATrackSimPlaneMap * m_pmap
Definition: FPGATrackSimRegionMap.h:107
FPGATrackSimRegionMap::loadModuleIDLUT
void loadModuleIDLUT(std::string const &filepath)
Definition: FPGATrackSimRegionMap.cxx:120
FPGATrackSimPlaneMap
Definition: FPGATrackSimPlaneMap.h:62
FPGATrackSimRegionBoundaries::phi_min
int phi_min
Definition: FPGATrackSimRegionMap.h:54
FPGATrackSimRegionMap::getAvgRadii
const std::vector< double > & getAvgRadii(unsigned region) const
Definition: FPGATrackSimRegionMap.h:103
FPGATrackSimRegionMap::m_map
std::vector< std::vector< std::vector< FPGATrackSimRegionBoundaries > > > m_map
Definition: FPGATrackSimRegionMap.h:110
FPGATrackSimRegionMap::getUnmappedID
uint32_t getUnmappedID(uint32_t region, const FPGATrackSimHit &hit) const
Definition: FPGATrackSimRegionMap.cxx:268
FPGATrackSimRegionMap::getPlaneMap
const FPGATrackSimPlaneMap * getPlaneMap() const
Definition: FPGATrackSimRegionMap.h:77
FPGATrackSimRegionMap::m_radii_map
std::vector< std::vector< double > > m_radii_map
Definition: FPGATrackSimRegionMap.h:116
FPGATrackSimRegionMap::isModuleIDLUTloaded
bool isModuleIDLUTloaded() const
Definition: FPGATrackSimRegionMap.h:81
FPGATrackSimRegionMap::getNRegions
int getNRegions() const
Definition: FPGATrackSimRegionMap.h:79
compute_lumi.fin
fin
Definition: compute_lumi.py:19
FPGATrackSimRegionMap::allocateMap
void allocateMap(std::ifstream &fin)
Definition: FPGATrackSimRegionMap.cxx:50
FPGATrackSimRegionMap
Definition: FPGATrackSimRegionMap.h:62
FPGATrackSimRegionMap::m_nregions
int m_nregions
Definition: FPGATrackSimRegionMap.h:108
section
void section(const std::string &sec)
Definition: TestTriggerMenuAccess.cxx:22
FPGATrackSimRegionMap::loadRadiiFile
void loadRadiiFile(std::string const &radii_file)
Definition: FPGATrackSimRegionMap.cxx:149
FPGATrackSimRegionMap::getAvgRadius
double getAvgRadius(unsigned region, unsigned layer) const
Definition: FPGATrackSimRegionMap.cxx:349