LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
PhotonVisibilityService.h
Go to the documentation of this file.
1 // \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 //
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 
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 
35 namespace phot {
36 
38 
41 
42  public:
45 
46  void reconfigure(fhicl::ParameterSet const& p);
47 
48  double GetQuenchingFactor(double dQdx) const;
49 
50  template <typename Point>
51  static double DistanceToOpDet(Point const& p, unsigned int OpDet)
52  {
53  return DistanceToOpDetImpl(geo::vect::toPoint(p), OpDet);
54  }
55  template <typename Point>
56  static double SolidAngleFactor(Point const& p, unsigned int OpDet)
57  {
58  return SolidAngleFactorImpl(geo::vect::toPoint(p), OpDet);
59  }
60 
61  template <typename Point>
62  bool HasVisibility(Point const& p, bool wantReflected = false) const
63  {
64  return doHasVisibility(geo::vect::toPoint(p), wantReflected);
65  }
66 
67  template <typename Point>
68  float GetVisibility(Point const& p, unsigned int OpChannel, bool wantReflected = false) const
69  {
70  return doGetVisibility(geo::vect::toPoint(p), OpChannel, wantReflected);
71  }
72 
73  template <typename Point>
74  MappedCounts_t GetAllVisibilities(Point const& p, bool wantReflected = false) const
75  {
76  return doGetAllVisibilities(geo::vect::toPoint(p), wantReflected);
77  }
78 
79  void LoadLibrary() const;
80  void StoreLibrary();
81 
82  void StoreLightProd(int VoxID, double N);
83  void RetrieveLightProd(int& VoxID, double& N) const;
84 
85  void SetLibraryEntry(int VoxID, OpDetID_t libOpChannel, float N, bool wantReflected = false);
86  float GetLibraryEntry(int VoxID, OpDetID_t libOpChannel, bool wantReflected = false) const;
87  bool HasLibraryEntries(int VoxID, bool wantReflected = false) const;
88  phot::IPhotonLibrary::Counts_t GetLibraryEntries(int VoxID, bool wantReflected = false) const;
89 
90  template <typename Point>
91  MappedT0s_t GetReflT0s(Point const& p) const
92  {
93  return doGetReflT0s(geo::vect::toPoint(p));
94  }
95  void SetLibraryReflT0Entry(int VoxID, int OpChannel, float value);
96  phot::IPhotonLibrary::Counts_t GetLibraryReflT0Entries(int VoxID) const;
97  float GetLibraryReflT0Entry(int VoxID, OpDetID_t libOpChannel) const;
98 
99  template <typename Point>
101  {
102  return doGetTimingPar(geo::vect::toPoint(p));
103  }
104  void SetLibraryTimingParEntry(int VoxID, int OpChannel, float value, size_t parnum);
105  phot::IPhotonLibrary::Params_t GetLibraryTimingParEntries(int VoxID) const;
106  float GetLibraryTimingParEntry(int VoxID, OpDetID_t libOpChannel, size_t npar) const;
107 
108  template <typename Point>
110  {
111  return doGetTimingTF1(geo::vect::toPoint(p));
112  }
113  void SetLibraryTimingTF1Entry(int VoxID, int OpChannel, TF1 const& func);
114  phot::IPhotonLibrary::Functions_t GetLibraryTimingTF1Entries(int VoxID) const;
115 
116  void SetDirectLightPropFunctions(TF1 const* functions[8],
117  double& d_break,
118  double& d_max,
119  double& tf1_sampling_factor) const;
120  void SetReflectedCOLightPropFunctions(TF1 const* functions[5],
121  double& t0_max,
122  double& t0_break_point) const;
123  void LoadTimingsForVUVPar(std::vector<std::vector<double>> (&v)[7],
124  double& step_size,
125  double& max_d,
126  double& min_d,
127  double& vuv_vgroup_mean,
128  double& vuv_vgroup_max,
129  double& inflexion_point_distance,
130  double& angle_bin_timing_vuv) const;
131  void LoadTimingsForVISPar(std::vector<double>& distances,
132  std::vector<double>& radial_distances,
133  std::vector<std::vector<std::vector<double>>>& cut_off,
134  std::vector<std::vector<std::vector<double>>>& tau,
135  double& vis_vmean,
136  double& angle_bin_timing_vis) const;
137  void LoadVUVSemiAnalyticProperties(bool& isFlatPDCorr,
138  bool& isDomePDCorr,
139  double& delta_angulo_vuv,
140  double& radius) const;
141  void LoadGHFlat(std::vector<std::vector<double>>& GHvuvpars_flat,
142  std::vector<double>& border_corr_angulo_flat,
143  std::vector<std::vector<double>>& border_corr_flat) const;
144  void LoadGHDome(std::vector<std::vector<double>>& GHvuvpars_dome,
145  std::vector<double>& border_corr_angulo_dome,
146  std::vector<std::vector<double>>& border_corr_dome) const;
147  void LoadVisSemiAnalyticProperties(double& delta_angulo_vis, double& radius) const;
148  void LoadVisParsFlat(std::vector<double>& vis_distances_x_flat,
149  std::vector<double>& vis_distances_r_flat,
150  std::vector<std::vector<std::vector<double>>>& vispars_flat) const;
151  void LoadVisParsDome(std::vector<double>& vis_distances_x_dome,
152  std::vector<double>& vis_distances_r_dome,
153  std::vector<std::vector<std::vector<double>>>& vispars_dome) const;
154 
155  bool IsBuildJob() const { return fLibraryBuildJob; }
156  bool UseParameterization() const { return fParameterization; }
157  bool StoreReflected() const { return fStoreReflected; }
158  bool StoreReflT0() const { return fStoreReflT0; }
159  bool IncludeParPropTime() const { return fParPropTime; }
160  size_t ParPropTimeNpar() const { return fParPropTime_npar; }
161  std::string ParPropTimeFormula() const { return fParPropTime_formula; }
162 
163  bool IncludePropTime() const { return fIncludePropTime; }
164  bool UseNhitsModel() const { return fUseNhitsModel; }
165  bool ApplyVISBorderCorrection() const { return fApplyVISBorderCorrection; }
166  std::string VISBorderCorrectionType() const { return fVISBorderCorrectionType; }
167 
168  const sim::PhotonVoxelDef& GetVoxelDef() const { return fVoxelDef; }
169  size_t NOpChannels() const;
170 
171  private:
174  // for c2: fCurrentReflValue is unused
175  //double fCurrentReflValue;
176 
177  float fXmin, fXmax;
178  float fYmin, fYmax;
179  float fZmin, fZmax;
180  int fNx, fNy, fNz;
181 
184  std::string fSaveTPCVoxels, fSaveOtherVoxels;
185 
189  bool fHybrid;
196 
199  std::string fParPropTime_formula;
203 
204  TF1* fparslogNorm = nullptr;
205  TF1* fparslogNorm_far = nullptr;
206  TF1* fparsMPV = nullptr;
207  TF1* fparsMPV_far = nullptr;
208  TF1* fparsWidth = nullptr;
209  TF1* fparsCte = nullptr;
210  TF1* fparsCte_far = nullptr;
211  TF1* fparsSlope = nullptr;
212  double fD_break, fD_max, fTF1_sampling_factor;
213  TF1* fparslogNorm_refl = nullptr;
214  TF1* fparsMPV_refl = nullptr;
215  TF1* fparsWidth_refl = nullptr;
216  TF1* fparsCte_refl = nullptr;
217  TF1* fparsSlope_refl = nullptr;
218  double fT0_max, fT0_break_point;
219 
220  //for vuv time parametrization
221  std::vector<double> fDistances_landau;
222  std::vector<std::vector<double>> fNorm_over_entries;
223  std::vector<std::vector<double>> fMpv;
224  std::vector<std::vector<double>> fWidth;
225  std::vector<double> fDistances_exp;
226  std::vector<std::vector<double>> fSlope;
227  std::vector<std::vector<double>> fExpo_over_Landau_norm;
228  double fstep_size, fmax_d, fmin_d, fvuv_vgroup_mean, fvuv_vgroup_max, finflexion_point_distance,
229  fangle_bin_timing_vuv;
230  // for vis time parameterisation (exists for SBND, DUNE-SP)
231  std::vector<double> fDistances_refl;
232  std::vector<double> fDistances_radial_refl;
233  std::vector<std::vector<std::vector<double>>> fCut_off;
234  std::vector<std::vector<std::vector<double>>> fTau;
235  double fvis_vmean, fangle_bin_timing_vis;
236 
237  //for the semi-analytic vuv/direct light signal (number of hits) correction
238  bool fIsFlatPDCorr, fIsDomePDCorr;
239  //parametrization exists for DUNE-SP and for SBND
241  // flat PDs
242  std::vector<std::vector<double>> fGHvuvpars_flat;
243  std::vector<double> fborder_corr_angulo_flat;
244  std::vector<std::vector<double>> fborder_corr_flat;
245  // dome PDs
246  std::vector<std::vector<double>> fGHvuvpars_dome;
247  std::vector<double> fborder_corr_angulo_dome;
248  std::vector<std::vector<double>> fborder_corr_dome;
249  // for the semi-analytic visible/reflection light hits correction
250  // parameterization exists for DUNE-SP and SBND
252  // flat PDs
253  std::vector<double> fvis_distances_x_flat;
254  std::vector<double> fvis_distances_r_flat;
255  std::vector<std::vector<std::vector<double>>> fvispars_flat;
256  // dome PDs
257  std::vector<double> fvis_distances_x_dome;
258  std::vector<double> fvis_distances_r_dome;
259  std::vector<std::vector<std::vector<double>>> fvispars_dome;
260 
261  // optical detector information, rest using geometry service
262  double fradius;
263 
264  std::string fLibraryFile;
267 
269  std::unique_ptr<phot::IPhotonMappingTransformations> fMapping;
270 
271  geo::Point_t LibLocation(geo::Point_t const& p) const;
272 
273  int VoxelAt(geo::Point_t const& p) const { return fVoxelDef.GetVoxelID(LibLocation(p)); }
274 
275  // same as `doGetVisibility()` but the channel number refers to the library
276  // ID rather than to the actual optical detector ID.
277  float doGetVisibilityOfOpLib(geo::Point_t const& p,
278  LibraryIndex_t libIndex,
279  bool wantReflected = false) const;
280 
281  // --- BEGIN Implementation functions --------------------------------------
284 
285  static double DistanceToOpDetImpl(geo::Point_t const& p, unsigned int OpDet);
286 
287  static double SolidAngleFactorImpl(geo::Point_t const& p, unsigned int OpDet);
288 
289  bool doHasVisibility(geo::Point_t const& p, bool wantReflected = false) const;
290 
291  float doGetVisibility(geo::Point_t const& p,
292  unsigned int OpChannel,
293  bool wantReflected = false) const;
294 
295  MappedCounts_t doGetAllVisibilities(geo::Point_t const& p, bool wantReflected = false) const;
296 
297  MappedT0s_t doGetReflT0s(geo::Point_t const& p) const;
298 
299  MappedParams_t doGetTimingPar(geo::Point_t const& p) const;
300 
301  MappedFunctions_t doGetTimingTF1(geo::Point_t const& p) const;
302 
303  void findVoxelSuggestion(float tpcMin,
304  float tpcMax,
305  float cryoMin,
306  float cryoMax,
307  int& nVoxels,
308  float& voxelMin,
309  float& voxelMax,
310  float voxelSizeGoal,
311  std::string* logString = nullptr) const;
312 
313  float testVoxelSuggestion(float tpcMin,
314  float tpcMax,
315  float cryoMin,
316  float cryoMax,
317  int& nVoxels,
318  float& voxelMin,
319  float& voxelMax,
320  float voxelSizeGoal,
321  int jog,
322  std::string* logString = nullptr) const;
323 
325  // --- END Implementation functions ----------------------------------------
326 
327  }; // class PhotonVisibilityService
328 } //namespace phot
330 #endif // PHOTONVISIBILITYSERVICE_H
Definitions of voxel data structures.
std::vector< std::vector< std::vector< double > > > fTau
Interface for transformation of photon visibility maps.
std::unique_ptr< phot::IPhotonMappingTransformations > fMapping
Mapping of detector space into library space.
std::vector< std::vector< double > > fborder_corr_flat
std::vector< double > fvis_distances_r_flat
std::vector< double > fvis_distances_x_dome
std::vector< std::vector< double > > fWidth
std::vector< double > fvis_distances_r_dome
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.
Definition: PhotonVoxels.h:58
::geo::Point_t toPoint(Point const &p)
Convert the specified point into a geo::Point_t.
MappedFunctions_t GetTimingTF1(Point const &p) const
std::vector< double > fvis_distances_x_flat
static double DistanceToOpDet(Point const &p, unsigned int OpDet)
std::vector< std::vector< std::vector< double > > > fCut_off
int VoxelAt(geo::Point_t const &p) const
int GetVoxelID(Point const &p) const
Returns the ID of the voxel containing p, or -1 if none.
Definition: PhotonVoxels.h:217
bool HasVisibility(Point const &p, bool wantReflected=false) const
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:289
MappedT0s_t GetReflT0s(Point const &p) const
Definitions of geometry vector data types.
std::vector< double > fDistances_radial_refl
#define DECLARE_ART_SERVICE(svc, scope)
Float_t radius
Definition: plot.C:23
std::string VISBorderCorrectionType() const
parameter set interface
Utilities to extend the interface of geometry vectors.
std::vector< std::vector< double > > fGHvuvpars_flat
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
double value
Definition: spectrum.C:18
std::vector< std::vector< double > > fGHvuvpars_dome
std::vector< std::vector< double > > fExpo_over_Landau_norm
const sim::PhotonVoxelDef & GetVoxelDef() const
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:180
General LArSoft Utilities.
std::vector< std::vector< double > > fMpv
A container for photon visibility mapping data.
Declaration of types related to photon visibility.
std::tuple< double, double, const reco::ClusterHit3D * > Point
Definitions used by the VoronoiDiagram algorithm.
Definition: DCEL.h:42
std::vector< std::vector< double > > fborder_corr_dome
std::vector< double > fborder_corr_angulo_flat
std::vector< std::vector< std::vector< double > > > fvispars_dome
std::vector< std::vector< double > > fNorm_over_entries
static double SolidAngleFactor(Point const &p, unsigned int OpDet)
const float * Counts_t
Type for visibility count per optical channel.
Interface shared by all PhotonLibrary-like classes.
MappedParams_t GetTimingPar(Point const &p) const
std::vector< std::vector< double > > fSlope
float GetVisibility(Point const &p, unsigned int OpChannel, bool wantReflected=false) const
std::vector< double > fborder_corr_angulo_dome
std::vector< std::vector< std::vector< double > > > fvispars_flat