Deprecated/RdWaveFit/Chi2ForPlaneWaveFit.cc
Go to the documentation of this file.
1 #include "Chi2ForPlaneWaveFit.h"
2 
3 
4 using namespace std;
5 using namespace utl;
6 
9 
10 // Set Antenna Times and Positions
11 void Chi2ForPlaneWaveFit::Set(const std::vector< utl::Vector >& _AntennaPositions, const std::vector< double >& _AntennaTimes, const std::vector< double >& _AntennaTimesError, const utl::CoordinateSystemPtr& _fgLocalCS)
12 {
13  AntennaPositions = _AntennaPositions;
14  AntennaTimes = _AntennaTimes;
15  AntennaTimesError = _AntennaTimesError;
16  fgLocalCS = _fgLocalCS;
17 
18 
19  /* 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
20  */
21  double tau0;
22  tau0 = TMath::Mean(AntennaTimes.begin(),AntennaTimes.end());
23  int n = AntennaTimes.size();
24  for (int i=0;i<n;i++)
25  {
26  AntennaTimes[i] -= tau0;
27  }
28 }
29 
30 // Objective function
31 double Chi2ForPlaneWaveFit::DoEval(const double* x) const
32 {
33  double chi = 0.; // Chi Square / NDF
34  double c = kSpeedOfLight; // in AugerUnits
35  std::vector<double> ExpectedTimes; // Expected time for each antenna if the test position is the source position
36 // utl::Vector::CoordinateType kSpherical;
37 
38  utl::Vector ShowerAxis(1.*utl::m,x[0],x[1], fgLocalCS, utl::Vector::kSpherical); // Unit vector pointing to where the wave is coming from!
39 // ShowerAxis.SetMagThetaPhi(1.,x[0],x[1]);
40 
41  // Calculate the expected times
42  int n = AntennaPositions.size();
43  double exp_time;
44 
45  for (int i=0;i<n;i++)
46  {
47  exp_time = (-(ShowerAxis*AntennaPositions[i]))/c; // calculate (negative) projection
48  ExpectedTimes.push_back(exp_time);
49 
50  }
51  double t0;
52  t0 = TMath::Mean(ExpectedTimes.begin(),ExpectedTimes.end());
53 
54  // Calculate chi square
55  for (int i=0;i<n;i++)
56  {
57  chi += pow(AntennaTimes[i]-(ExpectedTimes[i]-t0),2)/pow(AntennaTimesError[i],2);
58  }
59 
60  // Return Chi Square for input x
61  return chi;
62 
63 }
double pow(const double x, const unsigned int i)
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
void Set(const std::vector< utl::Vector > &_AntennaPositions, const std::vector< double > &_AntennaTimes, const std::vector< double > &_AntennaTimesError, const utl::CoordinateSystemPtr &_fgLocalCS)
static const CSpherical kSpherical
Definition: BasicVector.h:335
constexpr double kSpeedOfLight
double DoEval(const double *x) const
Vector object.
Definition: Vector.h:30
double Mean(const std::vector< double > &v)
Definition: Functions.h:31
constexpr double m
Definition: AugerUnits.h:121

, generated on Tue Sep 26 2023.