Chi2ForSphericalWaveFit.cc
Go to the documentation of this file.
2 
3 using namespace std;
4 using namespace utl;
5 
6 
8 {
9  Spherical = true;
10 }
12 
13 // Use cartesic coordinate system
15 // Use spherical coordinate system (default)
17 
18 // Set Antenna Times and Positions
19 void Chi2ForSphericalWaveFit::Set(const std::vector< Vector >& _AntennaPositions, const std::vector< double >& _AntennaTimes, const std::vector< double >& _AntennaTimesError, const utl::CoordinateSystemPtr& _fgLocalCS)
20 {
21  AntennaPositions = _AntennaPositions;
22  AntennaTimes = _AntennaTimes;
23  AntennaTimesError = _AntennaTimesError;
24  fgLocalCS = _fgLocalCS;
25 
26  double tau0;
27  tau0 = TMath::Mean(AntennaTimes.begin(),AntennaTimes.end());
28 
29  /* an absolute event time for both the test and measured times. The absolute event time is choosen to be the mean of all measured/test times
30  */
31  int n = AntennaTimes.size();
32  for (int i=0;i<n;i++)
33  {
34  AntennaTimes[i] -= tau0;
35  }
36 }
37 
38 // Objective function
39 double Chi2ForSphericalWaveFit::DoEval(const double* x) const
40 {
41  double chi = 0.; // Chi Square / NDF
42  double c = kSpeedOfLight; // in AugerUnits
43  std::vector<double> ExpectedTimes; // Expected time for each antenna if the test position is the source position
44 
45 
46  // Input values
47  utl::Vector TestPosition(x[0],x[1],x[2],fgLocalCS,utl::Vector::kSpherical); // Test Position
48 
49 
50  // Calculate the expected times
51  int n = AntennaPositions.size();
52  double exp_time;
53  for (int i=0;i<n;i++)
54  {
55  exp_time = ((AntennaPositions[i]-TestPosition).GetMag())/c;
56  ExpectedTimes.push_back(exp_time);
57  }
58 
59  // get the minimum of ExpectedTimes
60  double t0;
61  t0 = TMath::Mean(ExpectedTimes.begin(),ExpectedTimes.end());
62 
63  // Calculate chi square
64  for (int i=0;i<n;i++)
65  {
66  chi += pow(AntennaTimes[i]-(ExpectedTimes[i]-t0),2)/pow(AntennaTimesError[i],2);
67  }
68 
69  // Return Chi Square for input Test Position
70  return chi;
71 }
72 
73 
double DoEval(const double *x) const
double pow(const double x, const unsigned int i)
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
static const CSpherical kSpherical
Definition: BasicVector.h:335
constexpr double kSpeedOfLight
void Set(const std::vector< utl::Vector > &_AntennaPositions, const std::vector< double > &_AntennaTimes, const std::vector< double > &_AntennaTimesError, const utl::CoordinateSystemPtr &_fgLocalCS)
Vector object.
Definition: Vector.h:30
double Mean(const std::vector< double > &v)
Definition: Functions.h:31

, generated on Tue Sep 26 2023.