Jpp
15.0.0
the software that should make you happy
|
The JMarkovPathGenerator generates ensembles of photon paths using a Markov Chain Monte Carlo (MCMC). More...
#include <JMarkovPathGenerator.hh>
Public Member Functions | |
JMarkovPathGenerator () | |
standard constructor More... | |
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 scattering model. More... | |
int | getNsteps () |
get the number of Markov steps taken in the last call to generateEnsemble (after burn-in) More... | |
int | getNacceptedSteps () |
get the number of accepted steps taken during the last call to generateEnsemble (after burn-in) More... | |
int | getNrejectedSteps () |
get the number of rejected steps during the last call to generateEnsemble (after burn-in) More... | |
double | getFractionAccepted () |
get the fraction of accepted steps during the last call to generateEnsemble (after burn-in) More... | |
double | getFractionAccepted_radial () |
get the fraction of steps that were accepted when a radial step was performed during the last call to generateEnsemble (after burn-in) More... | |
double | getFractionAccepted_tangential () |
get the fraction of steps that were accepted when a tangential step was performed during the last call to generateEnsemble (after burn-in) More... | |
bool | doMarkovStep (JSourceModel *src, JScatteringModel *sm, JTargetModel *trg, double lambda_abs, JPhotonPath &p) |
make one Markov chain step for a path More... | |
virtual int | randomPathChange (JPhotonPath &p, JTargetModel *trg) |
void | setTargetStepSize_deg (double val) |
set the average step size in degrees for the impact point on the target More... | |
void | setRadialStepSize_m (double val) |
set the average step size in [m] in the radial direction for the scattering vertices More... | |
void | setTangentialStepSize_deg (double val) |
Set the average step size theta in degrees for steps in the tangential direction for the scattering vertices. More... | |
void | setCoordinateRemapping (bool val=true) |
activate or deactive coordinate remapping More... | |
bool | getCoordinateRemapping () |
returns true when coordinate remapping is activated, false otherwise More... | |
Private Member Functions | |
double | getR0 () |
return R0; the length scale used in the coordinate remapping More... | |
double | getRemappedDistance (double r) |
return the distance between the remapped vertex and the previous vertex given the distance between the not-remapped vertex and the previous vertex More... | |
double | getUnmappedDistance (double rprime) |
inverse of getRemappedDistance More... | |
JPosition3D | getRemappedPosition (const JPosition3D &xprev, const JPosition3D &x) |
Return the remapped vertex position of x. More... | |
JPosition3D | getUnmappedPosition (const JPosition3D &xprev, const JPosition3D &xprime) |
Inverse of getRemappedPosition. More... | |
JPhotonPath | getRemappedPhotonPath (const JPhotonPath &p) |
returns a remapped version of the photon path More... | |
JPhotonPath | getUnmappedPhotonPath (const JPhotonPath &pprime) |
inverse of getRemappedPhotonPath More... | |
double | getRemappingCorrection (const JPosition3D &xprev, const JPosition3D &xprime) |
Returns the conversion factor J needed to compute the path probability density in the remapped coordinates, for a given vertex. More... | |
double | getRemappingCorrection (const JPhotonPath &p, const JPhotonPath &pprime) |
Return the remapping correction for an entire photon path (product of the remapping correction for the individual scattering vertices). More... | |
Private Attributes | |
bool | apply_coordinate_remapping |
int | naccepted_r |
int | nrejected_r |
int | naccepted_t |
int | nrejected_t |
double | stepsize_angle_target |
double | stepsize_r |
double | stepsize_angle |
The JMarkovPathGenerator generates ensembles of photon paths using a Markov Chain Monte Carlo (MCMC).
In the Markov chain, the number of scatterings does not change. Therefore the ensembles have to be generated separately for each given number of scatterings.
The small modification of the path that is proposed in each step, is defined by the function 'randomPathChange'. This function is virtual so that it can be overrided in a derived class. The initial and final vertex are fixed and one of the other vertices is displaced in a random direction following an exponential distribution.
The source, target and scattering models are used to calculate the probability density of the path.
Random numbers are drawn from gRandom.
By default, the coordinates are remapped such that the 1/r^2 singularities in the path probability density disappear. This option can be turned off (but do not do it, unless you want to convince yourself that it is necessary) with the setCoordinateRemapping method.
Definition at line 50 of file JMarkovPathGenerator.hh.
|
inline |
standard constructor
Definition at line 54 of file JMarkovPathGenerator.hh.
std::vector< JPhotonPath > JMARKOV::JMarkovPathGenerator::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 scattering model.
The paths start at the source (a well-defined position) and end on the target (either a fixed position or, in the case of a finite source, the surface of a sphere).
start_path is a photon path that is used a starting point for the MCMC. It has to be supplied by the user (due to the various source and target profiles it is not straightforward to generate one automatically) and must have a path probability density != 0. The number of scatterings is also defined by the start_path.
nsteps_burn_in is the number of steps taken for burn-in.
nsteps_save determines the number of MCMC steps between the paths that are saved to the ensemble.
Definition at line 329 of file JMarkovPathGenerator.hh.
|
inline |
get the number of Markov steps taken in the last call to generateEnsemble (after burn-in)
Definition at line 86 of file JMarkovPathGenerator.hh.
|
inline |
get the number of accepted steps taken during the last call to generateEnsemble (after burn-in)
Definition at line 89 of file JMarkovPathGenerator.hh.
|
inline |
get the number of rejected steps during the last call to generateEnsemble (after burn-in)
Definition at line 92 of file JMarkovPathGenerator.hh.
|
inline |
get the fraction of accepted steps during the last call to generateEnsemble (after burn-in)
Definition at line 95 of file JMarkovPathGenerator.hh.
|
inline |
get the fraction of steps that were accepted when a radial step was performed during the last call to generateEnsemble (after burn-in)
Definition at line 101 of file JMarkovPathGenerator.hh.
|
inline |
get the fraction of steps that were accepted when a tangential step was performed during the last call to generateEnsemble (after burn-in)
Definition at line 107 of file JMarkovPathGenerator.hh.
bool JMARKOV::JMarkovPathGenerator::doMarkovStep | ( | JSourceModel * | src, |
JScatteringModel * | sm, | ||
JTargetModel * | trg, | ||
double | lambda_abs, | ||
JPhotonPath & | p | ||
) |
make one Markov chain step for a path
Definition at line 385 of file JMarkovPathGenerator.hh.
|
virtual |
Definition at line 264 of file JMarkovPathGenerator.hh.
|
inline |
set the average step size in degrees for the impact point on the target
Definition at line 118 of file JMarkovPathGenerator.hh.
|
inline |
set the average step size in [m] in the radial direction for the scattering vertices
Definition at line 123 of file JMarkovPathGenerator.hh.
|
inline |
Set the average step size theta in degrees for steps in the tangential direction for the scattering vertices.
When r * theta is larger than the radial step size, the effective theta will be temporarily set to a smaller value to avoid taking steps that are too large.
Definition at line 133 of file JMarkovPathGenerator.hh.
|
inline |
activate or deactive coordinate remapping
Definition at line 138 of file JMarkovPathGenerator.hh.
|
inline |
returns true when coordinate remapping is activated, false otherwise
Definition at line 143 of file JMarkovPathGenerator.hh.
|
inlineprivate |
return R0; the length scale used in the coordinate remapping
Definition at line 149 of file JMarkovPathGenerator.hh.
|
inlineprivate |
return the distance between the remapped vertex and the previous vertex given the distance between the not-remapped vertex and the previous vertex
Definition at line 155 of file JMarkovPathGenerator.hh.
|
inlineprivate |
inverse of getRemappedDistance
Definition at line 161 of file JMarkovPathGenerator.hh.
|
inlineprivate |
Return the remapped vertex position of x.
xprev is the (not remapped!) coordinate of the previous vertex in the photon path.
Definition at line 170 of file JMarkovPathGenerator.hh.
|
inlineprivate |
Inverse of getRemappedPosition.
Again, xprev is the (not remapped!) coordinate of the previous vertex in the photon path.
Definition at line 180 of file JMarkovPathGenerator.hh.
|
inlineprivate |
returns a remapped version of the photon path
Definition at line 187 of file JMarkovPathGenerator.hh.
|
inlineprivate |
inverse of getRemappedPhotonPath
Definition at line 196 of file JMarkovPathGenerator.hh.
|
inlineprivate |
Returns the conversion factor J needed to compute the path probability density in the remapped coordinates, for a given vertex.
xprime is the remapped vertex position xprev is the (not remapped!) position of the previous vertex
In casual notation (the ' indicates remapped coordinates):
rho(x) dV = rho(x) r^2 dr dOmega = rho(x) r^2 / r'^2 dr/dr' r'^2 dr' dOmega = rho( x(x') ) r^2 / r'^2 dr/dr' dV' <— since dOmega == dOmega' := J x rho( x(x') ) dV' := rho'(x') dV' Where J := r^2 / r'^2 dr/dr'
The point of this is that we typically pick r proportional to r'^3, so that dr/dr' is proportional to r'^2, which cancels the factor 1/r'^2 in rho'. The new factor r^2 then cancels the typical 1/r^2 singularity present in rho.
Definition at line 224 of file JMarkovPathGenerator.hh.
|
inlineprivate |
Return the remapping correction for an entire photon path (product of the remapping correction for the individual scattering vertices).
p is the photon path in normal coordinates pprime is the remapped version of p
Definition at line 245 of file JMarkovPathGenerator.hh.
|
private |
Definition at line 254 of file JMarkovPathGenerator.hh.
|
private |
Definition at line 255 of file JMarkovPathGenerator.hh.
|
private |
Definition at line 256 of file JMarkovPathGenerator.hh.
|
private |
Definition at line 257 of file JMarkovPathGenerator.hh.
|
private |
Definition at line 258 of file JMarkovPathGenerator.hh.
|
private |
Definition at line 259 of file JMarkovPathGenerator.hh.
|
private |
Definition at line 260 of file JMarkovPathGenerator.hh.
|
private |
Definition at line 261 of file JMarkovPathGenerator.hh.