21using namespace asg::msgUserCode;
35 ANA_MSG_INFO(
"Region map set to inclusive mode; will always treat hits as being in region");
46 ifstream fin(filepath);
50 throw (
"FPGATrackSimRegionMap Couldn't open " + filepath);
58 for (
int region = 0; region <
m_nregions; region++){
70 string line, towerKey;
73 ok = ok && getline(fin, line);
76 istringstream sline(line);
78 ok = ok && (towerKey ==
"towers");
82 throw (
"Pmap slice size does not match Rmap:" );
91 for (
int iRegion=0; iRegion<int(
m_map.size()); iRegion++)
93 m_map.at(iRegion).resize(
m_pmaps.at(0)->getNLogiLayers());
94 for (
size_t l = 0; l <
m_map.at(iRegion).size(); l++)
m_map.at(iRegion).at(l).resize(
m_pmaps.at(iRegion)->getNSections(l));
106 uint32_t linesRead = 0;
108 while (getline(fin, line))
110 if (line.empty() || line[0] ==
'#')
continue;
111 istringstream sline(line);
115 ok = ok && (sline >> region);
116 ok = ok && !(sline >> dummy);
117 ok = ok && (region == expected_region);
122 int isPix{}, BEC{}, physLayer{}, phi_min{}, phi_max{}, phi_tot{}, eta_min{}, eta_max{}, eta_tot{};
124 ok = ok && (sline >> isPix >> BEC >> physLayer >> phi_min >> phi_max >> phi_tot >> eta_min >> eta_max >> eta_tot);
131 m_map[region][logiLayer][
section] = { phi_min, phi_max, eta_min, eta_max };
133 if (++linesRead ==
m_pmaps.at(region)->getNDetLayers())
break;
140 throw "FPGATrackSimRegionMap read error";
149 ifstream fin(filepath);
153 throw (
"FPGATrackSimRegionMap Couldn't open " + filepath);
160 while (getline(fin, line))
162 uint32_t region, layer, globalID, localID;
163 istringstream sline(line);
165 if (!(sline >> region >> layer >> globalID >> localID))
168 ANA_MSG_WARNING(
"loadModuleIDLUT() bad region=" << region <<
" or layer=" << layer);
179 layer_max = (layer_max == 0) ?
m_pmaps.at(0)->getNLogiLayers() - layer_offset: layer_max - layer_offset;
182 std::ifstream fin(filepath);
194 while (getline(fin, line))
196 if (line.empty() || line[0] ==
'#')
continue;
197 std::istringstream sline(line);
198 std::vector<int> shifts;
201 ok = ok && (sline >> subregion);
215 for (
unsigned layer = 0; layer < layer_max; layer++) {
216 ok = ok && (sline >>
r);
218 unsigned eff_layer = layer + layer_offset;
219 ANA_MSG_DEBUG(
"Reading average radius at effective (actual) layer = " << eff_layer <<
" (" << layer <<
") = " <<
r);
221 ANA_MSG_WARNING(
"Radius in radiiFile is "<<
r <<
" for layer: " << eff_layer <<
" setting to dummy value!");
224 if (subregion == -1) {
262 if (ls.layer<0)
return false;
263 layer =
static_cast<uint32_t
>(ls.layer);
277 if ( region >=
m_map.size()
278 || layer >=
m_map[region].size()
293 if (phi_min <= phi_max)
308 for (uint32_t region = 0; region <
m_map.size(); region++) {
337 int err[] = {1,1,1,1,1,1};
339 if (region >=
m_map.size()) anyerr = err[1] = 2;
341 if (!anyerr && layer >=
m_map[region].size()) anyerr = err[2] = 2;
343 if (!anyerr &&
section >=
m_map[region][layer].size()) anyerr = err[3] = 2;
349 if (
eta < eta_min) err[4] = 3;
350 if (
eta > eta_max) err[4] = 2;
356 if (phi_min <= phi_max)
366 int error_code = 100000*err[0] + 10000*err[1] + 1000*err[2] + 100*err[3] + 10*err[4] + err[5];
377 return globalModuleID & 0x3ff;
385 ANA_MSG_ERROR(
"getGlobalID() bad region=" << region <<
" or layer=" << layer);
390 if (g_l.second == localModuleID)
return g_l.first;
392 ANA_MSG_ERROR(
"getGlobalID() Did not find global id for region " << region <<
", layer " << layer <<
", localID " << localModuleID);
400 ANA_MSG_ERROR(
"getAvgRadius() bad region=" << region <<
" or layer=" << layer);
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
Maps ITK module indices to FPGATrackSim regions.
static const std::vector< std::string > regions
int getPairedEtaModule() const
unsigned getPairedPhysLayer() const
unsigned getPairedPhiModule() const
int getEtaModule(bool old=false) const
DetectorZone getPairedDetZone() const
unsigned getPhiModule() const
SiliconTech getPairedDetType() const
unsigned getPhysLayer(bool old=false) const
SiliconTech getDetType() const
DetectorZone getDetectorZone() const
unsigned getSection() const
HitType getHitType() const
double getAvgRadius(unsigned region, unsigned layer) const
std::vector< std::vector< std::vector< FPGATrackSimRegionBoundaries > > > m_map
std::vector< std::unique_ptr< FPGATrackSimPlaneMap > > const & m_pmaps
std::vector< std::vector< double > > m_radii_map
uint32_t getLocalID(uint32_t region, uint32_t layer, uint32_t globalModuleID) const
uint32_t getUnmappedID(uint32_t region, const FPGATrackSimHit &hit) const
void loadRadiiFile(std::string const &radii_file, unsigned layer_offset, unsigned layer_max)
void allocateMap(std::ifstream &fin)
uint32_t getGlobalID(uint32_t region, uint32_t layer, uint32_t localModuleID) const
FPGATrackSimRegionMap(const std::vector< std::unique_ptr< FPGATrackSimPlaneMap > > &pmaps, std::string const &filepath, bool m_inclusive)
std::vector< uint32_t > getRegions(const FPGATrackSimHit &hit) const
void readRegion(std::ifstream &fin, int expected_region)
bool isInRegion(uint32_t region, const FPGATrackSimHit &hit) const
void loadModuleIDLUT(std::string const &filepath)
std::vector< std::vector< std::map< uint32_t, uint32_t > > > m_global_local_map