ATLAS Offline Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
FPGATrackSimSectorBank Class Reference

#include <FPGATrackSimSectorBank.h>

Collaboration diagram for FPGATrackSimSectorBank:

Public Member Functions

 FPGATrackSimSectorBank (std::string const &filepath)
 
size_t getNLayers () const
 
size_t getNSectors () const
 
std::vector< module_t > constgetModules (sector_t sector) const
 
std::vector< sector_tgetSectors (unsigned layer, module_t module) const
 
sector_t findSector (std::vector< module_t > const &modules) const
 
sector_t findSector (std::vector< std::vector< std::shared_ptr< const FPGATrackSimHit >>> const &hits) const
 
const std::vector< double > & getQOverPtBins () const
 
size_t getNQOverPtBins () const
 
bool isAbsQOverPtBinning () const
 
void storeQOverPtBinning (const std::vector< double > &qOverPtBins, bool absBinning)
 

Private Member Functions

void readHeader (std::ifstream &fin)
 
void readSectors (std::ifstream &fin)
 
void makeInverseMap ()
 

Private Attributes

size_t m_nLayers = 0UL
 
std::vector< std::vector< module_t > > m_s2mMap
 
std::vector< std::multimap< module_t, sector_t > > m_m2sMap
 
std::vector< double > m_qOverPtBins
 
bool m_absQOverPtBinning = false
 

Detailed Description

Definition at line 31 of file FPGATrackSimSectorBank.h.

Constructor & Destructor Documentation

◆ FPGATrackSimSectorBank()

FPGATrackSimSectorBank::FPGATrackSimSectorBank ( std::string const filepath)

Definition at line 23 of file FPGATrackSimSectorBank.cxx.

24 {
25  // Open the file for reading
26  ANA_MSG_INFO("Reading " << filepath);
27  std::ifstream fin(filepath);
28  if (!fin.is_open())
29  {
30  ANA_MSG_ERROR("Couldn't open " << filepath);
31  throw ("FPGATrackSimSectorBank couldn't open " + filepath);
32  }
33 
34  // Retrieve the number of sectors and layers, resize m_s2mMap
35  readHeader(fin);
36 
37  // Read the modules from each sector
39 
40  // Make m2sMap
42 }

Member Function Documentation

◆ findSector() [1/2]

sector_t FPGATrackSimSectorBank::findSector ( std::vector< module_t > const modules) const

Definition at line 121 of file FPGATrackSimSectorBank.cxx.

122 {
123  assert(modules.size() == m_nLayers);
124 
125  std::set<sector_t> sectors_good; // List of matching sectors so far.
126  for (size_t layer = 0; layer < m_nLayers; layer++)
127  {
128  std::set<sector_t> sectors_new;
129  auto range = m_m2sMap[layer].equal_range(modules[layer]);
130 
131  for (auto it_m2s = range.first; it_m2s != range.second; it_m2s++)
132  if (layer == 0 || sectors_good.count(it_m2s->second))
133  sectors_new.insert(it_m2s->second);
134 
135  if (sectors_new.empty()) return -1;
136  sectors_good = sectors_new;
137  }
138 
139  assert(sectors_good.size() == 1);
140  return *(sectors_good.begin());
141 }

◆ findSector() [2/2]

sector_t FPGATrackSimSectorBank::findSector ( std::vector< std::vector< std::shared_ptr< const FPGATrackSimHit >>> const hits) const

Definition at line 146 of file FPGATrackSimSectorBank.cxx.

147 {
148  std::vector<module_t> modules(hits.size());
149 
150  for (size_t i = 0; i < hits.size(); i++)
151  {
152  if (hits[i].empty())
153  {
154  modules[i] = MODULE_BADMODULE;
155  }
156  else if (hits[i].size() == 1)
157  {
158  modules[i] = hits[i][0]->getIdentifierHash();
159  }
160  else
161  {
162  std::unordered_map<unsigned, unsigned> hashCount;
163  for (auto const &h : hits[i]) hashCount[h->getIdentifierHash()]++;
164  modules[i] = std::max_element(hashCount.begin(), hashCount.end())->first;
165  }
166  }
167 
168  return findSector(modules);
169 }

◆ getModules()

std::vector<module_t> const& FPGATrackSimSectorBank::getModules ( sector_t  sector) const
inline

Definition at line 40 of file FPGATrackSimSectorBank.h.

40 { return m_s2mMap[sector]; }

◆ getNLayers()

size_t FPGATrackSimSectorBank::getNLayers ( ) const
inline

Definition at line 37 of file FPGATrackSimSectorBank.h.

37 { return m_nLayers; }

◆ getNQOverPtBins()

size_t FPGATrackSimSectorBank::getNQOverPtBins ( ) const
inline

Definition at line 53 of file FPGATrackSimSectorBank.h.

53 {return m_qOverPtBins.size(); }

◆ getNSectors()

size_t FPGATrackSimSectorBank::getNSectors ( ) const
inline

Definition at line 38 of file FPGATrackSimSectorBank.h.

38 { return m_s2mMap.size(); }

◆ getQOverPtBins()

const std::vector<double>& FPGATrackSimSectorBank::getQOverPtBins ( ) const
inline

Definition at line 52 of file FPGATrackSimSectorBank.h.

52 { return m_qOverPtBins; }

◆ getSectors()

std::vector< sector_t > FPGATrackSimSectorBank::getSectors ( unsigned  layer,
module_t  module 
) const

Definition at line 110 of file FPGATrackSimSectorBank.cxx.

111 {
112  std::vector<sector_t> out;
113  auto range = m_m2sMap[layer].equal_range(module);
114  for (auto it_m2s = range.first; it_m2s != range.second; it_m2s++)
115  out.push_back(it_m2s->second);
116 
117  return out;
118 }

◆ isAbsQOverPtBinning()

bool FPGATrackSimSectorBank::isAbsQOverPtBinning ( ) const
inline

Definition at line 54 of file FPGATrackSimSectorBank.h.

54 { return m_absQOverPtBinning; }

◆ makeInverseMap()

void FPGATrackSimSectorBank::makeInverseMap ( )
private

Definition at line 96 of file FPGATrackSimSectorBank.cxx.

97 {
98  m_m2sMap.resize(m_nLayers);
99  for (size_t layer = 0; layer < m_nLayers; layer++)
100  {
101  for (sector_t sector = 0; (size_t)sector < m_s2mMap.size(); sector++)
102  {
103  module_t moduleID = m_s2mMap[sector][layer];
104  m_m2sMap[layer].insert(std::make_pair(moduleID, sector));
105  }
106  }
107 }

◆ readHeader()

void FPGATrackSimSectorBank::readHeader ( std::ifstream &  fin)
private

Definition at line 46 of file FPGATrackSimSectorBank.cxx.

47 {
48  bool ok = true;
49  std::string line;
50  int nSectors;
51 
52  ok = ok && std::getline(fin, line);
54 
55  std::istringstream sline(line);
56  ok = ok && (sline >> nSectors >> m_nLayers);
57 
58  if (!ok) throw "Error reading header";
59 
60  m_s2mMap.resize(nSectors, std::vector<module_t>(m_nLayers));
61 }

◆ readSectors()

void FPGATrackSimSectorBank::readSectors ( std::ifstream &  fin)
private

Definition at line 64 of file FPGATrackSimSectorBank.cxx.

65 {
66  std::string line;
67  bool ok = true;
68  int sector = 0; // make sure sectors are numbered in order
69  int sector_file, UNUSED, coverage;
70 
71  while (std::getline(fin, line))
72  {
73  if (line.empty() || line[0] == '!') continue;
75  std::istringstream sline(line);
76 
77  ok = ok && (sline >> sector_file);
78  ok = ok && (sector_file == sector);
79 
80  for (unsigned i = 0; i < m_nLayers; i++)
81  ok = ok && (sline >> m_s2mMap[sector][i]);
82 
83  ok = ok && (sline >> UNUSED >> coverage); // both these are not stored
84 
85  if (!ok) break;
86  sector++;
87  }
88 
89  if (!ok) ANA_MSG_ERROR("Error reading file on line: " << line);
90 }

◆ storeQOverPtBinning()

void FPGATrackSimSectorBank::storeQOverPtBinning ( const std::vector< double > &  qOverPtBins,
bool  absBinning 
)

Definition at line 173 of file FPGATrackSimSectorBank.cxx.

174 {
175  m_absQOverPtBinning = absBinning;
176 
177  // Retrieve q/pt binning information. Fallback to no binning if not set.
178  // Note that this behavior on whether or not we are using |q/pt|.
179  m_qOverPtBins = qOverPtBins;
180  if (m_qOverPtBins.size() == 0) {
181  ANA_MSG_FATAL("q/pt bin information not set in bank tag!");
182  }
183 }

Member Data Documentation

◆ m_absQOverPtBinning

bool FPGATrackSimSectorBank::m_absQOverPtBinning = false
private

Definition at line 66 of file FPGATrackSimSectorBank.h.

◆ m_m2sMap

std::vector<std::multimap<module_t, sector_t> > FPGATrackSimSectorBank::m_m2sMap
private

Definition at line 62 of file FPGATrackSimSectorBank.h.

◆ m_nLayers

size_t FPGATrackSimSectorBank::m_nLayers = 0UL
private

Definition at line 60 of file FPGATrackSimSectorBank.h.

◆ m_qOverPtBins

std::vector<double> FPGATrackSimSectorBank::m_qOverPtBins
private

Definition at line 65 of file FPGATrackSimSectorBank.h.

◆ m_s2mMap

std::vector<std::vector<module_t> > FPGATrackSimSectorBank::m_s2mMap
private

Definition at line 61 of file FPGATrackSimSectorBank.h.


The documentation for this class was generated from the following files:
FPGATrackSimSectorBank::readSectors
void readSectors(std::ifstream &fin)
Definition: FPGATrackSimSectorBank.cxx:64
checkFileSG.line
line
Definition: checkFileSG.py:75
FPGATrackSimSectorBank::m_qOverPtBins
std::vector< double > m_qOverPtBins
Definition: FPGATrackSimSectorBank.h:65
TRTCalib_Extractor.hits
hits
Definition: TRTCalib_Extractor.py:35
FPGATrackSimSectorBank::readHeader
void readHeader(std::ifstream &fin)
Definition: FPGATrackSimSectorBank.cxx:46
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
ANA_MSG_ERROR
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:294
empty
bool empty(TH1 *h)
Definition: computils.cxx:294
FPGATrackSimSectorBank::m_m2sMap
std::vector< std::multimap< module_t, sector_t > > m_m2sMap
Definition: FPGATrackSimSectorBank.h:62
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
python.PyAthena.module
module
Definition: PyAthena.py:131
FPGATrackSimSectorBank::findSector
sector_t findSector(std::vector< module_t > const &modules) const
Definition: FPGATrackSimSectorBank.cxx:121
module_t
int32_t module_t
Definition: FPGATrackSimTypes.h:20
lumiFormat.i
int i
Definition: lumiFormat.py:85
h
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
ANA_MSG_INFO
#define ANA_MSG_INFO(xmsg)
Macro printing info messages.
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:290
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
ANA_MSG_FATAL
#define ANA_MSG_FATAL(xmsg)
Macro printing fatal messages.
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:296
sector_t
int32_t sector_t
Definition: FPGATrackSimTypes.h:21
FPGATrackSimSectorBank::m_absQOverPtBinning
bool m_absQOverPtBinning
Definition: FPGATrackSimSectorBank.h:66
FPGATrackSimSectorBank::m_nLayers
size_t m_nLayers
Definition: FPGATrackSimSectorBank.h:60
FPGATrackSimSectorBank::m_s2mMap
std::vector< std::vector< module_t > > m_s2mMap
Definition: FPGATrackSimSectorBank.h:61
FPGATrackSimSectorBank::makeInverseMap
void makeInverseMap()
Definition: FPGATrackSimSectorBank.cxx:96
compute_lumi.fin
fin
Definition: compute_lumi.py:19
MODULE_BADMODULE
#define MODULE_BADMODULE
Definition: FPGATrackSimTypes.h:13
ANA_MSG_DEBUG
#define ANA_MSG_DEBUG(xmsg)
Macro printing debug messages.
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:288