Jpp  15.0.0-rc.2
the software that should make you happy
 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
 
typedef minimiser_type::result_type result_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...
 
result_type operator() (const JLine3Z &value, T __begin, T __end)
 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 52 of file JLine3ZRegressor.hh.

Member Typedef Documentation

Definition at line 78 of file JRegressor.hh.

Definition at line 79 of file JRegressor.hh.

Definition at line 80 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 62 of file JLine3ZRegressor.hh.

62  :
64  {
65  this->sigma = sigma;
66  }
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 84 of file JLine3ZRegressor.hh.

85  {
86  using namespace JPP;
87 
88  JPosition3D D(hit.getX(), hit.getY(), hit.getZ());
89 
90  D.sub(track.getPosition());
91 
92  const double z = D.getDot(track.getDirection());
93  const double R = sqrt(D.getLengthSquared() - z*z);
94 
95  const double t1 = track.getT() + (z + R * getKappaC()) * getInverseSpeedOfLight();
96 
97  const double u = (t1 - hit.getT()) / sigma;
98 
99  return estimator->getRho(u) * hit.getW();
100  }
double getKappaC()
Get average R-dependence of arrival time of Cherenkov light (a.k.a.
double getT(const JVector3D &pos) const
Get arrival time of Cherenkov light at given position.
Definition: JLine3Z.hh:234
JVersor3D getDirection(const JVector3D &pos) const
Get photon direction of Cherenkov light on PMT.
Definition: JLine3Z.hh:255
JLANG::JSharedPointer< JMEstimator > estimator
M-Estimator function.
const JPosition3D & getPosition() const
Get position.
Definition: JPosition3D.hh:130
then usage $script[distance] fi case set_variable R
Definition: JDrawLED.sh:43
double sigma
Time resolution [ns].
const double getInverseSpeedOfLight()
Get inverse speed of light.
Data structure for position in three dimensions.
Definition: JPosition3D.hh:36
double u[N+1]
Definition: JPolint.hh:739
do echo Generating $dir eval D
Definition: JDrawLED.sh:53
result_type JFIT::JAbstractRegressor< JLine3Z , JSimplex >::operator() ( const JLine3Z value,
T  __begin,
T  __end 
)
inlineinherited

Global fit.

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

Definition at line 92 of file JRegressor.hh.

93  {
94  static_cast<minimiser_type&>(*this).value = value;
95 
96  return static_cast<minimiser_type&>(*this)(static_cast<regressor_type&>(*this), __begin, __end);
97  }
JRegressor< JLine3Z, JSimplex > regressor_type
Definition: JRegressor.hh:79
JModel_t value
Definition: JSimplex.hh:240
double JFIT::JSimplex< JLine3Z >::operator() ( const JFunction_t &  fit,
T  __begin,
T  __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 71 of file JSimplex.hh.

72  {
73  using namespace std;
74  using namespace JPP;
75 
76  double chi2_old = evaluate(fit, __begin, __end);
77 
78  const int N = step.size();
79 
80  if (N != 0) {
81 
82  p0 = value;
83  p1 = value;
84  wall = value;
85 
86  double chi2[N];
87 
89 
91 
92  DEBUG("old: " << FIXED(12,5) << chi2_old << endl);
93 
94  p0 = value;
95 
96  for (int i = 0; i != N; ++i) {
97 
98  DEBUG("step: " << i << ' ' << setw(5) << numberOfIterations << endl);
99 
100  chi2[i] = (*this)(fit, __begin, __end, step[i]);
101  }
102 
103  // overall step direction of last iteration
104 
105  wall = value;
106  wall -= p0;
107 
108  const double chi2_new = (*this)(fit, __begin, __end, wall);
109 
110  DEBUG("new: " << FIXED(12,5) << chi2_new << endl);
111 
112 
113  if (fabs(chi2_old - chi2_new) < EPSILON*fabs(chi2_old)) {
114  return chi2_new;
115  }
116 
117  // double overall step
118 
119  wall = value;
120  wall -= p0;
121  value += wall;
122 
123  const double fe = evaluate(fit, __begin, __end);
124 
125  value -= wall;
126 
127 
128  for (int i = N-1; i != 0; --i) {
129  chi2[i] = chi2[i-1] - chi2[i];
130  }
131 
132  chi2[0] = chi2_old - chi2[0];
133 
134 
135  double df = 0.0;
136 
137  for (int i = 0; i != N; ++i) {
138  if (chi2[i] > df) {
139  df = chi2[i];
140  }
141  }
142 
143  const double fn = chi2_new;
144  const double f0 = chi2_old;
145  const double ff = f0 - fn - df;
146 
147  // shift step directions
148 
149  if (fe < f0 && 2.0*(f0 - 2.0*fn + fe)*ff*ff < (f0-fe)*(f0-fe)*df) {
150 
151  for (int i = 0; i != N - 1; ++i) {
152  step[i] = step[i+1];
153  }
154 
155  step[N-1] = wall;
156  }
157 
158  chi2_old = chi2_new;
159  }
160  }
161 
162  return chi2_old;
163  }
then JShowerPostfit f $INPUT_FILE o $OUTPUT_FILE N
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:446
then usage $script< input_file >< detector_file > fi set_variable OUTPUT_DIR set_variable SELECTOR JDAQTimesliceL1 set_variable DEBUG case set_variable DEBUG
double evaluate(const JFunction_t &fit, T __begin, T __end) const
Evaluate chi2 for given data set.
Definition: JSimplex.hh:253
static int MAXIMUM_ITERATIONS
maximal number of iterations
Definition: JSimplex.hh:237
static double EPSILON
maximal distance to minimum
Definition: JSimplex.hh:238
std::vector< JLine3Z > step
Definition: JSimplex.hh:241
double JFIT::JSimplex< JLine3Z >::operator() ( const JFunction_t &  fit,
T  __begin,
T  __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 178 of file JSimplex.hh.

179  {
180  using namespace std;
181  using namespace JPP;
182 
183  double lambda = 0.5; // control parameter
184  double factor = 1.0; // multiplication factor
185 
186  double chi2_old = evaluate(fit, __begin, __end);
187 
188  for (int i = 0; numberOfIterations != MAXIMUM_ITERATIONS; ++numberOfIterations, ++i) {
189 
190  p1 = step;
191  p1 *= lambda;
192  value += p1;
193 
194  const double chi2_new = evaluate(fit, __begin, __end);
195 
196  DEBUG("step: " << setw(3) << i << ' ' << FIXED(12,5) << chi2_old << ' ' << FIXED(12,5) << chi2_new << ' ' << FIXED(5,2) << lambda << endl);
197 
198  if (fabs(chi2_old - chi2_new) < EPSILON*fabs(chi2_old)) {
199 
200  if (chi2_new > chi2_old) {
201 
202  p1 = step;
203  p1 *= lambda;
204  value -= p1; // undo last step
205 
206  return chi2_old;
207 
208  } else {
209 
210  return chi2_new;
211  }
212  }
213 
214  if (chi2_new < chi2_old) {
215 
216  chi2_old = chi2_new;
217 
218  } else {
219 
220  p1 = step;
221  p1 *= lambda;
222  value -= p1; // step back
223  lambda = -lambda; // change direction
224 
225  if (i != 0) {
226  factor = 0.5; // reduce step size
227  }
228  }
229 
230  lambda = factor * lambda;
231  }
232 
233  return chi2_old;
234  }
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:446
then usage $script< input_file >< detector_file > fi set_variable OUTPUT_DIR set_variable SELECTOR JDAQTimesliceL1 set_variable DEBUG case set_variable DEBUG
double evaluate(const JFunction_t &fit, T __begin, T __end) const
Evaluate chi2 for given data set.
Definition: JSimplex.hh:253
static int MAXIMUM_ITERATIONS
maximal number of iterations
Definition: JSimplex.hh:237
static double EPSILON
maximal distance to minimum
Definition: JSimplex.hh:238
std::vector< JLine3Z > step
Definition: JSimplex.hh:241

Member Data Documentation

M-Estimator function.

Definition at line 102 of file JLine3ZRegressor.hh.

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

Time resolution [ns].

Definition at line 103 of file JLine3ZRegressor.hh.

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

maximal number of iterations

maximal number of iterations.

Definition at line 237 of file JSimplex.hh.

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

maximal distance to minimum

maximal distance to minimum.

Definition at line 238 of file JSimplex.hh.

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

Definition at line 240 of file JSimplex.hh.

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

Definition at line 241 of file JSimplex.hh.

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

Definition at line 242 of file JSimplex.hh.

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

debug level (default is off).

Definition at line 45 of file JMessage.hh.


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