Jpp  18.6.0-rc.1
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::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 143 of file JScatteringModel.hh.

Constructor & Destructor Documentation

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 153 of file JScatteringModel.hh.

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

Member Function Documentation

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

return the opening angle in radians

Definition at line 204 of file JScatteringModel.hh.

204 { return alpha ; }
JVersor3D JMARKOV::JDirectedSource::getDirection ( ) const
inline

return the source direction

Definition at line 207 of file JScatteringModel.hh.

207 { return source_dir ; }
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 209 of file JScatteringModel.hh.

209  {
210  double ct = dir.getDot(source_dir) ;
211  if( ct>ctmin ) {
212  if( cutSurface && dir.getDot(surface_normal)<0 ) return 0.0 ;
213  return 1.0/omega ;
214  }
215  return 0.0 ;
216  }
double getDot(const JVersor3D &versor) const
Get dot product.
Definition: JVersor3D.hh:156
JVersor3D JMARKOV::JDirectedSource::generateDirection ( )
inlinevirtual

Return a randomly generated direction according to the emission distribution.

This uses gRandom.

Implements JMARKOV::JSourceModel.

Definition at line 218 of file JScatteringModel.hh.

218  {
219  while(true) {
220  double phi = gRandom->Uniform(0,2*M_PI) ;
221  double ct = gRandom->Uniform(ctmin,1) ;
222  JVersor3D _dir( JAngle3D(acos(ct),phi) ) ;
223  JRotation3D R( source_dir ) ;
224  JVersor3D dir(_dir.rotate_back(R)) ;
225  if( !cutSurface ) return dir ;
226  if( dir.getDot(surface_normal)>0 ) return dir ;
227  }
228  }
Data structure for angles in three dimensions.
Definition: JAngle3D.hh:33
Rotation matrix.
Definition: JRotation3D.hh:111
then JCookie sh JDataQuality D $DETECTOR_ID R
Definition: JDataQuality.sh:41
Data structure for normalised vector in three dimensions.
Definition: JVersor3D.hh:26
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 241 of file JScatteringModel.hh.

241  {
242  if( delta>0 ) {
243  if( theta<delta ) return M_PI ;
244  if( theta+delta > M_PI ) return 0.0 ;
245  }
246  if( delta<0 ) {
247  if( theta<fabs(delta) ) return 0.0 ;
248  if( theta+fabs(delta) > M_PI ) return M_PI ;
249  }
250  double phimax = acos(-tan(delta)/tan(theta)) ;
251  return phimax ;
252  }
void JMARKOV::JSourceModel::setPosition ( JPosition3D _pos)
inlineinherited

Definition at line 107 of file JScatteringModel.hh.

107 { pos = _pos ; }
const JPosition3D& JMARKOV::JSourceModel::getPosition ( ) const
inlineinherited

Definition at line 109 of file JScatteringModel.hh.

109 { return pos ; }

Member Data Documentation

JVersor3D JMARKOV::JDirectedSource::source_dir
protected

Definition at line 255 of file JScatteringModel.hh.

double JMARKOV::JDirectedSource::ctmin
protected

Definition at line 256 of file JScatteringModel.hh.

double JMARKOV::JDirectedSource::alpha
protected

Definition at line 257 of file JScatteringModel.hh.

bool JMARKOV::JDirectedSource::cutSurface
protected

Definition at line 258 of file JScatteringModel.hh.

JVersor3D JMARKOV::JDirectedSource::surface_normal
protected

Definition at line 259 of file JScatteringModel.hh.

double JMARKOV::JDirectedSource::delta
protected

Definition at line 260 of file JScatteringModel.hh.

double JMARKOV::JDirectedSource::omega
protected

Definition at line 262 of file JScatteringModel.hh.

JPosition3D JMARKOV::JSourceModel::pos
protectedinherited

Definition at line 113 of file JScatteringModel.hh.


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