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

In this implementation of the JMarkovIntegrator interface, the sample distribution is built up out of correlated path vertices. More...

#include <JMarkovIntegrator.hh>

Inheritance diagram for JMARKOV::JExperimentalIntegrator:
JMARKOV::JMarkovIntegrator

Public Member Functions

 JExperimentalIntegrator (double _lambda)
 constructor.
 
 ~JExperimentalIntegrator ()
 
vector< double > integrate (int N, int nscat, JSourceModel *src, JScatteringModel *sm, JTargetModel *trg, double lambda_abs)
 Integrate with N samples.
 
vector< double > dummy_integrate (int N, int nscat, JSourceModel *src, JScatteringModel *sm, JTargetModel *trg, double lambda_abs)
 Integrate a test function with N samples.
 
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.
 

Protected Member Functions

JPosition3D generatePosition (int nscat, int nv, double &winv)
 dummy implementation
 
JPhotonPath generatePath (int nscat, double &winv, JPosition3D source_pos, JPosition3D target_pos)
 
JPosition3D getFirstScatteringVertex (int nscat, JPosition3D src_pos, JPosition3D trg_pos, double &winv)
 recursive function to randomly generate the first scattering vertex for isotropic scattering from a source to a target
 
virtual JPhotonPath generatePath (int nscat, double &winv)
 Generate a random photon path with a given number of scatterings.
 

Protected Attributes

JExpRsqInvGenerator gen
 

Detailed Description

In this implementation of the JMarkovIntegrator interface, the sample distribution is built up out of correlated path vertices.

lambda is the effective length scale defined as:

1/lambda := 1/lambda_scat + 1/lambda_abs

Definition at line 633 of file JMarkovIntegrator.hh.

Constructor & Destructor Documentation

◆ JExperimentalIntegrator()

JMARKOV::JExperimentalIntegrator::JExperimentalIntegrator ( double _lambda)
inline

constructor.

Definition at line 639 of file JMarkovIntegrator.hh.

639: gen(_lambda) {}

◆ ~JExperimentalIntegrator()

JMARKOV::JExperimentalIntegrator::~JExperimentalIntegrator ( )
inline

Definition at line 641 of file JMarkovIntegrator.hh.

641{}

Member Function Documentation

◆ generatePosition()

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

dummy implementation

Implements JMARKOV::JMarkovIntegrator.

Definition at line 646 of file JMarkovIntegrator.hh.

646 {
647 return JPosition3D(0,0,0) ;
648 } ;

◆ generatePath() [1/2]

JPhotonPath JMARKOV::JExperimentalIntegrator::generatePath ( int nscat,
double & winv,
JPosition3D source_pos,
JPosition3D target_pos )
inlineprotected

Definition at line 650 of file JMarkovIntegrator.hh.

650 {
651 JPhotonPath p(nscat) ;
652 p.front() = source_pos ;
653 p.back() = target_pos ;
654 double _winv = 1 ;
655
656 for( int nv=1 ; nv<=nscat ; ++nv ) {
657 double __winv ;
658 p[nv] = getFirstScatteringVertex(nscat+1-nv,p[nv-1],p.back(),__winv ) ;
659 _winv *= __winv ;
660 }
661 winv = _winv ;
662 return p ;
663 }
JPosition3D getFirstScatteringVertex(int nscat, JPosition3D src_pos, JPosition3D trg_pos, double &winv)
recursive function to randomly generate the first scattering vertex for isotropic scattering from a s...

◆ getFirstScatteringVertex()

JPosition3D JMARKOV::JExperimentalIntegrator::getFirstScatteringVertex ( int nscat,
JPosition3D src_pos,
JPosition3D trg_pos,
double & winv )
inlineprotected

recursive function to randomly generate the first scattering vertex for isotropic scattering from a source to a target

Definition at line 671 of file JMarkovIntegrator.hh.

671 {
672 double _winv = 1 ;
673 if( nscat == 0 ) {
674 winv = 1 ;
675 return trg_pos ;
676 }
677 if( gRandom->Integer(2) == 0 ) {
678 src_pos = getFirstScatteringVertex(nscat-1,src_pos,trg_pos,_winv) ;
679 }
680 JPosition3D pos = gen.getPosition() ;
681 winv = 1.0 / gen.getWeight(pos) ;
682 return src_pos + pos ;
683 }
JPosition3D getPosition()
Return a randomly generated position.
double getWeight(JPosition3D pos)
return the weight (=probability density dP/dV) for the given position.

◆ integrate()

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 }
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.

◆ dummy_integrate()

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 }

◆ get_diagnostic_ensemble()

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 }

◆ generatePath() [2/2]

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 }
virtual JPosition3D generatePosition(int nscat, int nv, double &winv)=0
Generate a random position for vertex nv.

Member Data Documentation

◆ gen

JExpRsqInvGenerator JMARKOV::JExperimentalIntegrator::gen
protected

Definition at line 685 of file JMarkovIntegrator.hh.


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