Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Public Attributes | Static Public Attributes | List of all members
JFIT::JRegressor< JLine3Z, JSimplex > Struct Template Reference

Regressor function object for JLine3Z fit using JSimplex minimiser. More...

#include <JLine3ZRegressor.hh>

Inheritance diagram for JFIT::JRegressor< JLine3Z, JSimplex >:
JFIT::JAbstractRegressor< JLine3Z, JSimplex > JFIT::JSimplex< JLine3Z > JEEP::JMessage< T >

Public Types

typedef JSimplex< JLine3Zminimiser_type
 
typedef JRegressor< JLine3Z,
JSimplex
regressor_type
 

Public Member Functions

 JRegressor (double sigma)
 Constructor. More...
 
template<class JHit_t >
double operator() (const JLine3Z &track, const JHit_t &hit) const
 Fit function. More...
 
double operator() (const JLine3Z &value, T __begin, T __end)
 Global fit. More...
 
double operator() (const JLine3Z &value, T1 __begin1, T1 __end1, T2 __begin2, T2 __end2)
 Global fit. More...
 
double operator() (const JFunction_t &fit, T __begin, T __end)
 Multi-dimensional fit. More...
 
double operator() (const JFunction_t &fit, T __begin, T __end, const JLine3Z &step)
 1D fit. More...
 

Public Attributes

JLANG::JSharedPointer
< JMEstimator
estimator
 M-Estimator function. More...
 
double sigma
 Time resolution [ns]. More...
 
JLine3Z value
 
std::vector< JLine3Zstep
 
int numberOfIterations
 

Static Public Attributes

static int MAXIMUM_ITERATIONS
 maximal number of iterations More...
 
static double EPSILON
 maximal distance to minimum More...
 
static int debug = 0
 debug level (default is off). More...
 

Detailed Description

template<>
struct JFIT::JRegressor< JLine3Z, JSimplex >

Regressor function object for JLine3Z fit using JSimplex minimiser.

Definition at line 50 of file JLine3ZRegressor.hh.

Member Typedef Documentation

Definition at line 76 of file JRegressor.hh.

Definition at line 77 of file JRegressor.hh.

Constructor & Destructor Documentation

JFIT::JRegressor< JLine3Z, JSimplex >::JRegressor ( double  sigma)
inline

Constructor.

Parameters
sigmatime resolution of hit [ns]

Definition at line 60 of file JLine3ZRegressor.hh.

60  :
62  {
63  this->sigma = sigma;
64  }
Normal M-estimator.
Definition: JMEstimator.hh:66
JLANG::JSharedPointer< JMEstimator > estimator
M-Estimator function.
double sigma
Time resolution [ns].

Member Function Documentation

template<class JHit_t >
double JFIT::JRegressor< JLine3Z, JSimplex >::operator() ( const JLine3Z track,
const JHit_t &  hit 
) const
inline

Fit function.

This method is used to determine the chi2 of given hit with respect to trajectory of muon.

The template argument JHit_t refers to a data structure which should have the following member methods:

  • double getX(); // [m]
  • double getY(); // [m]
  • double getZ(); // [m]
  • double getT(); // [ns]
Parameters
tracktrack
hithit
Returns
chi2

Definition at line 82 of file JLine3ZRegressor.hh.

83  {
84  using namespace JGEOMETRY3D;
85  using namespace JTOOLS;
86 
87  JPosition3D D(hit.getX(), hit.getY(), hit.getZ());
88 
89  D.sub(track.getPosition());
90 
91  const double z = D.getDot(track.getDirection());
92  const double R = sqrt(D.getLengthSquared() - z*z);
93 
94  const double t1 = track.getT() + (z + R * getKappaC()) * getInverseSpeedOfLight();
95 
96  const double u = (t1 - hit.getT()) / sigma;
97 
98  return estimator->getRho(u) * hit.getW();
99  }
double getT(const JVector3D &pos) const
Get arrival time of Cherenkov light at given position.
Definition: JLine3Z.hh:233
const double getInverseSpeedOfLight()
Get inverse speed of light.
Definition: JConstants.hh:100
JVersor3D getDirection(const JVector3D &pos) const
Get photon direction of Cherenkov light on PMT.
Definition: JLine3Z.hh:254
JVector3D & sub(const JVector3D &vector)
Subtract vector.
Definition: JVector3D.hh:156
JLANG::JSharedPointer< JMEstimator > estimator
M-Estimator function.
const JPosition3D & getPosition() const
Get position.
Definition: JPosition3D.hh:129
double sigma
Time resolution [ns].
double getDot(const JVector3D &vector) const
Get dot product.
Definition: JVector3D.hh:278
Data structure for position in three dimensions.
Definition: JPosition3D.hh:35
double getKappaC()
Get average kappa of Cherenkov light in water.
Definition: JConstants.hh:155
double JFIT::JAbstractRegressor< JLine3Z , JSimplex >::operator() ( const JLine3Z value,
__begin,
__end 
)
inlineinherited

Global fit.

Parameters
valuestart value
__beginbegin of data set
__endend of data set
Returns
chi2

Definition at line 89 of file JRegressor.hh.

90  {
91  static_cast<minimiser_type&>(*this).value = value;
92 
93  return static_cast<minimiser_type&>(*this)(static_cast<regressor_type&>(*this), __begin, __end);
94  }
JRegressor< JLine3Z, JSimplex > regressor_type
Definition: JRegressor.hh:77
JModel_t value
Definition: JSimplex.hh:227
double JFIT::JAbstractRegressor< JLine3Z , JSimplex >::operator() ( const JLine3Z value,
T1  __begin1,
T1  __end1,
T2  __begin2,
T2  __end2 
)
inlineinherited

Global fit.

Parameters
valuestart value
__begin1begin of first data set
__end1end of first data set
__begin2begin of second data set
__end2end of second data set
Returns
chi2

Definition at line 108 of file JRegressor.hh.

111  {
112  static_cast<minimiser_type&>(*this).value = value;
113 
114  return static_cast<minimiser_type&>(*this)(static_cast<regressor_type&>(*this), __begin1, __end1, __begin2, __end2);
115  }
JRegressor< JLine3Z, JSimplex > regressor_type
Definition: JRegressor.hh:77
JModel_t value
Definition: JSimplex.hh:227
double JFIT::JSimplex< JLine3Z >::operator() ( const JFunction_t &  fit,
__begin,
__end 
)
inlineinherited

Multi-dimensional fit.

The given fit function should return the equivalent of chi2 for the current value of the given model and a given data point.

Parameters
fitfit function
__beginbegin of data
__endend of data
Returns
chi2

Definition at line 69 of file JSimplex.hh.

70  {
71  using namespace std;
72  using namespace JPP;
73 
74  double chi2_old = evaluate(fit, __begin, __end);
75 
76  const int N = step.size();
77 
78  if (N != 0) {
79 
80  double chi2[N];
81 
83 
85 
86  DEBUG("old: " << FIXED(12,5) << chi2_old << endl);
87 
88  const JModel_t p0(value);
89 
90  for (int i = 0; i != N; ++i) {
91 
92  DEBUG("step: " << i << ' ' << setw(5) << numberOfIterations << endl);
93 
94  chi2[i] = (*this)(fit, __begin, __end, step[i]);
95  }
96 
97  // overall step direction of last iteration
98 
99  JModel_t wall = value - p0;
100 
101  const double chi2_new = (*this)(fit, __begin, __end, wall);
102 
103  DEBUG("new: " << FIXED(12,5) << chi2_new << endl);
104 
105 
106  if (fabs(chi2_old - chi2_new) < EPSILON*fabs(chi2_old)) {
107  return chi2_new;
108  }
109 
110  // double overall step
111 
112  wall = value - p0;
113 
114  value += wall;
115 
116  const double fe = evaluate(fit, __begin, __end);
117 
118  value -= wall;
119 
120 
121  for (int i = N-1; i != 0; --i) {
122  chi2[i] = chi2[i-1] - chi2[i];
123  }
124 
125  chi2[0] = chi2_old - chi2[0];
126 
127 
128  double df = 0.0;
129 
130  for (int i = 0; i != N; ++i) {
131  if (chi2[i] > df) {
132  df = chi2[i];
133  }
134  }
135 
136  const double fn = chi2_new;
137  const double f0 = chi2_old;
138  const double ff = f0 - fn - df;
139 
140  // shift step directions
141 
142  if (fe < f0 && 2.0*(f0 - 2.0*fn + fe)*ff*ff < (f0-fe)*(f0-fe)*df) {
143 
144  for (int i = 0; i != N - 1; ++i) {
145  step[i] = step[i+1];
146  }
147 
148  step[N-1] = wall;
149  }
150 
151  chi2_old = chi2_new;
152  }
153  }
154 
155  return chi2_old;
156  }
Auxiliary data structure for floating point format specification.
Definition: JPrint.hh:461
double evaluate(const JFunction_t &fit, T __begin, T __end) const
Evaluate chi2 for given data set.
Definition: JSimplex.hh:240
static int MAXIMUM_ITERATIONS
maximal number of iterations
Definition: JSimplex.hh:224
static double EPSILON
maximal distance to minimum
Definition: JSimplex.hh:225
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:60
std::vector< JLine3Z > step
Definition: JSimplex.hh:228
double JFIT::JSimplex< JLine3Z >::operator() ( const JFunction_t &  fit,
__begin,
__end,
const JLine3Z step 
)
inlineinherited

1D fit.

The given fit function should return the equivalent of chi2 for the current value of the given model and a given data point.

Parameters
fitfit function
__beginbegin of data
__endend of data
stepstep direction

Definition at line 171 of file JSimplex.hh.

172  {
173  using namespace std;
174  using namespace JPP;
175 
176  double lambda = 0.5; // control parameter
177  double factor = 1.0; // multiplication factor
178 
179  double chi2_old = evaluate(fit, __begin, __end);
180 
181  for (int i = 0; numberOfIterations != MAXIMUM_ITERATIONS; ++numberOfIterations, ++i) {
182 
183  value += lambda * step;
184 
185  const double chi2_new = evaluate(fit, __begin, __end);
186 
187  DEBUG("step: " << setw(3) << i << ' ' << FIXED(12,5) << chi2_old << ' ' << FIXED(12,5) << chi2_new << ' ' << FIXED(5,2) << lambda << endl);
188 
189  if (fabs(chi2_old - chi2_new) < EPSILON*fabs(chi2_old)) {
190 
191  if (chi2_new > chi2_old) {
192 
193  value -= lambda * step; // undo last step
194 
195  return chi2_old;
196 
197  } else {
198 
199  return chi2_new;
200  }
201  }
202 
203  if (chi2_new < chi2_old) {
204 
205  chi2_old = chi2_new;
206 
207  } else {
208 
209  value -= lambda * step; // step back
210  lambda = -lambda; // change direction
211 
212  if (i != 0) {
213  factor = 0.5; // reduce step size
214  }
215  }
216 
217  lambda = factor * lambda;
218  }
219 
220  return chi2_old;
221  }
Auxiliary data structure for floating point format specification.
Definition: JPrint.hh:461
double evaluate(const JFunction_t &fit, T __begin, T __end) const
Evaluate chi2 for given data set.
Definition: JSimplex.hh:240
static int MAXIMUM_ITERATIONS
maximal number of iterations
Definition: JSimplex.hh:224
static double EPSILON
maximal distance to minimum
Definition: JSimplex.hh:225
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:60
std::vector< JLine3Z > step
Definition: JSimplex.hh:228

Member Data Documentation

M-Estimator function.

Definition at line 101 of file JLine3ZRegressor.hh.

double JFIT::JRegressor< JLine3Z, JSimplex >::sigma

Time resolution [ns].

Definition at line 102 of file JLine3ZRegressor.hh.

int JFIT::JSimplex< JLine3Z >::MAXIMUM_ITERATIONS
staticinherited

maximal number of iterations

maximal number of iterations.

Definition at line 224 of file JSimplex.hh.

double JFIT::JSimplex< JLine3Z >::EPSILON
staticinherited

maximal distance to minimum

maximal distance to minimum.

Definition at line 225 of file JSimplex.hh.

JLine3Z JFIT::JSimplex< JLine3Z >::value
inherited

Definition at line 227 of file JSimplex.hh.

std::vector<JLine3Z > JFIT::JSimplex< JLine3Z >::step
inherited

Definition at line 228 of file JSimplex.hh.

int JFIT::JSimplex< JLine3Z >::numberOfIterations
inherited

Definition at line 229 of file JSimplex.hh.

template<class T>
int JEEP::JMessage< T >::debug = 0
staticinherited

debug level (default is off).

Definition at line 43 of file JMessage.hh.


The documentation for this struct was generated from the following file: