CLHEP VERSION Reference Documentation
   
CLHEP Home Page     CLHEP Documentation     CLHEP Bug Reports

RandPoissonT.cc
Go to the documentation of this file.
1 // $Id: RandPoissonT.cc,v 1.7 2010/06/16 17:24:53 garren Exp $
2 // -*- C++ -*-
3 //
4 // -----------------------------------------------------------------------
5 // HEP Random
6 // --- RandPoissonT ---
7 // class implementation file
8 // -----------------------------------------------------------------------
9 
10 // =======================================================================
11 // M. Fischler - Implemented new, much faster table-driven algorithm
12 // applicable for mu < 100 (Nov 1999), using these as
13 // implementation of RandPoisson.
14 // M. Fischler - Moved the table driven algorithms into RandPoissonT (here)
15 // 1/26/00.
16 // M. Fischler - Removed mean=100 from the table-driven set, since it
17 // uses a value just off the end of the table. (April 2004)
18 // M Fischler - put and get to/from streams 12/15/04
19 // M Fischler - fireArray using defaultMean 2/10/05
20 // M Fischler - put/get to/from streams uses pairs of ulongs when
21 // + storing doubles avoid problems with precision
22 // -- appears not to need modification, relying on
23 // RandPoisson::put() instead 4/14/05
24 //
25 // =======================================================================
26 
27 #include "CLHEP/Random/defs.h"
28 #include "CLHEP/Random/RandPoissonT.h"
29 #include "CLHEP/Random/RandPoissonQ.h"
30 #include "CLHEP/Random/DoubConv.hh"
31 
32 //
33 // Constructors and destructors:
34 //
35 
36 namespace CLHEP {
37 
38 std::string RandPoissonT::name() const {return "RandPoissonT";}
40 
42 : RandPoisson(anEngine, m)
43 {}
44 
46 : RandPoisson(anEngine, m)
47 {}
48 
50 }
51 
52 //
53 // fire, operator(), and shoot methods:
54 //
55 
56 long RandPoissonT::shoot(double xm) {
58  return shoot ( e, xm );
59 } // shoot()
60 
62  return double( fire() );
63 }
64 
65 double RandPoissonT::operator()( double mean ) {
66  return double( fire( mean ) );
67 }
68 
69 long RandPoissonT::fire(double mean) {
70  return shoot (getLocalEngine(), mean);
71 }
72 
74 
77  } else {
79  }
80 
81 } // fire()
82 
83 long RandPoissonT::shoot(HepRandomEngine* anEngine, double mean) {
84 
85  if ( mean < RandPoissonQ::tableBoundary() ) {
86  return RandPoissonQ::shoot ( anEngine, mean );
87  } else {
88  return RandPoisson::shoot( anEngine, mean );
89  }
90 
91 } // shoot (anEngine, mean)
92 
93 void RandPoissonT::shootArray(const int size, long* vect, double m) {
94  int i;
95  for (i=0; i<size; ++i)
96  vect[i] = shoot(m);
97 }
98 
99 void RandPoissonT::fireArray(const int size, long* vect, double m) {
100  int i;
101  for (i=0; i<size; ++i) {
102  vect[i] = fire( m );
103  }
104 }
105 
106 void RandPoissonT::fireArray(const int size, long* vect) {
107  int i;
108  for (i=0; i<size; ++i) {
109  vect[i] = fire( defaultMean );
110  }
111 }
112 
113 
114 std::ostream & RandPoissonT::put ( std::ostream & os ) const {
115  int pr=os.precision(20);
116  os << " " << name() << "\n";
117  RandPoisson::put(os);
118  os.precision(pr);
119  return os;
120 }
121 
122 std::istream & RandPoissonT::get ( std::istream & is ) {
123  std::string inName;
124  is >> inName;
125  if (inName != name()) {
126  is.clear(std::ios::badbit | is.rdstate());
127  std::cerr << "Mismatch when expecting to read state of a "
128  << name() << " distribution\n"
129  << "Name found was " << inName
130  << "\nistream is left in the badbit state\n";
131  return is;
132  }
134  return is;
135 }
136 
137 
138 } // namespace CLHEP
CLHEP::RandPoissonT::~RandPoissonT
virtual ~RandPoissonT()
Definition: RandPoissonT.cc:49
CLHEP::RandPoissonT::shootArray
static void shootArray(const int size, long *vect, double m=1.0)
Definition: RandPoissonT.cc:93
double
#define double(obj)
Definition: excDblThrow.cc:32
CLHEP::RandPoisson::get
std::istream & get(std::istream &is)
Definition: RandPoisson.cc:311
CLHEP::HepRandomEngine
Definition: Matrix/CLHEP/Random/RandomEngine.h:55
CLHEP::RandPoisson::put
std::ostream & put(std::ostream &os) const
Definition: RandPoisson.cc:282
CLHEP::RandPoissonT::name
std::string name() const
Definition: RandPoissonT.cc:38
CLHEP::RandPoissonT::operator()
double operator()()
Definition: RandPoissonT.cc:61
CLHEP::RandPoisson::engine
HepRandomEngine & engine()
Definition: RandPoisson.cc:37
is
HepRotation and so forth isNear() norm2() rectify() static Rotation row1 row4(To avoid bloat in the code pulled in for programs which don 't use all these features, we split the implementation .cc files. Only isNear() goes into the original Rotation.cc) --------------------------------------- HepAxisAngle and HepEulerAngles classes --------------------------------------- These classes are very useful and simple structures for holding the result of a nice intuituve decomposition of a rotation there is no longer much content in the distinct ZOOM PhysicsVectors library The only content left in the library is the object files representing the various Exception objects When we build the CLHEP classes for the ZOOM we will set up so as to use ZOOM SpaceVector is(but we can disable namespace usage and most of our users do so at this point). What I do is leave Hep3Vector in the global namespace
CLHEP::RandPoissonQ::shoot
static long shoot(double m=1.0)
Definition: RandPoissonQ.cc:118
size
user code seldom needs to call this function directly ZMerrno whether or not they are still recorded ZMerrno size() Return the(integer) number of ZMthrow 'n exceptions currently recorded. 5) ZMerrno.clear() Set an internal counter to zero. This counter is available(see next function) to user code to track ZMthrow 'n exceptions that have occurred during any arbitrary time interval. 6) ZMerrno.countSinceCleared() Return the(integer) number of ZMthrow 'n exceptions that have been recorded via ZMerrno.write()
CLHEP
Definition: ClhepVersion.h:13
CLHEP::RandPoissonT::RandPoissonT
RandPoissonT(HepRandomEngine &anEngine, double m=1.0)
Definition: RandPoissonT.cc:41
CLHEP::RandPoissonT::shoot
static long shoot(double m=1.0)
Definition: RandPoissonT.cc:56
CLHEP::RandPoissonT::engine
HepRandomEngine & engine()
Definition: RandPoissonT.cc:39
CLHEP::RandPoisson::defaultMean
double defaultMean
Definition: Matrix/CLHEP/Random/RandPoisson.h:100
CLHEP::RandPoissonQ::tableBoundary
static int tableBoundary()
CLHEP::RandPoisson::getLocalEngine
HepRandomEngine * getLocalEngine()
i
long i
Definition: JamesRandomSeeding.txt:27
CLHEP::RandPoissonT::fire
long fire()
Definition: RandPoissonT.cc:73
CLHEP::RandPoissonT::fireArray
void fireArray(const int size, long *vect)
Definition: RandPoissonT.cc:106
CLHEP::HepRandom::getTheEngine
static HepRandomEngine * getTheEngine()
Definition: Random.cc:166
CLHEP::RandPoissonT::get
std::istream & get(std::istream &is)
Definition: RandPoissonT.cc:122
CLHEP::RandPoisson
Definition: Matrix/CLHEP/Random/RandPoisson.h:42
CLHEP::RandPoisson::shoot
static long shoot(double m=1.0)
Definition: RandPoisson.cc:92
CLHEP::RandPoissonT::put
std::ostream & put(std::ostream &os) const
Definition: RandPoissonT.cc:114