ThePEG::Selector< T, WeightType > Class Template Reference Selector is a templated class for storing objects associated with probabilities in a way such that, given a flat random number between 0 and 1, an object can be selected according to its relative probability. More...
Inheritance diagram for ThePEG::Selector< T, WeightType >:
Detailed Descriptiontemplate<typename T, typename WeightType = double>

typedef MapType::const_iterator ThePEG::Selector< T, WeightType >::const_iterator 
Iterator corresponding to the underlying map.
Definition at line 54 of file Selector.h.
typedef MapType::iterator ThePEG::Selector< T, WeightType >::iterator 
Iterator corresponding to the underlying map.
Definition at line 57 of file Selector.h.
typedef map<WeightType, T, less<WeightType> > ThePEG::Selector< T, WeightType >::MapType 
Map doubles to objects.
Definition at line 51 of file Selector.h.
typedef MapType::size_type ThePEG::Selector< T, WeightType >::size_type 
Size type of the underlying map.
Definition at line 60 of file Selector.h.

inline 
Access to the begin()
iterator of the underlying map.
Dereferenced, it will give a std::pair<WeightType, T>, where 'first' is the sum of all probabilities up to this one, and 'second' is the object inserted.
Definition at line 218 of file Selector.h.
WeightType ThePEG::Selector< T, WeightType >::erase  (  const T &  ) 
Erase an object, previously inserted.
If the object had not been inserted, nothing will happen. If several copies of the object has been inserted, all will be removed removed. In all cases the sum of the remaining probabilities is returned.
Referenced by ThePEG::Selector< tDMPtr >::reweight().

inline 
Insert an object given a probability for this object.
If the probability is zero or negative, the object will not be inserted and the probability itself is returned. Otherwise the sum of probabilities so far is returned.
Definition at line 84 of file Selector.h.
Referenced by ThePEG::Selector< tDMPtr >::reweight().

inline 
Selct an object randomly.
Given a random number flatly distributed in the interval ]0,1[ Select an object according to the individual probabilities specified when they were inserted. If rnd <= 0 or if rnd >= 1 or the Selector is empty, a range_error will be thrown.
Definition at line 140 of file Selector.h.

inline 
Selct an object randomly.
Given a random number flatly distributed in the interval ]0,1[ select an object according to the individual probabilities specified when they were inserted. If rnd <= 0 or if rnd >= 1 or the Selector is empty, a range_error will be thrown.
Definition at line 162 of file Selector.h.

inline 
Reweight an object previously inserted giving it a new weight.
Semantically reweight(w,o);
is equivalent to erase(o); insert(w,o);
Definition at line 97 of file Selector.h.
T& ThePEG::Selector< T, WeightType >::select  (  double  rnd, 
double *  remainder = 0 

) 
Select an object randomly.
Given a random number flatly distributed in the interval ]0,1[ Select an object according to the individual probabilities specified when they were inserted. If rnd <= 0 or if rnd >= 1 or the Selector is empty, a range_error will be thrown.
rnd  a flat random number in the interval ]0,1[ 
remainder  if nonzero the double pointed to will be set to a uniform random number in the interval ]0,1[ calculated from the fraction of rnd which was in the range of the selected object. 
Referenced by ThePEG::Selector< tDMPtr >::operator[](), ThePEG::Selector< tDMPtr >::replace(), and ThePEG::Selector< tDMPtr >::select().
const T& ThePEG::Selector< T, WeightType >::select  (  double  rnd, 
double *  remainder = 0 

)  const 
Selct an object randomly.
Given a random number flatly distributed in the interval ]0,1[ Select an object according to the individual probabilities specified when they were inserted. If rnd <= 0 or if rnd >= 1 or the Selector is empty, a range_error will be thrown.
rnd  a flat random number in the interval ]0,1[ 
remainder  if nonzero the double pointed to will be set to a uniform random number in the interval ]0,1[ calculated from the fraction of rnd which was in the range of the selected object. 

inline 
Selct an object randomly.
Given a random number generator which generates flat random numbers in the interval ]0,1[ with the operator()()
function, select an object according to the individual probabilities specified when they were inserted. If the generated number is outside the allowed range or the Selector is empty, a range_error will be thrown. The generator should have a push_back function which will be used push back a uniform random number in the interval ]0,1[ calculated from the fraction of rnd which was in the range of the selected object.
Definition at line 177 of file Selector.h.

inline 
Selct an object randomly.
Given a random number generator which generates flat random numbers in the interval ]0,1[ with the operator()()
function, select an object according to the individual probabilities specified when they were inserted. If the generated number is outside the allowed range or the Selector is empty, a range_error will be thrown. The generator should have a push_back function which will be used push back a uniform random number in the interval ]0,1[ calculated from the fraction of rnd which was in the range of the selected object.
Definition at line 197 of file Selector.h.

inline 
Return the sum of probabilities of the objects inserted.
Note that probabilities specified when objects are inserted are rescaled with this number to give unit probability for 'select()'.
Definition at line 210 of file Selector.h.