GENIEGenerator
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PathSegmentList.h
Go to the documentation of this file.
1 //____________________________________________________________________________
2 /*!
3 
4 \class genie::geometry::PathSegmentList
5 
6 \brief Object to be filled with the neutrino path-segments representing
7  geometry volume steps (generally boundary-to-boundary) along with
8  geometry materials. Good for a single starting position and
9  travelling along the direction of the neutrino 4-momentum.
10 
11 \author Robert Hatcher <rhatcher@fnal.gov>
12  FNAL
13 
14 \created May 26, 2009
15 
16 \cpright Copyright (c) 2003-2024, The GENIE Collaboration
17  For the full text of the license visit http://copyright.genie-mc.org
18 */
19 //____________________________________________________________________________
20 
21 #ifndef _PATH_SEGMENT_LIST_H_
22 #define _PATH_SEGMENT_LIST_H_
23 
24 /// --- for test purposes allow compilation of class without string member
25 /// fetching/keeping the geometry path seems to add a significant (2x)
26 /// overhead to swimming through the geometry.
27 #define PATHSEG_KEEP_PATH
28 //#undef PATHSEG_KEEP_PATH
29 
30 #include <utility> // for pair<>
31 #include <vector>
32 #include <list>
33 #include <ostream>
34 #include <string>
35 #include <map>
36 
37 #include <TVector3.h>
38 class TGeoVolume;
39 class TGeoMedium;
40 class TGeoMaterial;
41 
42 using std::vector;
43 using std::ostream;
44 using std::string;
45 using std::pair;
46 
47 namespace genie {
48 namespace geometry {
49 
50 class PathSegment;
51 ostream & operator << (ostream & stream, const PathSegment & list);
52 
53 typedef std::pair<Double_t,Double_t> StepRange;
54 typedef std::vector<StepRange> StepRangeSet;
55 
56 class PathSegment {
57 
58  public:
59  PathSegment();
60  ~PathSegment() { ; }
61 
62  /// point of entry to geometry element
63  void SetEnter(const TVector3 & p3enter, double raydist)
64  { fEnter = p3enter; fRayDist = raydist; }
65  void SetEnter(const Double_t * p3enter, double raydist)
66  { fEnter.SetXYZ(p3enter[0],p3enter[1],p3enter[2]); fRayDist = raydist; }
67 
68  /// point of exit from geometry element
69  void SetExit(const TVector3 & p3exit) { fExit = p3exit; }
70  void SetExit(const Double_t * p3exit)
71  { fExit.SetXYZ(p3exit[0],p3exit[1],p3exit[2]); }
72 
73  /// info about the geometry element
74  void SetGeo(const TGeoVolume * gvol, const TGeoMedium * gmed,
75  const TGeoMaterial * gmat)
76  { fVolume = gvol; fMedium = gmed; fMaterial = gmat; }
77 #ifdef PATHSEG_KEEP_PATH
78  void SetPath(const char* path) { fPathString = path; }
79 #endif
80 
81  /// step taken in the geometry element
82  void SetStep(Double_t step, bool setlimits = true );
83 
84  bool IsTrimmedEmpty() const { return fStepRangeSet.empty(); }
85 
86  /// get the sum of all the step range (in case step has been trimmed or split)
87  Double_t GetSummedStepRange() const;
88 
89  /// calculate position within allowed ranges passed on fraction of total
90  TVector3 GetPosition(Double_t frac) const;
91 
92  /// perform cross check on segment, return differences
93  void DoCrossCheck(const TVector3& startpos, double& ddist, double& dstep) const;
94 
95  //void Copy (const PathSegment & ps);
96  //PathSegment& operator = (const PathSegment & ps);
97 
98  void Print (ostream & stream) const;
99  friend ostream & operator << (ostream & stream, const PathSegment & list);
100  friend bool operator < (const PathSegment &lhs, const PathSegment &rhs);
101 
102 
103  Double_t fRayDist; ///< distance from start of ray
104  Double_t fStepLength; ///< total step size in volume
105  const TGeoVolume * fVolume; ///< ref only ptr to TGeoVolume
106  const TGeoMedium * fMedium; ///< ref only ptr to TGeoMedium
107  const TGeoMaterial * fMaterial; ///< ref only ptr to TGeoMaterial
108  TVector3 fEnter; ///< top vol coordinates and units
109  TVector3 fExit; ///< top vol coordinates and units
110 #ifdef PATHSEG_KEEP_PATH
111  std::string fPathString; ///< full path names
112 #endif
113  StepRangeSet fStepRangeSet; ///< collection of {steplo,stephi} pairs
114 };
115 
116 inline bool operator < (const PathSegment &lhs, const PathSegment &rhs)
117  { return ( lhs.fRayDist < rhs.fRayDist ); }
118 
119 
120 class PathSegmentList;
121 ostream & operator << (ostream & stream, const PathSegmentList & list);
122 
124 
125 public :
126  PathSegmentList();
127  PathSegmentList(const PathSegmentList & plist);
129 
130  void SetDoCrossCheck (bool doit = true) { fDoCrossCheck = doit; }
131  void SetPrintVerbose (bool doit = true) { fPrintVerbose = doit; }
132  void SetAllToZero (void);
133  void SetStartInfo (const TVector3& pos = TVector3(0,0,1e37),
134  const TVector3& dir = TVector3(0,0,0) );
135  bool IsSameStart (const TVector3& pos, const TVector3& dir) const;
136  void AddSegment (const PathSegment& ps) { fSegmentList.push_back(ps); }
137 
138  const TVector3& GetDirection() const { return fDirection; }
139  const TVector3& GetStartPos() const { return fStartPos; }
140 
141  typedef std::list<PathSegment> PathSegmentV_t;
142  typedef PathSegmentV_t::const_iterator PathSegVCItr_t;
143 
144  const PathSegmentV_t& GetPathSegmentV (void) const { return fSegmentList; }
145  size_t size(void) const { return fSegmentList.size(); }
146 
147  typedef std::map<const TGeoMaterial*,Double_t> MaterialMap_t;
148  typedef MaterialMap_t::const_iterator MaterialMapCItr_t;
149 
150  void FillMatStepSum (void);
151  const MaterialMap_t& GetMatStepSumMap (void) const { return fMatStepSum; };
152 
153  void CrossCheck(double& mxddist, double& mxdstep) const;
154 
155 #ifdef UNNEEDED_SEGFUNCS
156  // XmlParserStatus_t LoadFromXml (string filename);
157  // void SaveAsXml (string filename) const;
158 #endif
159 
160  void Copy (const PathSegmentList & plist);
162 
163  void Print (ostream & stream) const;
164  friend ostream & operator << (ostream & stream, const PathSegmentList & list);
165 
166  protected:
167 
168  /// Record, for future comparison, the path taken
169  TVector3 fStartPos; ///< starting position (in top vol coords)
170  TVector3 fDirection; ///< direction (in top vol coords)
171 
172  /// Actual list of segments
174 
175  /// Segment list re-evaluated by material for fast lookup of path lengths
177 
180 
181 };
182 
183 } // geometry namespace
184 } // genie namespace
185 
186 #endif // _PATH_SEGMENT_LIST_H_
void SetEnter(const TVector3 &p3enter, double raydist)
point of entry to geometry element
bool operator<(const PathSegment &lhs, const PathSegment &rhs)
const TVector3 & GetStartPos() const
void SetPrintVerbose(bool doit=true)
PathSegmentV_t fSegmentList
Actual list of segments.
std::vector< StepRange > StepRangeSet
void CrossCheck(double &mxddist, double &mxdstep) const
MaterialMap_t fMatStepSum
Segment list re-evaluated by material for fast lookup of path lengths.
void SetPath(const char *path)
StepRangeSet fStepRangeSet
collection of {steplo,stephi} pairs
TVector3 fEnter
top vol coordinates and units
TVector3 fStartPos
Record, for future comparison, the path taken.
void SetEnter(const Double_t *p3enter, double raydist)
void AddSegment(const PathSegment &ps)
friend ostream & operator<<(ostream &stream, const PathSegment &list)
Object to be filled with the neutrino path-segments representing geometry volume steps (generally bou...
const TVector3 & GetDirection() const
string dir
bool IsSameStart(const TVector3 &pos, const TVector3 &dir) const
void SetStep(Double_t step, bool setlimits=true)
step taken in the geometry element
const TGeoMaterial * fMaterial
ref only ptr to TGeoMaterial
PathSegmentV_t::const_iterator PathSegVCItr_t
void Print(ostream &stream) const
TVector3 fDirection
direction (in top vol coords)
const TGeoVolume * fVolume
ref only ptr to TGeoVolume
TVector3 fExit
top vol coordinates and units
const TGeoMedium * fMedium
ref only ptr to TGeoMedium
void Copy(const PathSegmentList &plist)
void SetStartInfo(const TVector3 &pos=TVector3(0, 0, 1e37), const TVector3 &dir=TVector3(0, 0, 0))
Double_t GetSummedStepRange() const
get the sum of all the step range (in case step has been trimmed or split)
std::pair< Double_t, Double_t > StepRange
static constexpr double ps
Definition: Units.h:99
const PathSegmentV_t & GetPathSegmentV(void) const
MaterialMap_t::const_iterator MaterialMapCItr_t
Double_t fRayDist
distance from start of ray
friend bool operator<(const PathSegment &lhs, const PathSegment &rhs)
void SetDoCrossCheck(bool doit=true)
void SetGeo(const TGeoVolume *gvol, const TGeoMedium *gmed, const TGeoMaterial *gmat)
info about the geometry element
std::map< const TGeoMaterial *, Double_t > MaterialMap_t
TVector3 GetPosition(Double_t frac) const
calculate position within allowed ranges passed on fraction of total
void Print(ostream &stream) const
const MaterialMap_t & GetMatStepSumMap(void) const
void SetExit(const Double_t *p3exit)
friend ostream & operator<<(ostream &stream, const PathSegmentList &list)
PathSegmentList & operator=(const PathSegmentList &list)
void SetExit(const TVector3 &p3exit)
point of exit from geometry element
void DoCrossCheck(const TVector3 &startpos, double &ddist, double &dstep) const
perform cross check on segment, return differences
std::list< PathSegment > PathSegmentV_t
std::ostream & operator<<(std::ostream &stream, const genie::geometry::PlaneParam &pparam)
Definition: FidShape.cxx:22
Double_t fStepLength
total step size in volume
std::string fPathString
full path names