ShowerFrontFunction.cc
Go to the documentation of this file.
1 #include "ShowerFrontFunction.h"
3 #include "Utilities.h"
4 
5 #include <utl/Point.h>
6 #include <utl/Vector.h>
7 #include <utl/CoordinateSystemPtr.h>
8 #include <utl/Math.h>
9 #include <utl/AugerUnits.h>
10 #include <utl/PhysicalConstants.h>
11 #include <utl/MuonArrivalTime.h>
12 #include <utl/AugerException.h>
13 
14 #include <tls/TankResponseUtilities.h>
15 
16 #include <sdet/STimeVariance.h>
17 
18 #include <limits>
19 
20 using namespace SdHorizontalReconstructionNS;
21 using namespace utl;
22 using namespace std;
23 using namespace tls;
24 
25 
27  const Point& core,
28  const StationList& list,
29  const ExternalGeometryData& gd)
30  : fConfig(config), fCore(core), fList(list), fExt(gd)
31 {
32 }
33 
34 
35 double
36 ShowerFrontFunction::operator()(const std::vector<double>& pars)
37  const
38 {
39  for (size_t i = 0; i < 4; ++i)
40  if (std::isnan(pars[i]))
42 
43  const double theta = pars[0];
44  const double phi = pars[1];
45  const double r = pars[2]*km;
46  const double ct = pars[3]*km;
47 
48  double result = 0;
49 
50  const Point origin(r, theta, phi, fConfig.fBaryCS, Point::kSpherical);
51 
52  for (StationList::const_iterator
53  sIt = fList.begin(),
54  sEnd = fList.end();
55  sIt != sEnd; ++sIt)
56  {
57  if (sIt->fRejected) continue;
58 
59  double meanCT, sigmaCT;
60  Predict(meanCT, sigmaCT, *sIt, origin, ct);
61  result += 0.5 * Sqr((sIt->fCTime - meanCT)/sigmaCT);
62  }
63 
64  {
65  const double delta[2] = {
66  theta - fExt.fPar[eThetaExt],
67  phi - fExt.fPar[ePhiExt]
68  };
69 
70  for (size_t i = 0; i < 2; ++i)
71  for (size_t j = 0; j < 2; ++j)
72  result += 0.5 * delta[i] * fExt.fInvCov[eThetaExt+i][eThetaExt+j] * delta[j];
73  }
74 
75  return result;
76 }
77 
78 
79 void
80 ShowerFrontFunction::Predict(double& meanCT, double& sigmaCT,
81  const StationData& sd,
82  const Point& originPos,
83  const double originCT)
84  const
85 {
86  const Vector posToOrigin = originPos - sd.fPos;
87  const double sTheta = Angle(posToOrigin, (sd.fPos - fConfig.fEarthCenter));
88 
89  switch (fConfig.fShowerFrontModel)
90  {
91  case eSphere:
92  {
93  const sdet::STimeVariance& timeVariance = sdet::STimeVariance::GetInstance();
94 
95  meanCT = originCT + posToOrigin.GetMag();
96  sigmaCT = sqrt(timeVariance.GetTimeSigma2(sd.fSignal, sd.fT50, cos(sTheta))) * kSpeedOfLight;
97  }
98  break;
99  case eMuonArrival:
100  {
101  // uses model of muon arrival times from Lorenzo Cazon
102  // model predicts time relative to plane shower front
103 
104  const Vector axis = originPos-fCore;
106 
107  static const double kVerticalTrackLength = TankMeanTrackLength(0);
108  static const double kStationTimeJitter = 20*ns; // according to USC code
109 
110  const int nmuon = round(sd.fSignal / (TankMeanTrackLength(sTheta)/kVerticalTrackLength));
111  double rho, delta;
112  GetRhoAndDelta(rho, delta, sd.fPos, fCore, originPos);
113  fMat.SetCoordinates(rho, delta);
114  double tmean, tsigma;
115  fMat.GetApproximateMeanAndStDev(tmean, tsigma, nmuon < 1 ? 1: nmuon);
116 
117  meanCT = originCT + (originPos-fCore).GetMag() - delta + tmean*kSpeedOfLight;
118  sigmaCT = sqrt(Sqr(tsigma)+Sqr(kStationTimeJitter))*kSpeedOfLight;
119  }
120  break;
121  default:
122  throw utl::NonExistentComponentException("shower front model not implemented");
123  }
124 }
constexpr T Sqr(const T &x)
Point object.
Definition: Point.h:32
double Angle(const double theta1, const double phi1, const double theta2, const double phi2)
ShowerFrontFunction(const SdHorizontalReconstruction &config, const utl::Point &core, const StationList &list, const ExternalGeometryData &gd)
void SetThetaAndDistance(const double theta, const double distance)
setup model for given zenith angle and mean production distance
void Predict(double &meanCT, double &sigmaCT, const StationData &sd, const utl::Point &originPos, const double originCT) const
double operator()(const std::vector< double > &pars) const
Base class for exceptions trying to access non-existing components.
double GetMag() const
Definition: Vector.h:58
#define max(a, b)
const double ns
const Data result[]
const double km
double TankMeanTrackLength(const double theta)
Mean track length of particle piercing Auger tank with zenith angle theta.
std::vector< StationData > StationList
Definition: FitInterface.h:80
constexpr double kSpeedOfLight
Vector object.
Definition: Vector.h:30
void SetCoordinates(const double r, const double delta)
void GetRhoAndDelta(double &rho, double &delta, const utl::Point &pos, const utl::Point &core, const utl::Point &origin)
double GetTimeSigma2(const double signal, const double t50, const double cosTheta, const double distance=0) const

, generated on Tue Sep 26 2023.