10 #include "cetlib_except/exception.h" 19 : fISTPC{*(lar::providerFrom<geo::Geometry>())}
30 std::cout <<
"Photon propagation time model initalized." <<
std::endl;
42 mf::LogInfo(
"PropagationTimeModel") <<
"Using VUV timing parameterization";
50 fparameters[6] =
fVUVTimingParams.
get<std::vector<std::vector<double>>>(
"Expo_over_Landau_norm");
62 const size_t num_params = (fmax_d -
fmin_d) / fstep_size;
63 size_t num_angles = std::round(90/fangle_bin_timing_vuv);
75 mf::LogInfo(
"PropagationTimeModel") <<
"Using VIS (reflected) timing parameterization";
87 mf::LogInfo(
"PropagationTimeModel") <<
"Using geometric VUV time propagation";
98 fActiveVolumes[0].CenterY(),
99 fActiveVolumes[0].CenterZ()};
113 else if (opDet.
isBar()) {
140 double distance =
std::hypot(x0.X() - opDetCenter.X(), x0.Y() - opDetCenter.Y(), x0.Z() - opDetCenter.Z());
143 else cosine =
std::abs(x0.X() - opDetCenter.X()) / distance;
147 getVUVTimes(arrival_time_dist, distance, angle_bin);
157 double distance =
std::hypot(x0.X() - opDetCenter.X(), x0.Y() - opDetCenter.Y(), x0.Z() - opDetCenter.Z());
162 <<
"Propagation time model not found.";
174 for (
size_t i = 0; i < arrivalTimes.size(); ++i) {
175 arrivalTimes[i] = t_prop_correction;
184 for (
size_t i = 0; i < arrivalTimes.size(); ++i) {
197 for (
size_t i = 0; i < arrivalTimes.size(); ++i) {
198 arrivalTimes[i] = t_prop_correction;
211 const double signal_t_range = 5000.;
222 std::array<double, 3> pars_landau;
233 double pars_far[4] = {t_direct_min, pars_landau[0], pars_landau[1], pars_landau[2]};
235 fVUVTiming = TF1(
"fVUVTiming",
model_far, 0, signal_t_range, 4);
236 fVUVTiming.SetParameters(pars_far);
240 fVUVTiming = TF1(
"fVUVTiming",
model_close, 0, signal_t_range, 7);
246 pars_expo[0] *= pars_landau[2];
247 pars_expo[0] = std::log(pars_expo[0]);
249 TF1 fint = TF1(
"fint",
finter_d, pars_landau[0], 4 * t_direct_mean, 5);
250 double parsInt[5] = {
251 pars_landau[0], pars_landau[1], pars_landau[2], pars_expo[0], pars_expo[1]};
252 fint.SetParameters(parsInt);
253 double t_int = fint.GetMinimumX();
254 double minVal = fint.Eval(t_int);
256 if (minVal > 0.015) {
257 std::cout <<
"WARNING: Parametrization of VUV light discontinuous for distance = " 259 std::cout <<
"WARNING: This shouldn't be happening " <<
std::endl;
261 double parsfinal[7] = {t_int,
268 fVUVTiming.SetParameters(parsfinal);
274 if (distance_in_cm < 50) fsampling = 10000;
275 else if (distance_in_cm < 100) fsampling = 5000;
276 else fsampling = 1000;
277 fVUVTiming.SetNpx(fsampling);
281 const size_t nq_max = 1;
282 double xq_max[nq_max];
283 double yq_max[nq_max];
285 fVUVTiming.GetQuantiles(nq_max, yq_max, xq_max);
286 double max = yq_max[0];
288 double min = t_direct_min;
302 const TVector3 &ScintPoint,
303 const TVector3 &OpDetPoint)
316 TVector3 bounce_point(plane_depth,ScintPoint[1],ScintPoint[2]);
319 double VUVdist = (bounce_point - ScintPoint).Mag();
320 double Visdist = (OpDetPoint - bounce_point).Mag();
323 int angle_bin_vuv = 0;
327 for (
size_t i = 0; i < arrivalTimes.size(); ++i) {
349 double fastest_time = vis_time + vuv_time;
352 double cosine_theta =
std::abs(OpDetPoint[0] - bounce_point[0]) / Visdist;
359 double distance_cathode_plane =
std::abs(plane_depth - ScintPoint[0]);
369 for (
size_t i = 0; i <
fcut_off_pars[theta_bin].size(); i++){
377 std::vector<double> interp_vals_tau(
ftau_pars[theta_bin].
size(), 0.0);
378 for (
size_t i = 0; i <
ftau_pars[theta_bin].size(); i++){
385 for (
size_t i = 0; i < arrivalTimes.size(); ++i) {
386 double arrival_time_smeared;
388 if (arrivalTimes[i] >= cutoff) {
continue; }
397 arrival_time_smeared = arrivalTimes[i];
404 arrival_time_smeared =
405 arrivalTimes[i] + (arrivalTimes[i] - fastest_time) * (
std::pow(x, -tau) - 1);
408 }
while (arrival_time_smeared > cutoff);
410 arrivalTimes[i] = arrival_time_smeared;
418 double negate = double(x < 0);
420 x -= double(x > 1.0) * (x - 1.0);
421 double ret = -0.0187293;
423 ret = ret + 0.0742610;
425 ret = ret - 0.2121144;
427 ret = ret + 1.5707288;
428 ret = ret * std::sqrt(1.0 - x);
429 ret = ret - 2. * negate * ret;
430 return negate * 3.14159265358979 + ret;
440 const std::vector<double>& yData,
446 size_t size = xData.size();
447 if (x >= xData[size - 2]) {
451 while (x > xData[i + 1])
455 double xL = xData[i];
456 double xR = xData[i + 1];
457 double yL = yData[i];
458 double yR = yData[i + 1];
460 if (x < xL)
return yL;
461 if (x > xR)
return yL;
463 const double dydx = (yR - yL) / (xR - xL);
464 return yL + dydx * (x - xL);
470 const std::vector<double>& xData,
471 const std::vector<double>& yData1,
472 const std::vector<double>& yData2,
473 const std::vector<double>& yData3,
477 size_t size = xData.size();
479 if (x >= xData[size - 2]) {
483 while (x > xData[i + 1])
486 double xL = xData[i];
487 double xR = xData[i + 1];
488 double yL1 = yData1[i];
489 double yR1 = yData1[i + 1];
490 double yL2 = yData2[i];
491 double yR2 = yData2[i + 1];
492 double yL3 = yData3[i];
493 double yR3 = yData3[i + 1];
509 const double m = (x - xL) / (xR - xL);
510 inter[0] = m * (yR1 - yL1) + yL1;
511 inter[1] = m * (yR2 - yL2) + yL2;
512 inter[2] = m * (yR3 - yL3) + yL3;
519 double y1 = par[2] * TMath::Landau(x[0], par[0], par[1]);
520 double y2 = TMath::Exp(par[3] + x[0] * par[4]);
522 return TMath::Abs(y1 - y2);
537 double y1 = par[3] * TMath::Landau(x[0], par[1], par[2]);
538 double y2 = TMath::Exp(par[4] + x[0] * par[5]);
539 if (x[0] <= par[6] || x[0] > par[0]) y1 = 0.;
540 if (x[0] < par[0]) y2 = 0.;
554 double y = par[3] * TMath::Landau(x[0], par[1], par[2]);
555 if (x[0] <= par[0]) y = 0.;
Index OpChannel(Index detNum, Index channel)
double fangle_bin_timing_vuv
static std::vector< geo::BoxBoundedGeo > extractActiveLArVolume(geo::GeometryCore const &geom)
void propagationTime(std::vector< double > &arrival_time_dist, geo::Point_t const &x0, const size_t OpChannel, bool Reflected=false)
Encapsulate the construction of a single cyostat.
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
fhicl::ParameterSet fVISTimingParams
CLHEP::HepRandomEngine & fScintTimeEngine
void getVUVTimes(std::vector< double > &arrivalTimes, const double distance_in_cm, const size_t angle_bin)
bool isBar() const
Returns whether the detector shape is a bar (TGeoBBox).
double fangle_bin_timing_vis
std::vector< std::vector< double > > VUV_max
void GetCenter(double *xyz, double localz=0.0) const
PropagationTimeModel(fhicl::ParameterSet VUVTimingParams, fhicl::ParameterSet VISTimingParams, CLHEP::HepRandomEngine &ScintTimeEngine, bool doReflectedLight=false, bool GeoPropTimeOnly=false)
static double model_close(const double *x, const double *par)
void getVISTimes(std::vector< double > &arrivalTimes, const TVector3 &ScintPoint, const TVector3 &OpDetPoint)
static double finter_d(const double *x, const double *par)
std::vector< geo::Point_t > fOpDetCenter
std::enable_if_t< std::is_arithmetic_v< T >, T > hypot(T x, T y)
bool isSphere() const
Returns whether the detector shape is a hemisphere (TGeoSphere).
void interpolate3(std::array< double, 3 > &inter, const std::vector< double > &xData, const std::vector< double > &yData1, const std::vector< double > &yData2, const std::vector< double > &yData3, double x, bool extrapolate)
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
double interpolate(const std::vector< double > &xData, const std::vector< double > &yData, double x, bool extrapolate, size_t i=0) const
std::vector< std::vector< std::vector< double > > > ftau_pars
auto counter(T begin, T end)
Returns an object to iterate values from begin to end in a range-for loop.
std::vector< double > fradial_distances_refl
static double model_far(const double *x, const double *par)
std::vector< geo::BoxBoundedGeo > fActiveVolumes
double finflexion_point_distance
T get(std::string const &key) const
double fast_acos(double x) const
Test of util::counter and support utilities.
double distance(double x1, double y1, double z1, double x2, double y2, double z2)
static int max(int a, int b)
std::vector< int > fOpDetOrientation
Description of geometry of one entire detector.
std::vector< std::vector< TF1 > > VUV_timing
Specializations of geo_vectors_utils.h for ROOT old vector types.
fhicl::ParameterSet fVUVTimingParams
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
Encapsulate the geometry of an optical detector.
void getVUVTimesGeo(std::vector< double > &arrivalTimes, const double distance_in_cm)
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
std::vector< std::vector< double > > fparameters[7]
std::vector< std::vector< double > > VUV_min
TVector3 toTVector3(Vector const &v)
Converts a vector into a TVector3.
std::vector< std::vector< std::vector< double > > > fcut_off_pars
std::vector< double > fdistances_refl
void generateParam(const size_t index, const size_t angle_bin)
cet::coded_exception< error, detail::translate > exception
QTextStream & endl(QTextStream &s)