All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SemiAnalyticalModel.h
Go to the documentation of this file.
1 #ifndef SEMIANALYTICALMODEL_H
2 #define SEMIANALYTICALMODEL_H
3 
4 // SemiAnalyticalModel
5 // - fast optical simulation using semi-analytical model
6 // - contains functions to calculate the number of direct and reflected photons incident
7 // each photo-detector, along with the necessary ultility functions (geometry calculations etc.)
8 // - full description of model: Eur. Phys. J. C 81, 349 (2021)
9 
10 // Nov 2021 by P. Green
11 
12 // LArSoft Libraries
15 
16 // fhicl
17 #include "fhiclcpp/ParameterSet.h"
18 
19 #include "TVector3.h"
20 
21 #include "boost/math/policies/policy.hpp"
22 
23 #include <map>
24 #include <vector>
25 
26 
27 // Define a new policy *not* internally promoting RealType to double:
28 typedef boost::math::policies::policy<boost::math::policies::promote_double<false>> noLDoublePromote;
29 
30 
32 
33 public:
34 
35  // constructor
36  SemiAnalyticalModel(fhicl::ParameterSet VUVHits, fhicl::ParameterSet VISHits, bool doReflectedLight = false, bool includeAnodeReflections = false);
37 
38  // direct / VUV light
39  void detectedDirectVisibilities(std::vector<double>& DetectedVisibilities,
40  geo::Point_t const& ScintPoint) const;
41 
42  // reflected / visible light
43  void detectedReflectedVisibilities(std::vector<double>& ReflDetectedVisibilities,
44  geo::Point_t const& ScintPoint,
45  bool AnodeMode = false) const;
46 
47 private:
48 
49  // parameter and geometry initialization
50  void Initialization();
51 
52  int VUVAbsorptionLength() const;
53 
54  // structure for rectangular solid angle calculation
55  struct Dims {
56  double h, w; // height, width
57  };
58 
59  // structure for optical detector information
60  struct OpticalDetector {
61  double h; // height
62  double w; // width
64  int type;
66  };
67 
68  // direct light photo-detector visibility calculation
69  double VUVVisibility(geo::Point_t const& ScintPoint, OpticalDetector const& opDet) const;
70 
71  // reflected light photo-detector visibility calculation
72  double VISVisibility(geo::Point_t const& ScintPoint, OpticalDetector const& opDet,
73  const double cathode_visibility, geo::Point_t const& hotspot,
74  bool AnodeMode = false) const;
75 
76  // Gaisser-Hillas
77  double Gaisser_Hillas(const double x, const double* par) const;
78 
79  // solid angle calculations
80  // rectangular aperture
81  double Rectangle_SolidAngle(const double a, const double b, const double d) const;
82  double Rectangle_SolidAngle(Dims const& o, geo::Vector_t const& v, const double OpDetOrientation) const;
83  // circular aperture
84  double Disk_SolidAngle(const double d, const double h, const double b) const;
85  // dome aperture calculation
86  double Omega_Dome_Model(const double distance, const double theta) const;
87 
88  // utility functions
89  bool isOpDetInSameTPC(geo::Point_t const& ScintPoint, geo::Point_t const& OpDetPoint) const;
90 
91  double fast_acos(double x) const;
92 
93  double interpolate(const std::vector<double>& xData,
94  const std::vector<double>& yData,
95  double x,
96  bool extrapolate,
97  size_t i = 0) const;
98 
99  double interpolate2(const std::vector<double>& xDistances,
100  const std::vector<double>& rDistances,
101  const std::vector<std::vector<std::vector<double>>>& parameters,
102  const double x,
103  const double r,
104  const size_t k) const;
105 
106  // implements relative method - do not use for comparing with zero
107  // use this most of the time, tolerance needs to be meaningful in your context
108  template <typename TReal>
109  inline constexpr static bool
110  isApproximatelyEqual(TReal a, TReal b, TReal tolerance = std::numeric_limits<TReal>::epsilon())
111  {
112  TReal diff = std::fabs(a - b);
113  if (diff <= tolerance) return true;
114  if (diff < std::fmax(std::fabs(a), std::fabs(b)) * tolerance) return true;
115  return false;
116  }
117 
118  // supply tolerance that is meaningful in your context
119  // for example, default tolerance may not work if you are comparing double with
120  // float
121  template <typename TReal>
122  inline constexpr static bool
123  isApproximatelyZero(TReal a, TReal tolerance = std::numeric_limits<TReal>::epsilon())
124  {
125  if (std::fabs(a) <= tolerance) return true;
126  return false;
127  }
128 
129  // use this when you want to be on safe side
130  // for example, don't start rover unless signal is above 1
131  template <typename TReal>
132  inline constexpr static bool
133  isDefinitelyLessThan(TReal a, TReal b, TReal tolerance = std::numeric_limits<TReal>::epsilon())
134  {
135  TReal diff = a - b;
136  if (diff < tolerance) return true;
137  if (diff < std::fmax(std::fabs(a), std::fabs(b)) * tolerance) return true;
138  return false;
139  }
140 
141  template <typename TReal>
142  inline constexpr static bool
143  isDefinitelyGreaterThan(TReal a, TReal b, TReal tolerance = std::numeric_limits<TReal>::epsilon())
144  {
145  TReal diff = a - b;
146  if (diff > tolerance) return true;
147  if (diff > std::fmax(std::fabs(a), std::fabs(b)) * tolerance) return true;
148  return false;
149  }
150 
151  // fhicl parameter sets
152  const fhicl::ParameterSet fVUVHitsParams;
153  const fhicl::ParameterSet fVISHitsParams;
154 
155  // geometry properties
158  const int fNTPC;
159  const std::vector<geo::BoxBoundedGeo> fActiveVolumes;
162 
163  // photodetector geometry properties
164  const size_t nOpDets;
165  double fradius;
168  std::vector<geo::Point_t> fOpDetCenter;
169  std::vector<int> fOpDetType;
170  std::vector<int> fOpDetOrientation;
171  std::vector<double> fOpDetLength;
172  std::vector<double> fOpDetHeight;
173 
175 
176  // For VUV semi-analytic hits
178  // flat PDs
180  std::vector<std::vector<double>> fGHvuvpars_flat;
181  std::vector<double> fborder_corr_angulo_flat;
182  std::vector<std::vector<double>> fborder_corr_flat;
183  // lateral PDs
185  std::vector<std::vector<double>> fGHvuvpars_flat_lateral;
186  std::vector<double> fborder_corr_angulo_flat_lateral;
187  std::vector<std::vector<double>> fborder_corr_flat_lateral;
188 
189  // dome PDs
191  std::vector<std::vector<double>> fGHvuvpars_dome;
192  std::vector<double> fborder_corr_angulo_dome;
193  std::vector<std::vector<double>> fborder_corr_dome;
194  // Field cage scaling
198 
199  // For VIS semi-analytic hits
200  const bool fDoReflectedLight;
202  // correction parameters for VIS Nhits estimation
205  // flat PDs
206  std::vector<double> fvis_distances_x_flat;
207  std::vector<double> fvis_distances_r_flat;
208  std::vector<std::vector<std::vector<double>>> fvispars_flat;
209  // lateral PDs
210  std::vector<double> fvis_distances_x_flat_lateral;
211  std::vector<double> fvis_distances_r_flat_lateral;
212  std::vector<std::vector<std::vector<double>>> fvispars_flat_lateral;
213  // dome PDs
214  std::vector<double> fvis_distances_x_dome;
215  std::vector<double> fvis_distances_r_dome;
216  std::vector<std::vector<std::vector<double>>> fvispars_dome;
217 
218 };
219 
220 #endif
std::vector< double > fvis_distances_r_dome
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Vector_t
Type for representation of momenta in 3D space.
Definition: geo_vectors.h:164
std::vector< double > fvis_distances_r_flat_lateral
double Gaisser_Hillas(const double x, const double *par) const
void detectedDirectVisibilities(std::vector< double > &DetectedVisibilities, geo::Point_t const &ScintPoint) const
std::vector< std::vector< double > > fborder_corr_dome
process_name opflash particleana ie x
double interpolate2(const std::vector< double > &xDistances, const std::vector< double > &rDistances, const std::vector< std::vector< std::vector< double >>> &parameters, const double x, const double r, const size_t k) const
std::vector< std::vector< std::vector< double > > > fvispars_flat_lateral
double VUVVisibility(geo::Point_t const &ScintPoint, OpticalDetector const &opDet) const
double Omega_Dome_Model(const double distance, const double theta) const
const TVector3 fcathode_centre
std::vector< std::vector< double > > fGHvuvpars_flat
auto const tolerance
std::vector< std::vector< double > > fGHvuvpars_dome
geo::GeometryCore const & fGeom
std::vector< double > fvis_distances_r_flat
std::vector< double > fOpDetHeight
const TVector3 fanode_centre
std::vector< std::vector< double > > fborder_corr_flat_lateral
const fhicl::ParameterSet fVUVHitsParams
std::vector< std::vector< std::vector< double > > > fvispars_flat
double fast_acos(double x) const
void detectedReflectedVisibilities(std::vector< double > &ReflDetectedVisibilities, geo::Point_t const &ScintPoint, bool AnodeMode=false) const
process_name gaushit a
while getopts h
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:265
double Rectangle_SolidAngle(const double a, const double b, const double d) const
const fhicl::ParameterSet fVISHitsParams
double distance(geo::Point_t const &point, CathodeDesc_t const &cathode)
Returns the distance of a point from the cathode.
std::vector< double > fvis_distances_x_flat
Definitions of geometry vector data types.
boost::math::policies::policy< boost::math::policies::promote_double< false > > noLDoublePromote
const larg4::ISTPC fISTPC
double interpolate(const std::vector< double > &xData, const std::vector< double > &yData, double x, bool extrapolate, size_t i=0) const
std::vector< double > fvis_distances_x_flat_lateral
std::vector< geo::Point_t > fOpDetCenter
std::vector< double > fOpDetLength
Description of geometry of one entire detector.
std::vector< double > fborder_corr_angulo_flat_lateral
std::vector< std::vector< double > > fborder_corr_flat
std::vector< std::vector< double > > fGHvuvpars_flat_lateral
std::vector< int > fOpDetType
std::vector< double > fborder_corr_angulo_dome
bool isOpDetInSameTPC(geo::Point_t const &ScintPoint, geo::Point_t const &OpDetPoint) const
std::vector< double > fvis_distances_x_dome
const std::vector< geo::BoxBoundedGeo > fActiveVolumes
pdgs k
Definition: selectors.fcl:22
double Disk_SolidAngle(const double d, const double h, const double b) const
SemiAnalyticalModel(fhicl::ParameterSet VUVHits, fhicl::ParameterSet VISHits, bool doReflectedLight=false, bool includeAnodeReflections=false)
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
Definition: geo_vectors.h:184
esac echo uname r
std::vector< double > fborder_corr_angulo_flat
std::vector< int > fOpDetOrientation
std::vector< std::vector< std::vector< double > > > fvispars_dome
double VISVisibility(geo::Point_t const &ScintPoint, OpticalDetector const &opDet, const double cathode_visibility, geo::Point_t const &hotspot, bool AnodeMode=false) const
const bool fIncludeAnodeReflections