23 namespace JPP {
using namespace JMARKOV; }
157 return r + 2.0 / (3.0*sqrt(3.0))*
getR0() ;
162 if( sqrt(3.0)*rprime <
getR0() )
return rprime*rprime*rprime/(
getR0()*
getR0()) ;
163 return rprime - 2.0/(3.0*sqrt(3.0))*
getR0() ;
173 return xprev + (rprime/
r)*(x-xprev) ;
183 return xprev + (r/rprime)*(xprime-xprev) ;
189 for(
int i=1;
i<(int)pprime.size()-1; ++
i ) {
198 for(
int i=1;
i<(int)p.size()-1; ++
i ) {
227 if( sqrt(3.0)*rprime >=
getR0() ) {
230 return r*r/(rprime*rprime) ;
247 for(
int i=1;
i<(int)p.size()-1; ++
i ) {
270 int nv = gRandom->Integer(nscat)+1 ;
273 double r = p[nv-1].getDistance(p[nv]) ;
275 if( gRandom->Uniform() > 0.5 ) {
289 gRandom->Sphere( _x, _y, _z, _r ) ;
291 double dr = _rnew -
r ;
302 double theta = gRandom->Exp(_stepsize_angle) ;
303 double phi = gRandom->Uniform(2.0*M_PI) ;
307 dir = dir.rotate_back(rot) ;
316 while( ct<=-1 ) ct = 1-gRandom->Exp(dct) ;
317 double theta = acos(ct) ;
318 double phi = gRandom->Uniform(2*M_PI) ;
322 new_dir = new_dir.rotate_back(R) ;
335 double dist = testpath[0].getDistanceSquared(src->
getPosition()) ;
337 cerr <<
"ERROR in generateEnsemble: testpath position " << testpath[0]
338 <<
"does not match source position " << src->
getPosition() <<
"!" << endl ;
344 cerr <<
"ERROR in generateEnsemble: testpath probability density = 0" << endl ;
354 while( i!=nsteps_burn_in ) {
368 while( j!=nsteps_save ) {
377 result.push_back( testpath ) ;
387 if( nscat == 0 && !trg->
getRadius()>0 ) {
405 if( rhoBefore == 0 ) {
406 cerr <<
"FATAL ERROR: starting probability density = 0" << endl ;
426 if( rhoAfter > rhoBefore ) {
434 double P = rhoAfter/rhoBefore ;
435 if( gRandom->Uniform()<
P ) {
Data structure for angles in three dimensions.
JPhotonPath getRemappedPhotonPath(const JPhotonPath &p)
returns a remapped version of the photon path
The JMarkovPathGenerator generates ensembles of photon paths using a Markov Chain Monte Carlo (MCMC)...
const JPosition3D & getPosition() const
bool apply_coordinate_remapping
int getNsteps()
get the number of Markov steps taken in the last call to generateEnsemble (after burn-in) ...
double getUnmappedDistance(double rprime)
inverse of getRemappedDistance
double getDistance(const JVector3D &pos) const
Get distance to point.
void setCoordinateRemapping(bool val=true)
activate or deactive coordinate remapping
int getNacceptedSteps()
get the number of accepted steps taken during the last call to generateEnsemble (after burn-in) ...
bool doMarkovStep(JSourceModel *src, JScatteringModel *sm, JTargetModel *trg, double lambda_abs, JPhotonPath &p)
make one Markov chain step for a path
void setTangentialStepSize_deg(double val)
Set the average step size theta in degrees for steps in the tangential direction for the scattering v...
const JPosition3D & getPosition() const
std::vector< JPhotonPath > generateEnsemble(int n, const JPhotonPath &start_path, JSourceModel *src, JScatteringModel *sm, JTargetModel *trg, double lambda_abs, int nsteps_burn_in, int nsteps_save)
Generate an ensemble of n paths with a fixed number of scatterings by MCMC-sampling the given scatter...
Data structure for vector in three dimensions.
JPosition3D getRemappedPosition(const JPosition3D &xprev, const JPosition3D &x)
Return the remapped vertex position of x.
double getRemappingCorrection(const JPhotonPath &p, const JPhotonPath &pprime)
Return the remapping correction for an entire photon path (product of the remapping correction for th...
double getFractionAccepted_radial()
get the fraction of steps that were accepted when a radial step was performed during the last call to...
double getFractionAccepted()
get the fraction of accepted steps during the last call to generateEnsemble (after burn-in) ...
double stepsize_angle_target
Virtual base class for a light source.
T pow(const T &x, const double y)
Power .
bool getCoordinateRemapping()
returns true when coordinate remapping is activated, false otherwise
double getR0()
return R0; the length scale used in the coordinate remapping
double getFractionAccepted_tangential()
get the fraction of steps that were accepted when a tangential step was performed during the last cal...
JPhotonPath getUnmappedPhotonPath(const JPhotonPath &pprime)
inverse of getRemappedPhotonPath
then JCookie sh JDataQuality D $DETECTOR_ID R
JPosition3D getUnmappedPosition(const JPosition3D &xprev, const JPosition3D &xprime)
Inverse of getRemappedPosition.
double getRemappedDistance(double r)
return the distance between the remapped vertex and the previous vertex given the distance between th...
JMarkovPathGenerator()
standard constructor
int getNrejectedSteps()
get the number of rejected steps during the last call to generateEnsemble (after burn-in) ...
void copy(const Head &from, JHead &to)
Copy header from from to to.
Virtual base class for a scattering model.
Virtual base class for a light detector ("photon target").
Data structure for position in three dimensions.
void setRadialStepSize_m(double val)
set the average step size in [m] in the radial direction for the scattering vertices ...
Data structure for normalised vector in three dimensions.
virtual int randomPathChange(JPhotonPath &p, JTargetModel *trg)
double getPhotonPathProbabilityDensity(JPhotonPath &p, JSourceModel *src, JScatteringModel *sm, JTargetModel *trg, double lambda_abs)
Return the probability density for a photon path with the given ingredients.
double getRemappingCorrection(const JPosition3D &xprev, const JPosition3D &xprime)
Returns the conversion factor J needed to compute the path probability density in the remapped coordi...
void setTargetStepSize_deg(double val)
set the average step size in degrees for the impact point on the target