Jpp
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 110 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 116 of file JMarkovGenerator.hh.

116  : R(_R), Rcube(_R*_R*_R) {
117  setVolume() ;
118  }

Member Function Documentation

◆ getPosition()

JPosition3D JMARKOV::JBallGenerator::getPosition ( )
inlinevirtual

Return a randomly generated position.

Implements JMARKOV::JGenerator.

Definition at line 120 of file JMarkovGenerator.hh.

120  {
121  double rcube = gRandom->Uniform(0,Rcube) ;
122  double r = pow(rcube,1.0/3.0) ;
123  double x,y,z ;
124  gRandom->Sphere(x,y,z,r) ;
125  return JPosition3D(x,y,z) ;
126  }

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

128  {
129  if( pos.getLength()>R ) return 0.0 ;
130  return 1.0/V ;
131  }

◆ setVolume()

void JMARKOV::JBallGenerator::setVolume ( )
inlineprotected

Definition at line 135 of file JMarkovGenerator.hh.

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

Member Data Documentation

◆ R

const double JMARKOV::JBallGenerator::R
protected

Definition at line 137 of file JMarkovGenerator.hh.

◆ Rcube

const double JMARKOV::JBallGenerator::Rcube
protected

Definition at line 138 of file JMarkovGenerator.hh.

◆ V

double JMARKOV::JBallGenerator::V
protected

Definition at line 139 of file JMarkovGenerator.hh.


The documentation for this class was generated from the following file:
JMARKOV::JBallGenerator::Rcube
const double Rcube
Definition: JMarkovGenerator.hh:138
JMARKOV::JBallGenerator::V
double V
Definition: JMarkovGenerator.hh:139
JGEOMETRY3D::JPosition3D
Data structure for position in three dimensions.
Definition: JPosition3D.hh:35
JMARKOV::JBallGenerator::setVolume
void setVolume()
Definition: JMarkovGenerator.hh:135
JTOOLS::r
data_type r[M+1]
Definition: JPolint.hh:709
JGEOMETRY3D::JVector3D::getLength
double getLength() const
Get length.
Definition: JVector3D.hh:244
JMARKOV::JBallGenerator::R
const double R
Definition: JMarkovGenerator.hh:137