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>, ETH Zurich
9  Costas Andreopoulos <costas.andreopoulos \at stfc.ac.uk>, STFC, Rutherford Lab
10  Robert Hatcher <rhatcher \at fnal.gov>, Fermilab
11 
12 \created May 24, 2005
13 
14 \cpright Copyright (c) 2003-2019, The GENIE Collaboration
15  For the full text of the license visit http://copyright.genie-mc.org
16  or see $GENIE/LICENSE
17 */
18 //____________________________________________________________________________
19 
20 #ifndef _ROOT_GEOMETRY_ANALYZER_H_
21 #define _ROOT_GEOMETRY_ANALYZER_H_
22 
23 #include <string>
24 #include <algorithm>
25 
26 #include <TGeoManager.h>
27 #include <TVector3.h>
28 
31 
32 class TGeoVolume;
33 class TGeoMaterial;
34 class TGeoMixture;
35 class TGeoElement;
36 class TGeoHMatrix;
37 
38 using std::string;
39 
40 namespace genie {
41 
42 class GFluxI;
43 
44 namespace geometry {
45 
46 class PathSegmentList;
47 class GeomVolSelectorI;
48 
50 
51 public :
52  ROOTGeomAnalyzer(string geometry_filename);
53  ROOTGeomAnalyzer(TGeoManager * gm);
54  ROOTGeomAnalyzer() : GeomAnalyzerI() { ; } // used ONLY for derived class overloading
56 
57  /// implement the GeomAnalyzerI interface
58 
59  virtual const PDGCodeList & ListOfTargetNuclei (void);
60  virtual const PathLengthList & ComputeMaxPathLengths (void);
61 
62  virtual const PathLengthList & ComputePathLengths(const TLorentzVector & x,
63  const TLorentzVector & p);
64  virtual const TVector3 & GenerateVertex(const TLorentzVector & x,
65  const TLorentzVector & p, int tgtpdg);
66 
67  /// set geometry driver's configuration options
68 
69  virtual void SetScannerNPoints (int np) { fNPoints = np; } /* box scanner */
70  virtual void SetScannerNRays (int nr) { fNRays = nr; } /* box scanner */
71  virtual void SetScannerNParticles (int np) { fNParticles = np; } /* flux scanner */
72  virtual void SetScannerFlux (GFluxI* f) { fFlux = f; } /* flux scanner */
73  virtual void SetWeightWithDensity (bool wt) { fDensWeight = wt; }
74  virtual void SetMixtureWeightsSum (double sum);
75  virtual void SetLengthUnits (double lu);
76  virtual void SetDensityUnits (double du);
77  virtual void SetMaxPlSafetyFactor (double sf);
78  virtual void SetTopVolName (string nm);
79  virtual void SetKeepSegPath (bool keep) { fKeepSegPath = keep; }
80  virtual void SetDebugFlags (int flgs) { fDebugFlags = flgs; }
81 
82  /// retrieve geometry driver's configuration options
83 
84  virtual int ScannerNPoints (void) const { return fNPoints; }
85  virtual int ScannerNRays (void) const { return fNRays; }
86  virtual int ScannerNParticles (void) const { return fNParticles; }
87  virtual bool WeightWithDensity (void) const { return fDensWeight; }
88  virtual double LengthUnits (void) const { return fLengthScale; }
89  virtual double DensityUnits (void) const { return fDensityScale; }
90  virtual double MixtureWeightsSum (void) const { return fMixtWghtSum; }
91  virtual double MaxPlSafetyFactor (void) const { return fMaxPlSafetyFactor; }
92  virtual string TopVolName (void) const { return fTopVolumeName; }
93  virtual TGeoManager * GetGeometry (void) const { return fGeometry; }
94  virtual bool GetKeepSegPath (void) const { return fKeepSegPath; }
95  virtual const PathLengthList& GetMaxPathLengths(void) const { return *fCurrMaxPathLengthList; } // call only after ComputeMaxPathLengths() has been called
96 
97  /// access to geometry coordinate/unit transforms for validation/test purposes
98 
99  virtual void Local2SI (PathLengthList & pl) const;
100  virtual void Local2SI (TVector3 & v) const;
101  virtual void SI2Local (TVector3 & v) const;
102  virtual void Master2Top (TVector3 & v) const;
103  virtual void Master2TopDir (TVector3 & v) const;
104  virtual void Top2Master (TVector3 & v) const;
105  virtual void Top2MasterDir (TVector3 & v) const;
106 
107  /// configure processing to perform path segment trimming
108 
109  virtual GeomVolSelectorI* AdoptGeomVolSelector (GeomVolSelectorI* selector) /// take ownership, return old
110  { std::swap(selector,fGeomVolSelector); return selector; }
111 
112 
113 protected:
114 
115  virtual void Initialize (void);
116  virtual void CleanUp (void);
117  virtual void Load (string geometry_filename);
118  virtual void Load (TGeoManager * gm);
119  virtual void BuildListOfTargetNuclei (void);
120 
121  virtual int GetTargetPdgCode (const TGeoMaterial * const m) const;
122  virtual int GetTargetPdgCode (const TGeoMixture * const m, int ielement) const;
123  virtual double GetWeight (const TGeoMaterial * mat, int pdgc);
124  virtual double GetWeight (const TGeoMixture * mixt, int pdgc);
125  virtual double GetWeight (const TGeoMixture * mixt, int ielement, int pdgc);
126 
127  virtual void MaxPathLengthsFluxMethod(void);
128  virtual void MaxPathLengthsBoxMethod (void);
129  virtual bool GenBoxRay (int indx, TLorentzVector& x4, TLorentzVector& p4);
130 
131  virtual double ComputePathLengthPDG (const TVector3 & r, const TVector3 & udir, int pdgc);
132  virtual void SwimOnce (const TVector3 & r, const TVector3 & udir);
133 
134  virtual bool FindMaterialInCurrentVol(int pdgc);
135  virtual bool WillNeverEnter (double step);
136  virtual double StepToNextBoundary (void);
137  virtual double Step (void);
138  virtual double StepUntilEntering (void);
139 
140 
141 
142  int fMaterial; ///< input selected material for vertex generation
143  TGeoManager * fGeometry; ///< input detector geometry
144  string fTopVolumeName; ///< input top vol [other than TGeoManager::GetTopVolume()]
145  int fNPoints; ///< max path length scanner (box method): points/surface [def:200]
146  int fNRays; ///< max path length scanner (box method): rays/point [def:200]
147  int fNParticles; ///< max path length scanner (flux method): particles in [def:10000]
148  GFluxI * fFlux; ///< a flux objects that can be used to scan the max path lengths
149  bool fDensWeight; ///< if true pathlengths are weighted with density [def:true]
150  double fLengthScale; ///< conversion factor: input geometry length units -> meters
151  double fDensityScale; ///< conversion factor: input geometry density units -> kgr/meters^3
152  double fMaxPlSafetyFactor; ///< factor that can multiply the computed max path lengths
153  double fMixtWghtSum; ///< norm of relative weights (<0 if explicit summing required)
154  TVector3 * fCurrVertex; ///< current generated vertex
155  PathLengthList * fCurrPathLengthList; ///< current list of path-lengths
156  PathLengthList * fCurrMaxPathLengthList; ///< current list of max path-lengths
157  PDGCodeList * fCurrPDGCodeList; ///< current list of target nuclei
158  TGeoVolume * fTopVolume; ///< top volume
159  TGeoHMatrix * fMasterToTop; ///< matrix connecting master coordinates to top volume coordinates
160  bool fMasterToTopIsIdentity; ///< is fMasterToTop matrix the identity matrix?
161 
162  bool fKeepSegPath; ///< need to fill path segment "path"
163  PathSegmentList* fCurrPathSegmentList; ///< current list of path-segments
164  GeomVolSelectorI* fGeomVolSelector; ///< optional path seg trimmer (owned)
165 
166  // used by GenBoxRay to retain history between calls
167  TVector3 fGenBoxRayPos;
168  TVector3 fGenBoxRayDir;
170  bool fnewpnt;
171  double fdx, fdy, fdz, fox, foy, foz; ///< top vol size/origin (top vol units)
172 
173  // test purposes
174  double fmxddist, fmxdstep; ///< max errors in pathsegmentlist
176 
177 };
178 
179 } // geometry namespace
180 } // genie namespace
181 
182 #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: GeneratorBase.h:8
virtual void SetDebugFlags(int flgs)
bool fDensWeight
if true pathlengths are weighted with density [def:true]
const char * p
Definition: xmltok.h:285
virtual const PathLengthList & GetMaxPathLengths(void) const
GFluxI * fFlux
a flux objects that can be used to scan the max path lengths
static constexpr Double_t nm
Definition: Munits.h:133
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:33
virtual double MixtureWeightsSum(void) const
void swap(art::HLTGlobalStatus &lhs, art::HLTGlobalStatus &rhs)
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]
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)
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
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
TRandom3 r(0)
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:30
Double_t sum
Definition: plot.C:31
virtual void SI2Local(TVector3 &v) const
bool fKeepSegPath
need to fill path segment "path"
TGeoManager * gm
Definition: make_fe_box.C:4
virtual void SwimOnce(const TVector3 &r, const TVector3 &udir)
virtual void Master2Top(TVector3 &v) const
Eigen::MatrixXd mat
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:37