22#include "CLHEP/Random/defs.h"
23#include "CLHEP/Random/RandBreitWigner.h"
24#include "CLHEP/Units/PhysicalConstants.h"
25#include "CLHEP/Random/DoubConv.h"
41 return fire( defaultA, defaultB );
49 return fire( a, b, c );
57 displ = 0.5*gamma*std::tan(rval*CLHEP::halfpi);
64 double val, rval, displ;
66 if ( gamma == 0.0 )
return mean;
67 val = std::atan(2.0*cut/gamma);
69 displ = 0.5*gamma*std::tan(rval*val);
76 double val, rval, displ;
78 if ( gamma == 0.0 )
return mean;
79 val = std::atan(-mean/gamma);
81 displ = gamma*std::tan(rval);
83 return std::sqrt(mean*mean + mean*displ);
89 double lower, upper, tmp;
91 if ( gamma == 0.0 )
return mean;
92 tmp = std::max(0.0,(mean-cut));
93 lower = std::atan( (tmp*tmp-mean*mean)/(mean*gamma) );
94 upper = std::atan( ((mean+cut)*(mean+cut)-mean*mean)/(mean*gamma) );
96 displ = gamma*std::tan(rval);
98 return std::sqrt(std::max(0.0, mean*mean + mean*displ));
103 for(
double* v = vect; v != vect + size; ++v )
104 *v =
shoot( 1.0, 0.2 );
110 for(
double* v = vect; v != vect + size; ++v )
118 for(
double* v = vect; v != vect + size; ++v )
119 *v =
shoot( a, b, c );
125 double mean,
double gamma)
129 rval = 2.0*anEngine->
flat()-1.0;
130 displ = 0.5*gamma*std::tan(rval*CLHEP::halfpi);
136 double mean,
double gamma,
double cut )
138 double val, rval, displ;
140 if ( gamma == 0.0 )
return mean;
141 val = std::atan(2.0*cut/gamma);
142 rval = 2.0*anEngine->
flat()-1.0;
143 displ = 0.5*gamma*std::tan(rval*val);
149 double mean,
double gamma )
151 double val, rval, displ;
153 if ( gamma == 0.0 )
return mean;
154 val = std::atan(-mean/gamma);
156 displ = gamma*std::tan(rval);
158 return std::sqrt(mean*mean + mean*displ);
162 double mean,
double gamma,
double cut )
165 double lower, upper, tmp;
167 if ( gamma == 0.0 )
return mean;
168 tmp = std::max(0.0,(mean-cut));
169 lower = std::atan( (tmp*tmp-mean*mean)/(mean*gamma) );
170 upper = std::atan( ((mean+cut)*(mean+cut)-mean*mean)/(mean*gamma) );
172 displ = gamma*std::tan(rval);
174 return std::sqrt( std::max(0.0, mean*mean+mean*displ) );
178 const int size,
double* vect )
180 for(
double* v = vect; v != vect + size; ++v )
181 *v =
shoot( anEngine, 1.0, 0.2 );
185 const int size,
double* vect,
188 for(
double* v = vect; v != vect + size; ++v )
189 *v =
shoot( anEngine, a, b );
193 const int size,
double* vect,
194 double a,
double b,
double c )
196 for(
double* v = vect; v != vect + size; ++v )
197 *v =
shoot( anEngine, a, b, c );
204 return fire( defaultA, defaultB );
211 rval = 2.0*localEngine->flat()-1.0;
212 displ = 0.5*gamma*std::tan(rval*CLHEP::halfpi);
219 double val, rval, displ;
221 if ( gamma == 0.0 )
return mean;
222 val = std::atan(2.0*cut/gamma);
223 rval = 2.0*localEngine->flat()-1.0;
224 displ = 0.5*gamma*std::tan(rval*val);
231 return fireM2( defaultA, defaultB );
236 double val, rval, displ;
238 if ( gamma == 0.0 )
return mean;
239 val = std::atan(-mean/gamma);
241 displ = gamma*std::tan(rval);
243 return std::sqrt(mean*mean + mean*displ);
249 double lower, upper, tmp;
251 if ( gamma == 0.0 )
return mean;
252 tmp = std::max(0.0,(mean-cut));
253 lower = std::atan( (tmp*tmp-mean*mean)/(mean*gamma) );
254 upper = std::atan( ((mean+cut)*(mean+cut)-mean*mean)/(mean*gamma) );
256 displ = gamma*std::tan(rval);
258 return std::sqrt(std::max(0.0, mean*mean + mean*displ));
263 for(
double* v = vect; v != vect + size; ++v )
264 *v =
fire(defaultA, defaultB );
270 for(
double* v = vect; v != vect + size; ++v )
275 double a,
double b,
double c )
277 for(
double* v = vect; v != vect + size; ++v )
278 *v =
fire( a, b, c );
283 long pr=os.precision(20);
284 std::vector<unsigned long> t(2);
285 os <<
" " <<
name() <<
"\n";
286 os <<
"Uvec" <<
"\n";
288 os << defaultA <<
" " << t[0] <<
" " << t[1] <<
"\n";
290 os << defaultB <<
" " << t[0] <<
" " << t[1] <<
"\n";
294 long pr=os.precision(20);
295 os <<
" " <<
name() <<
"\n";
296 os << defaultA <<
" " << defaultB <<
"\n";
305 if (inName !=
name()) {
306 is.clear(std::ios::badbit | is.rdstate());
307 std::cerr <<
"Mismatch when expecting to read state of a "
308 <<
name() <<
" distribution\n"
309 <<
"Name found was " << inName
310 <<
"\nistream is left in the badbit state\n";
314 std::vector<unsigned long> t(2);
static double longs2double(const std::vector< unsigned long > &v)
static std::vector< unsigned long > dto2longs(double d)
static HepRandomEngine * getTheEngine()
HepRandomEngine & engine()
static double shootM2(double a=1.0, double b=0.2)
static void shootArray(const int size, double *vect)
std::istream & get(std::istream &is)
virtual ~RandBreitWigner()
static double shoot(double a=1.0, double b=0.2)
std::ostream & put(std::ostream &os) const
void fireArray(const int size, double *vect)
bool possibleKeywordInput(IS &is, const std::string &key, T &t)