ATLAS Offline Software
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
TFCS1DFunction_HistogramContent< T, Trandom > Class Template Reference

#include <TFCS1DFunctionTemplateHelpers.h>

Collaboration diagram for TFCS1DFunction_HistogramContent< T, Trandom >:

Public Types

typedef TFCS1DFunction_size_t size_t
 
typedef T value_type
 
typedef Trandom random_type
 

Public Member Functions

 TFCS1DFunction_HistogramContent (size_t nbins=0)
 
std::size_t MemorySizeArray () const
 
std::size_t MemorySize () const
 
void set_fraction (size_t pos, Trandom value)
 Set the content of bin pos to a given value, where value is in the range [0,1]. More...
 
Trandom get_fraction (size_t pos) const
 Get the cumulative content at bin pos as fraction in the range [0,1]. More...
 
Trandom get_binfraction (size_t pos) const
 Get the content at bin pos as fraction in the range [0,1]. More...
 
void set_nbins (size_t nbins)
 set number of bins. More...
 
size_t get_nbins () const
 return number of bins. More...
 
size_t get_bin (Trandom drnd, Trandom &residual_rnd) const
 Get the matching bin for a given random value in the range [0,1). More...
 

Private Member Functions

size_t size () const
 

Private Attributes

TFCS1DFunction_Array< T > m_array
 

Detailed Description

template<typename T, typename Trandom = float>
class TFCS1DFunction_HistogramContent< T, Trandom >

Definition at line 157 of file TFCS1DFunctionTemplateHelpers.h.

Member Typedef Documentation

◆ random_type

template<typename T , typename Trandom = float>
typedef Trandom TFCS1DFunction_HistogramContent< T, Trandom >::random_type

Definition at line 161 of file TFCS1DFunctionTemplateHelpers.h.

◆ size_t

template<typename T , typename Trandom = float>
typedef TFCS1DFunction_size_t TFCS1DFunction_HistogramContent< T, Trandom >::size_t

Definition at line 159 of file TFCS1DFunctionTemplateHelpers.h.

◆ value_type

template<typename T , typename Trandom = float>
typedef T TFCS1DFunction_HistogramContent< T, Trandom >::value_type

Definition at line 160 of file TFCS1DFunctionTemplateHelpers.h.

Constructor & Destructor Documentation

◆ TFCS1DFunction_HistogramContent()

template<typename T , typename Trandom = float>
TFCS1DFunction_HistogramContent< T, Trandom >::TFCS1DFunction_HistogramContent ( size_t  nbins = 0)
inline

Definition at line 163 of file TFCS1DFunctionTemplateHelpers.h.

164  : m_array(nbins >= 1 ? nbins - 1 : 0){};

Member Function Documentation

◆ get_bin()

template<typename T , typename Trandom = float>
size_t TFCS1DFunction_HistogramContent< T, Trandom >::get_bin ( Trandom  drnd,
Trandom &  residual_rnd 
) const
inline

Get the matching bin for a given random value in the range [0,1).

A residual random number to calculate a position inside this bin is returned in residual_rnd

Definition at line 208 of file TFCS1DFunctionTemplateHelpers.h.

208  {
209  if (drnd <= 0)
210  drnd = 0;
211  if (drnd >= 1)
212  drnd = std::nextafter((Trandom)1.0, (Trandom)0.0);
213  if (size() == 0) {
214  residual_rnd = drnd;
215  return 0;
216  }
218  auto it = std::upper_bound(m_array.begin(), m_array.end(), rnd);
219 
220  T basecont = 0;
221  if (it != m_array.begin())
222  basecont = *(it - 1);
223 
225  if (it != m_array.end())
226  fullcont = *it;
227 
228  T dcont = fullcont - basecont;
229  if (dcont > 0) {
230  residual_rnd = ((Trandom)(rnd - basecont)) / dcont;
231  if (residual_rnd > 1)
232  residual_rnd = std::nextafter((Trandom)1.0, (Trandom)0.0);
233  } else {
234  residual_rnd = 0.5;
235  }
236 
237  if (it == m_array.end())
238  return size();
239  return std::distance(m_array.begin(), it);
240  };

◆ get_binfraction()

template<typename T , typename Trandom = float>
Trandom TFCS1DFunction_HistogramContent< T, Trandom >::get_binfraction ( size_t  pos) const
inline

Get the content at bin pos as fraction in the range [0,1].

Definition at line 185 of file TFCS1DFunctionTemplateHelpers.h.

185  {
186  if (pos == 0)
188  if (pos == size())
189  return 1 - (m_array[size() - 1] /
191  return (m_array[pos] - m_array[pos - 1]) /
193  };

◆ get_fraction()

template<typename T , typename Trandom = float>
Trandom TFCS1DFunction_HistogramContent< T, Trandom >::get_fraction ( size_t  pos) const
inline

Get the cumulative content at bin pos as fraction in the range [0,1].

Definition at line 178 of file TFCS1DFunctionTemplateHelpers.h.

178  {
179  if (pos >= size())
180  return 1;
182  };

◆ get_nbins()

template<typename T , typename Trandom = float>
size_t TFCS1DFunction_HistogramContent< T, Trandom >::get_nbins ( ) const
inline

return number of bins.

This is one larger than size, as the last bin is fixed with the range [get_fraction(size()-1,1]

Definition at line 203 of file TFCS1DFunctionTemplateHelpers.h.

203 { return size() + 1; };

◆ MemorySize()

template<typename T , typename Trandom = float>
std::size_t TFCS1DFunction_HistogramContent< T, Trandom >::MemorySize ( ) const
inline

Definition at line 167 of file TFCS1DFunctionTemplateHelpers.h.

167 { return sizeof(*this) + MemorySizeArray(); };

◆ MemorySizeArray()

template<typename T , typename Trandom = float>
std::size_t TFCS1DFunction_HistogramContent< T, Trandom >::MemorySizeArray ( ) const
inline

Definition at line 166 of file TFCS1DFunctionTemplateHelpers.h.

166 { return m_array.MemorySizeArray(); };

◆ set_fraction()

template<typename T , typename Trandom = float>
void TFCS1DFunction_HistogramContent< T, Trandom >::set_fraction ( size_t  pos,
Trandom  value 
)
inline

Set the content of bin pos to a given value, where value is in the range [0,1].

Definition at line 171 of file TFCS1DFunctionTemplateHelpers.h.

171  {
172  if (pos >= size())
173  return;
175  };

◆ set_nbins()

template<typename T , typename Trandom = float>
void TFCS1DFunction_HistogramContent< T, Trandom >::set_nbins ( size_t  nbins)
inline

set number of bins.

The actualy alocated size is one smaller than count, as the last bin is fixed with the range [get_fraction(size()-1,1]

Definition at line 198 of file TFCS1DFunctionTemplateHelpers.h.

198 { m_array.resize(nbins >= 1 ? nbins - 1 : 0); };

◆ size()

template<typename T , typename Trandom = float>
size_t TFCS1DFunction_HistogramContent< T, Trandom >::size ( ) const
inlineprivate

Definition at line 244 of file TFCS1DFunctionTemplateHelpers.h.

244 { return m_array.size(); };

Member Data Documentation

◆ m_array

template<typename T , typename Trandom = float>
TFCS1DFunction_Array<T> TFCS1DFunction_HistogramContent< T, Trandom >::m_array
private

Definition at line 243 of file TFCS1DFunctionTemplateHelpers.h.


The documentation for this class was generated from the following file:
TFCS1DFunction_HistogramContent::size
size_t size() const
Definition: TFCS1DFunctionTemplateHelpers.h:244
skel.it
it
Definition: skel.GENtoEVGEN.py:396
TFCS1DFunction_HistogramContent::MemorySizeArray
std::size_t MemorySizeArray() const
Definition: TFCS1DFunctionTemplateHelpers.h:166
athena.value
value
Definition: athena.py:124
TFCS1DFunction_HistogramContent::m_array
TFCS1DFunction_Array< T > m_array
Definition: TFCS1DFunctionTemplateHelpers.h:240
TFCS1DFunction_Numeric::MaxCeilOnlyForInt
static T MaxCeilOnlyForInt(const Tfloat value)
Definition: TFCS1DFunctionTemplateHelpers.h:24
SCT_CalibAlgs::nbins
@ nbins
Definition: SCT_CalibNumbers.h:10
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
Amg::distance
float distance(const Amg::Vector3D &p1, const Amg::Vector3D &p2)
calculates the distance between two point in 3D space
Definition: GeoPrimitivesHelpers.h:54
TFCS1DFunction_Numeric
Converter functions that does nothing for floats.
Definition: TFCS1DFunctionTemplateHelpers.h:19
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35