Jpp  18.0.0-rc.1
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
JACOUSTICS::JKatoomba< JSimplex > Struct Template Reference

Template specialisation of fit function of acoustic model based on JSimplex minimiser. More...

#include <JKatoomba.hh>

Inheritance diagram for JACOUSTICS::JKatoomba< JSimplex >:
JFIT::JSimplex< JModel_t > JACOUSTICS::JKatoomba<> JEEP::JMessage< T >

Public Types

typedef double result_type
 

Public Member Functions

 JKatoomba (const JGeometry &geometry, const JSoundVelocity &velocity, const int option)
 Constructor. More...
 
double operator() (const JModel &model, const JHit &hit) const
 Fit function. More...
 
template<class T >
double operator() (T __begin, T __end)
 Fit. More...
 
template<class JFunction_t , class T >
double operator() (const JFunction_t &fit, T __begin, T __end)
 Multi-dimensional fit. More...
 
template<class JFunction_t , class T >
double operator() (const JFunction_t &fit, T __begin, T __end, const JModel_t &step)
 1D fit. More...
 

Public Attributes

JModel_t value
 
std::vector< JModel_t > step
 
int numberOfIterations
 

Static Public Attributes

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

Detailed Description

template<>
struct JACOUSTICS::JKatoomba< JSimplex >

Template specialisation of fit function of acoustic model based on JSimplex minimiser.

Definition at line 463 of file JKatoomba.hh.

Member Typedef Documentation

template<class JModel_t>
typedef double JFIT::JSimplex< JModel_t >::result_type
inherited

Definition at line 47 of file JSimplex.hh.

Constructor & Destructor Documentation

JACOUSTICS::JKatoomba< JSimplex >::JKatoomba ( const JGeometry geometry,
const JSoundVelocity velocity,
const int  option 
)
inline

Constructor.

Parameters
geometrydetector geometry
velocitysound velocity
optionoption

Definition at line 474 of file JKatoomba.hh.

476  :
477  JKatoomba<>(geometry, velocity, option)
478  {};

Member Function Documentation

double JACOUSTICS::JKatoomba< JSimplex >::operator() ( const JModel model,
const JHit hit 
) const
inline

Fit function.


This method is used to determine the chi2 of given hit with respect to actual model.

Parameters
modelmodel
hithit
Returns
chi2

Definition at line 489 of file JKatoomba.hh.

490  {
491  const double toa_s = this->getToA(model, hit);
492  const double u = (toa_s - hit.getValue()) / hit.getSigma();
493 
494  return estimator->getRho(u);
495  }
double getValue() const
Get expectation value of time-of-arrival.
double u[N+1]
Definition: JPolint.hh:776
double getSigma() const
Get resolution of time-of-arrival.
template<class T >
double JACOUSTICS::JKatoomba< JSimplex >::operator() ( T  __begin,
T  __end 
)
inline

Fit.

Parameters
__beginbegin of hits
__endend of hits
Returns
chi2

Definition at line 506 of file JKatoomba.hh.

507  {
508  this->step.clear();
509 
510  for (JModel::string_type::const_iterator i = this->value.string.begin(); i != this->value.string.end(); ++i) {
511 
512  JModel model;
513 
514  switch (this->option) {
515 
517  model.string[i->first] = JMODEL::JString(0.0, 0.0, 0.0, 0.0, 1.0e-6); this->step.push_back(model);
518 
520  model.string[i->first] = JMODEL::JString(0.0, 0.0, 1.0e-6, 0.0, 0.0); this->step.push_back(model);
521  model.string[i->first] = JMODEL::JString(0.0, 0.0, 0.0, 1.0e-6, 0.0); this->step.push_back(model);
522 
524  model.string[i->first] = JMODEL::JString(1.0e-3, 0.0, 0.0, 0.0, 0.0); this->step.push_back(model);
525  model.string[i->first] = JMODEL::JString(0.0, 1.0e-3, 0.0, 0.0, 0.0); this->step.push_back(model);
526  break;
527 
528  default:
529  break;
530  }
531  }
532 
533  for (JModel::emission_type::const_iterator i = this->value.emission.begin(); i != this->value.emission.end(); ++i) {
534 
535  JModel model;
536 
537  model.emission[i->first] = JMODEL::JEmission(5.0e-5); this->step.push_back(model);
538  }
539 
540  return JSimplex<JModel>::operator()(*this, __begin, __end);
541  }
fit times of emission of emitters and tilt angles of strings with second order correction and stretch...
fit times of emission of emitters and tilt angles of strings
Model for fit to acoustics data.
JACOUSTICS::JModel::emission_type emission
fit times of emission of emitters and tilt angles of strings with second order correction ...
JModel_t value
Definition: JSimplex.hh:240
double operator()(const JFunction_t &fit, T __begin, T __end)
Multi-dimensional fit.
Definition: JSimplex.hh:71
JACOUSTICS::JModel::string_type string
container_type::const_iterator const_iterator
Definition: JHashMap.hh:86
std::vector< JModel_t > step
Definition: JSimplex.hh:241
template<class JModel_t>
template<class JFunction_t , class T >
double JFIT::JSimplex< JModel_t >::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  }
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:446
JModel_t p1
Definition: JSimplex.hh:265
int numberOfIterations
Definition: JSimplex.hh:242
JModel_t value
Definition: JSimplex.hh:240
then usage $script< input file >[option[primary[working directory]]] nWhere option can be N
Definition: JMuonPostfit.sh:36
JModel_t p0
Definition: JSimplex.hh:264
JModel_t wall
Definition: JSimplex.hh:266
then if[[!-f $DETECTOR]] then JDetector sh $DETECTOR fi cat $WORKDIR trigger_parameters txt<< EOFtrigger3DMuon.enabled=1;trigger3DMuon.numberOfHits=5;trigger3DMuon.gridAngle_deg=1;ctMin=0.0;TMaxLocal_ns=15.0;EOF set_variable TRIGGEREFFICIENCY_TRIGGERED_EVENTS_ONLY INPUT_FILES=() for((i=1;$i<=$NUMBER_OF_RUNS;++i));do JSirene.sh $DETECTOR $JPP_DATA/genhen.km3net_wpd_V2_0.evt.gz $WORKDIR/sirene_ ${i}.root JTriggerEfficiency.sh $DETECTOR $DETECTOR $WORKDIR/sirene_ ${i}.root $WORKDIR/trigger_efficiency_ ${i}.root $WORKDIR/trigger_parameters.txt $JPP_DATA/PMT_parameters.txt INPUT_FILES+=($WORKDIR/trigger_efficiency_ ${i}.root) done for ANGLE_DEG in $ANGLES_DEG[*];do set_variable SIGMA_NS 3.0 set_variable OUTLIERS 3 set_variable OUTPUT_FILE $WORKDIR/matrix\[${ANGLE_DEG}\deg\].root $JPP_DIR/examples/JReconstruction-f"$INPUT_FILES[*]"-o $OUTPUT_FILE-S ${SIGMA_NS}-A ${ANGLE_DEG}-O ${OUTLIERS}-d ${DEBUG}--!fiif[[$OPTION=="plot"]];then if((0));then for H1 in h0 h1;do JPlot1D-f"$WORKDIR/matrix["${^ANGLES_DEG}" deg].root:${H1}"-y"1 2e3"-Y-L TR-T""-\^"number of events [a.u.]"-> o chi2
Definition: JMatrixNZ.sh:106
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
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62
std::vector< JModel_t > step
Definition: JSimplex.hh:241
template<class JModel_t>
template<class JFunction_t , class T >
double JFIT::JSimplex< JModel_t >::operator() ( const JFunction_t &  fit,
T  __begin,
T  __end,
const JModel_t &  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
JModel_t p1
Definition: JSimplex.hh:265
int numberOfIterations
Definition: JSimplex.hh:242
JModel_t value
Definition: JSimplex.hh:240
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
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62
std::vector< JModel_t > step
Definition: JSimplex.hh:241

Member Data Documentation

template<class JModel_t>
int JFIT::JSimplex< JModel_t >::MAXIMUM_ITERATIONS = 1000
staticinherited

maximal number of iterations

maximal number of iterations.

Definition at line 237 of file JSimplex.hh.

template<class JModel_t>
double JFIT::JSimplex< JModel_t >::EPSILON = 1.0e-4
staticinherited

maximal distance to minimum

maximal distance to minimum.

Definition at line 238 of file JSimplex.hh.

template<class JModel_t>
JModel_t JFIT::JSimplex< JModel_t >::value
inherited

Definition at line 240 of file JSimplex.hh.

template<class JModel_t>
std::vector<JModel_t> JFIT::JSimplex< JModel_t >::step
inherited

Definition at line 241 of file JSimplex.hh.

template<class JModel_t>
int JFIT::JSimplex< JModel_t >::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: