LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
lar_content::DiscreteProbabilityVector Class Reference

DiscreteProbabilityVector class. More...

#include "LArDiscreteProbabilityVector.h"

Classes

class  DiscreteProbabilityDatum
 DiscreteProbabilityData class. More...
 

Public Types

template<typename TX , typename TY >
using InputDatum = std::pair< TX, TY >
 
template<typename TX , typename TY >
using InputData = std::vector< InputDatum< TX, TY >>
 
typedef InputData< float, float > AllFloatInputData
 
typedef pandora::FloatVector ResamplingPoints
 

Public Member Functions

template<typename TX , typename TY >
 DiscreteProbabilityVector (const InputData< TX, TY > &inputData, const TX xUpperBound, const bool useWidths)
 Constructor. More...
 
 DiscreteProbabilityVector (const DiscreteProbabilityVector &discreteProbabilityVector, const ResamplingPoints &resamplingPoints)
 Constructor. More...
 
 DiscreteProbabilityVector (const DiscreteProbabilityVector &discreteProbabilityVector, std::mt19937 &randomNumberGenerator)
 Constructor. More...
 
float EvaluateCumulativeProbability (const float x) const
 Evaluate the cumulative probability at arbitrary x. More...
 
unsigned int GetSize () const
 Get the size of the probability vector. More...
 
float GetX (const unsigned int index) const
 Get the x value of the element in the vector. More...
 
float GetProbability (const unsigned int index) const
 Get the probability value of the element in the vector. More...
 
float GetProbabilityDensity (const unsigned int index) const
 Get the probability density value of the element in the vector. More...
 
float GetCumulativeProbability (const unsigned int index) const
 Get the cumulative probability value of the element in the vector. More...
 
float GetWidth (const unsigned int index) const
 Get the width of the element in the vectorr. More...
 
void GetAllAtIndex (const unsigned int index, float &x, float &probabilityDensity, float &cumulativeProbability, float &width) const
 Get all information stored at a particular index. More...
 

Private Types

typedef std::vector< DiscreteProbabilityDatumDiscreteProbabilityData
 

Private Member Functions

template<typename TX , typename TY >
DiscreteProbabilityData InitialiseDiscreteProbabilityData (InputData< TX, TY > inputData) const
 Get a initialised probability data vector from the input data. More...
 
DiscreteProbabilityData ResampleDiscreteProbabilityData (const DiscreteProbabilityVector &discreteProbabilityVector, const ResamplingPoints &resamplingPoints) const
 Get a resampled probability data vector by resampling another probability data vector. More...
 
DiscreteProbabilityData RandomiseDiscreteProbabilityData (const DiscreteProbabilityVector &discreteProbabilityVector, std::mt19937 &randomNumberGenerator) const
 Get a randomised probability data vector in which the x values are unchanged, the probability density is randomised and the cumulative probability is recalculated. More...
 
template<typename TX , typename TY >
float CalculateNormalisation (const InputData< TX, TY > &inputData) const
 Calculate the probability normalisation. More...
 
void VerifyCompleteData () const
 Verify the integrity of the complete probability vector. More...
 
void VerifyElementRequest (const unsigned int index) const
 Verify the integrity of the element request. More...
 

Static Private Member Functions

template<typename TX , typename TY >
static bool SortInputDataByX (const InputDatum< TX, TY > &lhs, const InputDatum< TX, TY > &rhs)
 Sort the input data according to their x value. More...
 

Private Attributes

float m_xUpperBound
 the upper bound of the probability vector More...
 
bool m_useWidths
 controls whether bin widths are used in calculations More...
 
DiscreteProbabilityData m_discreteProbabilityData
 the probability data More...
 

Detailed Description

DiscreteProbabilityVector class.

Definition at line 25 of file LArDiscreteProbabilityVector.h.

Member Typedef Documentation

template<typename TX , typename TY >
using lar_content::DiscreteProbabilityVector::InputData = std::vector<InputDatum<TX, TY>>

Definition at line 32 of file LArDiscreteProbabilityVector.h.

template<typename TX , typename TY >
using lar_content::DiscreteProbabilityVector::InputDatum = std::pair<TX, TY>

Definition at line 29 of file LArDiscreteProbabilityVector.h.

Definition at line 36 of file LArDiscreteProbabilityVector.h.

Constructor & Destructor Documentation

template<typename TX , typename TY >
lar_content::DiscreteProbabilityVector::DiscreteProbabilityVector ( const InputData< TX, TY > &  inputData,
const TX  xUpperBound,
const bool  useWidths 
)

Constructor.

Parameters
inputDatathe data used to construct the probability vector
xUpperBoundthe upper bound of the probability vector
useWidthsbool controlling whether the bin widths are used in calculations

Definition at line 19 of file LArDiscreteProbabilityVector.cc.

References VerifyCompleteData().

Referenced by CalculateNormalisation().

19  :
20  m_xUpperBound(static_cast<float>(xUpperBound)),
21  m_useWidths(useWidths),
23 {
24  this->VerifyCompleteData();
25 }
void VerifyCompleteData() const
Verify the integrity of the complete probability vector.
DiscreteProbabilityData InitialiseDiscreteProbabilityData(InputData< TX, TY > inputData) const
Get a initialised probability data vector from the input data.
DiscreteProbabilityData m_discreteProbabilityData
the probability data
float m_xUpperBound
the upper bound of the probability vector
bool m_useWidths
controls whether bin widths are used in calculations
lar_content::DiscreteProbabilityVector::DiscreteProbabilityVector ( const DiscreteProbabilityVector discreteProbabilityVector,
const ResamplingPoints resamplingPoints 
)

Constructor.

Parameters
discreteProbabilityVectora discrete probability vector to resample from
resamplingPointsthe points to resample the discrete probability vector with

Definition at line 39 of file LArDiscreteProbabilityVector.cc.

References VerifyCompleteData().

39  :
40  m_xUpperBound(discreteProbabilityVector.m_xUpperBound),
41  m_useWidths(discreteProbabilityVector.m_useWidths),
42  m_discreteProbabilityData(this->ResampleDiscreteProbabilityData(discreteProbabilityVector, resamplingPoints))
43 {
44  this->VerifyCompleteData();
45 }
void VerifyCompleteData() const
Verify the integrity of the complete probability vector.
DiscreteProbabilityData ResampleDiscreteProbabilityData(const DiscreteProbabilityVector &discreteProbabilityVector, const ResamplingPoints &resamplingPoints) const
Get a resampled probability data vector by resampling another probability data vector.
DiscreteProbabilityData m_discreteProbabilityData
the probability data
float m_xUpperBound
the upper bound of the probability vector
bool m_useWidths
controls whether bin widths are used in calculations
lar_content::DiscreteProbabilityVector::DiscreteProbabilityVector ( const DiscreteProbabilityVector discreteProbabilityVector,
std::mt19937 &  randomNumberGenerator 
)

Constructor.

Parameters
discreteProbabilityVectora discrete probability vector to randomly rearrange
randomNumberGeneratorthe random number generator for the random reshuffling

Definition at line 29 of file LArDiscreteProbabilityVector.cc.

References VerifyCompleteData().

29  :
30  m_xUpperBound(discreteProbabilityVector.m_xUpperBound),
31  m_useWidths(discreteProbabilityVector.m_useWidths),
32  m_discreteProbabilityData(this->RandomiseDiscreteProbabilityData(discreteProbabilityVector, randomNumberGenerator))
33 {
34  this->VerifyCompleteData();
35 }
void VerifyCompleteData() const
Verify the integrity of the complete probability vector.
DiscreteProbabilityData RandomiseDiscreteProbabilityData(const DiscreteProbabilityVector &discreteProbabilityVector, std::mt19937 &randomNumberGenerator) const
Get a randomised probability data vector in which the x values are unchanged, the probability density...
DiscreteProbabilityData m_discreteProbabilityData
the probability data
float m_xUpperBound
the upper bound of the probability vector
bool m_useWidths
controls whether bin widths are used in calculations

Member Function Documentation

template<typename TX , typename TY >
template float lar_content::DiscreteProbabilityVector::CalculateNormalisation ( const InputData< TX, TY > &  inputData) const
private

Calculate the probability normalisation.

Parameters
inputDatathe input data
Returns
the probability normalisation

Definition at line 199 of file LArDiscreteProbabilityVector.cc.

References DiscreteProbabilityVector(), f, InitialiseDiscreteProbabilityData(), m_useWidths, m_xUpperBound, SortInputDataByX(), and y.

Referenced by InitialiseDiscreteProbabilityData().

200 {
201  if (2 > inputData.size())
202  throw pandora::StatusCodeException(pandora::STATUS_CODE_INVALID_PARAMETER);
203 
204  float normalisation(0.f);
205 
206  for (unsigned int iDatum = 0; iDatum < inputData.size() - 1; ++iDatum)
207  {
208  const float y(static_cast<float>(inputData.at(iDatum).second));
209  normalisation +=
210  y * (m_useWidths ? static_cast<float>(inputData.at(iDatum + 1).first) - static_cast<float>(inputData.at(iDatum).first) : 1.f);
211  }
212  const float y(static_cast<float>(inputData.back().second));
213  normalisation += y * (m_useWidths ? m_xUpperBound - static_cast<float>(inputData.back().first) : 1.f);
214 
215  return normalisation;
216 }
Float_t y
Definition: compare.C:6
TFile f
Definition: plotHisto.C:6
float m_xUpperBound
the upper bound of the probability vector
bool m_useWidths
controls whether bin widths are used in calculations
float lar_content::DiscreteProbabilityVector::EvaluateCumulativeProbability ( const float  x) const

Evaluate the cumulative probability at arbitrary x.

Parameters
xthe x value
Returns
the cumulative probability

Definition at line 49 of file LArDiscreteProbabilityVector.cc.

References f, and m_discreteProbabilityData.

Referenced by ResampleDiscreteProbabilityData().

50 {
51  if (x - m_discreteProbabilityData.back().GetX() > std::numeric_limits<float>::epsilon())
52  return 1.f;
53 
54  if (x - m_discreteProbabilityData.front().GetX() < std::numeric_limits<float>::epsilon())
55  return 0.f;
56 
57  for (unsigned int iDatum = 1; iDatum < m_discreteProbabilityData.size(); ++iDatum)
58  {
59  if (x - m_discreteProbabilityData.at(iDatum).GetX() > std::numeric_limits<float>::epsilon())
60  continue;
61 
62  const float xLow(m_discreteProbabilityData.at(iDatum - 1).GetX());
63  const float yLow(m_discreteProbabilityData.at(iDatum - 1).GetCumulativeDatum());
64  const float xHigh(m_discreteProbabilityData.at(iDatum).GetX());
65  const float yHigh(m_discreteProbabilityData.at(iDatum).GetCumulativeDatum());
66 
67  if (std::fabs(xHigh - xLow) < std::numeric_limits<float>::epsilon())
68  throw pandora::StatusCodeException(pandora::STATUS_CODE_INVALID_PARAMETER);
69 
70  const float m((yHigh - yLow) / (xHigh - xLow));
71  const float c(yLow - m * xLow);
72 
73  return m * x + c;
74  }
75 
76  throw pandora::StatusCodeException(pandora::STATUS_CODE_INVALID_PARAMETER);
77 }
Float_t x
Definition: compare.C:6
TFile f
Definition: plotHisto.C:6
DiscreteProbabilityData m_discreteProbabilityData
the probability data
void lar_content::DiscreteProbabilityVector::GetAllAtIndex ( const unsigned int  index,
float &  x,
float &  probabilityDensity,
float &  cumulativeProbability,
float &  width 
) const
inline

Get all information stored at a particular index.

Parameters
indexthe index in the vector
xthe x value
probabilityDensitythe probability density value
cumulativeProbabilitythe cumulative probability value
widththe width of the probability bin

Definition at line 315 of file LArDiscreteProbabilityVector.h.

References lar_content::DiscreteProbabilityVector::DiscreteProbabilityDatum::GetX(), m_discreteProbabilityData, and VerifyElementRequest().

317 {
318  this->VerifyElementRequest(index);
319 
320  const DiscreteProbabilityDatum &theDatum(m_discreteProbabilityData.at(index));
321  x = theDatum.GetX();
322  probabilityDensity = theDatum.GetDensityDatum();
323  cumulativeProbability = theDatum.GetCumulativeDatum();
324  width = theDatum.GetWidth();
325 }
Float_t x
Definition: compare.C:6
void VerifyElementRequest(const unsigned int index) const
Verify the integrity of the element request.
DiscreteProbabilityData m_discreteProbabilityData
the probability data
float lar_content::DiscreteProbabilityVector::GetCumulativeProbability ( const unsigned int  index) const
inline

Get the cumulative probability value of the element in the vector.

Parameters
indexthe index in the vector
Returns
the cumulative probability

Definition at line 297 of file LArDiscreteProbabilityVector.h.

References m_discreteProbabilityData, and VerifyElementRequest().

298 {
299  this->VerifyElementRequest(index);
300 
301  return m_discreteProbabilityData.at(index).GetCumulativeDatum();
302 }
void VerifyElementRequest(const unsigned int index) const
Verify the integrity of the element request.
DiscreteProbabilityData m_discreteProbabilityData
the probability data
float lar_content::DiscreteProbabilityVector::GetProbability ( const unsigned int  index) const
inline

Get the probability value of the element in the vector.

Parameters
indexthe index in the vector
Returns
the probability

Definition at line 279 of file LArDiscreteProbabilityVector.h.

References m_discreteProbabilityData, m_useWidths, and VerifyElementRequest().

Referenced by lar_content::TwoViewTransverseTracksAlgorithm::CalculateNumberOfLocallyMatchingSamplingPoints(), and lar_content::LArDiscreteProbabilityHelper::GetElement().

280 {
281  this->VerifyElementRequest(index);
282 
283  return m_discreteProbabilityData.at(index).GetDensityDatum() * (m_useWidths ? m_discreteProbabilityData.at(index).GetWidth() : 1.f);
284 }
void VerifyElementRequest(const unsigned int index) const
Verify the integrity of the element request.
DiscreteProbabilityData m_discreteProbabilityData
the probability data
bool m_useWidths
controls whether bin widths are used in calculations
float lar_content::DiscreteProbabilityVector::GetProbabilityDensity ( const unsigned int  index) const
inline

Get the probability density value of the element in the vector.

Parameters
indexthe index in the vector
Returns
the probability density

Definition at line 288 of file LArDiscreteProbabilityVector.h.

References m_discreteProbabilityData, and VerifyElementRequest().

Referenced by RandomiseDiscreteProbabilityData().

289 {
290  this->VerifyElementRequest(index);
291 
292  return m_discreteProbabilityData.at(index).GetDensityDatum();
293 }
void VerifyElementRequest(const unsigned int index) const
Verify the integrity of the element request.
DiscreteProbabilityData m_discreteProbabilityData
the probability data
unsigned int lar_content::DiscreteProbabilityVector::GetSize ( ) const
inline
float lar_content::DiscreteProbabilityVector::GetWidth ( const unsigned int  index) const
inline

Get the width of the element in the vectorr.

Parameters
indexthe index in the vector
Returns
the width of the probability bin

Definition at line 306 of file LArDiscreteProbabilityVector.h.

References m_discreteProbabilityData, and VerifyElementRequest().

Referenced by RandomiseDiscreteProbabilityData().

307 {
308  this->VerifyElementRequest(index);
309 
310  return m_discreteProbabilityData.at(index).GetWidth();
311 }
void VerifyElementRequest(const unsigned int index) const
Verify the integrity of the element request.
DiscreteProbabilityData m_discreteProbabilityData
the probability data
float lar_content::DiscreteProbabilityVector::GetX ( const unsigned int  index) const
inline

Get the x value of the element in the vector.

Parameters
indexthe index in the vector
Returns
the x value

Definition at line 270 of file LArDiscreteProbabilityVector.h.

References m_discreteProbabilityData, and VerifyElementRequest().

Referenced by RandomiseDiscreteProbabilityData().

271 {
272  this->VerifyElementRequest(index);
273 
274  return m_discreteProbabilityData.at(index).GetX();
275 }
void VerifyElementRequest(const unsigned int index) const
Verify the integrity of the element request.
DiscreteProbabilityData m_discreteProbabilityData
the probability data
template<typename TX , typename TY >
template DiscreteProbabilityVector::DiscreteProbabilityData lar_content::DiscreteProbabilityVector::InitialiseDiscreteProbabilityData ( InputData< TX, TY >  inputData) const
private

Get a initialised probability data vector from the input data.

Parameters
inputDatathe input data
Returns
a fully-initialised discrete probability data vector

Definition at line 82 of file LArDiscreteProbabilityVector.cc.

References CalculateNormalisation(), f, m_useWidths, m_xUpperBound, and x.

Referenced by CalculateNormalisation().

83 {
84  if (2 > inputData.size())
85  throw pandora::StatusCodeException(pandora::STATUS_CODE_INVALID_PARAMETER);
86 
87  std::sort(inputData.begin(), inputData.end(), DiscreteProbabilityVector::SortInputDataByX<TX, TY>);
88 
89  if (inputData.back().first - m_xUpperBound > std::numeric_limits<float>::epsilon())
90  throw pandora::StatusCodeException(pandora::STATUS_CODE_INVALID_PARAMETER);
91 
92  const float normalisation(this->CalculateNormalisation(inputData));
93 
94  if (normalisation < std::numeric_limits<float>::epsilon())
95  throw pandora::StatusCodeException(pandora::STATUS_CODE_FAILURE);
96 
97  float accumulationDatum(0.f);
98 
100  for (unsigned int iDatum = 0; iDatum < inputData.size() - 1; ++iDatum)
101  {
102  const float x(static_cast<float>(inputData.at(iDatum).first));
103  const float deltaX(static_cast<float>(inputData.at(iDatum + 1).first) - x);
104  const float densityDatum(static_cast<float>(inputData.at(iDatum).second) / normalisation);
105  accumulationDatum += densityDatum * (m_useWidths ? deltaX : 1.f);
106  data.emplace_back(DiscreteProbabilityVector::DiscreteProbabilityDatum(x, densityDatum, accumulationDatum, deltaX));
107  }
108  const float x(static_cast<float>(inputData.back().first));
109  const float deltaX(m_xUpperBound - x);
110  const float densityDatum(static_cast<float>(inputData.back().second) / normalisation);
111  accumulationDatum += densityDatum * (m_useWidths ? deltaX : 1.f);
112  data.emplace_back(DiscreteProbabilityVector::DiscreteProbabilityDatum(x, densityDatum, accumulationDatum, deltaX));
113 
114  return data;
115 }
Float_t x
Definition: compare.C:6
std::vector< DiscreteProbabilityDatum > DiscreteProbabilityData
float CalculateNormalisation(const InputData< TX, TY > &inputData) const
Calculate the probability normalisation.
TFile f
Definition: plotHisto.C:6
float m_xUpperBound
the upper bound of the probability vector
bool m_useWidths
controls whether bin widths are used in calculations
DiscreteProbabilityVector::DiscreteProbabilityData lar_content::DiscreteProbabilityVector::RandomiseDiscreteProbabilityData ( const DiscreteProbabilityVector discreteProbabilityVector,
std::mt19937 &  randomNumberGenerator 
) const
private

Get a randomised probability data vector in which the x values are unchanged, the probability density is randomised and the cumulative probability is recalculated.

Parameters
discreteProbabilityVectoranother discrete probability vector
randomNumberGeneratorthe random number generator for the random reshuffling
Returns
a resampled probability data vector

Definition at line 159 of file LArDiscreteProbabilityVector.cc.

References util::begin(), util::end(), f, GetProbabilityDensity(), GetSize(), GetWidth(), GetX(), and m_useWidths.

161 {
162  DiscreteProbabilityData randomisedProbabilityData;
163 
164  std::vector<unsigned int> randomisedElements(discreteProbabilityVector.GetSize());
165  std::iota(std::begin(randomisedElements), std::end(randomisedElements), 0);
166  std::shuffle(std::begin(randomisedElements), std::end(randomisedElements), randomNumberGenerator);
167 
168  float xPos(discreteProbabilityVector.GetX(0));
169  float cumulativeProbability(0.f);
170  for (unsigned int iElement = 0; iElement < discreteProbabilityVector.GetSize(); ++iElement)
171  {
172  const unsigned int randomElementIndex(randomisedElements.at(iElement));
173  const float deltaX(discreteProbabilityVector.GetWidth(randomElementIndex));
174  const float probabilityDensity(discreteProbabilityVector.GetProbabilityDensity(randomElementIndex));
175  cumulativeProbability += probabilityDensity * (m_useWidths ? deltaX : 1.f);
176  randomisedProbabilityData.emplace_back(
177  DiscreteProbabilityVector::DiscreteProbabilityDatum(xPos, probabilityDensity, cumulativeProbability, deltaX));
178  xPos += deltaX;
179  }
180 
181  return randomisedProbabilityData;
182 }
std::vector< DiscreteProbabilityDatum > DiscreteProbabilityData
TFile f
Definition: plotHisto.C:6
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
Definition: StdUtils.h:77
bool m_useWidths
controls whether bin widths are used in calculations
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:69
DiscreteProbabilityVector::DiscreteProbabilityData lar_content::DiscreteProbabilityVector::ResampleDiscreteProbabilityData ( const DiscreteProbabilityVector discreteProbabilityVector,
const ResamplingPoints resamplingPoints 
) const
private

Get a resampled probability data vector by resampling another probability data vector.

Parameters
discreteProbabilityVectoranother discrete probability vector
resamplingPointsthe points to resample the discrete probability vector with
Returns
a resampled probability data vector

Definition at line 119 of file LArDiscreteProbabilityVector.cc.

References EvaluateCumulativeProbability(), f, m_useWidths, and m_xUpperBound.

121 {
122  if (2 > resamplingPoints.size())
123  throw pandora::StatusCodeException(pandora::STATUS_CODE_INVALID_PARAMETER);
124 
125  DiscreteProbabilityData resampledProbabilityData;
126 
127  float prevCumulativeData(0.f);
128  for (unsigned int iSample = 0; iSample < resamplingPoints.size() - 1; ++iSample)
129  {
130  const float xResampled(resamplingPoints.at(iSample));
131  const float deltaX(resamplingPoints.at(iSample + 1) - xResampled);
132 
133  if (deltaX < std::numeric_limits<float>::epsilon())
134  throw pandora::StatusCodeException(pandora::STATUS_CODE_INVALID_PARAMETER);
135 
136  const float cumulativeDatumResampled(discreteProbabilityVector.EvaluateCumulativeProbability(xResampled));
137  const float densityDatumResampled((cumulativeDatumResampled - prevCumulativeData) / (m_useWidths ? deltaX : 1.f));
138  resampledProbabilityData.emplace_back(
139  DiscreteProbabilityVector::DiscreteProbabilityDatum(xResampled, densityDatumResampled, cumulativeDatumResampled, deltaX));
140  prevCumulativeData = cumulativeDatumResampled;
141  }
142 
143  const float xResampled(resamplingPoints.back());
144  const float deltaX(m_xUpperBound - xResampled);
145 
146  if (deltaX < std::numeric_limits<float>::epsilon())
147  throw pandora::StatusCodeException(pandora::STATUS_CODE_INVALID_PARAMETER);
148 
149  const float cumulativeDatumResampled(discreteProbabilityVector.EvaluateCumulativeProbability(xResampled));
150  const float densityDatumResampled((cumulativeDatumResampled - prevCumulativeData) / (m_useWidths ? deltaX : 1.f));
151  resampledProbabilityData.emplace_back(
152  DiscreteProbabilityVector::DiscreteProbabilityDatum(xResampled, densityDatumResampled, cumulativeDatumResampled, deltaX));
153 
154  return resampledProbabilityData;
155 }
std::vector< DiscreteProbabilityDatum > DiscreteProbabilityData
TFile f
Definition: plotHisto.C:6
float m_xUpperBound
the upper bound of the probability vector
bool m_useWidths
controls whether bin widths are used in calculations
template<typename TX , typename TY >
template bool lar_content::DiscreteProbabilityVector::SortInputDataByX ( const InputDatum< TX, TY > &  lhs,
const InputDatum< TX, TY > &  rhs 
)
staticprivate

Sort the input data according to their x value.

Parameters
lhsthe first InputDatum
lhsthe second InputDatum
Returns
a bool dictacting swapping the two InputDatums

Definition at line 187 of file LArDiscreteProbabilityVector.cc.

Referenced by CalculateNormalisation().

188 {
189  const float deltaX(static_cast<float>(rhs.first) - static_cast<float>(lhs.first));
190  if (std::fabs(deltaX) < std::numeric_limits<float>::epsilon())
191  return (lhs.second < rhs.second);
192 
193  return (lhs.first < rhs.first);
194 }
void lar_content::DiscreteProbabilityVector::VerifyCompleteData ( ) const
inlineprivate

Verify the integrity of the complete probability vector.

Definition at line 368 of file LArDiscreteProbabilityVector.h.

References m_discreteProbabilityData, and m_xUpperBound.

Referenced by DiscreteProbabilityVector().

369 {
370  if (2 > m_discreteProbabilityData.size())
371  throw pandora::StatusCodeException(pandora::STATUS_CODE_NOT_INITIALIZED);
372 
373  if (m_discreteProbabilityData.back().GetX() - m_xUpperBound > std::numeric_limits<float>::epsilon())
374  throw pandora::StatusCodeException(pandora::STATUS_CODE_INVALID_PARAMETER);
375 
376  return;
377 }
DiscreteProbabilityData m_discreteProbabilityData
the probability data
float m_xUpperBound
the upper bound of the probability vector
void lar_content::DiscreteProbabilityVector::VerifyElementRequest ( const unsigned int  index) const
inlineprivate

Verify the integrity of the element request.

Parameters
indexthe index in the probability vector

Definition at line 381 of file LArDiscreteProbabilityVector.h.

References GetSize().

Referenced by GetAllAtIndex(), GetCumulativeProbability(), GetProbability(), GetProbabilityDensity(), GetWidth(), and GetX().

382 {
383  if (this->GetSize() < index)
384  throw pandora::StatusCodeException(pandora::STATUS_CODE_OUT_OF_RANGE);
385 
386  return;
387 }
unsigned int GetSize() const
Get the size of the probability vector.

Member Data Documentation

DiscreteProbabilityData lar_content::DiscreteProbabilityVector::m_discreteProbabilityData
private
bool lar_content::DiscreteProbabilityVector::m_useWidths
private
float lar_content::DiscreteProbabilityVector::m_xUpperBound
private

the upper bound of the probability vector

Definition at line 256 of file LArDiscreteProbabilityVector.h.

Referenced by CalculateNormalisation(), InitialiseDiscreteProbabilityData(), ResampleDiscreteProbabilityData(), and VerifyCompleteData().


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