ATLAS Offline Software
Loading...
Searching...
No Matches
FPGATrackSimPlaneMap Class Reference

#include <FPGATrackSimPlaneMap.h>

Collaboration diagram for FPGATrackSimPlaneMap:

Public Member Functions

 FPGATrackSimPlaneMap (std::ifstream &fin, unsigned region, unsigned stage, std::vector< int > layerOverrides=std::vector< int >())
uint32_t getNDetLayers () const
uint32_t getNLogiLayers () const
uint32_t getNCoords () const
uint32_t getNSections (size_t logiLayer) const
uint32_t getDim (size_t logiLayer) const
SiliconTech getDetType (size_t logiLayer) const
uint32_t getCoordOffset (size_t logiLayer) const
uint32_t getCoordLayer (uint32_t coord) const
const LayerInfogetLayerInfo (uint32_t layer, uint32_t section) const
bool isSCT (int pl) const
bool isPixel (int pl) const
bool isEC (uint32_t layer, uint32_t section) const
std::string layerName (uint32_t layer, uint32_t section) const
const LayerSectiongetLayerSection (SiliconTech siTech, DetectorZone zone, uint32_t physLayer) const
const LayerSectiongetLayerSection (LayerInfo const &mi) const
int getLayer (SiliconTech siTech, DetectorZone zone, uint32_t physLayer) const
unsigned getSection (SiliconTech siTech, DetectorZone zone, uint32_t physLayer) const
void doRemap (FPGATrackSimHit &hit) const
void map (FPGATrackSimHit &hit) const

Private Member Functions

void allocateMap (std::ifstream &fin, uint32_t stage)
void seek (std::ifstream &fin, unsigned region)
void readLayers (std::ifstream &fin, uint32_t stage)
int getOverrideLayer (SiliconTech si, DetectorZone dz, int physLayer)

Private Attributes

uint32_t m_nLogiLayers = 0
uint32_t m_nDetLayers = 0
uint32_t m_nCoords = 0
std::vector< uint32_t > m_dimension
std::vector< uint32_t > m_coordOffset
std::vector< uint32_t > m_coordLayer
std::vector< std::vector< std::vector< LayerSection > > > m_map
std::vector< std::vector< LayerInfo > > m_layerInfo
std::vector< int > m_layerOverrides
std::vector< uint32_t > m_diskIndex
std::unique_ptr< FPGATrackSimModuleRelabelm_moduleRelabel {}
const LayerSection m_inValidLayerSection {}

Detailed Description

Definition at line 61 of file FPGATrackSimPlaneMap.h.

Constructor & Destructor Documentation

◆ FPGATrackSimPlaneMap()

FPGATrackSimPlaneMap::FPGATrackSimPlaneMap ( std::ifstream & fin,
unsigned region,
unsigned stage,
std::vector< int > layerOverrides = std::vector<int>() )

Definition at line 26 of file FPGATrackSimPlaneMap.cxx.

26 :
27 m_map(static_cast<int>(SiliconTech::nTechs),
28 vector<vector<LayerSection>>(static_cast<int>(DetectorZone::nZones))
29 ),
30 m_layerOverrides(std::move(layerOverrides))
31{
32 // Reads the header of the file to resize all the vector members
33 allocateMap(fin, stage);
34
35 // Seek to the correct region
36 seek(fin, region);
37
38 // Reads the rest of the file to populate all the member vectors
39 readLayers(fin, stage);
40
41 // Postprocessing on coordinate indices
42 for (uint32_t l = 0; l < m_nLogiLayers; l++)
43 {
46 for (uint32_t i = 0; i < m_dimension[l]; i++)
47 m_coordLayer.push_back(l);
48 }
49
50 ANA_MSG_DEBUG("Using " << m_nLogiLayers << " logical layers and " << m_nCoords << " coordinates");
51}
#define ANA_MSG_DEBUG(xmsg)
Macro printing debug messages.
std::vector< uint32_t > m_coordLayer
void readLayers(std::ifstream &fin, uint32_t stage)
void seek(std::ifstream &fin, unsigned region)
void allocateMap(std::ifstream &fin, uint32_t stage)
std::vector< uint32_t > m_dimension
std::vector< std::vector< std::vector< LayerSection > > > m_map
std::vector< int > m_layerOverrides
std::vector< uint32_t > m_coordOffset
l
Printing final latex table to .tex output file.

Member Function Documentation

◆ allocateMap()

void FPGATrackSimPlaneMap::allocateMap ( std::ifstream & fin,
uint32_t stage )
private

Definition at line 53 of file FPGATrackSimPlaneMap.cxx.

54{
55 // Initialize read variables
56 vector<int> layerCounts((int)SiliconTech::nTechs * static_cast<int>(DetectorZone::nZones)); // pixel_barrel, pixel_EC, SCT_barrel, SCT_EC
57 std::string line, silicon, detReg, layerKey, geoKey;
58 bool ok = true;
59 // Read Geometry Version
60 ok = ok && getline(fin, line);
61 while (line.empty() || line[0] == '!')
62 {
63 ok = ok && getline(fin, line);
64 }
65 ANA_MSG_VERBOSE(line);
66 istringstream sline(line);
67 ok = ok && (sline >> geoKey);
69
70 ANA_MSG_DEBUG("Allocating map for geometry " << geoKey <<" diskIndex size="<<m_diskIndex.size());
71 m_moduleRelabel = std::make_unique<FPGATrackSimModuleRelabel>(geoKey, false);
72
73
74
75 // Read number of logical layers
76 if (stage == 1)
77 {
78 ok = ok && getline(fin, line);
79 ANA_MSG_VERBOSE(line);
80 istringstream sline(line);
81 ok = ok && (sline >> m_nLogiLayers >> layerKey);
82 ok = ok && (layerKey == "logical_s1");
83 ok = ok && getline(fin, line); // skip the 2nd stage line
84 }
85 else if (stage == 2)
86 {
87 ok = ok && getline(fin, line); // skip the 1st stage line
88 ok = ok && getline(fin, line);
89 ANA_MSG_VERBOSE(line);
90 istringstream sline(line);
91 ok = ok && (sline >> m_nLogiLayers >> layerKey);
92 ok = ok && (layerKey == "logical_s2");
93 }
94 else ANA_MSG_ERROR("Bad stage " << stage << ". Stage should be 1 or 2");
95
96 if (!m_layerOverrides.empty()) m_nLogiLayers = m_layerOverrides.size();
97
98 // Read number of physical layers
99 int nHeaderLines = 6;
100 for (int i = 0; i < nHeaderLines; i++)
101 {
102 if (!ok) break;
103 ok = ok && getline(fin, line);
104 ANA_MSG_VERBOSE(line);
105
106 istringstream sline(line);
107 ok = ok && (sline >> layerCounts[i] >> silicon >> detReg);
108
109 ok = ok && ( (i < (nHeaderLines/2) && silicon == "pixel") || (i >= (nHeaderLines/2) && silicon == "SCT") );
110 ok = ok && ( (i % (nHeaderLines/2) == 0 && detReg == "barrel") || (i % (nHeaderLines/2) != 0 && (detReg == "endcap+" || detReg == "endcap-")) );
111 }
112
113 if (!ok) ANA_MSG_FATAL("Error reading layer counts");
114 m_nDetLayers = std::accumulate(layerCounts.begin(), layerCounts.end(), 0);
115
116 // Resize objects
117 m_map[(int)SiliconTech::pixel][(int)DetectorZone::barrel].resize(layerCounts[0]);
118 m_map[(int)SiliconTech::pixel][(int)DetectorZone::posEndcap].resize(layerCounts[1]);
119 m_map[(int)SiliconTech::pixel][(int)DetectorZone::negEndcap].resize(layerCounts[2]);
120 m_map[(int)SiliconTech::strip][(int)DetectorZone::barrel].resize(layerCounts[3]);
121 m_map[(int)SiliconTech::strip][(int)DetectorZone::posEndcap].resize(layerCounts[4]);
122 m_map[(int)SiliconTech::strip][(int)DetectorZone::negEndcap].resize(layerCounts[5]);
123
127}
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
#define ANA_MSG_VERBOSE(xmsg)
Macro printing verbose messages.
#define ANA_MSG_FATAL(xmsg)
Macro printing fatal messages.
std::vector< std::vector< LayerInfo > > m_layerInfo
std::unique_ptr< FPGATrackSimModuleRelabel > m_moduleRelabel
std::vector< uint32_t > m_diskIndex
std::vector< uint32_t > diskIndices(const std::string &geoKey)
for a given geo tag return disk indices remappings the format is this: 'GeometryVersion':'ATLAS-P2-RU...

◆ doRemap()

void FPGATrackSimPlaneMap::doRemap ( FPGATrackSimHit & hit) const

Definition at line 227 of file FPGATrackSimPlaneMap.cxx.

228{
229 if (!hit.isRemapped()) {
230 m_moduleRelabel->remap(hit);
231 }
232}
bool isRemapped() const

◆ getCoordLayer()

uint32_t FPGATrackSimPlaneMap::getCoordLayer ( uint32_t coord) const
inline

Definition at line 98 of file FPGATrackSimPlaneMap.h.

98{ return m_coordLayer[coord]; }
double coord
Type of coordination system.

◆ getCoordOffset()

uint32_t FPGATrackSimPlaneMap::getCoordOffset ( size_t logiLayer) const
inline

Definition at line 92 of file FPGATrackSimPlaneMap.h.

92{ return m_coordOffset[logiLayer]; }

◆ getDetType()

SiliconTech FPGATrackSimPlaneMap::getDetType ( size_t logiLayer) const
inline

Definition at line 79 of file FPGATrackSimPlaneMap.h.

79{ return m_dimension[logiLayer] == 2 ? SiliconTech::pixel : SiliconTech::strip; }

◆ getDim()

uint32_t FPGATrackSimPlaneMap::getDim ( size_t logiLayer) const
inline

Definition at line 78 of file FPGATrackSimPlaneMap.h.

78{ return m_dimension[logiLayer]; }

◆ getLayer()

int FPGATrackSimPlaneMap::getLayer ( SiliconTech siTech,
DetectorZone zone,
uint32_t physLayer ) const
inline

Definition at line 132 of file FPGATrackSimPlaneMap.h.

133 { return getLayerSection(siTech, zone, physLayer).layer; }
const LayerSection & getLayerSection(SiliconTech siTech, DetectorZone zone, uint32_t physLayer) const

◆ getLayerInfo()

const LayerInfo & FPGATrackSimPlaneMap::getLayerInfo ( uint32_t layer,
uint32_t section ) const
inline

Definition at line 104 of file FPGATrackSimPlaneMap.h.

104{ return m_layerInfo.at(layer).at(section); }
void section(const std::string &sec)

◆ getLayerSection() [1/2]

const LayerSection & FPGATrackSimPlaneMap::getLayerSection ( LayerInfo const & mi) const
inline

Definition at line 129 of file FPGATrackSimPlaneMap.h.

130 { return getLayerSection(mi.siTech, mi.zone, mi.physLayer); }

◆ getLayerSection() [2/2]

const LayerSection & FPGATrackSimPlaneMap::getLayerSection ( SiliconTech siTech,
DetectorZone zone,
uint32_t physLayer ) const
inline

Definition at line 117 of file FPGATrackSimPlaneMap.h.

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 }
const LayerSection m_inValidLayerSection

◆ getNCoords()

uint32_t FPGATrackSimPlaneMap::getNCoords ( ) const
inline

Definition at line 76 of file FPGATrackSimPlaneMap.h.

76{ return m_nCoords; }

◆ getNDetLayers()

uint32_t FPGATrackSimPlaneMap::getNDetLayers ( ) const
inline

Definition at line 74 of file FPGATrackSimPlaneMap.h.

74{ return m_nDetLayers; }

◆ getNLogiLayers()

uint32_t FPGATrackSimPlaneMap::getNLogiLayers ( ) const
inline

Definition at line 75 of file FPGATrackSimPlaneMap.h.

75{ return m_nLogiLayers; }

◆ getNSections()

uint32_t FPGATrackSimPlaneMap::getNSections ( size_t logiLayer) const
inline

Definition at line 77 of file FPGATrackSimPlaneMap.h.

77{ return m_layerInfo[logiLayer].size(); }

◆ getOverrideLayer()

int FPGATrackSimPlaneMap::getOverrideLayer ( SiliconTech si,
DetectorZone dz,
int physLayer )
private

Definition at line 259 of file FPGATrackSimPlaneMap.cxx.

260{
261 int code = static_cast<int>(si) * 1000 + static_cast<int>(dz) * 100 + physLayer;
262 for (unsigned i = 0; i < m_layerOverrides.size(); i++)
263 if (code == m_layerOverrides[i]) return i;
264 return -1;
265}

◆ getSection()

unsigned FPGATrackSimPlaneMap::getSection ( SiliconTech siTech,
DetectorZone zone,
uint32_t physLayer ) const
inline

Definition at line 135 of file FPGATrackSimPlaneMap.h.

136 { return getLayerSection(siTech, zone, physLayer).section; }

◆ isEC()

bool FPGATrackSimPlaneMap::isEC ( uint32_t layer,
uint32_t section ) const
inline

Definition at line 108 of file FPGATrackSimPlaneMap.h.

108{ return getLayerInfo(layer, section).zone != DetectorZone::barrel; }
const LayerInfo & getLayerInfo(uint32_t layer, uint32_t section) const
DetectorZone zone

◆ isPixel()

bool FPGATrackSimPlaneMap::isPixel ( int pl) const
inline

Definition at line 107 of file FPGATrackSimPlaneMap.h.

107{ return m_dimension[pl] == 2; }

◆ isSCT()

bool FPGATrackSimPlaneMap::isSCT ( int pl) const
inline

Definition at line 106 of file FPGATrackSimPlaneMap.h.

106{ return m_dimension[pl] == 1; }

◆ layerName()

std::string FPGATrackSimPlaneMap::layerName ( uint32_t layer,
uint32_t section ) const

Definition at line 267 of file FPGATrackSimPlaneMap.cxx.

268{
269 std::string out;
270 out += (isPixel(layer) ? "PIX" : "SCT");
271 out += (isEC(layer, section) ? "_EC_" : "_B_");
272 out += std::to_string(getLayerInfo(layer, section).physLayer);
273 return out;
274}
bool isPixel(int pl) const
bool isEC(uint32_t layer, uint32_t section) const

◆ map()

void FPGATrackSimPlaneMap::map ( FPGATrackSimHit & hit) const

Definition at line 234 of file FPGATrackSimPlaneMap.cxx.

235{
236 // re-assign layers in the pixel endcap to be each individual disk
237 // technically this returns a success/fail but I'm not sure we need it?
238 // This should only happen if the hit is not already mapped.
239 const LayerSection &pinfo = getLayerSection(hit.getDetType(), hit.getDetectorZone(), hit.getPhysLayer());
240 hit.setSection(pinfo.section);
241 hit.setLayer(pinfo.layer);
242 if (!hit.isMapped() && hit.getHitType() == HitType::unmapped) { // failsafe if for some reason someone calls this on a clustered hit again, or something
244 }
245 // Special case if this is a spacepoint (now possible because slicing engine happens after SP formation).
246 if (hit.getHitType() == HitType::spacepoint) {
247 const LayerSection &pinfo_sp = getLayerSection(hit.getPairedDetType(), hit.getPairedDetZone(), hit.getPairedPhysLayer());
248 hit.setPairedSection(pinfo_sp.section);
249 hit.setPairedLayer(pinfo_sp.layer);
250 }
251}
void setLayer(unsigned v)
unsigned getPairedPhysLayer() const
void setHitType(HitType type)
void setPairedSection(unsigned v)
void setPairedLayer(unsigned v)
DetectorZone getPairedDetZone() const
SiliconTech getPairedDetType() const
unsigned getPhysLayer(bool old=false) const
bool isMapped() const
SiliconTech getDetType() const
DetectorZone getDetectorZone() const
void setSection(unsigned v)
HitType getHitType() const

◆ readLayers()

void FPGATrackSimPlaneMap::readLayers ( std::ifstream & fin,
uint32_t stage )
private

Definition at line 150 of file FPGATrackSimPlaneMap.cxx.

151{
152 // Initialize read variables
153 int BEC{}, physLayer{}, physDisk{}, logiLayer{}, logiLayer1{}, logiLayer2{}, stereo{}, nDim{};
154 string line, silicon, planeKey1, planeKey2, stereoKey;
155 bool ok = true;
156
157 uint32_t linesRead = 0;
158
159 // Each line is a detector layer
160 while (getline(fin, line))
161 {
162 if (line.empty() || line[0] == '!') continue;
163 ANA_MSG_VERBOSE(line);
164 istringstream sline(line);
165
166 ok = ok && (sline >> silicon >> BEC >> physDisk >> physLayer);
167
168 // Detector
170 if (BEC == 0) zone = DetectorZone::barrel;
171 else if (BEC == 1) zone = DetectorZone::posEndcap;
172 else if (BEC == 2) zone = DetectorZone::negEndcap;
173 else ANA_MSG_FATAL("Bad Detector zone" << BEC);
174
175 // Case on silicon type
176 int sil = 0;
178 if (silicon == "pixel")
179 {
180 sil = static_cast<int>(SiliconTech::pixel);
181 nDim = 2;
182 stereo = -1;
183 ok = ok && (sline >> planeKey1 >> logiLayer1 >> planeKey2 >> logiLayer2);
184 ok = ok && (planeKey1 == "plane1" && planeKey2 == "plane2");
185 }
186 else if (silicon == "SCT")
187 {
188 sil = static_cast<int>(SiliconTech::strip);
189 siTech = SiliconTech::strip;
190
191 nDim = 1;
192 ok = ok && (sline >> stereoKey >> stereo >> planeKey1 >> logiLayer1 >> planeKey2 >> logiLayer2);
193 ok = ok && (planeKey1 == "plane1" && planeKey2 == "plane2" && stereoKey == "stereo");
194 }
195 else ANA_MSG_FATAL("Bad silicon type " << silicon);
196
197
198 if (!ok) break;
199
200 // Logical layer
201 if (!m_layerOverrides.empty()) logiLayer = getOverrideLayer(siTech, zone, physLayer);
202 else if (stage == 1) logiLayer = logiLayer1;
203 else if (stage == 2) logiLayer = logiLayer2;
204
205 // Check number of layers
206 linesRead++;
207 if (logiLayer >= (int)m_nLogiLayers) ANA_MSG_FATAL("Logical layer " << logiLayer << " exceeds expected number " << m_nLogiLayers);
208
209 // Store to map
210 m_map.at(sil).at(BEC).at(physLayer).layer = logiLayer;
211 if (logiLayer >= 0)
212 {
213 m_dimension[logiLayer] = nDim;
214 m_map[sil][BEC][physLayer].section = m_layerInfo[logiLayer].size(); // i.e. index into m_layerInfo[logiLayer] entry below
215 m_layerInfo[logiLayer].push_back({ siTech, zone, physLayer, physDisk, stereo});
216 }
217 if (m_nDetLayers == linesRead) break;
218 }
219
220 if (!ok) ANA_MSG_FATAL("Error reading file");
221}
SiliconTech
DetectorZone
int getOverrideLayer(SiliconTech si, DetectorZone dz, int physLayer)
setEventNumber uint32_t

◆ seek()

void FPGATrackSimPlaneMap::seek ( std::ifstream & fin,
unsigned region )
private

Definition at line 130 of file FPGATrackSimPlaneMap.cxx.

131{
132 std::string line, key;
133 unsigned region_read = -1;
134
135 while (getline(fin, line))
136 {
137 if (line.empty() || line[0] == '!') continue;
138 ANA_MSG_VERBOSE(line);
139 istringstream sline(line);
140
141 bool ok = static_cast<bool>(sline >> key >> region_read);
142 if (ok && key == "region" && region_read == region) break;
143 }
144
145 ANA_MSG_DEBUG("seek() ended at:" << line);
146}

Member Data Documentation

◆ m_coordLayer

std::vector<uint32_t> FPGATrackSimPlaneMap::m_coordLayer
private

Definition at line 156 of file FPGATrackSimPlaneMap.h.

◆ m_coordOffset

std::vector<uint32_t> FPGATrackSimPlaneMap::m_coordOffset
private

Definition at line 152 of file FPGATrackSimPlaneMap.h.

◆ m_dimension

std::vector<uint32_t> FPGATrackSimPlaneMap::m_dimension
private

Definition at line 151 of file FPGATrackSimPlaneMap.h.

◆ m_diskIndex

std::vector<uint32_t> FPGATrackSimPlaneMap::m_diskIndex
private

Definition at line 168 of file FPGATrackSimPlaneMap.h.

◆ m_inValidLayerSection

const LayerSection FPGATrackSimPlaneMap::m_inValidLayerSection {}
private

Definition at line 174 of file FPGATrackSimPlaneMap.h.

174{};

◆ m_layerInfo

std::vector<std::vector<LayerInfo> > FPGATrackSimPlaneMap::m_layerInfo
private

Definition at line 161 of file FPGATrackSimPlaneMap.h.

◆ m_layerOverrides

std::vector<int> FPGATrackSimPlaneMap::m_layerOverrides
private

Definition at line 164 of file FPGATrackSimPlaneMap.h.

◆ m_map

std::vector<std::vector<std::vector<LayerSection> > > FPGATrackSimPlaneMap::m_map
private

Definition at line 159 of file FPGATrackSimPlaneMap.h.

◆ m_moduleRelabel

std::unique_ptr<FPGATrackSimModuleRelabel> FPGATrackSimPlaneMap::m_moduleRelabel {}
private

Definition at line 171 of file FPGATrackSimPlaneMap.h.

171{};

◆ m_nCoords

uint32_t FPGATrackSimPlaneMap::m_nCoords = 0
private

Definition at line 149 of file FPGATrackSimPlaneMap.h.

◆ m_nDetLayers

uint32_t FPGATrackSimPlaneMap::m_nDetLayers = 0
private

Definition at line 148 of file FPGATrackSimPlaneMap.h.

◆ m_nLogiLayers

uint32_t FPGATrackSimPlaneMap::m_nLogiLayers = 0
private

Definition at line 147 of file FPGATrackSimPlaneMap.h.


The documentation for this class was generated from the following files: