1#ifndef H_MARKOV_GENERATOR
2#define H_MARKOV_GENERATOR
71 JUniformGenerator(
double xmin,
double ymin,
double zmin,
double xmax,
double ymax,
double zmax ) :
posmin(xmin,ymin,zmin),
posmax(xmax,ymax,zmax) {
125 double rcube = gRandom->Uniform(0,
Rcube) ;
126 double r = pow(rcube,1.0/3.0) ;
128 gRandom->Sphere(x,y,z,r) ;
164 double xi = gRandom->Uniform() ;
165 double r = -
lambda*log(1-xi) ;
167 gRandom->Sphere(x,y,z,r) ;
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 ) {
207 h->Scale( 1.0/
h->Integral(
"width") ) ;
215 double r =
h->GetRandom() ;
217 gRandom->Sphere(x,y,z,r) ;
223 Int_t bin =
h->FindBin(r) ;
224 return h->GetBinContent(bin)/(r*r) ;
250 double r = gRandom->Uniform(0,
R) ;
252 gRandom->Sphere(x,y,z,r) ;
290 r1(_r1),
r2(_r2),
L(_L)
305 gRandom->Sphere(x,y,z,r) ;
317 return exp(-r/
L) /
C ;
324 return -4*M_PI*
L*exp(-r/
L)*(2*
L*
L+2*
L*r+r*r) ;
329 const double precision = 1e-10 ;
338 while( rr-rl > precision ) {
341 if( (vc>0) == (vr>0) ) {
379 double x = gRandom->Gaus(0,
sigma) ;
380 double y = gRandom->Gaus(0,
sigma) ;
381 double z = gRandom->Gaus(0,
sigma) ;
424 if( gRandom->Uniform()<
p1 ) {
434 return p1*w1 +
p2*w2 ;
532 hx = (TH1*) _hx->Clone( _hx->GetName() ) ;
533 hy = (TH1*) _hy->Clone( _hy->GetName() ) ;
534 hz = (TH1*) _hz->Clone( _hz->GetName() ) ;
536 hx->Scale( 1.0/
hx->Integral(
"width") ) ;
537 hy->Scale( 1.0/
hy->Integral(
"width") ) ;
538 hz->Scale( 1.0/
hz->Integral(
"width") ) ;
548 double x =
hx->GetRandom() ;
549 double y =
hy->GetRandom() ;
550 double z =
hz->GetRandom() ;
558 bin =
hx->GetXaxis()->FindBin( pos.
getX() ) ;
559 if( bin==0 || bin==
hx->GetNbinsX()+1 )
return 0.0 ;
560 w *=
hx->GetBinContent(bin) ;
562 bin =
hy->GetXaxis()->FindBin( pos.
getY() ) ;
563 if( bin==0 || bin==
hy->GetNbinsX()+1 )
return 0.0 ;
564 w *=
hy->GetBinContent(bin) ;
566 bin =
hz->GetXaxis()->FindBin( pos.
getZ() ) ;
567 if( bin==0 || bin==
hz->GetNbinsX()+1 )
return 0.0 ;
568 w *=
hz->GetBinContent(bin) ;
605 h = (TH2*) _h->Clone( _h->GetName() ) ;
607 if(
h->GetXaxis()->GetXmin()<-1 ||
h->GetXaxis()->GetXmax()>1 ) {
608 cerr <<
"FATAL ERROR in JSphereGenerator. Invalid x-axis range." << endl ;
611 if(
h->GetYaxis()->GetXmin() < -M_PI ||
h->GetYaxis()->GetXmax() > M_PI ) {
612 cerr <<
"FATAL ERROR in JSphereGenerator. Invalid y-axis range." << endl ;
616 h->Scale( 1.0/
h->Integral(
"width") ) ;
617 h->SetOption(
"colz") ;
630 if(
r==0 )
return x0 ;
632 double costheta, phi ;
633 h->GetRandom2(costheta,phi) ;
642 if(
r==0 )
return 1 ;
645 const double tolerance = 1e-5 ;
651 double ct = dir.
getDZ() ;
652 double phi = dir.
getPhi() ;
654 if( ct < h->GetXaxis()->GetXmin() || ct >=
h->GetXaxis()->GetXmax() )
return 0.0 ;
655 if( phi< h->GetYaxis()->GetXmin() || phi>=
h->GetYaxis()->GetXmax() )
return 0.0 ;
657 Int_t bin =
h->FindBin(ct,phi) ;
658 return h->GetBinContent(bin) / (
r*
r) ;
683 h = (TH3*) _h->Clone( _h->GetName() ) ;
685 h->Scale( 1.0/
h->Integral(
"width") ) ;
694 h->GetRandom3(x,y,z) ;
700 if( pos.
getX()<
h->GetXaxis()->GetXmin() || pos.
getX()>=
h->GetXaxis()->GetXmax() )
return 0.0 ;
701 if( pos.
getY()<
h->GetYaxis()->GetXmin() || pos.
getY()>=
h->GetYaxis()->GetXmax() )
return 0.0 ;
702 if( pos.
getZ()<
h->GetZaxis()->GetXmin() || pos.
getZ()>=
h->GetZaxis()->GetXmax() )
return 0.0 ;
704 Int_t bin =
h->FindBin( pos.
getX(), pos.
getY(), pos.
getZ() ) ;
705 return h->GetBinContent(bin) ;
TCanvas * c1
Global variables to handle mouse events.
Double_t g1(const Double_t x)
Function.
Data structure for angles in three dimensions.
Data structure for direction in three dimensions.
Data structure for position in three dimensions.
double getY() const
Get y position.
double getLength() const
Get length.
double getLengthSquared() const
Get length squared.
double getDistance(const JVector3D &pos) const
Get distance to point.
double getZ() const
Get z position.
double getX() const
Get x position.
double getPhi() const
Get phi angle.
double getDZ() const
Get z direction.
Implementation of the JGenerator interface.
JPosition3D getPosition()
Return a randomly generated position.
J3DhistGenerator(TH3 *_h)
Constructor.
double getWeight(JPosition3D pos)
return the weight (=probability density dP/dV) for the given position.
Implementation of the JGenerator interface.
double getWeight(JPosition3D pos)
return the weight (=probability density dP/dV) for the given position.
JBallGenerator(double _R)
Constructor.
JPosition3D getPosition()
Return a randomly generated position.
Implementation of the JGenerator interface.
JPosition3D getPosition()
Return a randomly generated position.
JCombinedGenerator(double _c1, JGenerator *_g1, double _c2, JGenerator *_g2)
Constructor.
double getWeight(JPosition3D pos)
return the weight (=probability density dP/dV) for the given position.
Implementation of the JGenerator interface.
JPosition3D getPosition()
Return a randomly generated position.
double getWeight(JPosition3D pos)
return the weight (=probability density dP/dV) for the given position.
JExpRsqInvGenerator(double _lambda)
Constructor.
Implementation of the JGenerator interface.
double getWeight(JPosition3D pos)
return the weight (=probability density dP/dV) for the given position.
double getWeight(double r)
JExponentialGenerator(double _r1, double _r2, double _L)
Constructor.
double getIntegrand(double r)
JPosition3D getPosition()
Return a randomly generated position.
double getInvertedIntegrand(double x)
return value y such that getIntegrand(y) = x
Implementation of the JGenerator interface.
double getWeight(JPosition3D pos)
return the weight (=probability density dP/dV) for the given position.
JGaussianGenerator(double _sigma)
Constructor.
JPosition3D getPosition()
Return a randomly generated position.
Abstract interface for the generation of points in 3D space.
virtual JPosition3D getPosition()=0
Return a randomly generated position.
virtual double getWeight(JPosition3D pos)=0
return the weight (=probability density dP/dV) for the given position.
Implementation of the JGenerator interface.
double getWeight(JPosition3D pos)
return the weight (=probability density dP/dV) for the given position.
JHistGenerator(TH1 *_hx, TH1 *_hy, TH1 *_hz)
Constructor.
JPosition3D getPosition()
Return a randomly generated position.
The 'magical distributions' are a class of distributions.
JMagicalDistribution(unsigned int _N, double _lambda)
double getWeight(JPosition3D pos)
return the weight (=probability density dP/dV) for the given position.
JPosition3D getPosition()
Return a randomly generated position.
Implementation of the JGenerator interface.
JShiftedGenerator(JGenerator *_g, JPosition3D _shift)
Constructor.
JPosition3D getPosition()
Return a randomly generated position.
double getWeight(JPosition3D pos)
return the weight (=probability density dP/dV) for the given position.
Implementation of the JGenerator interface.
JPosition3D getPosition()
Return a randomly generated position.
double getWeight(JPosition3D pos)
return the weight (=probability density dP/dV) for the given position.
JSingularityGenerator(double _R, JPosition3D _x0)
Constructor.
Implementation of the JGenerator interface.
JPosition3D getPosition()
Return a randomly generated position.
JSphereGenerator(const JPosition3D &_x0, double _r=0, TH2 *_h=NULL)
Constructor.
double getWeight(JPosition3D pos)
return the weight (=probability density dP/dV) for the given position.
Implementation of the JGenerator interface.
JTripleGenerator(double c1, JGenerator *g1, double c2, JGenerator *g2, double c3, JGenerator *g3)
Constructor.
JPosition3D getPosition()
Return a randomly generated position.
double getWeight(JPosition3D pos)
return the weight (=probability density dP/dV) for the given position.
Auxiliary classes and methods for 3D geometrical objects and operations.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).