ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
Trk::BinUtility Class Referencefinal

#include <BinUtility.h>

Collaboration diagram for Trk::BinUtility:

Public Member Functions

 BinUtility ()
 Constructor for equidistant. More...
 
 BinUtility (size_t bins, float min, float max, BinningOption opt=open, BinningValue value=binR, float sStep=0.)
 Constructor for equidistant - the substep is for phi binning offsets
More...
 
 BinUtility (size_t subbins, float substep, float min, float max, BinningOption opt=open, BinningValue value=binR)
 Constructor for bi-equidistant. More...
 
 BinUtility (std::vector< float > &bValues, BinningOption opt=closed, BinningValue value=binPhi)
 Constructor for arbitrary. More...
 
 BinUtility (float phiRef, std::vector< std::pair< int, float >> &bValues)
 Constructor for binH. More...
 
 BinUtility (const BinUtility &sbu)
 Copy constructor. More...
 
BinUtilityoperator= (const BinUtility &sbu)
 Assignment operator Constructor. More...
 
BinUtilityoperator+= (const BinUtility &gbu)
 Operator++ to make multidimensional BinUtility. More...
 
 ~BinUtility ()
 Destructor. More...
 
BinUtilityclone () const
 Implizit Constructor. More...
 
const std::vector< BinningData > & binningData () const
 return the binning data More...
 
size_t bin (const Amg::Vector3D &position, size_t ba=0) const
 Bin from a 3D vector (already in binning frame) More...
 
size_t entry (const Amg::Vector3D &position, size_t ba=0) const
 Bin from a 3D vector (already in binning frame) More...
 
size_t next (const Amg::Vector3D &position, const Amg::Vector3D &direction, size_t ba=0) const
 Bin from a 3D vector (already in binning frame) More...
 
std::pair< size_t, float > distanceToNext (const Amg::Vector3D &position, const Amg::Vector3D &direction, size_t ba=0) const
 Distance estimate to next bin
More...
 
LayerOrder orderDirection (const Amg::Vector3D &position, const Amg::Vector3D &direction, size_t ba=0) const
 Return the oder direciton for fast interlinking. More...
 
size_t bin (const Amg::Vector2D &lposition, size_t ba=0) const
 Bin from a 2D vector (following local parameters defintitions) More...
 
bool inside (const Amg::Vector3D &position) const
 Check if bin is inside from Vector3D. More...
 
bool inside (const Amg::Vector2D &lposition) const
 Check if bin is inside from Vector3D. More...
 
size_t dimensions () const
 First bin maximal value. More...
 
size_t max (size_t ba=0) const
 First bin maximal value. More...
 
size_t bins (size_t ba=0) const
 Number of bins. More...
 
BinningValue binningValue (size_t ba=0) const
 The type/value of the binning. More...
 
float binPosition (size_t bin, float pos, size_t ba=0) const
 bin->BinningValue navigation : pos=+-1. More...
 
void clear ()
 Clear the data. More...
 
MsgStream & dump (MsgStream &sl) const
 Output Method for MsgStream, to be overloaded by child classes. More...
 
std::ostream & dump (std::ostream &sl) const
 Output Method for std::ostream, to be overloaded by child classes. More...
 

Private Attributes

std::vector< BinningDatam_binningData
 

Detailed Description

A generic symmetric BinUtility, for fully symmetric binning in terms of binning grid and binning type

Author
Andre.nosp@m.as.S.nosp@m.alzbu.nosp@m.rger.nosp@m.@cern.nosp@m..ch

Definition at line 38 of file BinUtility.h.

Constructor & Destructor Documentation

◆ BinUtility() [1/6]

Trk::BinUtility::BinUtility ( )
inline

Constructor for equidistant.

Definition at line 43 of file BinUtility.h.

44  : m_binningData()
45  {
46  m_binningData.reserve(3);
47  }

◆ BinUtility() [2/6]

Trk::BinUtility::BinUtility ( size_t  bins,
float  min,
float  max,
BinningOption  opt = open,
BinningValue  value = binR,
float  sStep = 0. 
)
inline

Constructor for equidistant - the substep is for phi binning offsets

Definition at line 50 of file BinUtility.h.

51  : m_binningData()
52  {
53  m_binningData.reserve(3);
54  std::vector<float> bValues;
55  float step = (max - min) / bins;
56  for (size_t ib = 0; ib <= bins; ++ib)
57  bValues.push_back(min + ib * step);
58  m_binningData.emplace_back(Trk::equidistant, opt, value, bins, min, max, step, sStep, bValues);
59  }

◆ BinUtility() [3/6]

Trk::BinUtility::BinUtility ( size_t  subbins,
float  substep,
float  min,
float  max,
BinningOption  opt = open,
BinningValue  value = binR 
)
inline

Constructor for bi-equidistant.

Definition at line 62 of file BinUtility.h.

63  : m_binningData()
64  {
65  m_binningData.reserve(3);
66  std::vector<float> bValues;
67  float step = (max - min) / (subbins + 1);
68  bValues.push_back(min);
69  for (size_t isb = 1; isb <= subbins; ++isb) {
70  bValues.push_back(min + isb * step - substep);
71  bValues.push_back(min + isb * step);
72  }
73  bValues.push_back(max);
74  m_binningData.emplace_back(Trk::biequidistant, opt, value, 2 * subbins + 1, min, max, step, substep, bValues);
75  }

◆ BinUtility() [4/6]

Trk::BinUtility::BinUtility ( std::vector< float > &  bValues,
BinningOption  opt = closed,
BinningValue  value = binPhi 
)
inline

Constructor for arbitrary.

Definition at line 78 of file BinUtility.h.

79  : m_binningData()
80  {
81  m_binningData.reserve(3);
82  size_t nBins = opt == 0 ? bValues.size() - 1 : bValues.size();
83 
84  m_binningData.emplace_back(Trk::arbitrary,
85  opt,
86  value,
87  nBins,
88  bValues[0],
89  bValues.back(),
90  (bValues.back() - bValues[0]) / (nBins),
91  0.,
92  bValues);
93  }

◆ BinUtility() [5/6]

Trk::BinUtility::BinUtility ( float  phiRef,
std::vector< std::pair< int, float >> &  bValues 
)
inline

Constructor for binH.

Definition at line 96 of file BinUtility.h.

97  : m_binningData()
98  {
99  m_binningData.reserve(3);
100  m_binningData.emplace_back(Trk::open, phiRef, bValues);
101  }

◆ BinUtility() [6/6]

Trk::BinUtility::BinUtility ( const BinUtility sbu)
inline

Copy constructor.

Definition at line 104 of file BinUtility.h.

105  : m_binningData(sbu.m_binningData)
106  {}

◆ ~BinUtility()

Trk::BinUtility::~BinUtility ( )
inline

Destructor.

Definition at line 127 of file BinUtility.h.

127 {}

Member Function Documentation

◆ bin() [1/2]

size_t Trk::BinUtility::bin ( const Amg::Vector2D lposition,
size_t  ba = 0 
) const
inline

Bin from a 2D vector (following local parameters defintitions)

  • USE WITH CARE !! You need to check if your local position is actually in the binning frame of the BinUtility

Definition at line 182 of file BinUtility.h.

183  {
184  if (ba >= m_binningData.size())
185  throw GaudiException("BinUtility", "dimension out of bounds", StatusCode::FAILURE);
186  return m_binningData[ba].searchLocal(lposition);
187  }

◆ bin() [2/2]

size_t Trk::BinUtility::bin ( const Amg::Vector3D position,
size_t  ba = 0 
) const
inline

Bin from a 3D vector (already in binning frame)

Definition at line 136 of file BinUtility.h.

137  {
138  if (ba >= m_binningData.size())
139  throw GaudiException("BinUtility", "dimension out of bounds", StatusCode::FAILURE);
140  size_t bEval = m_binningData[ba].searchGlobal(position);
141  return (bEval > bins(ba) - 1 ? bins(ba) - 1 : bEval); // ST additional protection : DEBUG source
142  }

◆ binningData()

const std::vector<BinningData>& Trk::BinUtility::binningData ( ) const
inline

return the binning data

Definition at line 133 of file BinUtility.h.

133 { return m_binningData; }

◆ binningValue()

BinningValue Trk::BinUtility::binningValue ( size_t  ba = 0) const
inline

The type/value of the binning.

Definition at line 231 of file BinUtility.h.

232  {
233  if (ba >= m_binningData.size())
234  throw GaudiException("BinUtility", "dimension out of bounds", StatusCode::FAILURE);
235  return (m_binningData[ba].binvalue);
236  }

◆ binPosition()

float Trk::BinUtility::binPosition ( size_t  bin,
float  pos,
size_t  ba = 0 
) const
inline

bin->BinningValue navigation : pos=+-1.

edges/ 0. bin center

Definition at line 239 of file BinUtility.h.

240  {
241  if (ba >= m_binningData.size())
242  throw GaudiException("BinUtility", "dimension out of bounds", StatusCode::FAILURE);
243  return (m_binningData[ba].binPosition(bin, pos));
244  }

◆ bins()

size_t Trk::BinUtility::bins ( size_t  ba = 0) const
inline

Number of bins.

Definition at line 223 of file BinUtility.h.

224  {
225  if (ba >= m_binningData.size())
226  return 0;
227  return (m_binningData[ba].bins);
228  }

◆ clear()

void Trk::BinUtility::clear ( )
inline

Clear the data.

Definition at line 247 of file BinUtility.h.

247 { m_binningData.clear(); }

◆ clone()

BinUtility* Trk::BinUtility::clone ( ) const
inline

Implizit Constructor.

Definition at line 130 of file BinUtility.h.

130 { return new BinUtility(*this); }

◆ dimensions()

size_t Trk::BinUtility::dimensions ( ) const
inline

First bin maximal value.

Definition at line 212 of file BinUtility.h.

212 { return m_binningData.size(); }

◆ distanceToNext()

std::pair<size_t, float> Trk::BinUtility::distanceToNext ( const Amg::Vector3D position,
const Amg::Vector3D direction,
size_t  ba = 0 
) const
inline

Distance estimate to next bin

Definition at line 161 of file BinUtility.h.

164  {
165  if (ba >= m_binningData.size())
166  throw GaudiException("BinUtility", "dimension out of bounds", StatusCode::FAILURE);
167  return m_binningData[ba].distanceToNext(position, direction);
168  }

◆ dump() [1/2]

MsgStream& Trk::BinUtility::dump ( MsgStream &  sl) const
inline

Output Method for MsgStream, to be overloaded by child classes.

Definition at line 250 of file BinUtility.h.

251  {
252  sl << "BinUtility for " << m_binningData.size() << "-dimensional array:" << endmsg;
253  std::vector<BinningData>::const_iterator bdIter = m_binningData.begin();
254  for (size_t ibd = 0; bdIter != m_binningData.end(); ++bdIter, ++ibd) {
255  sl << "dimension : " << ibd << endmsg << endmsg;
256  sl << " - type : " << size_t((*bdIter).type) << endmsg;
257  sl << " - option : " << size_t((*bdIter).option) << endmsg;
258  sl << " - value : " << size_t((*bdIter).binvalue) << endmsg;
259  sl << " - bins : " << (*bdIter).bins << endmsg;
260  sl << " - min/max : " << (*bdIter).min << " / " << (*bdIter).max << endmsg;
261  sl << " - step/sub : " << (*bdIter).step << " / " << (*bdIter).subStep << endmsg;
262  sl << " - boundaries : | ";
263  std::vector<float>::const_iterator bIter = (*bdIter).boundaries.begin();
264  for (; bIter != (*bdIter).boundaries.end(); ++bIter)
265  sl << (*bIter) << " | ";
266  sl << endmsg;
267  }
268  return sl;
269  }

◆ dump() [2/2]

std::ostream& Trk::BinUtility::dump ( std::ostream &  sl) const
inline

Output Method for std::ostream, to be overloaded by child classes.

Definition at line 272 of file BinUtility.h.

273  {
274  sl << "BinUtility for " << m_binningData.size() << "-dimensional array:" << std::endl;
275  std::vector<BinningData>::const_iterator bdIter = m_binningData.begin();
276  for (size_t ibd = 0; bdIter != m_binningData.end(); ++bdIter, ++ibd) {
277  sl << "dimension : " << ibd << std::endl;
278  sl << " - type : " << size_t((*bdIter).type) << std::endl;
279  sl << " - option : " << size_t((*bdIter).option) << std::endl;
280  sl << " - value : " << size_t((*bdIter).binvalue) << std::endl;
281  sl << " - bins : " << (*bdIter).bins << std::endl;
282  sl << " - min/max : " << (*bdIter).min << " / " << (*bdIter).max << std::endl;
283  sl << " - step/sub : " << (*bdIter).step << " / " << (*bdIter).subStep << std::endl;
284  sl << " - boundaries : | ";
285  std::vector<float>::const_iterator bIter = (*bdIter).boundaries.begin();
286  for (; bIter != (*bdIter).boundaries.end(); ++bIter)
287  sl << (*bIter) << " | ";
288  sl << std::endl;
289  }
290  return sl;
291  }

◆ entry()

size_t Trk::BinUtility::entry ( const Amg::Vector3D position,
size_t  ba = 0 
) const
inline

Bin from a 3D vector (already in binning frame)

Definition at line 145 of file BinUtility.h.

146  {
147  if (ba >= m_binningData.size())
148  throw GaudiException("BinUtility", "dimension out of bounds", StatusCode::FAILURE);
149  return m_binningData[ba].entry(position);
150  }

◆ inside() [1/2]

bool Trk::BinUtility::inside ( const Amg::Vector2D lposition) const
inline

Check if bin is inside from Vector3D.

Definition at line 201 of file BinUtility.h.

202  {
203  return true;
204  std::vector<BinningData>::const_iterator bdIter = m_binningData.begin();
205  for (; bdIter != m_binningData.end(); ++bdIter)
206  if (!(*bdIter).inside(lposition))
207  return false;
208  return true;
209  }

◆ inside() [2/2]

bool Trk::BinUtility::inside ( const Amg::Vector3D position) const
inline

Check if bin is inside from Vector3D.

Definition at line 190 of file BinUtility.h.

191  {
192  std::vector<BinningData>::const_iterator bdIter = m_binningData.begin();
193  for (; bdIter != m_binningData.end(); ++bdIter) {
194  if (!(*bdIter).inside(position))
195  return false;
196  }
197  return true;
198  }

◆ max()

size_t Trk::BinUtility::max ( size_t  ba = 0) const
inline

First bin maximal value.

Definition at line 215 of file BinUtility.h.

216  {
217  if (ba >= m_binningData.size())
218  return 0;
219  return (m_binningData[ba].bins - 1);
220  }

◆ next()

size_t Trk::BinUtility::next ( const Amg::Vector3D position,
const Amg::Vector3D direction,
size_t  ba = 0 
) const
inline

Bin from a 3D vector (already in binning frame)

Definition at line 153 of file BinUtility.h.

154  {
155  if (ba >= m_binningData.size())
156  throw GaudiException("BinUtility", "dimension out of bounds", StatusCode::FAILURE);
157  return m_binningData[ba].next(position, direction);
158  }

◆ operator+=()

BinUtility& Trk::BinUtility::operator+= ( const BinUtility gbu)
inline

Operator++ to make multidimensional BinUtility.

Definition at line 117 of file BinUtility.h.

118  {
119  const std::vector<BinningData>& bData = gbu.binningData();
120  if (m_binningData.size() + bData.size() > 3)
121  throw GaudiException("BinUtility does not support dim > 3", "FATAL", StatusCode::FAILURE);
122  m_binningData.insert(m_binningData.end(), bData.begin(), bData.end());
123  return (*this);
124  }

◆ operator=()

BinUtility& Trk::BinUtility::operator= ( const BinUtility sbu)
inline

Assignment operator Constructor.

Definition at line 109 of file BinUtility.h.

110  {
111  if (this != &sbu)
112  m_binningData = sbu.m_binningData;
113  return (*this);
114  }

◆ orderDirection()

LayerOrder Trk::BinUtility::orderDirection ( const Amg::Vector3D position,
const Amg::Vector3D direction,
size_t  ba = 0 
) const
inline

Return the oder direciton for fast interlinking.

Definition at line 171 of file BinUtility.h.

172  {
173  if (ba >= m_binningData.size())
174  throw GaudiException("BinUtility", "dimension out of bounds", StatusCode::FAILURE);
175  return m_binningData[ba].orderDirection(position, direction);
176  }

Member Data Documentation

◆ m_binningData

std::vector<BinningData> Trk::BinUtility::m_binningData
private

Definition at line 294 of file BinUtility.h.


The documentation for this class was generated from the following file:
Trk::equidistant
@ equidistant
Definition: BinningType.h:32
make_coralServer_rep.opt
opt
Definition: make_coralServer_rep.py:19
Trk::BinUtility::max
size_t max(size_t ba=0) const
First bin maximal value.
Definition: BinUtility.h:215
bin
Definition: BinsDiffFromStripMedian.h:43
PlotCalibFromCool.ib
ib
Definition: PlotCalibFromCool.py:419
Trk::biequidistant
@ biequidistant
Definition: BinningType.h:33
athena.value
value
Definition: athena.py:124
Trk::BinUtility::bins
size_t bins(size_t ba=0) const
Number of bins.
Definition: BinUtility.h:223
Trk::arbitrary
@ arbitrary
Definition: BinningType.h:34
Trk::BinUtility::BinUtility
BinUtility()
Constructor for equidistant.
Definition: BinUtility.h:43
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
min
#define min(a, b)
Definition: cfImp.cxx:40
dumpTgcDigiJitter.nBins
list nBins
Definition: dumpTgcDigiJitter.py:29
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
Trk::open
@ open
Definition: BinningType.h:40
Trk::BinUtility::m_binningData
std::vector< BinningData > m_binningData
Definition: BinUtility.h:294
LArCellBinning.step
step
Definition: LArCellBinning.py:158
Trk::BinUtility::binPosition
float binPosition(size_t bin, float pos, size_t ba=0) const
bin->BinningValue navigation : pos=+-1.
Definition: BinUtility.h:239