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 <constantinos.andreopoulos \at cern.ch>
12  University of Liverpool & STFC Rutherford Appleton Laboratory
13 
14  Robert Hatcher <rhatcher \at fnal.gov>
15  Fermilab
16 
17 \created May 24, 2005
18 
19 \cpright Copyright (c) 2003-2020, 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  virtual const TVector3 & GenerateVertex(const TLorentzVector & x,
70  const TLorentzVector & p, int tgtpdg);
71 
72  /// set geometry driver's configuration options
73 
74  virtual void SetScannerNPoints (int np) { fNPoints = np; } /* box scanner */
75  virtual void SetScannerNRays (int nr) { fNRays = nr; } /* box scanner */
76  virtual void SetScannerNParticles (int np) { fNParticles = np; } /* flux scanner */
77  virtual void SetScannerFlux (GFluxI* f) { fFlux = f; } /* flux scanner */
78  virtual void SetWeightWithDensity (bool wt) { fDensWeight = wt; }
79  virtual void SetMixtureWeightsSum (double sum);
80  virtual void SetLengthUnits (double lu);
81  virtual void SetDensityUnits (double du);
82  virtual void SetMaxPlSafetyFactor (double sf);
83  virtual void SetTopVolName (string nm);
84  virtual void SetKeepSegPath (bool keep) { fKeepSegPath = keep; }
85  virtual void SetDebugFlags (int flgs) { fDebugFlags = flgs; }
86 
87  /// retrieve geometry driver's configuration options
88 
89  virtual int ScannerNPoints (void) const { return fNPoints; }
90  virtual int ScannerNRays (void) const { return fNRays; }
91  virtual int ScannerNParticles (void) const { return fNParticles; }
92  virtual bool WeightWithDensity (void) const { return fDensWeight; }
93  virtual double LengthUnits (void) const { return fLengthScale; }
94  virtual double DensityUnits (void) const { return fDensityScale; }
95  virtual double MixtureWeightsSum (void) const { return fMixtWghtSum; }
96  virtual double MaxPlSafetyFactor (void) const { return fMaxPlSafetyFactor; }
97  virtual string TopVolName (void) const { return fTopVolumeName; }
98  virtual TGeoManager * GetGeometry (void) const { return fGeometry; }
99  virtual bool GetKeepSegPath (void) const { return fKeepSegPath; }
100  virtual const PathLengthList& GetMaxPathLengths(void) const { return *fCurrMaxPathLengthList; } // call only after ComputeMaxPathLengths() has been called
101 
102  /// access to geometry coordinate/unit transforms for validation/test purposes
103 
104  virtual void Local2SI (PathLengthList & pl) const;
105  virtual void Local2SI (TVector3 & v) const;
106  virtual void SI2Local (TVector3 & v) const;
107  virtual void Master2Top (TVector3 & v) const;
108  virtual void Master2TopDir (TVector3 & v) const;
109  virtual void Top2Master (TVector3 & v) const;
110  virtual void Top2MasterDir (TVector3 & v) const;
111 
112  /// configure processing to perform path segment trimming
113 
114  virtual GeomVolSelectorI* AdoptGeomVolSelector (GeomVolSelectorI* selector) /// take ownership, return old
115  { std::swap(selector,fGeomVolSelector); return selector; }
116 
117 
118 protected:
119 
120  virtual void Initialize (void);
121  virtual void CleanUp (void);
122  virtual void Load (string geometry_filename);
123  virtual void Load (TGeoManager * gm);
124  virtual void BuildListOfTargetNuclei (void);
125 
126  virtual int GetTargetPdgCode (const TGeoMaterial * const m) const;
127  virtual int GetTargetPdgCode (const TGeoMixture * const m, int ielement) const;
128  virtual double GetWeight (const TGeoMaterial * mat, int pdgc);
129  virtual double GetWeight (const TGeoMixture * mixt, int pdgc);
130  virtual double GetWeight (const TGeoMixture * mixt, int ielement, int pdgc);
131 
132  virtual void MaxPathLengthsFluxMethod(void);
133  virtual void MaxPathLengthsBoxMethod (void);
134  virtual bool GenBoxRay (int indx, TLorentzVector& x4, TLorentzVector& p4);
135 
136  virtual double ComputePathLengthPDG (const TVector3 & r, const TVector3 & udir, int pdgc);
137  virtual void SwimOnce (const TVector3 & r, const TVector3 & udir);
138 
139  virtual bool FindMaterialInCurrentVol(int pdgc);
140  virtual bool WillNeverEnter (double step);
141  virtual double StepToNextBoundary (void);
142  virtual double Step (void);
143  virtual double StepUntilEntering (void);
144 
145 
146 
147  int fMaterial; ///< input selected material for vertex generation
148  TGeoManager * fGeometry; ///< input detector geometry
149  string fTopVolumeName; ///< input top vol [other than TGeoManager::GetTopVolume()]
150  int fNPoints; ///< max path length scanner (box method): points/surface [def:200]
151  int fNRays; ///< max path length scanner (box method): rays/point [def:200]
152  int fNParticles; ///< max path length scanner (flux method): particles in [def:10000]
153  GFluxI * fFlux; ///< a flux objects that can be used to scan the max path lengths
154  bool fDensWeight; ///< if true pathlengths are weighted with density [def:true]
155  double fLengthScale; ///< conversion factor: input geometry length units -> meters
156  double fDensityScale; ///< conversion factor: input geometry density units -> kgr/meters^3
157  double fMaxPlSafetyFactor; ///< factor that can multiply the computed max path lengths
158  double fMixtWghtSum; ///< norm of relative weights (<0 if explicit summing required)
159  TVector3 * fCurrVertex; ///< current generated vertex
160  PathLengthList * fCurrPathLengthList; ///< current list of path-lengths
161  PathLengthList * fCurrMaxPathLengthList; ///< current list of max path-lengths
162  PDGCodeList * fCurrPDGCodeList; ///< current list of target nuclei
163  TGeoVolume * fTopVolume; ///< top volume
164  TGeoHMatrix * fMasterToTop; ///< matrix connecting master coordinates to top volume coordinates
165  bool fMasterToTopIsIdentity; ///< is fMasterToTop matrix the identity matrix?
166 
167  bool fKeepSegPath; ///< need to fill path segment "path"
168  PathSegmentList* fCurrPathSegmentList; ///< current list of path-segments
169  GeomVolSelectorI* fGeomVolSelector; ///< optional path seg trimmer (owned)
170 
171  // used by GenBoxRay to retain history between calls
172  TVector3 fGenBoxRayPos;
173  TVector3 fGenBoxRayDir;
175  bool fnewpnt;
176  double fdx, fdy, fdz, fox, foy, foz; ///< top vol size/origin (top vol units)
177 
178  // test purposes
179  double fmxddist, fmxdstep; ///< max errors in pathsegmentlist
181 
182 };
183 
184 } // geometry namespace
185 } // genie namespace
186 
187 #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)
THE MAIN GENIE PROJECT NAMESPACE
Definition: AlgCmp.h:25
virtual void SetDebugFlags(int flgs)
std::string string
Definition: nybbler.cc:12
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 -> 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 -> kgr/meters^3
int fNPoints
max path length scanner (box method): points/surface [def:200]
void swap(Handle< T > &a, Handle< T > &b)
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
p
Definition: test.py:223
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
list x
Definition: train.py:276
virtual double MaxPlSafetyFactor(void) const
virtual void SetLengthUnits(double lu)
virtual void Top2MasterDir(TVector3 &v) const
double fMixtWghtSum
norm of relative weights (<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 "path"
virtual void SwimOnce(const TVector3 &r, const TVector3 &udir)
virtual void Master2Top(TVector3 &v) const
virtual TGeoManager * GetGeometry(void) const
virtual int ScannerNRays(void) const
virtual bool WillNeverEnter(double step)
GENIE Interface for user-defined flux classes.
Definition: GFluxI.h:29