Jpp  18.2.1-ARCA-DF-PATCH
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  public:
29 
30  typedef double result_type;
31 
32  /**
33  * Default constructor.
34  */
36  {}
37 
38 
39  /**
40  * Get chi2.
41  *
42  * \param fit fit function
43  * \param __begin begin of data
44  * \param __end end of data
45  * \return chi2
46  */
47  template<class JFunction_t, class T>
48  result_type operator()(const JFunction_t& fit, T __begin, T __end)
49  {
50  double chi2 = 0.0;
51 
52  for (T i = __begin; i != __end; ++i) {
53  chi2 += fit(value, *i);
54  }
55 
56  return chi2;
57  }
58 
59  JModel_t value; //!< model value
60  };
61 
62 
63  /**
64  * Template definition of a data regressor of given model.
65  *
66  * The first template argument refers to the model that should be fitted to the data and
67  * the second to the type of minimiser.
68  */
69  template<class JModel_t, template<class> class JMinimiser_t = JAbstractMinimiser>
70  struct JRegressor;
71 
72 
73  /**
74  * Abstract class for global fit method.
75  */
76  template<class JModel_t, template<class> class JMinimiser_t = JAbstractMinimiser>
78  public JMinimiser_t<JModel_t>
79  {
80  typedef JMinimiser_t<JModel_t> minimiser_type;
83 
84 
85  /**
86  * Global fit.
87  *
88  * \param value start value
89  * \param __begin begin of data set
90  * \param __end end of data set
91  * \return chi2
92  */
93  template<class T>
94  result_type operator()(const JModel_t& value, T __begin, T __end)
95  {
96  static_cast<minimiser_type&>(*this).value = value;
97 
98  return static_cast<minimiser_type&>(*this)(static_cast<regressor_type&>(*this), __begin, __end);
99  }
100  };
101 }
102 
103 #endif
Template definition of a data regressor of given model.
Definition: JRegressor.hh:70
JMinimiser_t< JModel_t > minimiser_type
Definition: JRegressor.hh:80
result_type operator()(const JFunction_t &fit, T __begin, T __end)
Get chi2.
Definition: JRegressor.hh:48
JRegressor< JModel_t, JMinimiser_t > regressor_type
Definition: JRegressor.hh:81
minimiser_type::result_type result_type
Definition: JRegressor.hh:82
Regressor function object for JPoint4D fit using JSimplex minimiser.
JModel_t value
model value
Definition: JRegressor.hh:59
do set_variable OUTPUT_DIRECTORY $WORKDIR T
JAbstractMinimiser()
Default constructor.
Definition: JRegressor.hh:35
JModel_t value
Definition: JSimplex.hh:240
General purpose messaging.
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:77
Abstract minimiser.
Definition: JRegressor.hh:25
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:94