PhotonVisibilityService_service.cc
Go to the documentation of this file.
1 // ////////////////////////////////////////////////////////////////////////
2 //
3 // \file PhotonVisibilityService_service.cc
4 //
5 ////////////////////////////////////////////////////////////////////////
6 //
7 // Ben Jones, MIT 2012
8 //
9 // This service reports the visibility of a particular point in
10 // the detector to each OpDet. This is used by the fast
11 // optical simulation and by track-light association algorithms.
12 //
13 // Visibility is defined as the fraction of isotropically produced
14 // photons from a detector voxel which are expected to reach the
15 // OpDet in question.
16 //
17 // This information is lookup up from a previously generated
18 // optical library file, whose path is specified to this service.
19 //
20 // Note that it is important that the voxelization schemes match
21 // between the library and the service instance for sensible results.
22 //
23 //
24 
25 // LArSoft includes
31 
33 
34 // framework libraries
38 #include "art_root_io/TFileService.h"
41 
42 // ROOT libraries
43 #include "TF1.h"
44 
45 // C/C++ standard libraries
46 
47 namespace phot {
48 
50  {
51  delete fparslogNorm;
52  delete fparslogNorm_far;
53  delete fparsMPV;
54  delete fparsMPV_far;
55  delete fparsWidth;
56  delete fparsCte;
57  delete fparsCte_far;
58  delete fparsSlope;
59  delete fparslogNorm_refl;
60  delete fparsMPV_refl;
61  delete fparsWidth_refl;
62  delete fparsCte_refl;
63  delete fparsSlope_refl;
64  delete fTheLibrary;
65  }
66 
67  //--------------------------------------------------------------------
69  :
70 
71  fCurrentVoxel(0)
72  , fCurrentValue(0.)
73  , fXmin(0.)
74  , fXmax(0.)
75  , fYmin(0.)
76  , fYmax(0.)
77  , fZmin(0.)
78  , fZmax(0.)
79  , fNx(0)
80  , fNy(0)
81  , fNz(0)
82  , fUseCryoBoundary(false)
83  , fLibraryBuildJob(false)
84  , fDoNotLoadLibrary(false)
85  , fParameterization(false)
86  , fHybrid(false)
87  , fStoreReflected(false)
88  , fStoreReflT0(false)
89  , fIncludePropTime(false)
90  , fUseNhitsModel(false)
91  , fParPropTime(false)
95  , fInterpolate(false)
96  , fReflectOverZeroX(false)
97  , fparslogNorm(nullptr)
98  , fparslogNorm_far(nullptr)
99  , fparsMPV(nullptr)
100  , fparsMPV_far(nullptr)
101  , fparsWidth(nullptr)
102  , fparsCte(nullptr)
103  , fparsCte_far(nullptr)
104  , fparsSlope(nullptr)
105  , fD_break(0.0)
106  , fD_max(0.0)
107  , fTF1_sampling_factor(0.0)
108  , fparslogNorm_refl(nullptr)
109  , fparsMPV_refl(nullptr)
110  , fparsWidth_refl(nullptr)
111  , fparsCte_refl(nullptr)
112  , fparsSlope_refl(nullptr)
113  , fT0_max(0.0)
114  , fT0_break_point(0.0)
115  , fLibraryFile()
116  , fTheLibrary(nullptr)
117  , fVoxelDef()
118  {
119  this->reconfigure(pset);
120 
121  if (pset.has_key("ReflectOverZeroX")) { // legacy parameter warning
122  if (pset.has_key("Mapping")) {
124  << "`PhotonVisbilityService` configuration specifies both `Mapping` and "
125  "`ReflectOverZeroX`."
126  " Please remove the latter (and use `PhotonMappingXMirrorTransformations` tool).";
127  }
128  else {
129  mf::LogWarning("PhotonVisbilityService")
130  << "Please update the configuration of `PhotonVisbilityService` service"
131  " replacing `ReflectOverZeroX` with tool configuration:"
132  "\n Mapping: { tool_type: \"PhotonMappingXMirrorTransformations\" }";
133  }
134  } // if
135  fhicl::ParameterSet mapDefaultSet;
136  mapDefaultSet.put("tool_type",
137  fReflectOverZeroX ? "PhotonMappingXMirrorTransformations" :
138  "PhotonMappingIdentityTransformations");
139  fMapping = art::make_tool<phot::IPhotonMappingTransformations>(
140  pset.get<fhicl::ParameterSet>("Mapping", mapDefaultSet));
141 
142  mf::LogInfo("PhotonVisibilityService") << "PhotonVisbilityService initializing" << std::endl;
143  }
144 
145  //--------------------------------------------------------------------
146  void
148  {
149  // Don't do anything if the library has already been loaded.
150 
151  if (fTheLibrary == 0) {
152 
153  if ((!fLibraryBuildJob) && (!fDoNotLoadLibrary)) {
154  std::string LibraryFileWithPath;
155  cet::search_path sp("FW_SEARCH_PATH");
156 
157  if (!sp.find_file(fLibraryFile, LibraryFileWithPath))
158  throw cet::exception("PhotonVisibilityService")
159  << "Unable to find photon library in " << sp.to_string() << "\n";
160 
161  if (!fParameterization) {
163 
164  mf::LogInfo("PhotonVisibilityService")
165  << "PhotonVisibilityService Loading photon library from file " << LibraryFileWithPath
166  << " for " << GetVoxelDef().GetNVoxels() << " voxels and " << geom->NOpDets()
167  << " optical detectors." << std::endl;
168 
169  if (fHybrid) {
170  fTheLibrary = new PhotonLibraryHybrid(LibraryFileWithPath, GetVoxelDef());
171  }
172  else {
173  PhotonLibrary* lib = new PhotonLibrary;
174  fTheLibrary = lib;
175 
176  size_t NVoxels = GetVoxelDef().GetNVoxels();
177  lib->LoadLibraryFromFile(LibraryFileWithPath,
178  NVoxels,
180  fStoreReflT0,
183 
184  // if the library does not have metadata, we supply some;
185  // otherwise we check that it's compatible with the configured one
186  // (and shrug if it's not); overriding configured metadata
187  // from the one in the library is currently not supported
188  if (!lib->hasVoxelDef())
189  lib->SetVoxelDef(GetVoxelDef());
190  else if (GetVoxelDef() != lib->GetVoxelDef()) {
191  // this might become a fatal error in the future if some protocol
192  // is imposed... it may also be possible to check only the size
193  // rather than the coordinates, which may allow for translations
194  // of the geometry volumes in world space.
195  mf::LogWarning("PhotonVisbilityService")
196  << "Photon library reports the geometry:\n"
197  << lib->GetVoxelDef() << "while PhotonVisbilityService is configured with:\n"
198  << GetVoxelDef();
199  } // if metadata
200  }
201  }
202  }
203  else {
205 
206  size_t NOpDets = geom->NOpDets();
207  size_t NVoxels = GetVoxelDef().GetNVoxels();
208  if (fLibraryBuildJob) {
209  mf::LogInfo("PhotonVisibilityService")
210  << " Vis service running library build job. Please ensure "
211  << " job contains LightSource, LArG4, SimPhotonCounter";
212  }
213 
214  art::TFileDirectory* pDir = nullptr;
215  try {
217  }
218  catch (art::Exception const& e) {
219  if (e.categoryCode() != art::errors::ServiceNotFound) throw;
220  if (fLibraryBuildJob) {
221  throw art::Exception(e.categoryCode(), "", e)
222  << "PhotonVisibilityService: "
223  "service `TFileService` is required when building a photon library.\n";
224  }
225  }
226 
227  PhotonLibrary* lib = new PhotonLibrary(pDir);
228  fTheLibrary = lib;
229 
230  lib->CreateEmptyLibrary(NVoxels, NOpDets, fStoreReflected, fStoreReflT0, fParPropTime_npar);
231  lib->SetVoxelDef(GetVoxelDef());
232  }
233  }
234  }
235 
236  //--------------------------------------------------------------------
237  void
239  {
240  if (fTheLibrary == 0) LoadLibrary();
241 
242  if (fLibraryBuildJob) {
243 
244  if (fHybrid) {
245  std::cout << "This is would be building a Hybrid Library. Not defined. " << std::endl;
246  }
247  mf::LogInfo("PhotonVisibilityService") << " Vis service "
248  << " Storing Library entries to file..." << std::endl;
249  PhotonLibrary* lib = dynamic_cast<PhotonLibrary*>(fTheLibrary);
251  }
252  }
253 
254  //--------------------------------------------------------------------
255  void
257  {
258 
260 
261  // Library details
262  fLibraryBuildJob = p.get<bool>("LibraryBuildJob", false);
263  fParameterization = p.get<bool>("DUNE10ktParameterization", false);
264  fHybrid = p.get<bool>("HybridLibrary", false);
265  fLibraryFile = p.get<std::string>("LibraryFile", "");
266  fDoNotLoadLibrary = p.get<bool>("DoNotLoadLibrary");
267  fStoreReflected = p.get<bool>("StoreReflected", false);
268  fStoreReflT0 = p.get<bool>("StoreReflT0", false);
269  // Parametrizations (time and Nhits)
270  fIncludePropTime = p.get<bool>("IncludePropTime", false);
271  fUseNhitsModel = p.get<bool>("UseNhitsModel", false);
272  fApplyVISBorderCorrection = p.get<bool>("ApplyVISBorderCorrection", false);
273  fVISBorderCorrectionType = p.get<std::string>("VIS_BORDER_correction_type", "");
274 
275  // Voxel parameters
276  fUseCryoBoundary = p.get<bool>("UseCryoBoundary", false);
277  fInterpolate = p.get<bool>("Interpolate", false);
278  fReflectOverZeroX = p.get<bool>("ReflectOverZeroX", false);
279 
280  fParPropTime = p.get<bool>("ParametrisedTimePropagation", false);
281  fParPropTime_npar = p.get<size_t>("ParametrisedTimePropagationNParameters", 0);
282  fParPropTime_formula = p.get<std::string>("ParametrisedTimePropagationFittedFormula", "");
283  fParPropTime_MaxRange = p.get<int>("ParametrisedTimePropagationMaxRange", 200);
284 
285  if (!fParPropTime) { fParPropTime_npar = 0; }
286 
287  if (!fUseNhitsModel) {
288 
289  if (fUseCryoBoundary) {
290  double CryoBounds[6];
291  geom->CryostatBoundaries(CryoBounds);
292  fXmin = CryoBounds[0];
293  fXmax = CryoBounds[1];
294  fYmin = CryoBounds[2];
295  fYmax = CryoBounds[3];
296  fZmin = CryoBounds[4];
297  fZmax = CryoBounds[5];
298  }
299  else {
300  fXmin = p.get<double>("XMin");
301  fXmax = p.get<double>("XMax");
302  fYmin = p.get<double>("YMin");
303  fYmax = p.get<double>("YMax");
304  fZmin = p.get<double>("ZMin");
305  fZmax = p.get<double>("ZMax");
306  }
307 
308  fNx = p.get<int>("NX");
309  fNy = p.get<int>("NY");
310  fNz = p.get<int>("NZ");
311 
313  }
314 
315  if (fIncludePropTime) {
316 
317  // load VUV arrival time distribution parametrization (no detector dependent at first order)
318  std::cout << "Loading the VUV time parametrization" << std::endl;
319  fDistances_landau = p.get<std::vector<double>>("Distances_landau");
320  fNorm_over_entries = p.get<std::vector<std::vector<double>>>("Norm_over_entries");
321  fMpv = p.get<std::vector<std::vector<double>>>("Mpv");
322  fWidth = p.get<std::vector<std::vector<double>>>("Width");
323  fDistances_exp = p.get<std::vector<double>>("Distances_exp");
324  fSlope = p.get<std::vector<std::vector<double>>>("Slope");
325  fExpo_over_Landau_norm = p.get<std::vector<std::vector<double>>>("Expo_over_Landau_norm");
326  fstep_size = p.get<double>("step_size");
327  fmax_d = p.get<double>("max_d");
328  fmin_d = p.get<double>("min_d");
329  fvuv_vgroup_mean = p.get<double>("vuv_vgroup_mean");
330  fvuv_vgroup_max = p.get<double>("vuv_vgroup_max");
331  finflexion_point_distance = p.get<double>("inflexion_point_distance");
332  fangle_bin_timing_vuv = p.get<double>("angle_bin_timing_vuv");
333 
334  if (fStoreReflected) {
335 
336  // load VIS arrival time distribution paramterisation
337  std::cout << "Loading the VIS time paramterisation" << std::endl;
338  fDistances_refl = p.get<std::vector<double>>("Distances_refl");
339  fDistances_radial_refl = p.get<std::vector<double>>("Distances_radial_refl");
340  fCut_off = p.get<std::vector<std::vector<std::vector<double>>>>("Cut_off");
341  fTau = p.get<std::vector<std::vector<std::vector<double>>>>("Tau");
342  fvis_vmean = p.get<double>("vis_vmean");
343  fangle_bin_timing_vis = p.get<double>("angle_bin_timing_vis");
344  }
345  }
346 
347  if (fUseNhitsModel) {
348  std::cout << "Loading semi-analytic mode models" << std::endl;
349  // VUV
350  fIsFlatPDCorr = p.get<bool>("FlatPDCorr", false);
351  fIsDomePDCorr = p.get<bool>("DomePDCorr", false);
352  fdelta_angulo_vuv = p.get<double>("delta_angulo_vuv");
353  if(fIsFlatPDCorr) {
354  fGHvuvpars_flat = p.get<std::vector<std::vector<double>>>("GH_PARS_flat");
355  fborder_corr_angulo_flat = p.get<std::vector<double>>("GH_border_angulo_flat");
356  fborder_corr_flat = p.get<std::vector<std::vector<double>>>("GH_border_flat");
357  }
358  if(fIsDomePDCorr) {
359  fGHvuvpars_dome = p.get<std::vector<std::vector<double>>>("GH_PARS_dome");
360  fborder_corr_angulo_dome = p.get<std::vector<double>>("GH_border_angulo_dome");
361  fborder_corr_dome = p.get<std::vector<std::vector<double>>>("GH_border_dome");
362  }
363 
364  if (fStoreReflected) {
365  fdelta_angulo_vis = p.get<double>("delta_angulo_vis");
366  if(fIsFlatPDCorr) {
367  fvis_distances_x_flat = p.get<std::vector<double>>("VIS_distances_x_flat");
368  fvis_distances_r_flat = p.get<std::vector<double>>("VIS_distances_r_flat");
369  fvispars_flat = p.get<std::vector<std::vector<std::vector<double>>>>("VIS_correction_flat");
370  }
371  if(fIsDomePDCorr) {
372  fvis_distances_x_dome = p.get<std::vector<double>>("VIS_distances_x_dome");
373  fvis_distances_r_dome = p.get<std::vector<double>>("VIS_distances_r_dome");
374  fvispars_dome = p.get<std::vector<std::vector<std::vector<double>>>>("VIS_correction_dome");
375  }
376  }
377  // optical detector information
378  fradius = p.get<double>("PMT_radius", 10.16);
379  }
380 
381  return;
382  }
383 
384  //------------------------------------------------------
385 
386  // Eventually we will calculate the light quenching factor here
387  double
389  {
390  // for now, no quenching
391  return 1.0;
392  }
393 
394  //------------------------------------------------------
395 
396  // Get a vector of the relative visibilities of each OpDet
397  // in the event to a point p
398 
399  auto
401  -> MappedCounts_t
402  {
404 
405  // first we fill a container of visibilities in the library index space
406  // (it is directly the values of the library unless interpolation is
407  // requested)
408  if (fInterpolate) {
409  // this is a punch into multithreading face:
410  static std::vector<float> ret;
411  ret.resize(fMapping->libraryMappingSize(p));
412  for (std::size_t libIndex = 0; libIndex < ret.size(); ++libIndex) {
413  ret[libIndex] = doGetVisibilityOfOpLib(p, LibraryIndex_t(libIndex), wantReflected);
414  }
415  data = &ret.front();
416  }
417  else {
418  auto const VoxID = VoxelAt(p);
419  data = GetLibraryEntries(VoxID, wantReflected);
420  }
421  return fMapping->applyOpDetMapping(p, data);
422  }
423 
424  //------------------------------------------------------
425 
426  // Get distance to optical detector OpDet
427  double
429  {
431  return geom->OpDetGeoFromOpDet(OpDet).DistanceToPoint(p);
432  }
433 
434  //------------------------------------------------------
435 
436  // Get the solid angle reduction factor for planar optical detector OpDet
437  double
439  {
441  return geom->OpDetGeoFromOpDet(OpDet).CosThetaFromNormal(p);
442  }
443 
444  //------------------------------------------------------
445 
446  float
448  LibraryIndex_t libIndex,
449  bool wantReflected /* = false */) const
450  {
451  if (!fInterpolate) { return GetLibraryEntry(VoxelAt(p), libIndex, wantReflected); }
452 
453  // In case we're outside the bounding box we'll get a empty optional list.
454  auto const neis = GetVoxelDef().GetNeighboringVoxelIDs(LibLocation(p));
455  if (!neis) return 0.0;
456 
457  // Sum up all the weighted neighbours to get interpolation behaviour
458  float vis = 0.0;
459  for (const sim::PhotonVoxelDef::NeiInfo& n : neis.value()) {
460  if (n.id < 0) continue;
461  vis += n.weight * GetLibraryEntry(n.id, libIndex, wantReflected);
462  }
463  return vis;
464  }
465 
466  //------------------------------------------------------
467 
468  bool
470  bool wantReflected /* = false */) const
471  {
472  return HasLibraryEntries(VoxelAt(p), wantReflected);
473  }
474 
475  //------------------------------------------------------
476 
477  float
479  unsigned int OpChannel,
480  bool wantReflected) const
481  {
482  // here we quietly confuse op. det. channel (interface) and op. det. (library)
483  LibraryIndex_t const libIndex = fMapping->opDetToLibraryIndex(p, OpChannel);
484  return doGetVisibilityOfOpLib(p, libIndex, wantReflected);
485  }
486 
487  //------------------------------------------------------
488 
489  void
491  {
492  fCurrentVoxel = VoxID;
493  fCurrentValue = N;
494  mf::LogInfo("PhotonVisibilityService")
495  << " PVS notes production of " << N << " photons at Vox " << VoxID << std::endl;
496  }
497 
498  //------------------------------------------------------
499 
500  void
502  {
503  N = fCurrentValue;
504  VoxID = fCurrentVoxel;
505  }
506 
507  //------------------------------------------------------
508 
509  void
510  PhotonVisibilityService::SetLibraryEntry(int VoxID, int OpChannel, float N, bool wantReflected)
511  {
512  if (fTheLibrary == 0) LoadLibrary();
513 
514  PhotonLibrary* lib = dynamic_cast<PhotonLibrary*>(fTheLibrary);
515 
516  if (!wantReflected)
517  lib->SetCount(VoxID, OpChannel, N);
518 
519  else
520  lib->SetReflCount(VoxID, OpChannel, N);
521 
522  //std::cout<< " PVS logging " << VoxID << " " << OpChannel<<std::endl;
523  MF_LOG_DEBUG("PhotonVisibilityService")
524  << " PVS logging " << VoxID << " " << OpChannel << std::endl;
525  }
526 
527  //------------------------------------------------------
528 
530  PhotonVisibilityService::GetLibraryEntries(int VoxID, bool wantReflected) const
531  {
532  if (fTheLibrary == 0) LoadLibrary();
533 
534  if (!wantReflected)
535  return fTheLibrary->GetCounts(VoxID);
536  else
537  return fTheLibrary->GetReflCounts(VoxID);
538  }
539 
540  //------------------------------------------------------
541 
542  bool
544  bool /* wantReflected */ /* = false */) const
545  {
546  if (!fTheLibrary) LoadLibrary();
547  return fTheLibrary->isVoxelValid(VoxID);
548  }
549 
550  //------------------------------------------------------
551 
552  float
554  OpDetID_t libOpChannel,
555  bool wantReflected) const
556  {
557  if (fTheLibrary == 0) LoadLibrary();
558 
559  if (!wantReflected)
560  return fTheLibrary->GetCount(VoxID, libOpChannel);
561  else
562  return fTheLibrary->GetReflCount(VoxID, libOpChannel);
563  }
564  // Methodes to handle the extra library parameter refl T0
565  //------------------------------------------------------
566 
567  // Get a vector of the refl <tfirst> of each OpDet
568  // in the event to a point p
569 
570  auto
572  {
573  // both the input and the output go through mapping to apply needed symmetries.
574  int const VoxID = VoxelAt(p);
576  return fMapping->applyOpDetMapping(p, data);
577  }
578 
579  //------------------------------------------------------
580 
583  {
584  if (fTheLibrary == 0) LoadLibrary();
585 
586  return fTheLibrary->GetReflT0s(VoxID);
587  }
588 
589  //------------------------------------------------------
590 
591  void
593  {
594  PhotonLibrary* lib = dynamic_cast<PhotonLibrary*>(fTheLibrary);
595  if (fTheLibrary == 0) LoadLibrary();
596 
597  lib->SetReflT0(VoxID, OpChannel, T0);
598 
599  MF_LOG_DEBUG("PhotonVisibilityService")
600  << " PVS logging " << VoxID << " " << OpChannel << std::endl;
601  }
602 
603  //------------------------------------------------------
604 
605  float
607  {
608  if (fTheLibrary == 0) LoadLibrary();
609 
610  return fTheLibrary->GetReflT0(VoxID, libOpChannel);
611  }
612 
613  //------------------------------------------------------
614 
615  /////////////****////////////
616 
617  auto
619  {
620  int const VoxID = VoxelAt(p);
622  return fMapping->applyOpDetMapping(p, params);
623  }
624 
625  auto
627  {
628  int const VoxID = VoxelAt(p);
630  return fMapping->applyOpDetMapping(p, functions);
631  }
632 
633  //------------------------------------------------------
634 
637  {
638  PhotonLibrary* lib = dynamic_cast<PhotonLibrary*>(fTheLibrary);
639  if (fTheLibrary == 0) LoadLibrary();
640 
641  return lib->GetTimingPars(VoxID);
642  }
643 
644  //------------------------------------------------------
645 
648  {
649  PhotonLibrary* lib = dynamic_cast<PhotonLibrary*>(fTheLibrary);
650  if (fTheLibrary == 0) LoadLibrary();
651 
652  return lib->GetTimingTF1s(VoxID);
653  }
654 
655  //------------------------------------------------------
656 
657  void
659  int OpChannel,
660  float par,
661  size_t parnum)
662  {
663  PhotonLibrary* lib = dynamic_cast<PhotonLibrary*>(fTheLibrary);
664  if (fTheLibrary == 0) LoadLibrary();
665 
666  lib->SetTimingPar(VoxID, OpChannel, par, parnum);
667 
668  MF_LOG_DEBUG("PhotonVisibilityService")
669  << " PVS logging " << VoxID << " " << OpChannel << std::endl;
670  }
671 
672  //------------------------------------------------------
673 
674  void
676  {
677  PhotonLibrary* lib = dynamic_cast<PhotonLibrary*>(fTheLibrary);
678  if (fTheLibrary == 0) LoadLibrary();
679 
680  lib->SetTimingTF1(VoxID, OpChannel, func);
681 
682  MF_LOG_DEBUG("PhotonVisibilityService")
683  << " PVS logging " << VoxID << " " << OpChannel << std::endl;
684  }
685 
686  //------------------------------------------------------
687 
688  float
690  OpDetID_t libOpChannel,
691  size_t npar) const
692  {
693  PhotonLibrary* lib = dynamic_cast<PhotonLibrary*>(fTheLibrary);
694  if (fTheLibrary == 0) LoadLibrary();
695 
696  return lib->GetTimingPar(VoxID, libOpChannel, npar);
697  }
698 
699  //------------------------------------------------------
700 
701  size_t
703  {
704  // the last word about the number of channels belongs to the mapping;
705  // this should be also the same answer as `geo::GeometryCore::NOpDets()`.
706  return fMapping->opDetMappingSize();
707  }
708 
709  //------------------------------------------------------
710  void
712  double& d_break,
713  double& d_max,
714  double& tf1_sampling_factor) const
715  {
716  functions[0] = fparslogNorm;
717  functions[1] = fparsMPV;
718  functions[2] = fparsWidth;
719  functions[3] = fparsCte;
720  functions[4] = fparsSlope;
721  functions[5] = fparslogNorm_far;
722  functions[6] = fparsMPV_far;
723  functions[7] = fparsCte_far;
724 
725  d_break = fD_break;
726  d_max = fD_max;
727  tf1_sampling_factor = fTF1_sampling_factor;
728  }
729 
730  //------------------------------------------------------
731  void
733  double& t0_max,
734  double& t0_break_point) const
735  {
736  functions[0] = fparslogNorm_refl;
737  functions[1] = fparsMPV_refl;
738  functions[2] = fparsWidth_refl;
739  functions[3] = fparsCte_refl;
740  functions[4] = fparsSlope_refl;
741 
742  t0_max = fT0_max;
743  t0_break_point = fT0_break_point;
744  }
745 
746  //------------------------------------------------------
747  void
749  double& step_size,
750  double& max_d,
751  double& min_d,
752  double& vuv_vgroup_mean,
753  double& vuv_vgroup_max,
754  double& inflexion_point_distance,
755  double& angle_bin_timing_vuv) const
756  {
757  v[0] = std::vector(1, fDistances_landau);
758  v[1] = fNorm_over_entries;
759  v[2] = fMpv;
760  v[3] = fWidth;
761  v[4] = std::vector(1, fDistances_exp);
762  v[5] = fSlope;
763  v[6] = fExpo_over_Landau_norm;
764 
765  step_size = fstep_size;
766  max_d = fmax_d;
767  min_d = fmin_d;
768  vuv_vgroup_mean = fvuv_vgroup_mean;
769  vuv_vgroup_max = fvuv_vgroup_max;
770  inflexion_point_distance = finflexion_point_distance;
771  angle_bin_timing_vuv = fangle_bin_timing_vuv;
772  }
773 
774  void
775  PhotonVisibilityService::LoadTimingsForVISPar(std::vector<double>& distances,
776  std::vector<double>& radial_distances,
777  std::vector<std::vector<std::vector<double>>>& cut_off,
778  std::vector<std::vector<std::vector<double>>>& tau,
779  double& vis_vmean,
780  double& angle_bin_timing_vis) const
781  {
782  distances = fDistances_refl;
783  radial_distances = fDistances_radial_refl;
784  cut_off = fCut_off;
785  tau = fTau;
786 
787  vis_vmean = fvis_vmean;
788  angle_bin_timing_vis = fangle_bin_timing_vis;
789  }
790 
792  bool &isDomePDCorr,
793  double &delta_angulo_vuv,
794  double &radius) const
795  {
796  isFlatPDCorr = fIsFlatPDCorr;
797  isDomePDCorr = fIsDomePDCorr;
798  delta_angulo_vuv = fdelta_angulo_vuv;
799  radius = fradius;
800  }
801  void PhotonVisibilityService::LoadGHFlat( std::vector<std::vector<double>> &GHvuvpars_flat,
802  std::vector<double> &border_corr_angulo_flat,
803  std::vector<std::vector<double>> &border_corr_flat) const
804  {
805  if (!fIsFlatPDCorr) return;
806  GHvuvpars_flat = fGHvuvpars_flat;
807  border_corr_angulo_flat = fborder_corr_angulo_flat;
808  border_corr_flat = fborder_corr_flat;
809  }
810  void PhotonVisibilityService::LoadGHDome( std::vector<std::vector<double>> &GHvuvpars_dome,
811  std::vector<double> &border_corr_angulo_dome,
812  std::vector<std::vector<double>> &border_corr_dome) const
813  {
814  if (!fIsDomePDCorr) return;
815  GHvuvpars_dome = fGHvuvpars_dome;
816  border_corr_angulo_dome = fborder_corr_angulo_dome;
817  border_corr_dome = fborder_corr_dome;
818  }
820  double &radius) const
821  {
822  delta_angulo_vis = fdelta_angulo_vis;
823  radius = fradius;
824  }
825  void PhotonVisibilityService::LoadVisParsFlat(std::vector<double> &vis_distances_x_flat,
826  std::vector<double> &vis_distances_r_flat,
827  std::vector<std::vector<std::vector<double>>> &vispars_flat) const
828  {
829  if (!fIsFlatPDCorr) return;
830  vis_distances_x_flat = fvis_distances_x_flat;
831  vis_distances_r_flat = fvis_distances_r_flat;
832  vispars_flat = fvispars_flat;
833  }
834  void PhotonVisibilityService::LoadVisParsDome(std::vector<double> &vis_distances_x_dome,
835  std::vector<double> &vis_distances_r_dome,
836  std::vector<std::vector<std::vector<double>>> &vispars_dome) const
837  {
838  if (!fIsDomePDCorr) return;
839  vis_distances_x_dome = fvis_distances_x_dome;
840  vis_distances_r_dome = fvis_distances_r_dome;
841  vispars_dome = fvispars_dome;
842  }
843 
844  //------------------------------------------------------
845  /***
846  * Preform any necessary transformations on the coordinates before trying to access
847  * a voxel ID.
848  **/
851  {
852  return fMapping->detectorToLibrary(p);
853  }
854 
855 } // namespace
856 
857 namespace phot {
858 
860 
861 } // namespace phot
Definitions of voxel data structures.
std::vector< std::vector< std::vector< double > > > fTau
MappedParams_t doGetTimingPar(geo::Point_t const &p) const
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
Index OpChannel(Index detNum, Index channel)
phot::IPhotonLibrary::Counts_t GetLibraryReflT0Entries(int VoxID) const
OpDetGeo const & OpDetGeoFromOpDet(unsigned int OpDet) const
Returns the geo::OpDetGeo object for the given detector number.
virtual float GetReflT0(size_t Voxel, size_t OpChannel) const =0
std::string to_string() const
Definition: search_path.cc:161
double CosThetaFromNormal(geo::Point_t const &point) const
Get cos(angle) to normal of this detector - used for solid angle calcs.
Definition: OpDetGeo.cxx:138
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 LoadLibraryFromFile(std::string LibraryFile, size_t NVoxels, bool storeReflected=false, bool storeReflT0=false, size_t storeTiming=0, int maxrange=200)
std::vector< std::vector< double > > fborder_corr_flat
std::vector< double > fvis_distances_r_flat
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
std::vector< double > fvis_distances_x_dome
std::string string
Definition: nybbler.cc:12
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
void SetLibraryTimingParEntry(int VoxID, int OpChannel, float value, size_t parnum)
sim::PhotonVoxelDef const & GetVoxelDef() const
bool hasVoxelDef() const
Returns whether voxel metadata is available.
Definition: PhotonLibrary.h:98
std::vector< std::vector< double > > fWidth
std::vector< double > fvis_distances_r_dome
virtual float GetReflCount(size_t Voxel, size_t OpChannel) const =0
phot::IPhotonMappingTransformations::LibraryIndex_t LibraryIndex_t
Type of optical library index.
Representation of a region of space diced into voxels.
Definition: PhotonVoxels.h:58
struct vector vector
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
std::vector< double > fvis_distances_x_flat
void StoreLibraryToFile(std::string LibraryFile, bool storeReflected=false, bool storeReflT0=false, size_t storeTiming=0) const
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 VoxelAt(geo::Point_t const &p) const
void SetCount(size_t Voxel, size_t OpChannel, float Count)
void CryostatBoundaries(double *boundaries, geo::CryostatID const &cid) const
Returns the boundaries of the specified cryostat.
art framework interface to geometry description
void SetTimingTF1(size_t Voxel, size_t OpChannel, TF1 func)
void LoadVUVSemiAnalyticProperties(bool &isFlatPDCorr, bool &isDomePDCorr, double &delta_angulo_vuv, double &radius) const
float GetLibraryReflT0Entry(int VoxID, OpDetID_t libOpChannel) const
void SetReflectedCOLightPropFunctions(TF1 const *functions[5], double &t0_max, double &t0_break_point) const
void SetVoxelDef(sim::PhotonVoxelDef const &voxelDef)
PhotonVisibilityService(fhicl::ParameterSet const &pset)
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 SetReflT0(size_t Voxel, size_t OpChannel, float reflT0)
const double e
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
std::vector< double > fDistances_radial_refl
std::void_t< T > n
void SetLibraryReflT0Entry(int VoxID, int OpChannel, float value)
virtual Counts_t GetReflCounts(size_t Voxel) const =0
T get(std::string const &key) const
Definition: ParameterSet.h:271
virtual float GetCount(size_t Voxel, size_t OpChannel) const =0
virtual Counts_t GetCounts(size_t Voxel) const =0
Returns a pointer to NOpChannels() visibility values, one per channel.
void reconfigure(fhicl::ParameterSet const &p)
p
Definition: test.py:223
TF1 * GetTimingTF1s(size_t Voxel) const
const std::vector< float > * GetTimingPars(size_t Voxel) const
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
bool has_key(std::string const &key) const
unsigned int NOpDets() const
Number of OpDets in the whole detector.
virtual bool isVoxelValid(size_t Voxel) const
std::vector< std::vector< double > > fGHvuvpars_dome
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
Encapsulate the geometry of an optical detector.
void SetTimingPar(size_t Voxel, size_t OpChannel, float Count, size_t parnum)
std::vector< std::vector< double > > fExpo_over_Landau_norm
const sim::PhotonVoxelDef & GetVoxelDef() const
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
#define DEFINE_ART_SERVICE(svc)
double DistanceToPoint(geo::Point_t const &point) const
Returns the distance of the specified point from detector center [cm].
Definition: OpDetGeo.cxx:123
void LoadVisSemiAnalyticProperties(double &delta_angulo_vis, double &radius) const
General LArSoft Utilities.
std::vector< std::vector< double > > fMpv
std::optional< std::array< NeiInfo, 8U > > GetNeighboringVoxelIDs(Point const &v) const
Returns IDs of the eight neighboring voxels around v.
virtual T0s_t GetReflT0s(size_t Voxel) const =0
void SetLibraryEntry(int VoxID, OpDetID_t libOpChannel, float N, bool wantReflected=false)
A container for photon visibility mapping data.
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
std::vector< std::vector< double > > fborder_corr_dome
#define MF_LOG_DEBUG(id)
float GetTimingPar(size_t Voxel, size_t OpChannel, size_t parnum) const
float doGetVisibility(geo::Point_t const &p, unsigned int OpChannel, bool wantReflected=false) const
std::vector< double > fborder_corr_angulo_flat
def func()
Definition: docstring.py:7
std::string find_file(std::string const &filename) const
Definition: search_path.cc:96
unsigned int GetNVoxels() const
Returns the total number of voxels in the volume.
void SetLibraryTimingTF1Entry(int VoxID, int OpChannel, TF1 const &func)
std::vector< std::vector< std::vector< double > > > fvispars_dome
std::vector< std::vector< double > > fNorm_over_entries
const float * Counts_t
Type for visibility count per optical channel.
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)
void SetReflCount(size_t Voxel, size_t OpChannel, float Count)
std::vector< std::vector< double > > fSlope
phot::IPhotonLibrary::Functions_t GetLibraryTimingTF1Entries(int VoxID) const
std::vector< double > fborder_corr_angulo_dome
phot::IPhotonLibrary::Params_t GetLibraryTimingParEntries(int VoxID) const
std::vector< std::vector< std::vector< double > > > fvispars_flat
void put(std::string const &key)
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
QTextStream & endl(QTextStream &s)