Jpp test-rotations-old
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
4#include <memory>
5
7
8#include "JTools/JMultiMap.hh"
11#include "JTools/JArray.hh"
12#include "JIO/JSerialisable.hh"
13
14
15/**
16 * \author mdejong
17 */
18
19namespace JTOOLS {}
20namespace JPP { using namespace JTOOLS; }
21
22namespace JTOOLS {
23
24 using JIO::JReader;
25 using JIO::JWriter;
26
27
28 /**
29 * Transformable multidimensional histogram.
30 *
31 * This class implements the JTransformable interface.
32 */
33 template<class JHistogram_t,
34 class JMaplist_t,
37 public JMultiHistogram<JHistogram_t, JMaplist_t, JDistance_t>,
38 public JTransformable<JMapLength<JMaplist_t>::value, typename JHistogram_t::abscissa_type>
39 {
40 public:
41
42 typedef JMultiHistogram<JHistogram_t,
43 JMaplist_t,
44 JDistance_t> JMultiHistogram_t;
45
47
48 typedef JHistogram_t histogram_type;
49
50 typedef typename histogram_type::contents_type contents_type;
51 typedef typename histogram_type::value_type value_type;
52
55
60
63
66
67
68 /**
69 * Default constructor.
70 */
74
75
76 /**
77 * Get transformable multidimensional histogram.
78 *
79 * \return this transformable multidimensional histogram
80 */
82 {
83 return static_cast<const JTransformableMultiHistogram&>(*this);
84 }
85
86
87 /**
88 * Get transformable multidimensional histogram.
89 *
90 * \return this transformable multidimensional histogram
91 */
96
97
98 /**
99 * Application of weight function and coordinate transformation.
100 *
101 * \param transformer function transformer
102 */
103 virtual void transform(const transformer_type& transformer) override
104 {
106
107 for (super_iterator i = this->super_begin(); i != this->super_end(); ++i) {
108
109 const array_type array = (*i).getKey();
110 histogram_type& histogram = (*i).getValue();
111
112 const JMultiMapGetTransformer<NUMBER_OF_DIMENSIONS - 1, value_type> get(*(this->transformer), array);
114
115 histogram.transform(get);
116 histogram.transform(put);
117 }
118
119 this->transformer.reset(transformer.clone());
120 }
121
122
123 /**
124 * Read transformable multidimensional histogram.
125 *
126 * \param in reader
127 * \param object transformable multidimensional histogram.
128 * \return reader
129 */
131 {
132 in >> static_cast<JMultiHistogram_t&>(object);
133
134 return object.transformer->read(in);
135 }
136
137
138 /**
139 * Write transformable multidimensional histogram.
140 *
141 * \param out writer
142 * \param object transformable multidimensional histogram
143 * \return writer
144 */
145 friend inline JWriter& operator<<(JWriter& out, const JTransformableMultiHistogram& object)
146 {
147 out << static_cast<const JMultiHistogram_t&>(object);
148
149 return object.transformer->write(out);
150 }
151
152
153 std::shared_ptr<transformer_type> transformer;
154
155 protected:
156 /**
157 * Termination method for filling histogram.
158 *
159 * \param i index
160 * \param x abscissa value
161 * \param w weight
162 */
163 virtual void __fill__(const int i, const abscissa_type x, const contents_type w) override
164 {
165 this->buffer[NUMBER_OF_DIMENSIONS - 1] = transformer->putXn(this->buffer, this->buffer[NUMBER_OF_DIMENSIONS - 1]);
166
167 const double z = transformer->putXn(this->buffer, 1.0) - transformer->putXn(this->buffer, 0.0);
168 const double W = transformer->getWeight(this->buffer);
169
170 this->evaluate(this->buffer.begin(), w * z / W);
171
172 this->evaluate(this->buffer.begin(), w);
173 }
174 };
175}
176
177#endif
General purpose multidimensional map based on a type list of maps.
Interface for binary input.
Interface for binary output.
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:220
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
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.
std::shared_ptr< transformer_type > transformer
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.
Template class for distance evaluation.
Definition JDistance.hh:24
Abstract interface for transformable multidimensional map.