Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
JMARKOV::JMagicalDistribution Class Reference

The 'magical distributions' are a class of distributions. More...

#include <JMarkovGenerator.hh>

Inheritance diagram for JMARKOV::JMagicalDistribution:
JMARKOV::JGenerator

Public Member Functions

 JMagicalDistribution (unsigned int _N, double _lambda)
 
 ~JMagicalDistribution ()
 
JPosition3D getPosition ()
 Return a randomly generated position.
 
double getWeight (JPosition3D pos)
 return the weight (=probability density dP/dV) for the given position.
 

Protected Attributes

unsigned int N
 
double lambda
 
JExpRsqInvGenerator gen
 
TH1F * h
 

Detailed Description

The 'magical distributions' are a class of distributions.

The magical distribution of degree N is the distribution of the distance to the origin after taking N random steps where the step size r is drawn from an "exponential inverse r-squared" 1/r^2 exp(-r/lambda) distribution, which is the base behaviour for scattering

Note that it seems to satisfy the property (for lambda = 1 ) mean = -0.5 + sqrt( (1+8*n)/4 )

Definition at line 192 of file JMarkovGenerator.hh.

Constructor & Destructor Documentation

◆ JMagicalDistribution()

JMARKOV::JMagicalDistribution::JMagicalDistribution ( unsigned int _N,
double _lambda )
inline

Definition at line 196 of file JMarkovGenerator.hh.

196 : N(_N), lambda(_lambda), gen(1) {
197 const int nbins = 1000 ;
198 const double xmax = 100 ;
199 const int nsamples = 10000000 ;
200 h = new TH1F("h","",nbins,0,xmax) ;
201 for( int i=0 ; i<nsamples ; ++i ) {
202 JPosition3D pos = gen.getPosition() ;
203 for( unsigned int n=1 ; n<N ; ++n ) pos += gen.getPosition() ;
204 double r = pos.getLength() ;
205 h->Fill(r) ;
206 }
207 h->Scale( 1.0/h->Integral("width") ) ;
208 }
double getLength() const
Get length.
Definition JVector3D.hh:246
JPosition3D getPosition()
Return a randomly generated position.
const double xmax
const int n
Definition JPolint.hh:791

◆ ~JMagicalDistribution()

JMARKOV::JMagicalDistribution::~JMagicalDistribution ( )
inline

Definition at line 210 of file JMarkovGenerator.hh.

210 {
211 delete h ;
212 }

Member Function Documentation

◆ getPosition()

JPosition3D JMARKOV::JMagicalDistribution::getPosition ( )
inlinevirtual

Return a randomly generated position.

Implements JMARKOV::JGenerator.

Definition at line 214 of file JMarkovGenerator.hh.

214 {
215 double r = h->GetRandom() ;
216 double x,y,z ;
217 gRandom->Sphere(x,y,z,r) ;
218 return JPosition3D(x,y,z) ;
219 }

◆ getWeight()

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

221 {
222 double r = pos.getLength() ;
223 Int_t bin = h->FindBin(r) ;
224 return h->GetBinContent(bin)/(r*r) ;
225 }

Member Data Documentation

◆ N

unsigned int JMARKOV::JMagicalDistribution::N
protected

Definition at line 229 of file JMarkovGenerator.hh.

◆ lambda

double JMARKOV::JMagicalDistribution::lambda
protected

Definition at line 230 of file JMarkovGenerator.hh.

◆ gen

JExpRsqInvGenerator JMARKOV::JMagicalDistribution::gen
protected

Definition at line 231 of file JMarkovGenerator.hh.

◆ h

TH1F* JMARKOV::JMagicalDistribution::h
protected

Definition at line 232 of file JMarkovGenerator.hh.


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