ATLAS Offline Software
Loading...
Searching...
No Matches
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
27
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 */
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:
65 // Constructor/Destructor
67 // See doc on m_layerOverrides for info on argument layerOverrides
68 FPGATrackSimPlaneMap(std::ifstream& fin, unsigned region, unsigned stage,
69 std::vector<int> layerOverrides = std::vector<int>());
71 // Sizing
73
74 uint32_t getNDetLayers() const { return m_nDetLayers; }
75 uint32_t getNLogiLayers() const { return m_nLogiLayers; }
76 uint32_t getNCoords() const { return m_nCoords; }
77 uint32_t getNSections(size_t logiLayer) const { return m_layerInfo[logiLayer].size(); }
78 uint32_t getDim(size_t logiLayer) const { return m_dimension[logiLayer]; }
79 SiliconTech getDetType(size_t logiLayer) const { return m_dimension[logiLayer] == 2 ? SiliconTech::pixel : SiliconTech::strip; }
80
82 // Layer <-> Coordinates
84
85 /* Coordinates in tracks / matrices are flattened into a single array.
86 * Each layer, in order, gets 1 (strip) or 2 (pixel) entries.
87 * This entry gives the offset for the first coordinate for a given layer.
88 * The coordinates for a pixel hit are e.g.
89 * x = coords[getCoordOffset(layer)];
90 * y = coords[getCoordOffset(layer) + 1]
91 */
92 uint32_t getCoordOffset(size_t logiLayer) const { return m_coordOffset[logiLayer]; }
93
94 /* This does the inverse search of the above function getCoordOffset.
95 * Given the coordinate index/offset, this function returns the logical layer
96 * that coordinate belongs to.
97 */
98 uint32_t getCoordLayer(uint32_t coord) const { return m_coordLayer[coord]; }
99
101 // Info about a logical layer
103
104 const LayerInfo & getLayerInfo(uint32_t layer, uint32_t section) const { return m_layerInfo.at(layer).at(section); }
105
106 bool isSCT(int pl) const { return m_dimension[pl] == 1; }
107 bool isPixel(int pl) const { return m_dimension[pl] == 2; }
108 bool isEC(uint32_t layer, uint32_t section) const { return getLayerInfo(layer, section).zone != DetectorZone::barrel; }
109
110 std::string layerName(uint32_t layer, uint32_t section) const;
111
113 // Getting the logical layer
115
116 // Main function. Wrapper/shortcuts below.
117 const LayerSection & getLayerSection(SiliconTech siTech, DetectorZone zone, uint32_t physLayer) const
118 {
119 if ( static_cast<size_t>(siTech) < m_map.size() ) {
120 if ( static_cast<size_t>(zone) < m_map.at(static_cast<size_t>(siTech)).size() ) {
121 if ( physLayer < m_map.at(static_cast<size_t>(siTech)).at(static_cast<size_t>(zone)).size() ) {
122 return m_map[static_cast<size_t>(siTech)][static_cast<size_t>(zone)][physLayer];
123 }
124 }
125 }
127 }
128
129 const LayerSection & getLayerSection(LayerInfo const & mi) const
130 { return getLayerSection(mi.siTech, mi.zone, mi.physLayer); }
131
132 int getLayer(SiliconTech siTech, DetectorZone zone, uint32_t physLayer) const
133 { return getLayerSection(siTech, zone, physLayer).layer; }
134
135 unsigned getSection(SiliconTech siTech, DetectorZone zone, uint32_t physLayer) const
136 { return getLayerSection(siTech, zone, physLayer).section; }
137
138
140 // Mapping Hits
142 void doRemap(FPGATrackSimHit & hit) const;
143 void map(FPGATrackSimHit & hit) const ;
144
145 private:
146
147 uint32_t m_nLogiLayers = 0; // number of logical layers
148 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());
149 uint32_t m_nCoords = 0; // total number of coordinates in a pattern == accumulate(m_dimension)
150
151 std::vector<uint32_t> m_dimension; // Index by (logiLayer). Dimension of layer (1 for strip, 2 for pixels). Assumes same across logical layer.
152 std::vector<uint32_t> m_coordOffset; // Index by (logiLayer).
153 // Coordinates for a track i.e. are flattened into a single array. Each layer, in order, gets 1 (strip) or 2 (pixel) entries.
154 // This entry gives the offset for the first coordinate for a given layer.
155 // The coordinates for a pixel hit are e.g. x = coords[m_coordOffset(layer)], y = coords[m_coordOffset(layer) + 1]
156 std::vector<uint32_t> m_coordLayer; // Index by (coordinate #)
157 // Inverse of above map. Given the coordinate index, returns the logical layer of the coordinate.
158
159 std::vector<std::vector<std::vector<LayerSection>>> m_map; // index by (SCT/PIXEL, BARREL/posENDCAP/negENDCAP, physLayer)
160 // Maps detector layers to logical layer and section numbers
161 std::vector<std::vector<LayerInfo>> m_layerInfo; // index by (logiLayer, section)
162 // Get info about a logical layer section
163
164 std::vector<int> m_layerOverrides; // Overrides the selection of logical layers
165 // If not empty, each entry declares a detector layer to use as a logical layer
166 // Specify a detector layer with { SilictonTech * 1000 + DetectorZone * 100 + PhysicalLayer }
167
168 std::vector<uint32_t> m_diskIndex; // index of disks in the pixel endcap, indexed by ITK layer_disk
169
170 // Module relabel object for remapping pixel endcap hits.
171 std::unique_ptr<FPGATrackSimModuleRelabel> m_moduleRelabel{};
172
173 // this is used when the getLayerSection needs to return a reference to an invalid LayerSection
175
177 // Helper Functions
178 void allocateMap(std::ifstream & fin, uint32_t stage);
179 void seek(std::ifstream & fin, unsigned region);
180 void readLayers(std::ifstream & fin, uint32_t stage);
181 int getOverrideLayer(SiliconTech si, DetectorZone dz, int physLayer);
182};
183
184
185
186#endif // FPGATrackSimPLANEMAP_H
: FPGATrackSim-specific class to represent an hit in the detector.
SiliconTech
DetectorZone
double coord
Type of coordination system.
void section(const std::string &sec)
uint32_t getNLogiLayers() const
uint32_t getDim(size_t logiLayer) const
uint32_t getNCoords() const
const LayerSection & getLayerSection(LayerInfo const &mi) const
uint32_t getNSections(size_t logiLayer) const
std::vector< uint32_t > m_coordLayer
int getOverrideLayer(SiliconTech si, DetectorZone dz, int physLayer)
std::vector< std::vector< LayerInfo > > m_layerInfo
void readLayers(std::ifstream &fin, uint32_t stage)
SiliconTech getDetType(size_t logiLayer) const
uint32_t getCoordLayer(uint32_t coord) const
std::unique_ptr< FPGATrackSimModuleRelabel > m_moduleRelabel
void seek(std::ifstream &fin, unsigned region)
void allocateMap(std::ifstream &fin, uint32_t stage)
std::vector< uint32_t > m_dimension
FPGATrackSimPlaneMap(std::ifstream &fin, unsigned region, unsigned stage, std::vector< int > layerOverrides=std::vector< int >())
void map(FPGATrackSimHit &hit) const
int getLayer(SiliconTech siTech, DetectorZone zone, uint32_t physLayer) const
bool isPixel(int pl) const
void doRemap(FPGATrackSimHit &hit) const
unsigned getSection(SiliconTech siTech, DetectorZone zone, uint32_t physLayer) const
std::vector< std::vector< std::vector< LayerSection > > > m_map
std::string layerName(uint32_t layer, uint32_t section) const
const LayerSection m_inValidLayerSection
std::vector< int > m_layerOverrides
std::vector< uint32_t > m_coordOffset
std::vector< uint32_t > m_diskIndex
uint32_t getNDetLayers() const
const LayerSection & getLayerSection(SiliconTech siTech, DetectorZone zone, uint32_t physLayer) const
const LayerInfo & getLayerInfo(uint32_t layer, uint32_t section) const
uint32_t getCoordOffset(size_t logiLayer) const
bool isEC(uint32_t layer, uint32_t section) const
SiliconTech siTech
DetectorZone zone