Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
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.
 
double getWeight (JPosition3D pos)
 return the weight (=probability density dP/dV) for the given position.
 
JPosition3D getPosition ()
 Return a randomly generated position.
 
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
 

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 280 of file JMarkovGenerator.hh.

Constructor & Destructor Documentation

◆ JExponentialGenerator()

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 289 of file JMarkovGenerator.hh.

Member Function Documentation

◆ getWeight() [1/2]

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 298 of file JMarkovGenerator.hh.

298 {
299 return getWeight( pos.getLength() ) ;
300 }
double getWeight(JPosition3D pos)
return the weight (=probability density dP/dV) for the given position.

◆ getPosition()

JPosition3D JMARKOV::JExponentialGenerator::getPosition ( )
inlinevirtual

Return a randomly generated position.

Implements JMARKOV::JGenerator.

Definition at line 302 of file JMarkovGenerator.hh.

302 {
303 double x, y, z ;
304 double r = getR() ;
305 gRandom->Sphere(x,y,z,r) ;
306 return JPosition3D(x,y,z) ;
307 }

◆ getR()

double JMARKOV::JExponentialGenerator::getR ( )
inline

Definition at line 309 of file JMarkovGenerator.hh.

309 {
310 // generate integrand value
311 double xi = gRandom->Uniform(ximin,ximax) ;
312 // find matching value of r
313 return getInvertedIntegrand(xi) ;
314 }
double getInvertedIntegrand(double x)
return value y such that getIntegrand(y) = x

◆ getWeight() [2/2]

double JMARKOV::JExponentialGenerator::getWeight ( double r)
inline

Definition at line 316 of file JMarkovGenerator.hh.

316 {
317 return exp(-r/L) / C ;
318 }

◆ getIntegrand()

double JMARKOV::JExponentialGenerator::getIntegrand ( double r)
inlineprotected

Definition at line 323 of file JMarkovGenerator.hh.

323 {
324 return -4*M_PI*L*exp(-r/L)*(2*L*L+2*L*r+r*r) ;
325 }

◆ getInvertedIntegrand()

double JMARKOV::JExponentialGenerator::getInvertedIntegrand ( double x)
inlineprotected

return value y such that getIntegrand(y) = x

Definition at line 328 of file JMarkovGenerator.hh.

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

Member Data Documentation

◆ r1

double JMARKOV::JExponentialGenerator::r1
protected

Definition at line 354 of file JMarkovGenerator.hh.

◆ r2

double JMARKOV::JExponentialGenerator::r2
protected

Definition at line 355 of file JMarkovGenerator.hh.

◆ L

double JMARKOV::JExponentialGenerator::L
protected

Definition at line 356 of file JMarkovGenerator.hh.

◆ C

double JMARKOV::JExponentialGenerator::C
protected

Definition at line 357 of file JMarkovGenerator.hh.

◆ ximin

double JMARKOV::JExponentialGenerator::ximin
protected

Definition at line 358 of file JMarkovGenerator.hh.

◆ ximax

double JMARKOV::JExponentialGenerator::ximax
protected

Definition at line 359 of file JMarkovGenerator.hh.


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