55 using Seed_t = std::default_random_engine::result_type;
97 inline constexpr
T sqr(
T v) {
return v*v; }
110 <<
" using " <<
samples <<
" samples per event, random seed " <<
seed;
118 std::uniform_real_distribution<float>
flat(0.0, 1.0);
125 while (tries_left-- > 0) {
127 if (
sqr(x) +
sqr(
y) < 1.0) ++local_hits;
130 double local_pi = double(local_hits) / double(
samples) * 4.0;
Counter_t tries
total number of tries (samples)
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
std::default_random_engine generator
random generator
Counter_t best_pi_tries() const
Returns the current best estimation of pi.
unsigned long long Counter_t
type used for integral counters
EDAnalyzer(fhicl::ParameterSet const &pset)
Q_EXPORT QTSManip setprecision(int p)
Counter_t hits
total number of hits
virtual ~ComputePi()=default
#define DEFINE_ART_MODULE(klass)
double best_pi() const
Returns the current best estimation of pi.
bool bFixed
whether the random sequence is always the same
Seed_t seed
number of digits to compute
Counter_t samples
number of samples to try on each event
virtual void analyze(const art::Event &) override
Computes pi (but it does not make it available)
static const char * VersionString
version of the algorithm
bool bVerbose
whether to put stuff on screen
std::default_random_engine::result_type Seed_t
type for seed and random numbers
LArSoft-specific namespace.
ComputePi(fhicl::ParameterSet const &p)
auto const & get(AssnsNode< L, R, D > const &r)