Jpp  17.2.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JRegressor.hh
Go to the documentation of this file.
1 #ifndef __JFIT__JREGRESSOR__
2 #define __JFIT__JREGRESSOR__
3 
4 #include "Jeep/JMessage.hh"
5 
6 
7 /**
8  * \file
9  * General purpose data regression method.
10  * \author mdejong
11  */
12 namespace JFIT {}
13 namespace JPP { using namespace JFIT; }
14 
15 namespace JFIT {
16 
17  using JEEP::JMessage;
18 
19 
20  /**
21  * Abstract minimiser.
22  * This "minimiser" can be used to determine the chi2 of the data for a given model value.
23  */
24  template<class JModel_t>
26  public JMessage< JAbstractMinimiser<JModel_t> >
27  {
28  typedef double result_type;
29 
30  /**
31  * Default constructor.
32  */
34  {}
35 
36 
37  /**
38  * Get chi2.
39  *
40  * \param fit fit function
41  * \param __begin begin of data
42  * \param __end end of data
43  * \return chi2
44  */
45  template<class JFunction_t, class T>
46  result_type operator()(const JFunction_t& fit, T __begin, T __end)
47  {
48  double chi2 = 0.0;
49 
50  for (T i = __begin; i != __end; ++i) {
51  chi2 += fit(value, *i);
52  }
53 
54  return chi2;
55  }
56 
57  JModel_t value; //!< model value
58  };
59 
60 
61  /**
62  * Template definition of a data regressor of given model.
63  *
64  * The first template argument refers to the model that should be fitted to the data and
65  * the second to the type of minimiser.
66  */
67  template<class JModel_t, template<class> class JMinimiser_t = JAbstractMinimiser>
68  struct JRegressor;
69 
70 
71  /**
72  * Abstract class for global fit method.
73  */
74  template<class JModel_t, template<class> class JMinimiser_t = JAbstractMinimiser>
76  public JMinimiser_t<JModel_t>
77  {
78  typedef JMinimiser_t<JModel_t> minimiser_type;
81 
82 
83  /**
84  * Global fit.
85  *
86  * \param value start value
87  * \param __begin begin of data set
88  * \param __end end of data set
89  * \return chi2
90  */
91  template<class T>
92  result_type operator()(const JModel_t& value, T __begin, T __end)
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  }
98  };
99 }
100 
101 #endif
Template definition of a data regressor of given model.
Definition: JRegressor.hh:68
JMinimiser_t< JModel_t > minimiser_type
Definition: JRegressor.hh:78
result_type operator()(const JFunction_t &fit, T __begin, T __end)
Get chi2.
Definition: JRegressor.hh:46
Abstract minimiser.
Definition: JRegressor.hh:25
JRegressor< JModel_t, JMinimiser_t > regressor_type
Definition: JRegressor.hh:79
minimiser_type::result_type result_type
Definition: JRegressor.hh:80
Regressor function object for JPoint4D fit using JSimplex minimiser.
do set_variable OUTPUT_DIRECTORY $WORKDIR T
JModel_t value
Definition: JSimplex.hh:240
General purpose messaging.
JAbstractMinimiser()
Default constructor.
Definition: JRegressor.hh:33
JModel_t value
model value
Definition: JRegressor.hh:57
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
Abstract class for global fit method.
Definition: JRegressor.hh:75
Auxiliary class for handling debug parameter within a class.
Definition: JMessage.hh:44
result_type operator()(const JModel_t &value, T __begin, T __end)
Global fit.
Definition: JRegressor.hh:92