ATLAS Offline Software
Loading...
Searching...
No Matches
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].
Trandom get_fraction (size_t pos) const
 Get the cumulative content at bin pos as fraction in the range [0,1].
Trandom get_binfraction (size_t pos) const
 Get the content at bin pos as fraction in the range [0,1].
void set_nbins (size_t nbins)
 set number of bins.
size_t get_nbins () const
 return number of bins.
size_t get_bin (Trandom drnd, Trandom &residual_rnd) const
 Get the matching bin for a given random value in the range [0,1).

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

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) {
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
229 if (dcont > 0) {
231 if (residual_rnd > 1)
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.

◆ 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 };
static T MaxCeilOnlyForInt(const Tfloat value)

◆ 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: