Jpp master_rocky-44-g75b7c4f75
the software that should make you happy
Loading...
Searching...
No Matches
JTransformableMultiHistogram.hh
Go to the documentation of this file.
1#ifndef __JTOOLS__JTRANSFORMABLEMULTIHISTOGRAM__
2#define __JTOOLS__JTRANSFORMABLEMULTIHISTOGRAM__
3
6
7#include "JTools/JMultiMap.hh"
10#include "JTools/JArray.hh"
11#include "JIO/JSerialisable.hh"
12
13
14/**
15 * \author mdejong
16 */
17
18namespace JTOOLS {}
19namespace JPP { using namespace JTOOLS; }
20
21namespace JTOOLS {
22
23 using JIO::JReader;
24 using JIO::JWriter;
25
26
27 /**
28 * Transformable multidimensional histogram.
29 *
30 * This class implements the JTransformable interface.
31 */
32 template<class JHistogram_t,
33 class JMaplist_t,
36 public JMultiHistogram<JHistogram_t, JMaplist_t, JDistance_t>,
37 public JTransformable<JMapLength<JMaplist_t>::value, typename JHistogram_t::abscissa_type>
38 {
39 public:
40
41 typedef JMultiHistogram<JHistogram_t,
42 JMaplist_t,
43 JDistance_t> JMultiHistogram_t;
44
46
47 typedef JHistogram_t histogram_type;
48
49 typedef typename histogram_type::contents_type contents_type;
50 typedef typename histogram_type::value_type value_type;
51
54
59
62
65
66
67 /**
68 * Default constructor.
69 */
73
74
75 /**
76 * Get transformable multidimensional histogram.
77 *
78 * \return this transformable multidimensional histogram
79 */
81 {
82 return static_cast<const JTransformableMultiHistogram&>(*this);
83 }
84
85
86 /**
87 * Get transformable multidimensional histogram.
88 *
89 * \return this transformable multidimensional histogram
90 */
95
96
97 /**
98 * Application of weight function and coordinate transformation.
99 *
100 * \param transformer function transformer
101 */
102 virtual void transform(const transformer_type& transformer) override
103 {
105
106 for (super_iterator i = this->super_begin(); i != this->super_end(); ++i) {
107
108 const array_type array = (*i).getKey();
109 histogram_type& histogram = (*i).getValue();
110
111 const JMultiMapGetTransformer<NUMBER_OF_DIMENSIONS - 1, value_type> get(*(this->transformer), array);
113
114 histogram.transform(get);
115 histogram.transform(put);
116 }
117
118 this->transformer.reset(transformer.clone());
119 }
120
121
122 /**
123 * Read transformable multidimensional histogram.
124 *
125 * \param in reader
126 * \param object transformable multidimensional histogram.
127 * \return reader
128 */
130 {
131 in >> static_cast<JMultiHistogram_t&>(object);
132
133 return object.transformer->read(in);
134 }
135
136
137 /**
138 * Write transformable multidimensional histogram.
139 *
140 * \param out writer
141 * \param object transformable multidimensional histogram
142 * \return writer
143 */
144 friend inline JWriter& operator<<(JWriter& out, const JTransformableMultiHistogram& object)
145 {
146 out << static_cast<const JMultiHistogram_t&>(object);
147
148 return object.transformer->write(out);
149 }
150
151
153
154 protected:
155 /**
156 * Termination method for filling histogram.
157 *
158 * \param i index
159 * \param x abscissa value
160 * \param w weight
161 */
162 virtual void __fill__(const int i, const abscissa_type x, const contents_type w) override
163 {
164 this->buffer[NUMBER_OF_DIMENSIONS - 1] = transformer->putXn(this->buffer, this->buffer[NUMBER_OF_DIMENSIONS - 1]);
165
166 const double z = transformer->putXn(this->buffer, 1.0) - transformer->putXn(this->buffer, 0.0);
167 const double W = transformer->getWeight(this->buffer);
168
169 this->evaluate(this->buffer.begin(), w * z / W);
170
171 this->evaluate(this->buffer.begin(), w);
172 }
173 };
174}
175
176#endif
General purpose multidimensional map based on a type list of maps.
Interface for binary input.
Interface for binary output.
The template JSharedPointer class can be used to share a pointer to an object.
One dimensional array of template objects with fixed length.
Definition JArray.hh:43
const_iterator begin() const
get iterator to begin of data
Definition JArray.hh:209
Multidimensional histogram.
multimap_type::super_iterator super_iterator
multimap_type::iterator iterator
multimap_type::abscissa_type abscissa_type
multimap_type::super_const_iterator super_const_iterator
multimap_type::reverse_iterator reverse_iterator
multimap_type::const_iterator const_iterator
JArray< NUMBER_OF_DIMENSIONS, abscissa_type > buffer
multimap_type::ordinate_type ordinate_type
multimap_type::const_reverse_iterator const_reverse_iterator
Auxiliary class to convert JMultiMapTransformer to JCollectionElementTransformer.
Auxiliary class to convert JMultiMapTransformer to JCollectionElementTransformer.
Interface for weight application and coordinate transformation of function.
Transformable multidimensional histogram.
JMultiMapTransformer< JMapLength< JMaplist_t >::value, abscissa_type > transformer_type
JLANG::JSharedPointer< transformer_type > transformer
friend JReader & operator>>(JReader &in, JTransformableMultiHistogram &object)
Read transformable multidimensional histogram.
const JTransformableMultiHistogram & getTransformableMultiHistogram() const
Get transformable multidimensional histogram.
JTransformableMultiHistogram & getTransformableMultiHistogram()
Get transformable multidimensional histogram.
JMultiHistogram_t::ordinate_type ordinate_type
JMultiHistogram_t::const_reverse_iterator const_reverse_iterator
JMultiHistogram_t::super_iterator super_iterator
virtual void __fill__(const int i, const abscissa_type x, const contents_type w) override
Termination method for filling histogram.
JMultiHistogram_t::abscissa_type abscissa_type
JMultiHistogram< JHistogram_t, JMaplist_t, JDistance_t > JMultiHistogram_t
virtual void transform(const transformer_type &transformer) override
Application of weight function and coordinate transformation.
JMultiHistogram_t::super_const_iterator super_const_iterator
friend JWriter & operator<<(JWriter &out, const JTransformableMultiHistogram &object)
Write transformable multidimensional histogram.
JMultiHistogram_t::const_iterator const_iterator
JMultiHistogram_t::reverse_iterator reverse_iterator
JAbstractHistogram< double > JHistogram_t
Type definition for scan along axis.
Definition JBillabong.cc:61
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary classes and methods for multi-dimensional interpolations and histograms.
data_type w[N+1][M+1]
Definition JPolint.hh:867
Template class for distance evaluation.
Definition JDistance.hh:24
Abstract interface for transformable multidimensional map.