g4tools  5.4.0
Public Member Functions | Protected Attributes | List of all members
tools::rpoiss< FLAT, REAL, UINT > Class Template Reference

Public Member Functions

 rpoiss (FLAT &a_flat, REAL a_mean=1)
 
virtual ~rpoiss ()
 
 rpoiss (const rpoiss &a_from)
 
rpoissoperator= (const rpoiss &a_from)
 
UINT shoot (const REAL &a_two_pi, REAL(*a_sqrt)(REAL), REAL(*a_log)(REAL), REAL(*a_exp)(REAL), REAL(*a_cos)(REAL)) const
 
FLAT & flat ()
 
void set_seed (unsigned int a_seed)
 

Protected Attributes

FLAT & m_flat
 
REAL m_mean
 

Detailed Description

template<class FLAT, class REAL, class UINT>
class tools::rpoiss< FLAT, REAL, UINT >

Definition at line 154 of file randT.

Constructor & Destructor Documentation

◆ rpoiss() [1/2]

template<class FLAT , class REAL , class UINT >
tools::rpoiss< FLAT, REAL, UINT >::rpoiss ( FLAT &  a_flat,
REAL  a_mean = 1 
)
inline

Definition at line 156 of file randT.

156 :m_flat(a_flat),m_mean(a_mean){}

◆ ~rpoiss()

template<class FLAT , class REAL , class UINT >
virtual tools::rpoiss< FLAT, REAL, UINT >::~rpoiss ( )
inlinevirtual

Definition at line 157 of file randT.

157 {}

◆ rpoiss() [2/2]

template<class FLAT , class REAL , class UINT >
tools::rpoiss< FLAT, REAL, UINT >::rpoiss ( const rpoiss< FLAT, REAL, UINT > &  a_from)
inline

Definition at line 159 of file randT.

159 :m_flat(a_from.m_flat),m_mean(a_from.m_mean){}

Member Function Documentation

◆ flat()

template<class FLAT , class REAL , class UINT >
FLAT& tools::rpoiss< FLAT, REAL, UINT >::flat ( )
inline

Definition at line 188 of file randT.

188 {return m_flat;}

◆ operator=()

template<class FLAT , class REAL , class UINT >
rpoiss& tools::rpoiss< FLAT, REAL, UINT >::operator= ( const rpoiss< FLAT, REAL, UINT > &  a_from)
inline

Definition at line 160 of file randT.

160  {
161  m_mean = a_from.m_mean;
162  return *this;
163  }

◆ set_seed()

template<class FLAT , class REAL , class UINT >
void tools::rpoiss< FLAT, REAL, UINT >::set_seed ( unsigned int  a_seed)
inline

Definition at line 189 of file randT.

189 {m_flat.set_seed(a_seed);}

◆ shoot()

template<class FLAT , class REAL , class UINT >
UINT tools::rpoiss< FLAT, REAL, UINT >::shoot ( const REAL &  a_two_pi,
REAL(*)(REAL)  a_sqrt,
REAL(*)(REAL)  a_log,
REAL(*)(REAL)  a_exp,
REAL(*)(REAL)  a_cos 
) const
inline

Definition at line 165 of file randT.

165  {
166  UINT number = 0;
167  if(m_mean <= 16) {
168  REAL position = m_flat.shoot();
169  REAL poissonValue = a_exp(-m_mean);
170  REAL poissonSum = poissonValue;
171  while(poissonSum <= position) {
172  number++;
173  poissonValue *= m_mean/REAL(number);
174  poissonSum += poissonValue;
175  }
176  return number;
177  }
178  // m_mean > 16 :
179  REAL t = a_sqrt(-REAL(2)*a_log(m_flat.shoot()));
180  REAL y = a_two_pi*m_flat.shoot();
181  t *= a_cos(y);
182  REAL value = m_mean + t*a_sqrt(m_mean) + REAL(0.5);
183  if(value <= REAL(0)) return UINT(0);
184  static const REAL limit = REAL(2e9);
185  if(value >= limit) return UINT(limit);
186  return UINT(value);
187  }

Member Data Documentation

◆ m_flat

template<class FLAT , class REAL , class UINT >
FLAT& tools::rpoiss< FLAT, REAL, UINT >::m_flat
protected

Definition at line 191 of file randT.

◆ m_mean

template<class FLAT , class REAL , class UINT >
REAL tools::rpoiss< FLAT, REAL, UINT >::m_mean
protected

Definition at line 192 of file randT.


The documentation for this class was generated from the following file:
tools::rpoiss::m_mean
REAL m_mean
Definition: randT:192
tools::rpoiss::m_flat
FLAT & m_flat
Definition: randT:191