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  // See doc on m_layerOverrides for info on argument layerOverrides
68 
69  FPGATrackSimRegionMap(const std::vector<std::unique_ptr<FPGATrackSimPlaneMap>> & pmaps, std::string const & filepath);
70 
71  void loadModuleIDLUT(std::string const & filepath);
72 
73  void loadRadiiFile(std::string const& radii_file);
74 
76  // Simple Getters/Setters
77 
78  const FPGATrackSimPlaneMap* getPlaneMap(int iRegion) const { return m_pmaps.at(iRegion).get(); }
79 
80  int getNRegions() const { return m_nregions; }
81 
82  bool isModuleIDLUTloaded() const { return !m_global_local_map.empty(); }
83 
85  // Main Interface Functions
86 
87  const FPGATrackSimRegionBoundaries & getRegionBoundaries(int region, int layer, int section) const
88  { return m_map.at(region).at(layer).at(section); }
89 
90  bool isInRegion(uint32_t region, const FPGATrackSimHit &hit) const;
91  bool isInRegion(uint32_t region, uint32_t plane, uint32_t section, int eta, int phi) const;
92 
93  // Returns a list of regions that hit belongs to
94  std::vector<uint32_t> getRegions(const FPGATrackSimHit &hit) const;
95 
96  uint32_t getUnmappedID(uint32_t region, const FPGATrackSimHit &hit) const;
97 
98  // These require the module LUT file to be loaded
99  uint32_t getLocalID(uint32_t region, uint32_t layer, uint32_t globalModuleID) const;
100  uint32_t getGlobalID(uint32_t region, uint32_t layer, uint32_t localModuleID) const;
101 
102  // These require the radii file to be loaded.
103  double getAvgRadius(unsigned region, unsigned layer) const;
104  const std::vector<double>& getAvgRadii(unsigned region) const { return m_radii_map.at(region); };
105 
106  private:
107  std::string m_filepath;
108  std::vector<std::unique_ptr<FPGATrackSimPlaneMap>> const & m_pmaps ;
109  int m_nregions = 0;
110 
111  std::vector<std::vector<std::vector<FPGATrackSimRegionBoundaries>>> m_map;
112  // Index by region, logical layer, section
113 
114  std::vector<std::vector<std::map<uint32_t, uint32_t>>> m_global_local_map;
115  // Index by region, logical layer, globalID. Returns a local id.
116 
117  std::vector<std::vector<double>> m_radii_map;
118  // Index by region, logical layer. Assume we DON'T have separate radii per section.
119 
121  // Helper Functions
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:114
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:87
FPGATrackSimRegionMap::readRegion
void readRegion(std::ifstream &fin, int expected_region)
Definition: FPGATrackSimRegionMap.cxx:82
FPGATrackSimHit
Definition: FPGATrackSimHit.h:41
FPGATrackSimRegionBoundaries::phi_max
int phi_max
Definition: FPGATrackSimRegionMap.h:55
FPGATrackSimRegionMap::getGlobalID
uint32_t getGlobalID(uint32_t region, uint32_t layer, uint32_t localModuleID) const
Definition: FPGATrackSimRegionMap.cxx:358
FPGATrackSimRegionBoundaries::eta_min
int eta_min
Definition: FPGATrackSimRegionMap.h:56
FPGATrackSimRegionMap::FPGATrackSimRegionMap
FPGATrackSimRegionMap(const std::vector< std::unique_ptr< FPGATrackSimPlaneMap >> &pmaps, std::string const &filepath)
Definition: FPGATrackSimRegionMap.cxx:29
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:349
FPGATrackSimRegionMap::isInRegion
bool isInRegion(uint32_t region, const FPGATrackSimHit &hit) const
Definition: FPGATrackSimRegionMap.cxx:225
FPGATrackSimRegionMap::getRegions
std::vector< uint32_t > getRegions(const FPGATrackSimHit &hit) const
Definition: FPGATrackSimRegionMap.cxx:282
FPGATrackSimRegionMap::loadModuleIDLUT
void loadModuleIDLUT(std::string const &filepath)
Definition: FPGATrackSimRegionMap.cxx:128
FPGATrackSimPlaneMap
Definition: FPGATrackSimPlaneMap.h:62
FPGATrackSimRegionMap::getPlaneMap
const FPGATrackSimPlaneMap * getPlaneMap(int iRegion) const
Definition: FPGATrackSimRegionMap.h:78
FPGATrackSimRegionBoundaries::phi_min
int phi_min
Definition: FPGATrackSimRegionMap.h:54
FPGATrackSimRegionMap::getAvgRadii
const std::vector< double > & getAvgRadii(unsigned region) const
Definition: FPGATrackSimRegionMap.h:104
FPGATrackSimRegionMap::m_map
std::vector< std::vector< std::vector< FPGATrackSimRegionBoundaries > > > m_map
Definition: FPGATrackSimRegionMap.h:111
FPGATrackSimRegionMap::getUnmappedID
uint32_t getUnmappedID(uint32_t region, const FPGATrackSimHit &hit) const
Definition: FPGATrackSimRegionMap.cxx:292
FPGATrackSimRegionMap::m_radii_map
std::vector< std::vector< double > > m_radii_map
Definition: FPGATrackSimRegionMap.h:117
FPGATrackSimRegionMap::isModuleIDLUTloaded
bool isModuleIDLUTloaded() const
Definition: FPGATrackSimRegionMap.h:82
FPGATrackSimRegionMap::m_filepath
std::string m_filepath
Definition: FPGATrackSimRegionMap.h:104
FPGATrackSimRegionMap::m_pmaps
std::vector< std::unique_ptr< FPGATrackSimPlaneMap > > const & m_pmaps
Definition: FPGATrackSimRegionMap.h:108
FPGATrackSimRegionMap::getNRegions
int getNRegions() const
Definition: FPGATrackSimRegionMap.h:80
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:109
section
void section(const std::string &sec)
Definition: TestTriggerMenuAccess.cxx:22
FPGATrackSimRegionMap::loadRadiiFile
void loadRadiiFile(std::string const &radii_file)
Definition: FPGATrackSimRegionMap.cxx:157
FPGATrackSimRegionMap::getAvgRadius
double getAvgRadius(unsigned region, unsigned layer) const
Definition: FPGATrackSimRegionMap.cxx:373