Jpp 19.3.0-rc.1
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
4#include <memory>
5
6#include "JLang/JException.hh"
7
12
14
15
16/**
17 * \author mdejong
18 */
19
20namespace JPHYSICS {}
21namespace JPP { using namespace JPHYSICS; }
22
23namespace JPHYSICS {
24
26 using JTOOLS::JMapList;
30
31
32 /**
33 * Custom class for integrated values of the PDF of the arrival time of Cherenkov light.
34 *
35 * This class provides for the number of photo-electrons as a function
36 * of the leading <tt>(n - 1)</tt> parameter values.
37 */
38 template<class JArgument_t,
39 class JResult_t,
40 class JMaplist_t,
41 class JDistance_t = JTOOLS::JDistance<JArgument_t> >
42 class JNPETable :
43 public JMultiFunction<JConstantFunction1D<JArgument_t, JResult_t>,
44 JMaplist_t,
45 JDistance_t>
46 {
47 public:
48
50 JMaplist_t,
51 JDistance_t> multifunction_t;
52
54
56 typedef typename multifunction_t::map_type map_type;
57
60 typedef typename multifunction_t::supervisor_type supervisor_type;
61
65
70
73
75
76
77 /**
78 * Default constructor.
79 */
81 transformer(transformer_type::getClone())
82 {}
83
84
85 /**
86 * Constructor.
87 *
88 * \param input multi-dimensional PDF
89 * \param range time range [ns]
90 */
91 template<class JPDF_t, class JPDFMaplist_t, class JPDFDistance_t>
93 transformer(transformer_type::getClone())
94 {
95 using namespace JTOOLS;
96
98 typedef JMultiKey<JTransformableMultiFunction_t::NUMBER_OF_DIMENSIONS - 1, argument_type> JMultiKey_t;
99 typedef typename JTransformableMultiFunction_t::transformer_type transformer_type;
100
101
102 this->transformer.reset(input.transformer->clone());
103
104 for (typename JTransformableMultiFunction_t::super_const_iterator i = input.super_begin(); i != input.super_end(); ++i) {
105
106 const JMultiKey_t& key = (*i).getKey();
107 const JPDF_t& value = (*i).getValue();
108
109 const typename transformer_type::array_type array(key);
110
111 const double V = getIntegral(value, JTimeRange(input.transformer->putXn(array, range.getLowerLimit()),
112 input.transformer->putXn(array, range.getUpperLimit())));
113
114 const argument_type z = input.transformer->getXn(array, 1.0) - input.transformer->getXn(array, 0.0);
115
116 this->insert(key, function_type(z*V));
117 }
118
119 this->compile();
120 }
121
122
123 /**
124 * Add NPE table.
125 *
126 * Note that the summation is made via iteration of the elements in this multidimensional table.
127 *
128 * \param input NPE table
129 */
130 void add(const JNPETable& input)
131 {
132 using namespace JTOOLS;
133
134 for (super_iterator i = this->super_begin(); i != this->super_end(); ++i) {
135
136 map_type& f1 = (*i).getValue();
137
138 for (typename map_type::iterator j = f1.begin(); j != f1.end(); ++j) {
139
140 try {
141
142 const JArray<NUMBER_OF_DIMENSIONS, argument_type> buffer((*i).getKey(), j->getX());
143
144 const double npe = get_value(input.evaluate(buffer.data()));
145 const double W = this->transformer->getWeight(buffer);
146
147 j->getY() += npe/W;
148 }
149 catch(JLANG::JException& error) {}
150 }
151 }
152 }
153
154
155 /**
156 * Get number of photo-electrons.
157 *
158 * \param args comma separated argument list
159 * \return number of photo-electrons
160 */
161 template<class ...Args>
162 result_type operator()(const Args& ...args) const
163 {
164 using namespace JTOOLS;
165
167
168 return this->evaluate(buffer.data());
169 }
170
171
172 /**
173 * Recursive function value evaluation.
174 *
175 * \param pX pointer to abscissa values
176 * \return function value
177 */
178 virtual result_type evaluate(const argument_type* pX) const override
179 {
180 using namespace JTOOLS;
181
183
184 for (int i = 0; i != NUMBER_OF_DIMENSIONS; ++i) {
185 buffer[i] = pX[i];
186 }
187
188 const double W = transformer->getWeight(buffer);
189 const result_type npe = multifunction_t::evaluate(buffer.data());
190
191 return W * npe;
192 }
193
194
195 /**
196 * Application of weight function.
197 *
198 * \param transformer function transformer
199 */
201 {
202 using namespace JTOOLS;
203
204 for (super_iterator i = this->super_begin(); i != this->super_end(); ++i) {
205
206 map_type& f1 = (*i).getValue();
207
208 for (typename map_type::iterator j = f1.begin(); j != f1.end(); ++j) {
209
210 const JArray<NUMBER_OF_DIMENSIONS, argument_type> array((*i).getKey(), j->getX());
211
212 j->getY() *= this->transformer->getWeight(array) / transformer.getWeight(array);
213 }
214 }
215
216 this->transformer.reset(transformer.clone());
217 this->compile();
218 }
219
220
221 std::shared_ptr<transformer_type> transformer;
222 };
223}
224
225#endif
Exceptions.
This include file contains various recursive methods to operate on multi-dimensional collections.
General exception.
Definition JException.hh:24
Custom class for integrated values of the PDF of the arrival time of Cherenkov light.
Definition JNPETable.hh:46
multifunction_t::result_type result_type
Definition JNPETable.hh:64
virtual result_type evaluate(const argument_type *pX) const override
Recursive function value evaluation.
Definition JNPETable.hh:178
JNPETable()
Default constructor.
Definition JNPETable.hh:80
multifunction_t::abscissa_type abscissa_type
Definition JNPETable.hh:62
multifunction_t::argument_type argument_type
Definition JNPETable.hh:59
JNPETable(const JTransformableMultiFunction< JPDF_t, JPDFMaplist_t, JPDFDistance_t > &input, const JTimeRange range=JTimeRange())
Constructor.
Definition JNPETable.hh:92
void transform(const transformer_type &transformer)
Application of weight function.
Definition JNPETable.hh:200
multifunction_t::reverse_iterator reverse_iterator
Definition JNPETable.hh:69
JConstantFunction1D< JArgument_t, JResult_t > function_type
Definition JNPETable.hh:55
multifunction_t::map_type map_type
Definition JNPETable.hh:56
multifunction_t::ordinate_type ordinate_type
Definition JNPETable.hh:63
multifunction_t::value_type value_type
Definition JNPETable.hh:58
multifunction_t::iterator iterator
Definition JNPETable.hh:68
multifunction_t::const_reverse_iterator const_reverse_iterator
Definition JNPETable.hh:67
multifunction_t::const_iterator const_iterator
Definition JNPETable.hh:66
multifunction_t::super_iterator super_iterator
Definition JNPETable.hh:71
JMultiFunction< JConstantFunction1D< JArgument_t, JResult_t >, JMaplist_t, JDistance_t > multifunction_t
Definition JNPETable.hh:51
std::shared_ptr< transformer_type > transformer
Definition JNPETable.hh:221
result_type operator()(const Args &...args) const
Get number of photo-electrons.
Definition JNPETable.hh:162
JMultiMapTransformer< NUMBER_OF_DIMENSIONS, argument_type > transformer_type
Definition JNPETable.hh:74
multifunction_t::supervisor_type supervisor_type
Definition JNPETable.hh:60
multifunction_t::super_const_iterator super_const_iterator
Definition JNPETable.hh:72
void add(const JNPETable &input)
Add NPE table.
Definition JNPETable.hh:130
One dimensional array of template objects with fixed length.
Definition JArray.hh:43
const_pointer data() const
Get pointer to data.
Definition JArray.hh:295
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.
std::shared_ptr< transformer_type > transformer
Auxiliary methods for light properties of deep-sea water.
JTOOLS::JRange< double > JTimeRange
Type definition for time range (unit [ns]).
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