CLHEP 2.4.6.4
C++ Class Library for High Energy Physics
Loading...
Searching...
No Matches
RandGaussT.cc
Go to the documentation of this file.
1//
2// -*- C++ -*-
3//
4// -----------------------------------------------------------------------
5// HEP Random
6// --- RandGaussT ---
7// class implementation file
8// -----------------------------------------------------------------------
9
10// =======================================================================
11// M Fischler - Created 04 Feb 2000
12// M Fischler - put and get to/from streams 12/13/04
13// M Fischler - operator() modified to use localEngine 12/13/04
14// =======================================================================
15
16#include "CLHEP/Random/defs.h"
17#include "CLHEP/Random/RandGaussT.h"
18#include <iostream>
19
20namespace CLHEP {
21
22std::string RandGaussT::name() const {return "RandGaussT";}
24
26}
27
31}
32
33double RandGaussT::operator()( double mean, double stdDev ) {
34 return HepStat::flatToGaussian(localEngine->flat()) * stdDev + mean;
35}
36
37void RandGaussT::shootArray( const int size, double* vect,
38 double mean, double stdDev )
39{
40 for( double* v = vect; v != vect + size; ++v )
41 *v = shoot(mean,stdDev);
42}
43
45 const int size, double* vect,
46 double mean, double stdDev )
47{
48 for( double* v = vect; v != vect + size; ++v )
49 *v = shoot(anEngine,mean,stdDev);
50}
51
52void RandGaussT::fireArray( const int size, double* vect)
53{
54 for( double* v = vect; v != vect + size; ++v )
56}
57
58void RandGaussT::fireArray( const int size, double* vect,
59 double mean, double stdDev )
60{
61 for( double* v = vect; v != vect + size; ++v )
62 *v = fire( mean, stdDev );
63}
64
65std::ostream & RandGaussT::put ( std::ostream & os ) const {
66 long pr=os.precision(20);
67 os << " " << name() << "\n";
69 os.precision(pr);
70 return os;
71}
72
73std::istream & RandGaussT::get ( std::istream & is ) {
74 std::string inName;
75 is >> inName;
76 if (inName != name()) {
77 is.clear(std::ios::badbit | is.rdstate());
78 std::cerr << "Mismatch when expecting to read state of a "
79 << name() << " distribution\n"
80 << "Name found was " << inName
81 << "\nistream is left in the badbit state\n";
82 return is;
83 }
85 return is;
86}
87
88} // namespace CLHEP
89
static double flatToGaussian(double r)
virtual ~RandGaussT()
Definition: RandGaussT.cc:25
HepRandomEngine & engine()
Definition: RandGaussT.cc:23
static void shootArray(const int size, double *vect, double mean=0.0, double stdDev=1.0)
Definition: RandGaussT.cc:37
static double shoot()
std::ostream & put(std::ostream &os) const
Definition: RandGaussT.cc:65
void fireArray(const int size, double *vect)
Definition: RandGaussT.cc:52
std::istream & get(std::istream &is)
Definition: RandGaussT.cc:73
virtual double operator()()
Definition: RandGaussT.cc:28
std::string name() const
Definition: RandGaussT.cc:22
std::istream & get(std::istream &is)
Definition: RandGauss.cc:285
double defaultStdDev
Definition: RandGauss.h:154
std::ostream & put(std::ostream &os) const
Definition: RandGauss.cc:260
HepRandomEngine & engine()
Definition: RandGauss.cc:47
double defaultMean
Definition: RandGauss.h:153
std::shared_ptr< HepRandomEngine > localEngine
Definition: RandGauss.h:156