Jpp  18.3.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JRegressorHelper.hh
Go to the documentation of this file.
1 #ifndef __JFIT_JREGRESSORHELPER__
2 #define __JFIT_JREGRESSORHELPER__
3 
4 #include <string>
5 #include <array>
6 
7 #include "JPhysics/JPDFTypes.hh"
8 #include "JPhysics/JPDFTable.hh"
9 #include "JPhysics/JNPETable.hh"
10 
11 #include "JTools/JRange.hh"
12 #include "JTools/JFunction1D_t.hh"
14 
15 /**
16  * \author mdejong
17  */
18 
19 namespace JFIT {}
20 namespace JPP { using namespace JFIT; }
21 
22 namespace JFIT {
23 
31 
32  /**
33  * forward declarations
34  */
35  class JLine3Z;
36  template<class JModel_t>
37  class JAbstractMinimiser;
38  template<class JModel_t>
39  class JSimplex;
40  template<class JModel_t>
41  class JGandalf;
42 
43 
44  /**
45  * Template data structure for PDF tables.
46  */
47  template<class JModel_t, template<class> class JMinimiser_t>
49 
50 
51  /**
52  * Template specialisation for PDF tables.
53  */
54  template<>
56  {
62 
67 
69 
70  static const int NUMBER_OF_PDFS = 6; //!< Number of PDFs
71 
74 
75 
76  /**
77  * PDF types.
78  */
79  static const JPDFType_t pdf_t[NUMBER_OF_PDFS];
80  };
81 
82 
83  /**
84  * PDF types.
85  */
92 
93 
94 
95  /**
96  * Template data structure for storage for PDF tables.
97  */
98  template<class JModel_t, template<class> class JMinimiser_t>
100 
101 
102  /**
103  * Template specialisation for storage for PDF tables.
104  */
105  template<>
107  public JRegressorHelper<JLine3Z, JGandalf>
108  {
109  /**
110  * Default constructor.
111  */
113  {}
114 
115 
116  /**
117  * Constructor.
118  *
119  * The PDF file descriptor should contain the wild card character JPHYSICS::WILDCARD which
120  * will be replaced by the corresponding PDF types listed in JRegressor<JLine3Z, JGandalf>::pdf_t.
121  *
122  * The <tt>TTS</tt> corresponds to the additional time smearing applied to the PDFs.
123  *
124  * \param fileDescriptor PDF file descriptor
125  * \param TTS TTS [ns]
126  * \param numberOfPoints number of points for Gauss-Hermite integration of TTS
127  * \param epsilon precision for Gauss-Hermite integration of TTS
128  */
129  JRegressorStorage(const std::string& fileDescriptor,
130  const double TTS,
131  const int numberOfPoints = 25,
132  const double epsilon = 1.0e-10)
133  {
134  using namespace std;
135  using namespace JPP;
136 
137  const JPDF_t::JSupervisor supervisor(new JPDF_t::JDefaultResult(JMATH::zero));
138 
139  for (int i = 0; i != NUMBER_OF_PDFS; ++i) {
140 
141  const string file_name = getFilename(fileDescriptor, pdf_t[i]);
142 
143  _pdf[i].load(file_name.c_str());
144 
145  _pdf[i].setExceptionHandler(supervisor);
146  }
147 
148  // Add PDFs
149 
150  for (int i = 1; i < NUMBER_OF_PDFS; i += 2) {
151 
152  _pdf[ i ].add(_pdf[i-1]);
153 
154  JPDF_t buffer;
155 
156  _pdf[i-1].swap(buffer);
157 
158  if (TTS > 0.0) {
159  _pdf[i].blur(TTS, numberOfPoints, epsilon);
160  }
161 
162  _npe[ i ] = JNPE_t(_pdf[i]);
163  }
164  }
165 
166 
167  /**
168  * Get PDFs.
169  *
170  * \return PDFs
171  */
172  const JPDFs_t& getPDF() const
173  {
174  return _pdf;
175  }
176 
177 
178  /**
179  * Get NPEs.
180  *
181  * \return NPEs
182  */
183  const JNPEs_t& getNPE() const
184  {
185  return _npe;
186  }
187 
188 
189  /**
190  * Transform PDFs and NPEs.
191  *
192  * \param transformer transformer
193  */
194  void transform(const transformer_type& transformer)
195  {
196  for (int i = 0; i != NUMBER_OF_PDFS; ++i) {
197  _pdf[i].transform(transformer);
198  _npe[i].transform(transformer);
199  }
200  }
201 
202 
203  /**
204  * Set maximal road width of PDF.
205  *
206  * \param Rmax road width [m]
207  */
208  inline void setRmax(const double Rmax)
209  {
211 
212  for (int i = 0; i != NUMBER_OF_PDFS; ++i) {
213  if (!_pdf[i].empty()) {
214  _pdf[i].compress(range);
215  }
216  }
217  }
218 
219 
220  private:
221  JPDFs_t _pdf; //!< PDFs
222  JNPEs_t _npe; //!< NPEs
223  };
224 }
225 
226 #endif
Type definition of a spline interpolation method based on a JCollection with JResultPDF result type...
void transform(const transformer_type &transformer)
Transform PDFs and NPEs.
Template data structure for PDF tables.
const JNPEs_t & getNPE() const
Get NPEs.
direct light from EM showers
Definition: JPDFTypes.hh:29
void blur(const double TTS, const int numberOfPoints=25, const double epsilon=1.0e-10, const double quantile=0.99)
Blur PDF.
Definition: JPDFTable.hh:111
Data structure for fit of straight line in positive z-direction.
Definition: JLine3Z.hh:36
static const JZero zero
Function object to assign zero value.
Definition: JZero.hh:105
Template data structure for storage for PDF tables.
Type definition of a 1st degree polynomial interpolation based on a JMap implementation.
direct light from muon
Definition: JPDFTypes.hh:26
Various implementations of functional maps.
Numbering scheme for PDF types.
scattered light from muon
Definition: JPDFTypes.hh:27
Type definition of a 1st degree polynomial interpolation based on a JGridMap implementation.
JPHYSICS::JNPETable< double, double, JNPEMaplist_t > JNPE_t
time integrated PDF
const JPDFs_t & getPDF() const
Get PDFs.
Type definition of a 1st degree polynomial interpolation based on a JMap implementation.
scattered light from delta-rays
Definition: JPDFTypes.hh:33
then awk string
JRegressorStorage(const std::string &fileDescriptor, const double TTS, const int numberOfPoints=25, const double epsilon=1.0e-10)
Constructor.
scattered light from EM showers
Definition: JPDFTypes.hh:30
JPDFType_t
PDF types.
Definition: JPDFTypes.hh:24
Auxiliary class for recursive map list generation.
Definition: JMapList.hh:108
Range of values.
Definition: JRange.hh:38
std::array< JNPE_t, NUMBER_OF_PDFS > JNPEs_t
NPEs.
transformablemultifunction_type::transformer_type transformer_type
Definition: JPDFTable.hh:54
Fit method based on the Levenberg-Marquardt method.
Definition: JGandalf.hh:53
direct light from delta-rays
Definition: JPDFTypes.hh:32
z range($ZMAX-$ZMIN)< $MINIMAL_DZ." fi fi typeset -Z 4 STRING typeset -Z 2 FLOOR JPlot1D -f $
JPHYSICS::JPDFTable< JFunction1D_t, JPDFMaplist_t > JPDF_t
time dependent PDF
Auxiliary class to define a range between two values.
Simple fit method based on Powell&#39;s algorithm, see reference: Numerical Recipes in C++...
Type definition of a zero degree polynomial interpolation based on a JGridMap implementation.
int numberOfPoints
Definition: JResultPDF.cc:22
std::string getFilename(const std::string &file_name)
Get file name part, i.e. part after last JEEP::PATHNAME_SEPARATOR if any.
Definition: JeepToolkit.hh:128
JTOOLS::JMAPLIST< JTOOLS::JPolint1FunctionalMap, JTOOLS::JPolint0FunctionalGridMap, JTOOLS::JPolint0FunctionalGridMap >::maplist JPDFMaplist_t
std::array< JPDF_t, NUMBER_OF_PDFS > JPDFs_t
PDFs.
Abstract minimiser.
Definition: JRegressor.hh:25
const double epsilon
Definition: JQuadrature.cc:21
JTOOLS::JMAPLIST< JTOOLS::JPolint1FunctionalMapH, JTOOLS::JPolint1FunctionalGridMap, JTOOLS::JPolint1FunctionalGridMap >::maplist JNPEMaplist_t
void setRmax(const double Rmax)
Set maximal road width of PDF.