Jpp  debug
the software that should make you happy
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
JMARKOV::JDirectedSource Class Reference

Implementation of the JSourceModel class that represents a directed source with a flat intensity distribution. More...

#include <JScatteringModel.hh>

Inheritance diagram for JMARKOV::JDirectedSource:
JMARKOV::JSourceModel

Public Member Functions

 JDirectedSource (JVersor3D _source_dir, double _alpha, bool _cutSurface=false, const JVersor3D _surface_normal=JVersor3D())
 Constructor. More...
 
double getOpeningAngle () const
 return the opening angle in radians More...
 
JVersor3D getDirection () const
 return the source direction More...
 
double getEmissionProbability (JVersor3D dir)
 Return the probability density. More...
 
JVersor3D generateDirection ()
 Return a randomly generated direction according to the emission distribution. More...
 
void setPosition (JPosition3D &_pos)
 
const JPosition3DgetPosition () const
 

Protected Member Functions

double getPhiMax (double theta)
 For a given angle theta with respect to the beam direction, and a given surface normal, we define phi as the rotation angle around the beam, where phi=0 corresponds to the direction sticking out over the surface a much as possible. More...
 

Protected Attributes

JVersor3D source_dir
 
double ctmin
 
double alpha
 
bool cutSurface
 
JVersor3D surface_normal
 
double delta
 
double omega
 
JPosition3D pos
 

Detailed Description

Implementation of the JSourceModel class that represents a directed source with a flat intensity distribution.

When _cutSurface = true, photons that would be emitted into the surface (defined by the surface normal) will not be emitted.

Definition at line 144 of file JScatteringModel.hh.

Constructor & Destructor Documentation

◆ JDirectedSource()

JMARKOV::JDirectedSource::JDirectedSource ( JVersor3D  _source_dir,
double  _alpha,
bool  _cutSurface = false,
const JVersor3D  _surface_normal = JVersor3D() 
)
inline

Constructor.

_source_dir is the source direction _alpha is the opening angle in radians

note that _alpha should be > -1

Definition at line 154 of file JScatteringModel.hh.

154  :
155  source_dir(_source_dir), ctmin(cos(0.5*_alpha)), alpha(_alpha), cutSurface(_cutSurface), surface_normal(_surface_normal) {
156  // we have to find out which fraction of photons would be emitted into the surface, given
157  // the direction and opening angle
158  // as far as I can tell, this is a non-trivial integral, so I solve it numerically
159 
160  // delta is the angle of the beam direction over the surface
161  // (negative means the beam points into the surface)
162  delta = 0.5*M_PI - acos(surface_normal.getDot(source_dir)) ;
163  omega = 2.0*M_PI*(1.0-ctmin) ; // space angle of beam ("spherical cap")
164 
165  if( cutSurface ) {
166  if( delta>0.0 && delta>0.5*_alpha ) {
167  // no part of the beam points into the surface
168  //fraction_into_surface = 0.0 ;
169  } else if( delta<=0 && fabs(delta)>=0.5*alpha ) {
170  // the beam points completely into the surface, throw an error
171  //fraction_into_surface = 1.0 ;
172  omega = 0.0 ;
173  cerr << "FATAL ERROR in JDirectedSource: beam points completely into the surface." << endl ;
174  exit(1) ;
175  } else {
176  // part of the beam points into the surface, which effectively reduces
177  // the space angle omega
178  // here we numerically compute omega
179 
180  // only at theta=delta to alpha/2 is part of the beam absorbed
181  // we calculate the space angle of the absorbed beam part
182  double omega_absorbed = 0.0 ;
183  const int __nct = 100000 ;
184  const double __ctmin = cos(0.5*alpha) ;
185  const double __ctmax = cos(delta) ;
186  const double __dct = (__ctmax - __ctmin)/__nct ;
187  for( int i=0; i<__nct; ++i ) {
188  double __ct = __ctmin + (i+0.5) * __dct ;
189  double __theta = acos(__ct) ;
190  double __phirange = 2.0*(M_PI-getPhiMax(__theta)) ;
191  omega_absorbed += __phirange ;
192  }
193  omega_absorbed *= __dct ;
194  omega -= omega_absorbed ;
195 
196  // if the beam direction is into the surface, this part gets absorbed completely
197  if( delta<0 ) {
198  omega -= 2.0 * M_PI * (1.0-cos(delta)) ;
199  }
200  }
201  }
202  }
double getDot(const JVersor3D &versor) const
Get dot product.
Definition: JVersor3D.hh:156
double getPhiMax(double theta)
For a given angle theta with respect to the beam direction, and a given surface normal,...

Member Function Documentation

◆ getOpeningAngle()

double JMARKOV::JDirectedSource::getOpeningAngle ( ) const
inline

return the opening angle in radians

Definition at line 205 of file JScatteringModel.hh.

205 { return alpha ; }

◆ getDirection()

JVersor3D JMARKOV::JDirectedSource::getDirection ( ) const
inline

return the source direction

Definition at line 208 of file JScatteringModel.hh.

208 { return source_dir ; }

◆ getEmissionProbability()

double JMARKOV::JDirectedSource::getEmissionProbability ( JVersor3D  dir)
inlinevirtual

Return the probability density.

dP / dOmega = dP / dCosTheta dPhi

that a photon from this source is emitted in a given direction, given that a photon is emitted.

Implements JMARKOV::JSourceModel.

Definition at line 210 of file JScatteringModel.hh.

210  {
211  double ct = dir.getDot(source_dir) ;
212  if( ct>ctmin ) {
213  if( cutSurface && dir.getDot(surface_normal)<0 ) return 0.0 ;
214  return 1.0/omega ;
215  }
216  return 0.0 ;
217  }

◆ generateDirection()

JVersor3D JMARKOV::JDirectedSource::generateDirection ( )
inlinevirtual

Return a randomly generated direction according to the emission distribution.

This uses gRandom.

Implements JMARKOV::JSourceModel.

Definition at line 219 of file JScatteringModel.hh.

219  {
220  while(true) {
221  double phi = gRandom->Uniform(0,2*M_PI) ;
222  double ct = gRandom->Uniform(ctmin,1) ;
223  JDirection3D _dir( JAngle3D(acos(ct),phi) ) ;
224  JRotation3D R( source_dir ) ;
225  JVersor3D dir(_dir.rotate_back(R)) ;
226  if( !cutSurface ) return dir ;
227  if( dir.getDot(surface_normal)>0 ) return dir ;
228  }
229  }
Data structure for angles in three dimensions.
Definition: JAngle3D.hh:35
Data structure for direction in three dimensions.
Definition: JDirection3D.hh:35
Rotation matrix.
Definition: JRotation3D.hh:114
Data structure for normalised vector in three dimensions.
Definition: JVersor3D.hh:28

◆ getPhiMax()

double JMARKOV::JDirectedSource::getPhiMax ( double  theta)
inlineprotected

For a given angle theta with respect to the beam direction, and a given surface normal, we define phi as the rotation angle around the beam, where phi=0 corresponds to the direction sticking out over the surface a much as possible.

This function returns 'phi max', which is the largest value of phi for which the direction does not point into the surface.

Definition at line 242 of file JScatteringModel.hh.

242  {
243  if( delta>0 ) {
244  if( theta<delta ) return M_PI ;
245  if( theta+delta > M_PI ) return 0.0 ;
246  }
247  if( delta<0 ) {
248  if( theta<fabs(delta) ) return 0.0 ;
249  if( theta+fabs(delta) > M_PI ) return M_PI ;
250  }
251  double phimax = acos(-tan(delta)/tan(theta)) ;
252  return phimax ;
253  }

◆ setPosition()

void JMARKOV::JSourceModel::setPosition ( JPosition3D _pos)
inlineinherited

Definition at line 108 of file JScatteringModel.hh.

108 { pos = _pos ; }

◆ getPosition()

const JPosition3D& JMARKOV::JSourceModel::getPosition ( ) const
inlineinherited

Definition at line 110 of file JScatteringModel.hh.

110 { return pos ; }

Member Data Documentation

◆ source_dir

JVersor3D JMARKOV::JDirectedSource::source_dir
protected

Definition at line 256 of file JScatteringModel.hh.

◆ ctmin

double JMARKOV::JDirectedSource::ctmin
protected

Definition at line 257 of file JScatteringModel.hh.

◆ alpha

double JMARKOV::JDirectedSource::alpha
protected

Definition at line 258 of file JScatteringModel.hh.

◆ cutSurface

bool JMARKOV::JDirectedSource::cutSurface
protected

Definition at line 259 of file JScatteringModel.hh.

◆ surface_normal

JVersor3D JMARKOV::JDirectedSource::surface_normal
protected

Definition at line 260 of file JScatteringModel.hh.

◆ delta

double JMARKOV::JDirectedSource::delta
protected

Definition at line 261 of file JScatteringModel.hh.

◆ omega

double JMARKOV::JDirectedSource::omega
protected

Definition at line 263 of file JScatteringModel.hh.

◆ pos

JPosition3D JMARKOV::JSourceModel::pos
protectedinherited

Definition at line 114 of file JScatteringModel.hh.


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