GENIEGenerator
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Protected Attributes | List of all members
genie::geometry::FidPolyhedron Class Reference

#include <FidShape.h>

Inheritance diagram for genie::geometry::FidPolyhedron:
Inheritance graph
[legend]
Collaboration diagram for genie::geometry::FidPolyhedron:
Collaboration graph
[legend]

Public Member Functions

 FidPolyhedron ()
 convex polyhedron is made of multiple planar equations More...
 
void push_back (const PlaneParam &pln)
 
void clear ()
 
RayIntercept Intercept (const TVector3 &start, const TVector3 &dir) const
 
void ConvertMaster2Top (const ROOTGeomAnalyzer *rgeom)
 
void Print (std::ostream &stream) const
 
- Public Member Functions inherited from genie::geometry::FidShape
 FidShape ()
 
virtual ~FidShape ()
 

Protected Attributes

std::vector< PlaneParamfPolyFaces
 

Detailed Description

Definition at line 136 of file FidShape.h.

Constructor & Destructor Documentation

genie::geometry::FidPolyhedron::FidPolyhedron ( )
inline

convex polyhedron is made of multiple planar equations

Definition at line 139 of file FidShape.h.

139 { ; }

Member Function Documentation

void genie::geometry::FidPolyhedron::clear ( )
inline

Definition at line 141 of file FidShape.h.

References fPolyFaces.

141 { fPolyFaces.clear(); }
std::vector< PlaneParam > fPolyFaces
Definition: FidShape.h:146
void FidPolyhedron::ConvertMaster2Top ( const ROOTGeomAnalyzer rgeom)
virtual

derived classes must implement the ConvertMaster2Top() method which transforms the shape specification from master coordinates to "top vol"

Implements genie::geometry::FidShape.

Definition at line 296 of file FidShape.cxx.

References genie::geometry::PlaneParam::ConvertMaster2Top().

297 {
298  for (unsigned int i = 0; i < fPolyFaces.size(); ++i ) {
299  PlaneParam& aplane = fPolyFaces[i];
300  aplane.ConvertMaster2Top(rgeom);
301  }
302 }
void ConvertMaster2Top(const ROOTGeomAnalyzer *rgeom)
Definition: FidShape.cxx:48
std::vector< PlaneParam > fPolyFaces
Definition: FidShape.h:146
RayIntercept FidPolyhedron::Intercept ( const TVector3 &  start,
const TVector3 &  dir 
) const
virtual

derived classes must implement the Intercept() method which calculates the entry/exit point of a ray w/ the shape

Implements genie::geometry::FidShape.

Definition at line 216 of file FidShape.cxx.

References genie::geometry::RayIntercept::fDistIn, genie::geometry::RayIntercept::fDistOut, genie::geometry::RayIntercept::fIsHit, genie::geometry::RayIntercept::fSurfIn, genie::geometry::RayIntercept::fSurfOut, genie::geometry::PlaneParam::IsValid(), genie::geometry::PlaneParam::Vd(), and genie::geometry::PlaneParam::Vn().

217 {
218  // A new neutrino ray has been set, calculate the entrance/exit distances.
219  // Calculate the point of intersection of a ray (directed line) and a
220  // *convex* polyhedron constructed from the intersection of a list
221  // of planar equations (no check on convex condition).
222 
223  RayIntercept intercept;
224 
225  Double_t tnear = -DBL_MAX;
226  Double_t tfar = DBL_MAX;
227  Int_t surfNear = -1;
228  Int_t surfFar = -1;
229  Bool_t parallel = false;
230 
231  // test each plane in the polyhedron
232  for ( size_t iface=0; iface < fPolyFaces.size(); ++iface ) {
233  const PlaneParam& pln = fPolyFaces[iface];
234  if ( ! pln.IsValid() ) continue;
235 
236  // calculate numerator, denominator to "t" = distance along ray to intersection w/ pln
237  Double_t vd = pln.Vd(dir);
238  Double_t vn = pln.Vn(start);
239 
240  //LOG("GeomVolSel", pNOTICE)
241  // << " face " << iface << " [" << pln.a << "," << pln.b << "," << pln.c << "," << pln.d
242  // << "] vd=" << vd << " vn=" << vn;
243 
244  if ( vd == 0.0 ) {
245  // ray is parallel to plane - check if ray origin is inside plane's half-space
246  //LOG("GeomVolSel", pNOTICE)
247  // << " vd=0, " << " possibly parallel ";
248  if ( vn > 0.0 ) { parallel = true; break; } // wrong side ... complete miss
249  } else {
250  // ray is not parallel to plane -- get the distance to the plane
251  Double_t t = -vn / vd; // notice negative sign!
252  //LOG("GeomVolSel", pNOTICE) << " t=" << t << " tnear=" << tnear << " tfar=" << tfar;
253  if ( vd < 0.0 ) {
254  // front face: t is a near point
255  if ( t > tnear ) {
256  surfNear = iface;
257  tnear = t;
258  }
259  } else {
260  // back face: t is a far point
261  if ( t < tfar ) {
262  surfFar = iface;
263  tfar = t;
264  }
265  }
266  //LOG("GeomVolSel", pNOTICE) << " new surf " << surfNear << "," << surfFar
267  // << " tnear=" << tnear << " tfar=" << tfar;
268  }
269  }
270  if ( ! parallel ) {
271  // survived all the tests
272  if ( tnear > 0.0 ) {
273  if ( tnear < tfar ) {
274  //LOG("GeomVolSel", pNOTICE) << "is hit case1 ";
275  intercept.fIsHit = true;
276  intercept.fSurfIn = surfNear;
277  intercept.fSurfOut = surfFar;
278  }
279  } else {
280  if ( tfar > 0.0 ) {
281  //LOG("GeomVolSel", pNOTICE) << "is hit case2 ";
282  intercept.fIsHit = true;
283  intercept.fSurfIn = -1;
284  intercept.fSurfOut = surfFar;
285  }
286  }
287  }
288  intercept.fDistIn = tnear;
289  intercept.fDistOut = tfar;
290  //LOG("GeomVolSel", pNOTICE) << " hit? " << (fIsHit?"true":"false")
291  // << " dist in " << fDistIn << " out " << fDistOut;
292  return intercept;
293 }
Int_t fSurfOut
what surface was hit on way in
Definition: FidShape.h:54
Double_t Vn(const TVector3 &raybase) const
Definition: FidShape.h:73
Bool_t fIsHit
distance along ray to exit fid volume
Definition: FidShape.h:52
string dir
Int_t fSurfIn
was the volume hit
Definition: FidShape.h:53
Double_t fDistOut
distance along ray to enter fid volume
Definition: FidShape.h:51
Bool_t IsValid() const
Definition: FidShape.h:77
std::vector< PlaneParam > fPolyFaces
Definition: FidShape.h:146
Double_t Vd(const TVector3 &raycos) const
Definition: FidShape.h:75
void FidPolyhedron::Print ( std::ostream &  stream) const
virtual

Implements genie::geometry::FidShape.

Definition at line 303 of file FidShape.cxx.

304 {
305  size_t nfaces = fPolyFaces.size();
306  stream << "FidPolyhedron n=" << nfaces;
307  for ( size_t i=0; i<nfaces; ++i) {
308  const PlaneParam& aface = fPolyFaces[i];
309  stream << std::endl << "[" << setw(2) << i << "]" << aface;
310  }
311 }
std::vector< PlaneParam > fPolyFaces
Definition: FidShape.h:146
void genie::geometry::FidPolyhedron::push_back ( const PlaneParam pln)
inline

Member Data Documentation

std::vector<PlaneParam> genie::geometry::FidPolyhedron::fPolyFaces
protected

Definition at line 146 of file FidShape.h.

Referenced by clear(), and push_back().


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