GENIEGenerator
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ROOTGeomAnalyzer.h
Go to the documentation of this file.
1 //____________________________________________________________________________
2 /*!
3 
4 \class genie::geometry::ROOTGeomAnalyzer
5 
6 \brief A ROOT/GEANT4 geometry driver
7 
8 \author Anselmo Meregaglia <anselmo.meregaglia \at cern.ch>
9  ETH Zurich
10 
11  Costas Andreopoulos <c.andreopoulos \at cern.ch>
12  University of Liverpool
13 
14  Robert Hatcher <rhatcher \at fnal.gov>
15  Fermilab
16 
17 \created May 24, 2005
18 
19 \cpright Copyright (c) 2003-2024, The GENIE Collaboration
20  For the full text of the license visit http://copyright.genie-mc.org
21 
22 */
23 //____________________________________________________________________________
24 
25 #ifndef _ROOT_GEOMETRY_ANALYZER_H_
26 #define _ROOT_GEOMETRY_ANALYZER_H_
27 
28 #include <string>
29 #include <algorithm>
30 
31 #include <TGeoManager.h>
32 #include <TVector3.h>
33 
36 
37 class TGeoVolume;
38 class TGeoMaterial;
39 class TGeoMixture;
40 class TGeoElement;
41 class TGeoHMatrix;
42 
43 using std::string;
44 
45 namespace genie {
46 
47 class GFluxI;
48 
49 namespace geometry {
50 
51 class PathSegmentList;
52 class GeomVolSelectorI;
53 
55 
56 public :
57  ROOTGeomAnalyzer(string geometry_filename);
58  ROOTGeomAnalyzer(TGeoManager * gm);
59  ROOTGeomAnalyzer() : GeomAnalyzerI() { ; } // used ONLY for derived class overloading
61 
62  /// implement the GeomAnalyzerI interface
63 
64  virtual const PDGCodeList & ListOfTargetNuclei (void);
65  virtual const PathLengthList & ComputeMaxPathLengths (void);
66 
67  virtual const PathLengthList & ComputePathLengths(const TLorentzVector & x,
68  const TLorentzVector & p);
69 
70  virtual std::vector< std::pair<double, const TGeoMaterial*> > ComputeMatLengths(const TLorentzVector & x,
71  const TLorentzVector & p);
72 
73  virtual const TVector3 & GenerateVertex(const TLorentzVector & x,
74  const TLorentzVector & p, int tgtpdg);
75 
76  virtual int GetTargetPdgCode (const TGeoMaterial * const m) const;
77  virtual int GetTargetPdgCode (const TGeoMixture * const m, int ielement) const;
78 
79  /// set geometry driver's configuration options
80 
81  virtual void SetScannerNPoints (int np) { fNPoints = np; } /* box scanner */
82  virtual void SetScannerNRays (int nr) { fNRays = nr; } /* box scanner */
83  virtual void SetScannerNParticles (int np) { fNParticles = np; } /* flux scanner */
84  virtual void SetScannerFlux (GFluxI* f) { fFlux = f; } /* flux scanner */
85  virtual void SetWeightWithDensity (bool wt) { fDensWeight = wt; }
86  virtual void SetMixtureWeightsSum (double sum);
87  virtual void SetLengthUnits (double lu);
88  virtual void SetDensityUnits (double du);
89  virtual void SetMaxPlSafetyFactor (double sf);
90  virtual void SetTopVolName (string nm);
91  virtual void SetKeepSegPath (bool keep) { fKeepSegPath = keep; }
92  virtual void SetDebugFlags (int flgs) { fDebugFlags = flgs; }
93 
94  /// retrieve geometry driver's configuration options
95 
96  virtual int ScannerNPoints (void) const { return fNPoints; }
97  virtual int ScannerNRays (void) const { return fNRays; }
98  virtual int ScannerNParticles (void) const { return fNParticles; }
99  virtual bool WeightWithDensity (void) const { return fDensWeight; }
100  virtual double LengthUnits (void) const { return fLengthScale; }
101  virtual double DensityUnits (void) const { return fDensityScale; }
102  virtual double MixtureWeightsSum (void) const { return fMixtWghtSum; }
103  virtual double MaxPlSafetyFactor (void) const { return fMaxPlSafetyFactor; }
104  virtual string TopVolName (void) const { return fTopVolumeName; }
105  virtual TGeoManager * GetGeometry (void) const { return fGeometry; }
106  virtual bool GetKeepSegPath (void) const { return fKeepSegPath; }
107  virtual const PathLengthList& GetMaxPathLengths(void) const { return *fCurrMaxPathLengthList; } // call only after ComputeMaxPathLengths() has been called
108 
109  /// access to geometry coordinate/unit transforms for validation/test purposes
110 
111  virtual void Local2SI (PathLengthList & pl) const;
112  virtual void Local2SI (TVector3 & v) const;
113  virtual void SI2Local (TVector3 & v) const;
114  virtual void Master2Top (TVector3 & v) const;
115  virtual void Master2TopDir (TVector3 & v) const;
116  virtual void Top2Master (TVector3 & v) const;
117  virtual void Top2MasterDir (TVector3 & v) const;
118 
119  /// configure processing to perform path segment trimming
120 
121  virtual GeomVolSelectorI* AdoptGeomVolSelector (GeomVolSelectorI* selector) /// take ownership, return old
122  { std::swap(selector,fGeomVolSelector); return selector; }
123 
124 
125 protected:
126 
127  virtual void Initialize (void);
128  virtual void CleanUp (void);
129  virtual void Load (string geometry_filename);
130  virtual void Load (TGeoManager * gm);
131  virtual void BuildListOfTargetNuclei (void);
132 
133  virtual double GetWeight (const TGeoMaterial * mat, int pdgc);
134  virtual double GetWeight (const TGeoMixture * mixt, int pdgc);
135  virtual double GetWeight (const TGeoMixture * mixt, int ielement, int pdgc);
136 
137  virtual void MaxPathLengthsFluxMethod(void);
138  virtual void MaxPathLengthsBoxMethod (void);
139  virtual bool GenBoxRay (int indx, TLorentzVector& x4, TLorentzVector& p4);
140 
141  virtual double ComputePathLengthPDG (const TVector3 & r, const TVector3 & udir, int pdgc);
142  virtual void SwimOnce (const TVector3 & r, const TVector3 & udir);
143 
144  virtual bool FindMaterialInCurrentVol(int pdgc);
145  virtual bool WillNeverEnter (double step);
146  virtual double StepToNextBoundary (void);
147  virtual double Step (void);
148  virtual double StepUntilEntering (void);
149 
150 
151 
152  int fMaterial; ///< input selected material for vertex generation
153  TGeoManager * fGeometry; ///< input detector geometry
154  string fTopVolumeName; ///< input top vol [other than TGeoManager::GetTopVolume()]
155  int fNPoints; ///< max path length scanner (box method): points/surface [def:200]
156  int fNRays; ///< max path length scanner (box method): rays/point [def:200]
157  int fNParticles; ///< max path length scanner (flux method): particles in [def:10000]
158  GFluxI * fFlux; ///< a flux objects that can be used to scan the max path lengths
159  bool fDensWeight; ///< if true pathlengths are weighted with density [def:true]
160  double fLengthScale; ///< conversion factor: input geometry length units -> meters
161  double fDensityScale; ///< conversion factor: input geometry density units -> kgr/meters^3
162  double fMaxPlSafetyFactor; ///< factor that can multiply the computed max path lengths
163  double fMixtWghtSum; ///< norm of relative weights (<0 if explicit summing required)
164  TVector3 * fCurrVertex; ///< current generated vertex
165  PathLengthList * fCurrPathLengthList; ///< current list of path-lengths
166  PathLengthList * fCurrMaxPathLengthList; ///< current list of max path-lengths
167  PDGCodeList * fCurrPDGCodeList; ///< current list of target nuclei
168  TGeoVolume * fTopVolume; ///< top volume
169  TGeoHMatrix * fMasterToTop; ///< matrix connecting master coordinates to top volume coordinates
170  bool fMasterToTopIsIdentity; ///< is fMasterToTop matrix the identity matrix?
171 
172  bool fKeepSegPath; ///< need to fill path segment "path"
173  PathSegmentList* fCurrPathSegmentList; ///< current list of path-segments
174  GeomVolSelectorI* fGeomVolSelector; ///< optional path seg trimmer (owned)
175 
176  // used by GenBoxRay to retain history between calls
177  TVector3 fGenBoxRayPos;
178  TVector3 fGenBoxRayDir;
180  bool fnewpnt;
181  double fdx, fdy, fdz, fox, foy, foz; ///< top vol size/origin (top vol units)
182 
183  // test purposes
184  double fmxddist, fmxdstep; ///< max errors in pathsegmentlist
186 
187 };
188 
189 } // geometry namespace
190 } // genie namespace
191 
192 #endif // _ROOT_GEOMETRY_ANALYZER_H_
virtual int ScannerNParticles(void) const
virtual void SetMaxPlSafetyFactor(double sf)
TGeoManager * fGeometry
input detector geometry
virtual GeomVolSelectorI * AdoptGeomVolSelector(GeomVolSelectorI *selector)
configure processing to perform path segment trimming
virtual double GetWeight(const TGeoMaterial *mat, int pdgc)
virtual bool WeightWithDensity(void) const
virtual const PathLengthList & ComputeMaxPathLengths(void)
virtual void SetDebugFlags(int flgs)
bool fDensWeight
if true pathlengths are weighted with density [def:true]
virtual const PathLengthList & GetMaxPathLengths(void) const
GFluxI * fFlux
a flux objects that can be used to scan the max path lengths
virtual void Top2Master(TVector3 &v) const
double fLengthScale
conversion factor: input geometry length units -&gt; meters
Object to be filled with the neutrino path-segments representing geometry volume steps (generally bou...
virtual int ScannerNPoints(void) const
retrieve geometry driver&#39;s configuration options
int fNRays
max path length scanner (box method): rays/point [def:200]
TVector3 * fCurrVertex
current generated vertex
double fMaxPlSafetyFactor
factor that can multiply the computed max path lengths
GENIE Interface for user-defined volume selector functors.
virtual void SetScannerNParticles(int np)
string fTopVolumeName
input top vol [other than TGeoManager::GetTopVolume()]
virtual void SetDensityUnits(double du)
virtual const PDGCodeList & ListOfTargetNuclei(void)
implement the GeomAnalyzerI interface
virtual bool FindMaterialInCurrentVol(int pdgc)
A list of PDG codes.
Definition: PDGCodeList.h:32
virtual double MixtureWeightsSum(void) const
virtual const PathLengthList & ComputePathLengths(const TLorentzVector &x, const TLorentzVector &p)
int fMaterial
input selected material for vertex generation
Object to be filled with the neutrino path-length, for all detector geometry materials, when starting from a position x and travelling along the direction of the neutrino 4-momentum.
virtual int GetTargetPdgCode(const TGeoMaterial *const m) const
double foz
top vol size/origin (top vol units)
double fDensityScale
conversion factor: input geometry density units -&gt; kgr/meters^3
int fNPoints
max path length scanner (box method): points/surface [def:200]
virtual bool GenBoxRay(int indx, TLorentzVector &x4, TLorentzVector &p4)
virtual double LengthUnits(void) const
virtual void SetScannerNRays(int nr)
PDGCodeList * fCurrPDGCodeList
current list of target nuclei
virtual void SetWeightWithDensity(bool wt)
PathSegmentList * fCurrPathSegmentList
current list of path-segments
PathLengthList * fCurrMaxPathLengthList
current list of max path-lengths
A ROOT/GEANT4 geometry driver.
virtual void Load(string geometry_filename)
virtual double ComputePathLengthPDG(const TVector3 &r, const TVector3 &udir, int pdgc)
virtual void Local2SI(PathLengthList &pl) const
access to geometry coordinate/unit transforms for validation/test purposes
GeomVolSelectorI * fGeomVolSelector
optional path seg trimmer (owned)
double fmxdstep
max errors in pathsegmentlist
virtual double DensityUnits(void) const
virtual void Master2TopDir(TVector3 &v) const
virtual string TopVolName(void) const
virtual const TVector3 & GenerateVertex(const TLorentzVector &x, const TLorentzVector &p, int tgtpdg)
PathLengthList * fCurrPathLengthList
current list of path-lengths
virtual void SetTopVolName(string nm)
virtual bool GetKeepSegPath(void) const
TGeoHMatrix * fMasterToTop
matrix connecting master coordinates to top volume coordinates
bool fMasterToTopIsIdentity
is fMasterToTop matrix the identity matrix?
int fNParticles
max path length scanner (flux method): particles in [def:10000]
virtual void SetScannerNPoints(int np)
set geometry driver&#39;s configuration options
virtual void SetKeepSegPath(bool keep)
virtual void SetScannerFlux(GFluxI *f)
virtual void SetMixtureWeightsSum(double sum)
TGeoVolume * fTopVolume
top volume
virtual double MaxPlSafetyFactor(void) const
virtual void SetLengthUnits(double lu)
virtual void Top2MasterDir(TVector3 &v) const
double fMixtWghtSum
norm of relative weights (&lt;0 if explicit summing required)
Defines the GENIE Geometry Analyzer Interface.
Definition: GeomAnalyzerI.h:29
virtual void SI2Local(TVector3 &v) const
bool fKeepSegPath
need to fill path segment &quot;path&quot;
static constexpr double m
Definition: Units.h:71
virtual void SwimOnce(const TVector3 &r, const TVector3 &udir)
virtual void Master2Top(TVector3 &v) const
virtual TGeoManager * GetGeometry(void) const
virtual std::vector< std::pair< double, const TGeoMaterial * > > ComputeMatLengths(const TLorentzVector &x, const TLorentzVector &p)
virtual int ScannerNRays(void) const
virtual bool WillNeverEnter(double step)
GENIE Interface for user-defined flux classes.
Definition: GFluxI.h:29