Template class for randomly sampling from a JLANG::JRewindableObjectIterator using a JLANG::JObjectSampler.
More...
#include <JRandomSampler.hh>
template<class T>
struct JSUPPORT::JRandomSampler< T >
Template class for randomly sampling from a JLANG::JRewindableObjectIterator using a JLANG::JObjectSampler.
The JRandomSampler class provides for an implementation of randomly sampling objects.
The sampling is controlled via two parameters, namely:
Definition at line 33 of file JRandomSampler.hh.
◆ JRandomSampler() [1/2]
Default constructor.
This constructor will sample all objects.
Definition at line 39 of file JRandomSampler.hh.
◆ JRandomSampler() [2/2]
Constructor.
- Parameters
-
on | average number of consecutively accepted events |
off | average number of consecutively rejected events |
Definition at line 52 of file JRandomSampler.hh.
◆ getRandomSampler() [1/2]
Get random sampler.
- Returns
- random sampler
Definition at line 65 of file JRandomSampler.hh.
66 {
68 }
JRandomSampler()
Default constructor.
◆ getRandomSampler() [2/2]
◆ operator()()
Acceptance test operator.
Return value 0 means accept and >0 number of objects to skip.
- Parameters
-
- Returns
- number of objects to skip
Definition at line 89 of file JRandomSampler.hh.
90 {
92
94
96
97 } else {
98
100
101 return 0;
102 }
103 }
unsigned int skip_type
Type definition for number of objects to skip.
◆ operator>>
template<class T >
std::istream & operator>> |
( |
std::istream & | in, |
|
|
JRandomSampler< T > & | sampler ) |
|
friend |
Read random sampler from input.
- Parameters
-
in | input stream |
sampler | random sampler |
- Returns
- input stream
Definition at line 113 of file JRandomSampler.hh.
114 {
115 in >> sampler.averageOn;
116 in >> sampler.averageOff;
117
118 sampler.count = 0;
119
120 return in;
121 }
◆ operator<<
template<class T >
std::ostream & operator<< |
( |
std::ostream & | out, |
|
|
const JRandomSampler< T > & | sampler ) |
|
friend |
Write random sampler to output.
- Parameters
-
out | output stream |
sampler | random sampler |
- Returns
- output stream
Definition at line 131 of file JRandomSampler.hh.
132 {
133 out << sampler.averageOn;
134 out << ' ';
135 out << sampler.averageOff;
136
137 return out;
138 }
◆ averageOn
◆ averageOff
◆ count
The documentation for this struct was generated from the following file: