GENIEGenerator
Loading...
Searching...
No Matches
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-2025, 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>
38class TGeoVolume;
39class TGeoMedium;
40class TGeoMaterial;
41
42using std::vector;
43using std::ostream;
44using std::string;
45using std::pair;
46
47namespace genie {
48namespace geometry {
49
50class PathSegment;
51ostream & operator << (ostream & stream, const PathSegment & list);
52
53typedef std::pair<Double_t,Double_t> StepRange;
54typedef std::vector<StepRange> StepRangeSet;
55
57
58 public:
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
116inline bool operator < (const PathSegment &lhs, const PathSegment &rhs)
117 { return ( lhs.fRayDist < rhs.fRayDist ); }
118
119
120class PathSegmentList;
121ostream & operator << (ostream & stream, const PathSegmentList & list);
122
124
125public :
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_
string dir
Object to be filled with the neutrino path-segments representing geometry volume steps (generally bou...
TVector3 fDirection
direction (in top vol coords)
void Print(ostream &stream) const
std::map< const TGeoMaterial *, Double_t > MaterialMap_t
void SetDoCrossCheck(bool doit=true)
void SetPrintVerbose(bool doit=true)
void Copy(const PathSegmentList &plist)
PathSegmentList & operator=(const PathSegmentList &list)
const TVector3 & GetDirection() const
const TVector3 & GetStartPos() const
bool IsSameStart(const TVector3 &pos, const TVector3 &dir) const
PathSegmentV_t fSegmentList
Actual list of segments.
const MaterialMap_t & GetMatStepSumMap(void) const
friend ostream & operator<<(ostream &stream, const PathSegmentList &list)
const PathSegmentV_t & GetPathSegmentV(void) const
TVector3 fStartPos
Record, for future comparison, the path taken.
void SetStartInfo(const TVector3 &pos=TVector3(0, 0, 1e37), const TVector3 &dir=TVector3(0, 0, 0))
MaterialMap_t fMatStepSum
Segment list re-evaluated by material for fast lookup of path lengths.
void AddSegment(const PathSegment &ps)
std::list< PathSegment > PathSegmentV_t
PathSegmentV_t::const_iterator PathSegVCItr_t
void CrossCheck(double &mxddist, double &mxdstep) const
MaterialMap_t::const_iterator MaterialMapCItr_t
TVector3 GetPosition(Double_t frac) const
calculate position within allowed ranges passed on fraction of total
const TGeoMaterial * fMaterial
ref only ptr to TGeoMaterial
TVector3 fEnter
top vol coordinates and units
void SetEnter(const TVector3 &p3enter, double raydist)
point of entry to geometry element
void SetExit(const TVector3 &p3exit)
point of exit from geometry element
void SetExit(const Double_t *p3exit)
void SetGeo(const TGeoVolume *gvol, const TGeoMedium *gmed, const TGeoMaterial *gmat)
info about the geometry element
void SetEnter(const Double_t *p3enter, double raydist)
void DoCrossCheck(const TVector3 &startpos, double &ddist, double &dstep) const
perform cross check on segment, return differences
friend ostream & operator<<(ostream &stream, const PathSegment &list)
void SetStep(Double_t step, bool setlimits=true)
step taken in the geometry element
StepRangeSet fStepRangeSet
collection of {steplo,stephi} pairs
void Print(ostream &stream) const
std::string fPathString
full path names
Double_t GetSummedStepRange() const
get the sum of all the step range (in case step has been trimmed or split)
TVector3 fExit
top vol coordinates and units
const TGeoVolume * fVolume
ref only ptr to TGeoVolume
Double_t fStepLength
total step size in volume
void SetPath(const char *path)
friend bool operator<(const PathSegment &lhs, const PathSegment &rhs)
const TGeoMedium * fMedium
ref only ptr to TGeoMedium
Double_t fRayDist
distance from start of ray
std::pair< Double_t, Double_t > StepRange
std::vector< StepRange > StepRangeSet
std::ostream & operator<<(std::ostream &stream, const genie::geometry::PlaneParam &pparam)
Definition FidShape.cxx:22
bool operator<(const PathSegment &lhs, const PathSegment &rhs)
THE MAIN GENIE PROJECT NAMESPACE
Definition AlgCmp.h:25