Jpp  15.0.3
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
JMARKOV::JExponentialGenerator Class Reference

Implementation of the JGenerator interface. More...

#include <JMarkovGenerator.hh>

Inheritance diagram for JMARKOV::JExponentialGenerator:
JMARKOV::JGenerator

Public Member Functions

 JExponentialGenerator (double _r1, double _r2, double _L)
 Constructor. More...
 
double getWeight (JPosition3D pos)
 return the weight (=probability density dP/dV) for the given position. More...
 
JPosition3D getPosition ()
 Return a randomly generated position. More...
 
double getR ()
 
double getWeight (double r)
 

Protected Member Functions

double getIntegrand (double r)
 
double getInvertedIntegrand (double x)
 return value y such that getIntegrand(y) = x More...
 

Protected Attributes

double r1
 
double r2
 
double L
 
double C
 
double ximin
 
double ximax
 

Detailed Description

Implementation of the JGenerator interface.

Generates positions according to an exponential distribution, around the origin, i.e. with probability density

rho( vec x ) = alpha * exp(-r/l)

for given l. The minimal and maximal values of r are given by r1 and r2, respectively.

Definition at line 276 of file JMarkovGenerator.hh.

Constructor & Destructor Documentation

JMARKOV::JExponentialGenerator::JExponentialGenerator ( double  _r1,
double  _r2,
double  _L 
)
inline

Constructor.

_r1 and _r2 are the minimal and maximal allowed value of r. _L is the length scale.

Definition at line 285 of file JMarkovGenerator.hh.

Member Function Documentation

double JMARKOV::JExponentialGenerator::getWeight ( JPosition3D  pos)
inlinevirtual

return the weight (=probability density dP/dV) for the given position.

When the generator is properly normalized, the integral of this quantity over the whole space is 1.

Implements JMARKOV::JGenerator.

Definition at line 294 of file JMarkovGenerator.hh.

294  {
295  return getWeight( pos.getLength() ) ;
296  }
double getWeight(JPosition3D pos)
return the weight (=probability density dP/dV) for the given position.
double getLength() const
Get length.
Definition: JVector3D.hh:246
JPosition3D JMARKOV::JExponentialGenerator::getPosition ( )
inlinevirtual

Return a randomly generated position.

Implements JMARKOV::JGenerator.

Definition at line 298 of file JMarkovGenerator.hh.

298  {
299  double x, y, z ;
300  double r = getR() ;
301  gRandom->Sphere(x,y,z,r) ;
302  return JPosition3D(x,y,z) ;
303  }
data_type r[M+1]
Definition: JPolint.hh:742
Data structure for position in three dimensions.
Definition: JPosition3D.hh:36
double JMARKOV::JExponentialGenerator::getR ( )
inline

Definition at line 305 of file JMarkovGenerator.hh.

305  {
306  // generate integrand value
307  double xi = gRandom->Uniform(ximin,ximax) ;
308  // find matching value of r
309  return getInvertedIntegrand(xi) ;
310  }
double getInvertedIntegrand(double x)
return value y such that getIntegrand(y) = x
double JMARKOV::JExponentialGenerator::getWeight ( double  r)
inline

Definition at line 312 of file JMarkovGenerator.hh.

312  {
313  return exp(-r/L) / C ;
314  }
data_type r[M+1]
Definition: JPolint.hh:742
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable STRING $argv[2] set_array QUANTILES set_variable FORMULA *[0] exp(-0.5 *(x-[1])*(x-[1])/([2]*[2]))" set_variable MODULE `getModule -a $DETECTOR -L "$STRING 0"` source JAcoustics.sh -- typeset -A TRIPODS get_tripods $WORKDIR/tripod.txt TRIPODS XMEAN
double JMARKOV::JExponentialGenerator::getIntegrand ( double  r)
inlineprotected

Definition at line 319 of file JMarkovGenerator.hh.

319  {
320  return -4*M_PI*L*exp(-r/L)*(2*L*L+2*L*r+r*r) ;
321  }
data_type r[M+1]
Definition: JPolint.hh:742
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable STRING $argv[2] set_array QUANTILES set_variable FORMULA *[0] exp(-0.5 *(x-[1])*(x-[1])/([2]*[2]))" set_variable MODULE `getModule -a $DETECTOR -L "$STRING 0"` source JAcoustics.sh -- typeset -A TRIPODS get_tripods $WORKDIR/tripod.txt TRIPODS XMEAN
double JMARKOV::JExponentialGenerator::getInvertedIntegrand ( double  x)
inlineprotected

return value y such that getIntegrand(y) = x

Definition at line 324 of file JMarkovGenerator.hh.

324  {
325  const double precision = 1e-10 ;
326  // using the bisection algorithm
327  double rl = r1 ;
328  double vl = getIntegrand(rl)-x ;
329  double rr = r2 ;
330  double vr = getIntegrand(rr)-x ;
331  double rc ;
332  double vc ;
333 
334  while( rr-rl > precision ) {
335  rc = 0.5*(rl+rr) ;
336  vc = getIntegrand(rc)-x ;
337  if( (vc>0) == (vr>0) ) {
338  // must be in left half
339  rr = rc ;
340  vr = vc ;
341  } else {
342  // must be in right half
343  rl = rc ;
344  vl = vc ;
345  }
346  }
347  return rc ;
348  }

Member Data Documentation

double JMARKOV::JExponentialGenerator::r1
protected

Definition at line 350 of file JMarkovGenerator.hh.

double JMARKOV::JExponentialGenerator::r2
protected

Definition at line 351 of file JMarkovGenerator.hh.

double JMARKOV::JExponentialGenerator::L
protected

Definition at line 352 of file JMarkovGenerator.hh.

double JMARKOV::JExponentialGenerator::C
protected

Definition at line 353 of file JMarkovGenerator.hh.

double JMARKOV::JExponentialGenerator::ximin
protected

Definition at line 354 of file JMarkovGenerator.hh.

double JMARKOV::JExponentialGenerator::ximax
protected

Definition at line 355 of file JMarkovGenerator.hh.


The documentation for this class was generated from the following file: