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

#include <FPGATrackSimRegionSlices.h>

Collaboration diagram for FPGATrackSimRegionSlices:

Public Member Functions

 FPGATrackSimRegionSlices (std::string const &filepath)
 
unsigned nRegions () const
 
std::pair< FPGATrackSimTrackPars, FPGATrackSimTrackPars > constgetRegion (unsigned region) const
 
FPGATrackSimTrackPars constgetMin (unsigned region) const
 
FPGATrackSimTrackPars constgetMax (unsigned region) const
 
bool inRegion (unsigned region, FPGATrackSimTruthTrack const &t) const
 

Private Attributes

std::vector< std::pair< FPGATrackSimTrackPars, FPGATrackSimTrackPars > > m_regions
 

Detailed Description

Definition at line 24 of file FPGATrackSimRegionSlices.h.

Constructor & Destructor Documentation

◆ FPGATrackSimRegionSlices()

FPGATrackSimRegionSlices::FPGATrackSimRegionSlices ( std::string const filepath)

Definition at line 27 of file FPGATrackSimRegionSlices.cxx.

28 {
29  // Open the file
30  std::ifstream fin(filepath);
31  if (!fin.is_open())
32  {
33  ANA_MSG_ERROR("Couldn't open " << filepath);
34  throw ("FPGATrackSimRegionSlices couldn't open " + filepath);
35  }
36 
37  // Variables to fill
38  unsigned region;
39  std::string line, key;
41 
42  // Parse the file
43  bool ok = true;
44  while (getline(fin, line))
45  {
46  if (line.empty() || line[0] == '#') continue;
47  std::istringstream sline(line);
48 
49  ok = ok && (sline >> key);
50  if (!ok) break;
51  if (key == "region")
52  {
53  ok = ok && (sline >> region);
54  if (ok && region > 0) m_regions.push_back({ min, max });
55  ok = ok && (region == m_regions.size());
56  min = FPGATrackSimTrackPars(); // reset
57  max = FPGATrackSimTrackPars(); // reset
58  }
59  else if (key == "phi") ok = ok && (sline >> min.phi >> max.phi);
60  else if (key == "eta") ok = ok && (sline >> min.eta >> max.eta);
61  else if (key == "qpt") ok = ok && (sline >> min.qOverPt >> max.qOverPt);
62  else if (key == "d0") ok = ok && (sline >> min.d0 >> max.d0);
63  else if (key == "z0") ok = ok && (sline >> min.z0 >> max.z0);
64  else ok = false;
65 
66  if (!ok) break;
67  }
68 
69  if (!ok)
70  {
71  ANA_MSG_ERROR("Found error reading file at line: " << line);
72  throw "FPGATrackSimRegionSlices read error";
73  }
74 
75  m_regions.push_back({ min, max }); // last region still needs to be added
76 }

Member Function Documentation

◆ getMax()

FPGATrackSimTrackPars const& FPGATrackSimRegionSlices::getMax ( unsigned  region) const
inline

Definition at line 33 of file FPGATrackSimRegionSlices.h.

33 { return m_regions.at(region).second; }

◆ getMin()

FPGATrackSimTrackPars const& FPGATrackSimRegionSlices::getMin ( unsigned  region) const
inline

Definition at line 32 of file FPGATrackSimRegionSlices.h.

32 { return m_regions.at(region).first; }

◆ getRegion()

std::pair<FPGATrackSimTrackPars, FPGATrackSimTrackPars> const& FPGATrackSimRegionSlices::getRegion ( unsigned  region) const
inline

Definition at line 31 of file FPGATrackSimRegionSlices.h.

31 { return m_regions.at(region); }

◆ inRegion()

bool FPGATrackSimRegionSlices::inRegion ( unsigned  region,
FPGATrackSimTruthTrack const t 
) const

Definition at line 85 of file FPGATrackSimRegionSlices.cxx.

86 {
87  if (region >= m_regions.size())
88  {
89  ANA_MSG_WARNING("inRegion() region " << region << " out-of-bounds " << m_regions.size());
90  return false;
91  }
92  FPGATrackSimTrackPars min = m_regions[region].first;
93  FPGATrackSimTrackPars max = m_regions[region].second;
94  FPGATrackSimTrackPars cur = t.getPars();
95 
96  for (unsigned i = 0; i < FPGATrackSimTrackPars::NPARS; i++)
97  {
98  if (cur[i] < min[i]) return false;
99  if (cur[i] > max[i]) return false;
100  }
101 
102  return true;
103 }

◆ nRegions()

unsigned FPGATrackSimRegionSlices::nRegions ( ) const
inline

Definition at line 29 of file FPGATrackSimRegionSlices.h.

29 { return m_regions.size(); }

Member Data Documentation

◆ m_regions

std::vector<std::pair<FPGATrackSimTrackPars, FPGATrackSimTrackPars> > FPGATrackSimRegionSlices::m_regions
private

Definition at line 39 of file FPGATrackSimRegionSlices.h.


The documentation for this class was generated from the following files:
checkFileSG.line
line
Definition: checkFileSG.py:75
max
#define max(a, b)
Definition: cfImp.cxx:41
FPGATrackSimTrackPars
Definition: FPGATrackSimTrackPars.h:22
beamspotman.cur
def cur
Definition: beamspotman.py:671
ANA_MSG_ERROR
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:294
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
lumiFormat.i
int i
Definition: lumiFormat.py:85
ANA_MSG_WARNING
#define ANA_MSG_WARNING(xmsg)
Macro printing warning messages.
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:292
min
#define min(a, b)
Definition: cfImp.cxx:40
FPGATrackSimTrackPars::NPARS
@ NPARS
Definition: FPGATrackSimTrackPars.h:49
compute_lumi.fin
fin
Definition: compute_lumi.py:19
FPGATrackSimRegionSlices::m_regions
std::vector< std::pair< FPGATrackSimTrackPars, FPGATrackSimTrackPars > > m_regions
Definition: FPGATrackSimRegionSlices.h:39
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37