All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
larsim/larsim/PhotonPropagation/PhotonVisibilityService.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // \file PhotonVisibilityService.h
3 //
4 // \brief Service to report opdet visibility to different points in
5 // the system
6 //
7 // \author bjpjones@mit.edu
8 //
9 ////////////////////////////////////////////////////////////////////////
10 #ifndef PHOTONVISIBILITYSERVICE_H
11 #define PHOTONVISIBILITYSERVICE_H
12 
13 #include "larcorealg/Geometry/geo_vectors_utils.h" // geo::vect namespace
14 #include "larcoreobj/SimpleTypesAndConstants/geo_vectors.h" // geo::Point_t
19 
20 #include "art/Framework/Services/Registry/ServiceDeclarationMacros.h"
21 
22 namespace fhicl {
23  class ParameterSet;
24 }
25 
26 // ROOT
27 class TF1;
28 
29 // C/C++ standard libraries
30 #include <memory> // std::unique_ptr<>
31 #include <string>
32 #include <vector>
33 
34 ///General LArSoft Utilities
35 namespace phot {
36 
38 
39  /// Type of optical library index.
41 
42  public:
44  PhotonVisibilityService(fhicl::ParameterSet const& pset);
45 
46  void reconfigure(fhicl::ParameterSet const& p);
47 
48  double GetQuenchingFactor(double dQdx) const;
49 
50  template <typename Point>
51  static double
52  DistanceToOpDet(Point const& p, unsigned int OpDet)
53  {
54  return DistanceToOpDetImpl(geo::vect::toPoint(p), OpDet);
55  }
56  template <typename Point>
57  static double
58  SolidAngleFactor(Point const& p, unsigned int OpDet)
59  {
60  return SolidAngleFactorImpl(geo::vect::toPoint(p), OpDet);
61  }
62 
63  template <typename Point>
64  bool
65  HasVisibility(Point const& p, bool wantReflected = false) const
66  {
67  return doHasVisibility(geo::vect::toPoint(p), wantReflected);
68  }
69 
70  template <typename Point>
71  float
72  GetVisibility(Point const& p, unsigned int OpChannel, bool wantReflected = false) const
73  {
74  return doGetVisibility(geo::vect::toPoint(p), OpChannel, wantReflected);
75  }
76 
77  template <typename Point>
79  GetAllVisibilities(Point const& p, bool wantReflected = false) const
80  {
81  return doGetAllVisibilities(geo::vect::toPoint(p), wantReflected);
82  }
83 
84  void LoadLibrary() const;
85  void StoreLibrary();
86 
87  void StoreLightProd(int VoxID, double N);
88  void RetrieveLightProd(int& VoxID, double& N) const;
89 
90  void SetLibraryEntry(int VoxID, OpDetID_t libOpChannel, float N, bool wantReflected = false);
91  float GetLibraryEntry(int VoxID, OpDetID_t libOpChannel, bool wantReflected = false) const;
92  bool HasLibraryEntries(int VoxID, bool wantReflected = false) const;
93  phot::IPhotonLibrary::Counts_t GetLibraryEntries(int VoxID, bool wantReflected = false) const;
94 
95  template <typename Point>
97  GetReflT0s(Point const& p) const
98  {
100  }
101  void SetLibraryReflT0Entry(int VoxID, int OpChannel, float value);
103  float GetLibraryReflT0Entry(int VoxID, OpDetID_t libOpChannel) const;
104 
105  template <typename Point>
107  GetTimingPar(Point const& p) const
108  {
110  }
111  void SetLibraryTimingParEntry(int VoxID, int OpChannel, float value, size_t parnum);
113  float GetLibraryTimingParEntry(int VoxID, OpDetID_t libOpChannel, size_t npar) const;
114 
115  template <typename Point>
117  GetTimingTF1(Point const& p) const
118  {
120  }
121  void SetLibraryTimingTF1Entry(int VoxID, int OpChannel, TF1 const& func);
123 
124  void SetDirectLightPropFunctions(TF1 const* functions[8],
125  double& d_break,
126  double& d_max,
127  double& tf1_sampling_factor) const;
128  void SetReflectedCOLightPropFunctions(TF1 const* functions[5],
129  double& t0_max,
130  double& t0_break_point) const;
131  void LoadTimingsForVUVPar(std::vector<std::vector<double>> (&v)[7],
132  double& step_size,
133  double& max_d,
134  double& min_d,
135  double& vuv_vgroup_mean,
136  double& vuv_vgroup_max,
137  double& inflexion_point_distance,
138  double& angle_bin_timing_vuv) const;
139  void LoadTimingsForVISPar(std::vector<double>& distances,
140  std::vector<double>& radial_distances,
141  std::vector<std::vector<std::vector<double>>>& cut_off,
142  std::vector<std::vector<std::vector<double>>>& tau,
143  double& vis_vmean,
144  double& angle_bin_timing_vis) const;
145  void LoadVUVSemiAnalyticProperties ( bool &isFlatPDCorr,
146  bool &isDomePDCorr,
147  double &delta_angulo_vuv,
148  double &radius) const;
149  void LoadGHFlat( std::vector<std::vector<double>> &GHvuvpars_flat,
150  std::vector<double> &border_corr_angulo_flat,
151  std::vector<std::vector<double>> &border_corr_flat) const;
152  void LoadGHDome( std::vector<std::vector<double>> &GHvuvpars_dome,
153  std::vector<double> &border_corr_angulo_dome,
154  std::vector<std::vector<double>> &border_corr_dome) const;
155  void LoadVisSemiAnalyticProperties ( double &delta_angulo_vis,
156  double &radius) const;
157  void LoadVisParsFlat(std::vector<double> &vis_distances_x_flat,
158  std::vector<double> &vis_distances_r_flat,
159  std::vector<std::vector<std::vector<double>>> &vispars_flat) const;
160  void LoadVisParsDome(std::vector<double> &vis_distances_x_dome,
161  std::vector<double> &vis_distances_r_dome,
162  std::vector<std::vector<std::vector<double>>> &vispars_dome) const;
163 
164  bool
165  IsBuildJob() const
166  {
167  return fLibraryBuildJob;
168  }
169  bool
171  {
172  return fParameterization;
173  }
174  bool
176  {
177  return fStoreReflected;
178  }
179  bool
180  StoreReflT0() const
181  {
182  return fStoreReflT0;
183  }
184  bool
186  {
187  return fParPropTime;
188  }
189  size_t
191  {
192  return fParPropTime_npar;
193  }
194  std::string
196  {
197  return fParPropTime_formula;
198  }
199 
200  bool
202  {
203  return fIncludePropTime;
204  }
205  bool
207  {
208  return fUseNhitsModel;
209  }
210  bool
212  {
214  }
215  std::string
217  {
219  }
220 
221  const sim::PhotonVoxelDef&
222  GetVoxelDef() const
223  {
224  return fVoxelDef;
225  }
226  size_t NOpChannels() const;
227 
228  private:
231  // for c2: fCurrentReflValue is unused
232  //double fCurrentReflValue;
233 
234  float fXmin, fXmax;
235  float fYmin, fYmax;
236  float fZmin, fZmax;
237  int fNx, fNy, fNz;
238 
240 
244  bool fHybrid;
251 
254  std::string fParPropTime_formula;
258 
259  TF1* fparslogNorm = nullptr;
260  TF1* fparslogNorm_far = nullptr;
261  TF1* fparsMPV = nullptr;
262  TF1* fparsMPV_far = nullptr;
263  TF1* fparsWidth = nullptr;
264  TF1* fparsCte = nullptr;
265  TF1* fparsCte_far = nullptr;
266  TF1* fparsSlope = nullptr;
268  TF1* fparslogNorm_refl = nullptr;
269  TF1* fparsMPV_refl = nullptr;
270  TF1* fparsWidth_refl = nullptr;
271  TF1* fparsCte_refl = nullptr;
272  TF1* fparsSlope_refl = nullptr;
274 
275  //for vuv time parametrization
276  std::vector<double> fDistances_landau;
277  std::vector<std::vector<double>> fNorm_over_entries;
278  std::vector<std::vector<double>> fMpv;
279  std::vector<std::vector<double>> fWidth;
280  std::vector<double> fDistances_exp;
281  std::vector<std::vector<double>> fSlope;
282  std::vector<std::vector<double>> fExpo_over_Landau_norm;
284  // for vis time parameterisation (exists for SBND, DUNE-SP)
285  std::vector<double> fDistances_refl;
286  std::vector<double> fDistances_radial_refl;
287  std::vector<std::vector<std::vector<double>>> fCut_off;
288  std::vector<std::vector<std::vector<double>>> fTau;
290 
291  //for the semi-analytic vuv/direct light signal (number of hits) correction
293  //parametrization exists for DUNE-SP and for SBND
295  // flat PDs
296  std::vector<std::vector<double>> fGHvuvpars_flat;
297  std::vector<double> fborder_corr_angulo_flat;
298  std::vector<std::vector<double>> fborder_corr_flat;
299  // dome PDs
300  std::vector<std::vector<double>> fGHvuvpars_dome;
301  std::vector<double> fborder_corr_angulo_dome;
302  std::vector<std::vector<double>> fborder_corr_dome;
303  // for the semi-analytic visible/reflection light hits correction
304  // parameterization exists for DUNE-SP and SBND
306  // flat PDs
307  std::vector<double> fvis_distances_x_flat;
308  std::vector<double> fvis_distances_r_flat;
309  std::vector<std::vector<std::vector<double>>> fvispars_flat;
310  // dome PDs
311  std::vector<double> fvis_distances_x_dome;
312  std::vector<double> fvis_distances_r_dome;
313  std::vector<std::vector<std::vector<double>>> fvispars_dome;
314 
315  // optical detector information, rest using geometry service
316  double fradius;
317 
318  std::string fLibraryFile;
321 
322  /// Mapping of detector space into library space.
323  std::unique_ptr<phot::IPhotonMappingTransformations> fMapping;
324 
325  geo::Point_t LibLocation(geo::Point_t const& p) const;
326 
327  int
328  VoxelAt(geo::Point_t const& p) const
329  {
330  return fVoxelDef.GetVoxelID(LibLocation(p));
331  }
332 
333  // same as `doGetVisibility()` but the channel number refers to the library
334  // ID rather than to the actual optical detector ID.
336  LibraryIndex_t libIndex,
337  bool wantReflected = false) const;
338 
339  // --- BEGIN Implementation functions --------------------------------------
340  /// @name Implementation functions
341  /// @{
342 
343  static double DistanceToOpDetImpl(geo::Point_t const& p, unsigned int OpDet);
344 
345  static double SolidAngleFactorImpl(geo::Point_t const& p, unsigned int OpDet);
346 
347  bool doHasVisibility(geo::Point_t const& p, bool wantReflected = false) const;
348 
349  float doGetVisibility(geo::Point_t const& p,
350  unsigned int OpChannel,
351  bool wantReflected = false) const;
352 
353  MappedCounts_t doGetAllVisibilities(geo::Point_t const& p, bool wantReflected = false) const;
354 
355  MappedT0s_t doGetReflT0s(geo::Point_t const& p) const;
356 
358 
360 
361  /// @}
362  // --- END Implementation functions ----------------------------------------
363 
364  }; // class PhotonVisibilityService
365 } //namespace phot
366 DECLARE_ART_SERVICE(phot::PhotonVisibilityService, LEGACY)
367 #endif // PHOTONVISIBILITYSERVICE_H
std::vector< std::vector< std::vector< double > > > fTau
MappedParams_t doGetTimingPar(geo::Point_t const &p) const
Interface for transformation of photon visibility maps.
void LoadTimingsForVISPar(std::vector< double > &distances, std::vector< double > &radial_distances, std::vector< std::vector< std::vector< double >>> &cut_off, std::vector< std::vector< std::vector< double >>> &tau, double &vis_vmean, double &angle_bin_timing_vis) const
phot::IPhotonLibrary::Counts_t GetLibraryReflT0Entries(int VoxID) const
MappedCounts_t doGetAllVisibilities(geo::Point_t const &p, bool wantReflected=false) const
phot::IPhotonLibrary::Counts_t GetLibraryEntries(int VoxID, bool wantReflected=false) const
std::unique_ptr< phot::IPhotonMappingTransformations > fMapping
Mapping of detector space into library space.
void RetrieveLightProd(int &VoxID, double &N) const
void SetDirectLightPropFunctions(TF1 const *functions[8], double &d_break, double &d_max, double &tf1_sampling_factor) const
void LoadTimingsForVUVPar(std::vector< std::vector< double >>(&v)[7], double &step_size, double &max_d, double &min_d, double &vuv_vgroup_mean, double &vuv_vgroup_max, double &inflexion_point_distance, double &angle_bin_timing_vuv) const
void SetLibraryTimingParEntry(int VoxID, int OpChannel, float value, size_t parnum)
pdgs p
Definition: selectors.fcl:22
OpDetID_t LibraryIndex_t
Type describing a library index. FIXME former LibraryOpDetID_t.
phot::IPhotonMappingTransformations::LibraryIndex_t LibraryIndex_t
Type of optical library index.
Representation of a region of space diced into voxels.
::geo::Point_t toPoint(Point const &p)
Convert the specified point into a geo::Point_t.
float GetLibraryTimingParEntry(int VoxID, OpDetID_t libOpChannel, size_t npar) const
bool HasLibraryEntries(int VoxID, bool wantReflected=false) const
void LoadVisParsFlat(std::vector< double > &vis_distances_x_flat, std::vector< double > &vis_distances_r_flat, std::vector< std::vector< std::vector< double >>> &vispars_flat) const
float doGetVisibilityOfOpLib(geo::Point_t const &p, LibraryIndex_t libIndex, bool wantReflected=false) const
bool doHasVisibility(geo::Point_t const &p, bool wantReflected=false) const
static double DistanceToOpDet(Point const &p, unsigned int OpDet)
std::vector< std::vector< std::vector< double > > > fCut_off
float GetLibraryEntry(int VoxID, OpDetID_t libOpChannel, bool wantReflected=false) const
void LoadGHDome(std::vector< std::vector< double >> &GHvuvpars_dome, std::vector< double > &border_corr_angulo_dome, std::vector< std::vector< double >> &border_corr_dome) const
int GetVoxelID(Point const &p) const
Returns the ID of the voxel containing p, or -1 if none.
void LoadVUVSemiAnalyticProperties(bool &isFlatPDCorr, bool &isDomePDCorr, double &delta_angulo_vuv, double &radius) const
double GetQuenchingFactor(double dQdx) const
float GetLibraryReflT0Entry(int VoxID, OpDetID_t libOpChannel) const
bool HasVisibility(Point const &p, bool wantReflected=false) const
void SetReflectedCOLightPropFunctions(TF1 const *functions[5], double &t0_max, double &t0_break_point) const
void StoreLightProd(int VoxID, double N)
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:265
PhotonVisibilityService(fhicl::ParameterSet const &pset)
Definitions of voxel data structures.
void LoadGHFlat(std::vector< std::vector< double >> &GHvuvpars_flat, std::vector< double > &border_corr_angulo_flat, std::vector< std::vector< double >> &border_corr_flat) const
MappedFunctions_t doGetTimingTF1(geo::Point_t const &p) const
geo::Point_t LibLocation(geo::Point_t const &p) const
void LoadVisParsDome(std::vector< double > &vis_distances_x_dome, std::vector< double > &vis_distances_r_dome, std::vector< std::vector< std::vector< double >>> &vispars_dome) const
Definitions of geometry vector data types.
std::tuple< double, double, const reco::ClusterHit3D * > Point
Definitions used by the VoronoiDiagram algorithm.
Definition: DCEL.h:44
void SetLibraryReflT0Entry(int VoxID, int OpChannel, float value)
Utilities to extend the interface of geometry vectors.
void reconfigure(fhicl::ParameterSet const &p)
phot::IPhotonMappingTransformations::OpDetID_t OpDetID_t
Type of (global) optical detector ID.
std::vector< float > const * Params_t
MappedCounts_t GetAllVisibilities(Point const &p, bool wantReflected=false) const
void LoadVisSemiAnalyticProperties(double &delta_angulo_vis, double &radius) const
void SetLibraryEntry(int VoxID, OpDetID_t libOpChannel, float N, bool wantReflected=false)
A container for photon visibility mapping data.
Declaration of types related to photon visibility.
process_name largeant stream1 can override from command line with o or output physics producers generator N
float doGetVisibility(geo::Point_t const &p, unsigned int OpChannel, bool wantReflected=false) const
void SetLibraryTimingTF1Entry(int VoxID, int OpChannel, TF1 const &func)
std::vector< std::vector< std::vector< double > > > fvispars_dome
static double SolidAngleFactor(Point const &p, unsigned int OpDet)
const float * Counts_t
Type for visibility count per optical channel.
temporary value
Interface shared by all PhotonLibrary-like classes.
static double DistanceToOpDetImpl(geo::Point_t const &p, unsigned int OpDet)
MappedT0s_t doGetReflT0s(geo::Point_t const &p) const
static double SolidAngleFactorImpl(geo::Point_t const &p, unsigned int OpDet)
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
float GetVisibility(Point const &p, unsigned int OpChannel, bool wantReflected=false) const
phot::IPhotonLibrary::Functions_t GetLibraryTimingTF1Entries(int VoxID) const
phot::IPhotonLibrary::Params_t GetLibraryTimingParEntries(int VoxID) const
std::vector< std::vector< std::vector< double > > > fvispars_flat