Jpp master_rocky-44-g75b7c4f75
the software that should make you happy
Loading...
Searching...
No Matches
JNPETable.hh
Go to the documentation of this file.
1#ifndef __JPHYSICS__JNPETABLE__
2#define __JPHYSICS__JNPETABLE__
3
5#include "JLang/JException.hh"
6
11
12
13/**
14 * \author mdejong
15 */
16
17namespace JPHYSICS {}
18namespace JPP { using namespace JPHYSICS; }
19
20namespace JPHYSICS {
21
23 using JTOOLS::JMapList;
27
28
29 /**
30 * Custom class for integrated values of the PDF of the arrival time of Cherenkov light.
31 *
32 * This class provides for the number of photo-electrons as a function
33 * of the leading <tt>(n - 1)</tt> parameter values.
34 */
35 template<class JArgument_t,
36 class JResult_t,
37 class JMaplist_t,
38 class JDistance_t = JTOOLS::JDistance<JArgument_t> >
39 class JNPETable :
40 public JMultiFunction<JConstantFunction1D<JArgument_t, JResult_t>,
41 JMaplist_t,
42 JDistance_t>
43 {
44 public:
45
47 JMaplist_t,
48 JDistance_t> multifunction_t;
49
51
53 typedef typename multifunction_t::map_type map_type;
54
57 typedef typename multifunction_t::supervisor_type supervisor_type;
58
62
67
70
72
73
74 /**
75 * Default constructor.
76 */
78 transformer(transformer_type::getClone())
79 {}
80
81
82 /**
83 * Constructor.
84 *
85 * \param input multi-dimensional PDF
86 */
87 template<class JPDF_t, class JPDFMaplist_t, class JPDFDistance_t>
89 transformer(transformer_type::getClone())
90 {
91 using namespace JTOOLS;
92
94 typedef JMultiKey<JTransformableMultiFunction_t::NUMBER_OF_DIMENSIONS - 1, argument_type> JMultiKey_t;
95 typedef typename JTransformableMultiFunction_t::transformer_type transformer_type;
96
97
98 this->transformer.reset(input.transformer->clone());
99
100 for (typename JTransformableMultiFunction_t::super_const_iterator i = input.super_begin(); i != input.super_end(); ++i) {
101
102 const JMultiKey_t& key = (*i).getKey();
103 const JPDF_t& value = (*i).getValue();
104
105 const typename transformer_type::array_type array(key);
106
107 const double V = getIntegral(value);
108 const argument_type z = input.transformer->getXn(array, 1.0) - input.transformer->getXn(array, 0.0);
109
110 this->insert(key, function_type(z*V));
111 }
112
113 this->compile();
114 }
115
116
117 /**
118 * Add NPE table.
119 *
120 * Note that the summation is made via iteration of the elements in this multidimensional table.
121 *
122 * \param input NPE table
123 */
124 void add(const JNPETable& input)
125 {
126 using namespace JTOOLS;
127
128 for (super_iterator i = this->super_begin(); i != this->super_end(); ++i) {
129
130 map_type& f1 = (*i).getValue();
131
132 for (typename map_type::iterator j = f1.begin(); j != f1.end(); ++j) {
133
134 try {
135
136 const JArray<NUMBER_OF_DIMENSIONS, argument_type> buffer((*i).getKey(), j->getX());
137
138 const double npe = get_value(input.evaluate(buffer.data()));
139 const double W = this->transformer->getWeight(buffer);
140
141 j->getY() += npe/W;
142 }
143 catch(JLANG::JException& error) {}
144 }
145 }
146 }
147
148
149 /**
150 * Get number of photo-electrons.
151 *
152 * \param args comma separated argument list
153 * \return number of photo-electrons
154 */
155 template<class ...Args>
156 result_type operator()(const Args& ...args) const
157 {
158 this->buffer.set(args...);
159
160 return this->evaluate(this->buffer.data());
161 }
162
163
164 /**
165 * Recursive function value evaluation.
166 *
167 * \param pX pointer to abscissa values
168 * \return function value
169 */
170 virtual result_type evaluate(const argument_type* pX) const override
171 {
172 for (int i = 0; i != NUMBER_OF_DIMENSIONS; ++i) {
173 this->buffer[i] = pX[i];
174 }
175
176 const double W = transformer->getWeight(buffer);
177 const result_type npe = multifunction_t::evaluate(buffer.data());
178
179 return W * npe;
180 }
181
182
183 /**
184 * Application of weight function.
185 *
186 * \param transformer function transformer
187 */
189 {
190 using namespace JTOOLS;
191
192 for (super_iterator i = this->super_begin(); i != this->super_end(); ++i) {
193
194 map_type& f1 = (*i).getValue();
195
196 for (typename map_type::iterator j = f1.begin(); j != f1.end(); ++j) {
197
198 const JArray<NUMBER_OF_DIMENSIONS, argument_type> array((*i).getKey(), j->getX());
199
200 j->getY() *= this->transformer->getWeight(array) / transformer.getWeight(array);
201 }
202 }
203
204 this->transformer.reset(transformer.clone());
205 this->compile();
206 }
207
208
210
211 protected:
213 };
214}
215
216#endif
Exceptions.
This include file contains various recursive methods to operate on multi-dimensional collections.
General exception.
Definition JException.hh:24
The template JSharedPointer class can be used to share a pointer to an object.
Custom class for integrated values of the PDF of the arrival time of Cherenkov light.
Definition JNPETable.hh:43
multifunction_t::result_type result_type
Definition JNPETable.hh:61
virtual result_type evaluate(const argument_type *pX) const override
Recursive function value evaluation.
Definition JNPETable.hh:170
JNPETable()
Default constructor.
Definition JNPETable.hh:77
multifunction_t::abscissa_type abscissa_type
Definition JNPETable.hh:59
multifunction_t::argument_type argument_type
Definition JNPETable.hh:56
JTOOLS::JArray< NUMBER_OF_DIMENSIONS, argument_type > buffer
Definition JNPETable.hh:212
void transform(const transformer_type &transformer)
Application of weight function.
Definition JNPETable.hh:188
multifunction_t::reverse_iterator reverse_iterator
Definition JNPETable.hh:66
JConstantFunction1D< JArgument_t, JResult_t > function_type
Definition JNPETable.hh:52
multifunction_t::map_type map_type
Definition JNPETable.hh:53
multifunction_t::ordinate_type ordinate_type
Definition JNPETable.hh:60
multifunction_t::value_type value_type
Definition JNPETable.hh:55
JNPETable(const JTransformableMultiFunction< JPDF_t, JPDFMaplist_t, JPDFDistance_t > &input)
Constructor.
Definition JNPETable.hh:88
multifunction_t::iterator iterator
Definition JNPETable.hh:65
JLANG::JSharedPointer< transformer_type > transformer
Definition JNPETable.hh:209
multifunction_t::const_reverse_iterator const_reverse_iterator
Definition JNPETable.hh:64
multifunction_t::const_iterator const_iterator
Definition JNPETable.hh:63
multifunction_t::super_iterator super_iterator
Definition JNPETable.hh:68
JMultiFunction< JConstantFunction1D< JArgument_t, JResult_t >, JMaplist_t, JDistance_t > multifunction_t
Definition JNPETable.hh:48
result_type operator()(const Args &...args) const
Get number of photo-electrons.
Definition JNPETable.hh:156
JMultiMapTransformer< NUMBER_OF_DIMENSIONS, argument_type > transformer_type
Definition JNPETable.hh:71
multifunction_t::supervisor_type supervisor_type
Definition JNPETable.hh:57
multifunction_t::super_const_iterator super_const_iterator
Definition JNPETable.hh:69
void add(const JNPETable &input)
Add NPE table.
Definition JNPETable.hh:124
One dimensional array of template objects with fixed length.
Definition JArray.hh:43
const_pointer data() const
Get pointer to data.
Definition JArray.hh:284
JArray & set(const Args &...args)
Set array.
Definition JArray.hh:199
Template implementation of function object in one dimension returning a constant value.
Multidimensional interpolation method.
multimap_type::super_iterator super_iterator
multimap_type::super_const_iterator super_const_iterator
multimap_type::result_type result_type
multimap_type::ordinate_type ordinate_type
void compile()
Compilation.
multimap_type::const_iterator const_iterator
multimap_type::iterator iterator
multimap_type::reverse_iterator reverse_iterator
multimap_type::const_reverse_iterator const_reverse_iterator
function_type::value_type value_type
function_type::argument_type argument_type
multimap_type::abscissa_type abscissa_type
Multidimensional key.
Definition JMultiKey.hh:69
Interface for weight application and coordinate transformation of function.
virtual double getWeight(const_array_type &buffer) const =0
Weight function.
Transformable multidimensional function.
JLANG::JSharedPointer< transformer_type > transformer
Auxiliary methods for light properties of deep-sea water.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary classes and methods for multi-dimensional interpolations and histograms.
double getValue(const double x) const
Function value.
Definition JMathlib.hh:1421
Template class for distance evaluation.
Definition JDistance.hh:24
Map list.
Definition JMapList.hh:25