Jpp  17.0.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
JMARKOV::JSourceTargetIntegrator Class Reference

In this implementation of the JMarkovIntegrator interface, the sample distribution is built up out of three components: More...

#include <JMarkovIntegrator.hh>

Inheritance diagram for JMARKOV::JSourceTargetIntegrator:
JMARKOV::JMarkovIntegrator

Public Member Functions

 JSourceTargetIntegrator (double Rsing, JPosition3D src_pos, JPosition3D trg_pos, double fraction_exp, double Lexp, double Rexp)
 constructor. More...
 
 ~JSourceTargetIntegrator ()
 
vector< double > integrate (int N, int nscat, JSourceModel *src, JScatteringModel *sm, JTargetModel *trg, double lambda_abs)
 Integrate with N samples. More...
 
vector< double > dummy_integrate (int N, int nscat, JSourceModel *src, JScatteringModel *sm, JTargetModel *trg, double lambda_abs)
 Integrate a test function with N samples. More...
 
vector< JPhotonPathget_diagnostic_ensemble (int N, int nscat, JSourceModel *src, JScatteringModel *sm, JTargetModel *trg, double lambda_abs)
 Return photon paths generated with the generatePath method. More...
 

Protected Member Functions

virtual JPosition3D generatePosition (int nscat, int nv, double &winv)
 Generate a random position for vertex nv. More...
 
virtual JPhotonPath generatePath (int nscat, double &winv)
 Generate a random photon path with a given number of scatterings. More...
 

Protected Attributes

JExponentialGenerator gen_exp
 
JSingularityGenerator gen_s1
 
JSingularityGenerator gen_s2
 
JGeneratorgen_exp_shift
 
JTripleGeneratorgen
 

Detailed Description

In this implementation of the JMarkovIntegrator interface, the sample distribution is built up out of three components:

Definition at line 582 of file JMarkovIntegrator.hh.

Constructor & Destructor Documentation

JMARKOV::JSourceTargetIntegrator::JSourceTargetIntegrator ( double  Rsing,
JPosition3D  src_pos,
JPosition3D  trg_pos,
double  fraction_exp,
double  Lexp,
double  Rexp 
)
inline

constructor.

Arguments:

  • position of the source
  • position of the target
  • the fraction of points that is drawn from the exponential distribution
  • the minimal radius of the exp. distr.
  • the maximal radius of the exp. distr.
  • the length parameter of the exp. distr.
  • the maximal radius for the 1/r^2 distributions

Definition at line 597 of file JMarkovIntegrator.hh.

597  : gen_exp(0,Rexp,Lexp), gen_s1(Rsing,src_pos), gen_s2(Rsing,trg_pos) {
598  JPosition3D cnt_pos = 0.5*(src_pos+trg_pos) ;
599  gen_exp_shift = new JShiftedGenerator(&gen_exp,cnt_pos) ;
600  double fraction_sing = 0.5*(1-fraction_exp) ;
601  gen = new JTripleGenerator( fraction_sing, &gen_s1, fraction_sing, &gen_s2, fraction_exp, gen_exp_shift ) ;
602  }
Implementation of the JGenerator interface.
Implementation of the JGenerator interface.
JMARKOV::JSourceTargetIntegrator::~JSourceTargetIntegrator ( )
inline

Definition at line 604 of file JMarkovIntegrator.hh.

604  {
605  delete gen_exp_shift ;
606  delete gen ;
607  }

Member Function Documentation

virtual JPosition3D JMARKOV::JSourceTargetIntegrator::generatePosition ( int  nscat,
int  nv,
double &  winv 
)
inlineprotectedvirtual

Generate a random position for vertex nv.

nv = 1 is the first scattering vertex, nv = 2 is the second scattering vertex etc.

So we require that 0 < nv <= nscat

winv has to be set to 1 over the probability density for this particular position. NOTE: this only works when the positions of each vertex are UNCORRELATED to each other (as in the default implementation of generatePath. If they are not, this method can be given a dummy implementation and be ignored.

Implements JMARKOV::JMarkovIntegrator.

Definition at line 611 of file JMarkovIntegrator.hh.

611  {
612  JPosition3D pos = gen->getPosition() ;
613  winv = 1.0/gen->getWeight(pos) ;
614  return pos ;
615  }
double getWeight(JPosition3D pos)
return the weight (=probability density dP/dV) for the given position.
JPosition3D getPosition()
Return a randomly generated position.
vector< double > JMARKOV::JMarkovIntegrator::integrate ( int  N,
int  nscat,
JSourceModel src,
JScatteringModel sm,
JTargetModel trg,
double  lambda_abs 
)
inherited

Integrate with N samples.

Returns a vector with the contribution to the integral of each sample. The mean of those values is the estimate of the result of the integral, while the distribution itself can be used to estimate the stability of the result. In this distribution, you want to avoid

  • long tails (because they make the result unstable)
  • small contributions (because it means that parts of the parameter space are being oversampled, so it is less efficient) This can be achieved by tuning the sample distribution to the problem at hand.

Definition at line 130 of file JMarkovIntegrator.hh.

130  {
131  vector<double> contributions(N,-1) ;
132 
133  for( int i=0 ; i<N ; ++i ) {
134  double winv ;
135  JPhotonPath p = generatePath(nscat,winv) ;
136 
137  double rho = getPhotonPathProbabilityDensity(p,src,sm,trg,lambda_abs) ;
138  contributions[i] = rho * winv ;
139  }
140  return contributions ;
141  }
A photon path.
Definition: JPhotonPath.hh:38
then JShowerPostfit f $INPUT_FILE o $OUTPUT_FILE N
virtual JPhotonPath generatePath(int nscat, double &winv)
Generate a random photon path with a given number of scatterings.
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.
vector< double > JMARKOV::JMarkovIntegrator::dummy_integrate ( int  N,
int  nscat,
JSourceModel src,
JScatteringModel sm,
JTargetModel trg,
double  lambda_abs 
)
inherited

Integrate a test function with N samples.

This can be used as a sanity check for derived classes of JMarkovIntegrator.

The integral should yield 1 when the complete relevant part of the volume is taken into account. If it does not, it may be a sign that the implementation is not correct.

Returns a vector with the contribution to the integral of each sample.

Definition at line 143 of file JMarkovIntegrator.hh.

143  {
144  vector<double> contributions(N,-1) ;
145 
146  for( int i=0 ; i<N ; ++i ) {
147  const double r = 10 ;
148  double winv ;
149  JPhotonPath p = generatePath(nscat,winv) ;
150  double rho = 1.0/(4.0/3.0*M_PI*r*r*r) ;
151  if( p[1].getLength()>r ) rho = 0 ;
152  contributions[i] = rho * winv ;
153  }
154  return contributions ;
155  }
A photon path.
Definition: JPhotonPath.hh:38
then JShowerPostfit f $INPUT_FILE o $OUTPUT_FILE N
data_type r[M+1]
Definition: JPolint.hh:758
virtual JPhotonPath generatePath(int nscat, double &winv)
Generate a random photon path with a given number of scatterings.
vector< JPhotonPath > JMARKOV::JMarkovIntegrator::get_diagnostic_ensemble ( int  N,
int  nscat,
JSourceModel src,
JScatteringModel sm,
JTargetModel trg,
double  lambda_abs 
)
inherited

Return photon paths generated with the generatePath method.

This can be used to identify the parts of parameter space that are over- or undersampled in a given problem so that the integrator may be optimized to handle those better.

Definition at line 157 of file JMarkovIntegrator.hh.

157  {
158  vector<JPhotonPath> paths ;
159 
160  for( int i=0 ; i<N ; ++i ) {
161  double winv ;
162  JPhotonPath p = generatePath(nscat,winv) ;
163  paths.push_back(p) ;
164  }
165  return paths ;
166  }
A photon path.
Definition: JPhotonPath.hh:38
then JShowerPostfit f $INPUT_FILE o $OUTPUT_FILE N
virtual JPhotonPath generatePath(int nscat, double &winv)
Generate a random photon path with a given number of scatterings.
virtual JPhotonPath JMARKOV::JMarkovIntegrator::generatePath ( int  nscat,
double &  winv 
)
inlineprotectedvirtualinherited

Generate a random photon path with a given number of scatterings.

winv must be set to the inverted probability density to generate this particular path.

Definition at line 94 of file JMarkovIntegrator.hh.

94  {
95  // this default implementation assumes that the vertex positions
96  // are completely uncorrelated
97  JPhotonPath p(nscat) ;
98  double _winv = 1 ;
99  for( int nv=0 ; nv<nscat+2 ; ++nv ) {
100  double part_winv ;
101  p[nv] = generatePosition( nscat, nv, part_winv ) ;
102  _winv *= part_winv ;
103  }
104  winv = _winv ;
105  return p ;
106  }
A photon path.
Definition: JPhotonPath.hh:38
virtual JPosition3D generatePosition(int nscat, int nv, double &winv)=0
Generate a random position for vertex nv.

Member Data Documentation

JExponentialGenerator JMARKOV::JSourceTargetIntegrator::gen_exp
protected

Definition at line 617 of file JMarkovIntegrator.hh.

JSingularityGenerator JMARKOV::JSourceTargetIntegrator::gen_s1
protected

Definition at line 618 of file JMarkovIntegrator.hh.

JSingularityGenerator JMARKOV::JSourceTargetIntegrator::gen_s2
protected

Definition at line 619 of file JMarkovIntegrator.hh.

JGenerator* JMARKOV::JSourceTargetIntegrator::gen_exp_shift
protected

Definition at line 620 of file JMarkovIntegrator.hh.

JTripleGenerator* JMARKOV::JSourceTargetIntegrator::gen
protected

Definition at line 621 of file JMarkovIntegrator.hh.


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