Jpp  master_rocky-43-ge265d140c
the software that should make you happy
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
JMARKOV::JBallGenerator Class Reference

Implementation of the JGenerator interface. More...

#include <JMarkovGenerator.hh>

Inheritance diagram for JMARKOV::JBallGenerator:
JMARKOV::JGenerator

Public Member Functions

 JBallGenerator (double _R)
 Constructor. More...
 
JPosition3D getPosition ()
 Return a randomly generated position. More...
 
double getWeight (JPosition3D pos)
 return the weight (=probability density dP/dV) for the given position. More...
 

Protected Member Functions

void setVolume ()
 

Protected Attributes

const double R
 
const double Rcube
 
double V
 

Detailed Description

Implementation of the JGenerator interface.

Generates positions uniformly within a ball of a given radius centered around the origin.

Definition at line 114 of file JMarkovGenerator.hh.

Constructor & Destructor Documentation

◆ JBallGenerator()

JMARKOV::JBallGenerator::JBallGenerator ( double  _R)
inline

Constructor.

The argument is the radius of the ball.

Definition at line 120 of file JMarkovGenerator.hh.

120  : R(_R), Rcube(_R*_R*_R) {
121  setVolume() ;
122  }

Member Function Documentation

◆ getPosition()

JPosition3D JMARKOV::JBallGenerator::getPosition ( )
inlinevirtual

Return a randomly generated position.

Implements JMARKOV::JGenerator.

Definition at line 124 of file JMarkovGenerator.hh.

124  {
125  double rcube = gRandom->Uniform(0,Rcube) ;
126  double r = pow(rcube,1.0/3.0) ;
127  double x,y,z ;
128  gRandom->Sphere(x,y,z,r) ;
129  return JPosition3D(x,y,z) ;
130  }
Data structure for position in three dimensions.
Definition: JPosition3D.hh:38
T pow(const T &x, const double y)
Power .
Definition: JMath.hh:97
data_type r[M+1]
Definition: JPolint.hh:868

◆ getWeight()

double JMARKOV::JBallGenerator::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 132 of file JMarkovGenerator.hh.

132  {
133  if( pos.getLength()>R ) return 0.0 ;
134  return 1.0/V ;
135  }
double getLength() const
Get length.
Definition: JVector3D.hh:246

◆ setVolume()

void JMARKOV::JBallGenerator::setVolume ( )
inlineprotected

Definition at line 139 of file JMarkovGenerator.hh.

139 { V = 4.0/3.0*M_PI*Rcube ; }

Member Data Documentation

◆ R

const double JMARKOV::JBallGenerator::R
protected

Definition at line 141 of file JMarkovGenerator.hh.

◆ Rcube

const double JMARKOV::JBallGenerator::Rcube
protected

Definition at line 142 of file JMarkovGenerator.hh.

◆ V

double JMARKOV::JBallGenerator::V
protected

Definition at line 143 of file JMarkovGenerator.hh.


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