ATLAS Offline Software
FPGATrackSimPlaneMap.h
Go to the documentation of this file.
1 // Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2 
3 #ifndef FPGATrackSimPLANEMAP_H
4 #define FPGATrackSimPLANEMAP_H
5 
30 
31 
32 #include <vector>
33 #include <string>
34 #include <stdexcept>
35 #include <fstream>
36 #include <memory>
37 
38 
40 {
41  int layer = -1; // logical layer, -1 if unused
42  uint32_t section = 0; // arbitrary enumeration (identifier) if there are multiple detector elements in the same logical layer
43 };
44 
45 
46 /* Max index of modules along phi and eta is specified.
47  * Attention: on SCT layers the modules with eta index 0 is missing so the actual number of modules is neta-1.
48  * ^ ^ ^
49  * Is this still true???
50  */
51 struct LayerInfo
52 {
55  int physLayer = -1; // physical layer number (see this file's header)
56  int physDisk = -1; //
57  int stereo = -1; // strip layer side
58 };
59 
60 
62 {
63  public:
64 
66  // Constructor/Destructor
68 
69  // See doc on m_layerOverrides for info on argument layerOverrides
70  FPGATrackSimPlaneMap(const std::string & filepath, unsigned region, unsigned stage,
71  std::vector<int> layerOverrides = std::vector<int>());
72 
74  // Sizing
76 
77  uint32_t getNDetLayers() const { return m_nDetLayers; }
79  uint32_t getNCoords() const { return m_nCoords; }
80  uint32_t getNSections(size_t logiLayer) const { return m_layerInfo[logiLayer].size(); }
81  uint32_t getDim(size_t logiLayer) const { return m_dimension[logiLayer]; }
82  SiliconTech getDetType(size_t logiLayer) const { return m_dimension[logiLayer] == 2 ? SiliconTech::pixel : SiliconTech::strip; }
83 
85  // Layer <-> Coordinates
87 
88  /* Coordinates in tracks / matrices are flattened into a single array.
89  * Each layer, in order, gets 1 (strip) or 2 (pixel) entries.
90  * This entry gives the offset for the first coordinate for a given layer.
91  * The coordinates for a pixel hit are e.g.
92  * x = coords[getCoordOffset(layer)];
93  * y = coords[getCoordOffset(layer) + 1]
94  */
95  uint32_t getCoordOffset(size_t logiLayer) const { return m_coordOffset[logiLayer]; }
96 
97  /* This does the inverse search of the above function getCoordOffset.
98  * Given the coordinate index/offset, this function returns the logical layer
99  * that coordinate belongs to.
100  */
102 
104  // Info about a logical layer
106 
108 
109  bool isSCT(int pl) const { return m_dimension[pl] == 1; }
110  bool isPixel(int pl) const { return m_dimension[pl] == 2; }
112 
113  std::string layerName(uint32_t layer, uint32_t section) const;
114 
116  // Getting the logical layer
118 
119  // Main function. Wrapper/shortcuts below.
121  {
122  try {
123  return m_map.at(static_cast<int>(siTech)).at(static_cast<int>(zone)).at(physLayer);
124  } catch ( std::out_of_range const & e)
125  {
126  // TMP HACK FIX REMOVE ME
127  return m_map.at(1).at(0).at(0);
128  }
129  }
130 
131  const LayerSection & getLayerSection(LayerInfo const & mi) const
132  { return getLayerSection(mi.siTech, mi.zone, mi.physLayer); }
133 
134  int getLayer(SiliconTech siTech, DetectorZone zone, uint32_t physLayer) const
135  { return getLayerSection(siTech, zone, physLayer).layer; }
136 
137  unsigned getSection(SiliconTech siTech, DetectorZone zone, uint32_t physLayer) const
138  { return getLayerSection(siTech, zone, physLayer).section; }
139 
140 
142  // Mapping Hits
144 
145  void map(FPGATrackSimHit & hit) const ;
146 
147  private:
148 
149  uint32_t m_nLogiLayers = 0; // number of logical layers
150  uint32_t m_nDetLayers = 0; // number of physical detector layers used (I think this is different than physical layers, i.e. the index into getMap());
151  uint32_t m_nCoords = 0; // total number of coordinates in a pattern == accumulate(m_dimension)
152 
153  std::vector<uint32_t> m_dimension; // Index by (logiLayer). Dimension of layer (1 for strip, 2 for pixels). Assumes same across logical layer.
154  std::vector<uint32_t> m_coordOffset; // Index by (logiLayer).
155  // Coordinates for a track i.e. are flattened into a single array. Each layer, in order, gets 1 (strip) or 2 (pixel) entries.
156  // This entry gives the offset for the first coordinate for a given layer.
157  // The coordinates for a pixel hit are e.g. x = coords[m_coordOffset(layer)], y = coords[m_coordOffset(layer) + 1]
158  std::vector<uint32_t> m_coordLayer; // Index by (coordinate #)
159  // Inverse of above map. Given the coordinate index, returns the logical layer of the coordinate.
160 
161  std::vector<std::vector<std::vector<LayerSection>>> m_map; // index by (SCT/PIXEL, BARREL/posENDCAP/negENDCAP, physLayer)
162  // Maps detector layers to logical layer and section numbers
163  std::vector<std::vector<LayerInfo>> m_layerInfo; // index by (logiLayer, section)
164  // Get info about a logical layer section
165 
166  std::vector<int> m_layerOverrides; // Overrides the selection of logical layers
167  // If not empty, each entry declares a detector layer to use as a logical layer
168  // Specify a detector layer with { SilictonTech * 1000 + DetectorZone * 100 + PhysicalLayer }
169 
170  std::vector<uint32_t> m_diskIndex; // index of disks in the pixel endcap, indexed by ITK layer_disk
171 
172  // Module relabel object for remapping pixel endcap hits.
173  std::unique_ptr<FPGATrackSimModuleRelabel> m_moduleRelabel{};
174 
175 
177  // Helper Functions
178 
179  void allocateMap(std::ifstream & fin, uint32_t stage);
180  void seek(std::ifstream & fin, unsigned region);
181  void readLayers(std::ifstream & fin, uint32_t stage);
182  int getOverrideLayer(SiliconTech si, DetectorZone dz, int physLayer);
183 };
184 
185 
186 
187 #endif // FPGATrackSimPLANEMAP_H
FPGATrackSimPlaneMap::m_nCoords
uint32_t m_nCoords
Definition: FPGATrackSimPlaneMap.h:151
FPGATrackSimPlaneMap::getNSections
uint32_t getNSections(size_t logiLayer) const
Definition: FPGATrackSimPlaneMap.h:80
FPGATrackSimPlaneMap::getNLogiLayers
uint32_t getNLogiLayers() const
Definition: FPGATrackSimPlaneMap.h:78
SiliconTech::strip
@ strip
python.FPGATrackSimAnalysisConfig.stage
stage
Definition: FPGATrackSimAnalysisConfig.py:604
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
FPGATrackSimPlaneMap::getLayerSection
const LayerSection & getLayerSection(LayerInfo const &mi) const
Definition: FPGATrackSimPlaneMap.h:131
FPGATrackSimPlaneMap::getLayer
int getLayer(SiliconTech siTech, DetectorZone zone, uint32_t physLayer) const
Definition: FPGATrackSimPlaneMap.h:134
LayerInfo::stereo
int stereo
Definition: FPGATrackSimPlaneMap.h:57
FPGATrackSimPlaneMap::m_nDetLayers
uint32_t m_nDetLayers
Definition: FPGATrackSimPlaneMap.h:150
FPGATrackSimPlaneMap::getNCoords
uint32_t getNCoords() const
Definition: FPGATrackSimPlaneMap.h:79
FPGATrackSimPlaneMap::isEC
bool isEC(uint32_t layer, uint32_t section) const
Definition: FPGATrackSimPlaneMap.h:111
FPGATrackSimPlaneMap::readLayers
void readLayers(std::ifstream &fin, uint32_t stage)
Definition: FPGATrackSimPlaneMap.cxx:157
FPGATrackSimPlaneMap::m_map
std::vector< std::vector< std::vector< LayerSection > > > m_map
Definition: FPGATrackSimPlaneMap.h:161
FPGATrackSimPlaneMap::getLayerSection
const LayerSection & getLayerSection(SiliconTech siTech, DetectorZone zone, uint32_t physLayer) const
Definition: FPGATrackSimPlaneMap.h:120
FPGATrackSimPlaneMap::getCoordLayer
uint32_t getCoordLayer(uint32_t coord) const
Definition: FPGATrackSimPlaneMap.h:101
FPGATrackSimHit
Definition: FPGATrackSimHit.h:38
FPGATrackSimPlaneMap::getDim
uint32_t getDim(size_t logiLayer) const
Definition: FPGATrackSimPlaneMap.h:81
LayerInfo::physDisk
int physDisk
Definition: FPGATrackSimPlaneMap.h:56
FPGATrackSimPlaneMap::getCoordOffset
uint32_t getCoordOffset(size_t logiLayer) const
Definition: FPGATrackSimPlaneMap.h:95
FPGATrackSimPlaneMap::isPixel
bool isPixel(int pl) const
Definition: FPGATrackSimPlaneMap.h:110
FPGATrackSimPlaneMap::m_layerOverrides
std::vector< int > m_layerOverrides
Definition: FPGATrackSimPlaneMap.h:166
FPGATrackSimPlaneMap::map
void map(FPGATrackSimHit &hit) const
Definition: FPGATrackSimPlaneMap.cxx:237
SiliconTech
SiliconTech
Definition: FPGATrackSimTypes.h:25
FPGATrackSimPlaneMap::getSection
unsigned getSection(SiliconTech siTech, DetectorZone zone, uint32_t physLayer) const
Definition: FPGATrackSimPlaneMap.h:137
FPGATrackSimPlaneMap::seek
void seek(std::ifstream &fin, unsigned region)
Definition: FPGATrackSimPlaneMap.cxx:137
FPGATrackSimPlaneMap::FPGATrackSimPlaneMap
FPGATrackSimPlaneMap(const std::string &filepath, unsigned region, unsigned stage, std::vector< int > layerOverrides=std::vector< int >())
Definition: FPGATrackSimPlaneMap.cxx:27
FPGATrackSimPlaneMap::m_coordOffset
std::vector< uint32_t > m_coordOffset
Definition: FPGATrackSimPlaneMap.h:154
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
FPGATrackSimPlaneMap::getDetType
SiliconTech getDetType(size_t logiLayer) const
Definition: FPGATrackSimPlaneMap.h:82
FPGATrackSimModuleRelabel.h
FPGATrackSimPlaneMap::getLayerInfo
const LayerInfo & getLayerInfo(uint32_t layer, uint32_t section) const
Definition: FPGATrackSimPlaneMap.h:107
LayerSection
Definition: FPGATrackSimPlaneMap.h:40
FPGATrackSimPlaneMap
Definition: FPGATrackSimPlaneMap.h:62
python.draw_obj.zone
def zone(nx, ny)
Definition: draw_obj.py:288
FPGATrackSimPlaneMap::m_nLogiLayers
uint32_t m_nLogiLayers
Definition: FPGATrackSimPlaneMap.h:149
LayerInfo
Definition: FPGATrackSimPlaneMap.h:52
FPGATrackSimHit.h
: FPGATrackSim-specific class to represent an hit in the detector.
LayerSection::section
uint32_t section
Definition: FPGATrackSimPlaneMap.h:42
FPGATrackSimPlaneMap::isSCT
bool isSCT(int pl) const
Definition: FPGATrackSimPlaneMap.h:109
FPGATrackSimPlaneMap::m_moduleRelabel
std::unique_ptr< FPGATrackSimModuleRelabel > m_moduleRelabel
Definition: FPGATrackSimPlaneMap.h:173
FPGATrackSimPlaneMap::allocateMap
void allocateMap(std::ifstream &fin, uint32_t stage)
Definition: FPGATrackSimPlaneMap.cxx:64
JetVoronoiDiagramHelpers::coord
double coord
Definition: JetVoronoiDiagramHelpers.h:45
LayerInfo::zone
DetectorZone zone
Definition: FPGATrackSimPlaneMap.h:54
FPGATrackSimPlaneMap::layerName
std::string layerName(uint32_t layer, uint32_t section) const
Definition: FPGATrackSimPlaneMap.cxx:266
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
DetectorZone
DetectorZone
Definition: FPGATrackSimTypes.h:28
FPGATrackSimPlaneMap::getOverrideLayer
int getOverrideLayer(SiliconTech si, DetectorZone dz, int physLayer)
Definition: FPGATrackSimPlaneMap.cxx:258
LayerSection::layer
int layer
Definition: FPGATrackSimPlaneMap.h:41
LayerInfo::siTech
SiliconTech siTech
Definition: FPGATrackSimPlaneMap.h:53
FPGATrackSimPlaneMap::m_dimension
std::vector< uint32_t > m_dimension
Definition: FPGATrackSimPlaneMap.h:153
DetectorZone::barrel
@ barrel
FPGATrackSimPlaneMap::getNDetLayers
uint32_t getNDetLayers() const
Definition: FPGATrackSimPlaneMap.h:77
compute_lumi.fin
fin
Definition: compute_lumi.py:19
FPGATrackSimPlaneMap::m_layerInfo
std::vector< std::vector< LayerInfo > > m_layerInfo
Definition: FPGATrackSimPlaneMap.h:163
section
void section(const std::string &sec)
Definition: TestTriggerMenuAccess.cxx:22
LayerInfo::physLayer
int physLayer
Definition: FPGATrackSimPlaneMap.h:55
FPGATrackSimPlaneMap::m_diskIndex
std::vector< uint32_t > m_diskIndex
Definition: FPGATrackSimPlaneMap.h:170
SiliconTech::undefined
@ undefined
SiliconTech::pixel
@ pixel
FPGATrackSimPlaneMap::m_coordLayer
std::vector< uint32_t > m_coordLayer
Definition: FPGATrackSimPlaneMap.h:158
DetectorZone::undefined
@ undefined