GENIEGenerator
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
HNLVertexGenerator.h
Go to the documentation of this file.
1 //____________________________________________________________________________
2 /*!
3 
4 \class genie::hnl::VertexGenerator
5 
6 \brief Heavy Neutral Lepton decay vertex generator
7  *** given production vertex and momentum ***
8 
9 \author John Plows <komninos-john.plows \at physics.ox.ac.uk>
10 
11 \created March 31st, 2022
12 
13 \cpright Copyright (c) 2003-2024, The GENIE Collaboration
14  For the full text of the license visit http://copyright.genie-mc.org
15 */
16 //____________________________________________________________________________
17 
18 #ifndef _HNL_DECAY_VOLUME_H_
19 #define _HNL_DECAY_VOLUME_H_
20 
21 #include <cmath>
22 #include <cassert>
23 
24 #include <TVector3.h>
25 //#ifdef __GENIE_GEOM_DRIVERS_ENABLED__ // why do we crash with this guard on?
26 #include <TGeoManager.h>
27 #include <TGeoVolume.h>
28 #include <TGeoNode.h>
29 #include <TGeoBBox.h>
30 //#endif // #ifdef __GENIE_GEOM_DRIVERS_ENABLED__
31 
32 //#include "Framework/Conventions/Constants.h"
42 
44 
45 namespace genie {
46 namespace hnl {
47 
48  class SimpleHNL;
49 
51 
52  public:
53 
55  VertexGenerator(string name);
56  VertexGenerator(string name, string config);
58 
59  //-- implement the EventRecordVisitorI interface
60  void ProcessEventRecord(GHepRecord * event_rec) const;
61 
62  // overload the Algorithm::Configure() methods to load private data
63  // members from configuration options
64  void Configure(const Registry & config);
65  void Configure(string config);
66 
67  void SetGeomFile( std::string geomfile ) const;
68 
69  private:
70 
71  void LoadConfig();
72 
73 #ifdef __GENIE_GEOM_DRIVERS_ENABLED__
74  // use bounding box origin & sides
75  void ImportBoundingBox( TGeoBBox * box ) const;
76 #endif // #ifdef __GENIE_GEOM_DRIVERS_ENABLED__
77 
78  void SetStartingParameters( GHepRecord * event_rec ) const;
79 
80  // --------------------------------------------------
81  // Utilities
82  // --------------------------------------------------
83 
84  // simple getter
85  void GetInterestingPoints( TVector3 & entryPoint, TVector3 & exitPoint, TVector3 & decayPoint ) const;
86 
87  // Build a simple 1x1x1 m3 box around (0,0,0).
88  void MakeSDV() const;
89 
90  // enforce chosen units
91  void EnforceUnits( std::string length_units, std::string angle_units, std::string time_units ) const;
92 
93  // calculate travel length in detector
94  double CalcTravelLength( double betaMag, double CoMLifetime, double maxLength ) const;
95 
96  // assign decay point given length
97  TVector3 GetDecayPoint( double travelLength, TVector3 & entryPoint, TVector3 & momentum ) const;
98 
99  // get max length in detector
100  double GetMaxLength( TVector3 & entryPoint, TVector3 & exitPoint ) const;
101 
102  // --------------------------------------------------
103  // Simple Decay Volume - fallback if no geometry
104  // --------------------------------------------------
105 
106  // in case of SDV, calculate entry and exit points (if any) of some trajectory
107  // if no entry/exit points return false
108  bool SDVEntryAndExitPoints( TVector3 & startPoint, TVector3 momentum,
109  TVector3 & entryPoint,
110  TVector3 & exitPoint ) const;
111 
112  // --------------------------------------------------
113  // ROOT geometry stuff
114  // --------------------------------------------------
115 
116 #ifdef __GENIE_GEOM_DRIVERS_ENABLED__
117 
118  // get entry & exit points directly from volume
119  bool VolumeEntryAndExitPoints( TVector3 & startPoint, TVector3 & momentum,
120  TVector3 & entryPoint, TVector3 & exitPoint,
121  TGeoManager * gm, TGeoVolume * vol ) const;
122 #endif // #ifdef __GENIE_GEOM_DRIVERS_ENABLED__
123 
124  TVector3 ApplyUserRotation( TVector3 vec, bool doBackwards ) const;
125  TVector3 ApplyUserRotation( TVector3 vec, TVector3 oriVec, std::vector<double> rotVec, bool doBackwards ) const;
126 
127  std::string CheckGeomPoint( Double_t x, Double_t y, Double_t z ) const;
128 
129  // --------------------------------------------------
130 
131  mutable bool fIsConfigLoaded = false;
132 
133  mutable double lunits = genie::units::mm; mutable std::string lunitString = "mm";
134  mutable double aunits = genie::units::rad;
135  mutable double tunits = genie::units::ns; mutable std::string tunitString = "ns";
136 
137  mutable double fSx = 0.0, fSy = 0.0, fSz = 0.0; //start point
138  mutable double fPx = 0.0, fPy = 0.0, fPz = 0.0; //momentum
139  mutable double fEx = 0.0, fEy = 0.0, fEz = 0.0; //entry point
140  mutable double fXx = 0.0, fXy = 0.0, fXz = 0.0; //exit point
141 
142  mutable double fSxROOT = 0.0, fSyROOT = 0.0, fSzROOT = 0.0; // start point in cm
143  mutable double fExROOT = 0.0, fEyROOT = 0.0, fEzROOT = 0.0; // entry point in cm
144  mutable double fXxROOT = 0.0, fXyROOT = 0.0, fXzROOT = 0.0; // exit point in cm
145 
146  mutable double fDx = 0.0, fDy = 0.0, fDz = 0.0; //decay point
147  mutable double fOx = 0.0, fOy = 0.0, fOz = 0.0; //origin
148  mutable double fLx = 0.0, fLy = 0.0, fLz = 0.0; //dimensions
149 
150  mutable double fDxROOT = 0.0, fDyROOT = 0.0, fDzROOT = 0.0; // decay point in cm
151  mutable double fOxROOT = 0.0, fOyROOT = 0.0, fOzROOT = 0.0; // origin in cm
152  mutable double fLxROOT = 0.0, fLyROOT = 0.0, fLzROOT = 0.0; // dimensions in cm
153 
154  mutable double fCoMLifetime = 0.0; // HNL lifetime in ns
155 
157 
158  mutable string fGeomFile = "";
159  mutable TGeoManager * fGeoManager = 0;
160  mutable TGeoVolume * fGeoVolume = 0;
161 
162  mutable bool isUsingDk2nu = false;
163  mutable bool isUsingRootGeom = false;
164  mutable double uMult = 1.0, xMult = 1.0; // these need to be different.
165 
166  mutable double fCx, fCy, fCz; // translation: from beamline origin to user origin
167  mutable double fUx, fUy, fUz; // translation: from user origin to detector centre
168  mutable double fAx1, fAz, fAx2; // rotation: from target-hall frame to beam frame
169  mutable double fBx1, fBz, fBx2; // rotation: from target-hall frame to user frame
170  mutable std::vector< double > fB2UTranslation, fB2URotation, fDetTranslation, fDetRotation;
171 
172  }; // class VertexGenerator
173 
174 } // namespace hnl
175 } // namespace genie
176 
177 #endif // #ifndef _HNL_DECAY_VOLUME_H_
bool SDVEntryAndExitPoints(TVector3 &startPoint, TVector3 momentum, TVector3 &entryPoint, TVector3 &exitPoint) const
double CoMLifetime
static constexpr double rad
Definition: Units.h:164
std::vector< double > fDetRotation
Heavy Neutral Lepton decay vertex generator given production vertex and momentum ***.
static constexpr double s
Definition: Units.h:95
static constexpr double ns
Definition: Units.h:98
std::string CheckGeomPoint(Double_t x, Double_t y, Double_t z) const
void Configure(const Registry &config)
Expands the EventRecordVisitorI interface to include public interfaces for the HNL VertexGenerator mo...
void ProcessEventRecord(GHepRecord *event_rec) const
std::vector< double > fDetTranslation
TVector3 ApplyUserRotation(TVector3 vec, bool doBackwards) const
double CalcTravelLength(double betaMag, double CoMLifetime, double maxLength) const
void SetStartingParameters(GHepRecord *event_rec) const
double GetMaxLength(TVector3 &entryPoint, TVector3 &exitPoint) const
std::vector< double > fB2URotation
A registry. Provides the container for algorithm configuration parameters.
Definition: Registry.h:65
std::vector< double > fB2UTranslation
static constexpr double mm
Definition: Units.h:65
void GetInterestingPoints(TVector3 &entryPoint, TVector3 &exitPoint, TVector3 &decayPoint) const
void EnforceUnits(std::string length_units, std::string angle_units, std::string time_units) const
void SetGeomFile(std::string geomfile) const
static constexpr double kSpeedOfLight
Definition: Units.h:32
GENIE&#39;s GHEP MC event record.
Definition: GHepRecord.h:45
static constexpr double m
Definition: Units.h:71
Most commonly used PDG codes. A set of utility functions to handle PDG codes is provided in PDGUtils...
TVector3 GetDecayPoint(double travelLength, TVector3 &entryPoint, TVector3 &momentum) const