Jpp  17.1.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JMultiHistogram.hh
Go to the documentation of this file.
1 #ifndef __JTOOLS__JMULTIHISTOGRAM__
2 #define __JTOOLS__JMULTIHISTOGRAM__
3 
4 #include "JTools/JMultiMap.hh"
5 #include "JTools/JHistogram.hh"
6 #include "JTools/JArray.hh"
7 
8 
9 /**
10  * \author mdejong
11  */
12 
13 namespace JTOOLS {}
14 namespace JPP { using namespace JTOOLS; }
15 
16 namespace JTOOLS {
17 
18 
19  /**
20  * Multidimensional histogram.
21  *
22  * The template parameters respectively refer to:
23  * -# histogram object used for the lowest dimension(s);
24  * -# list of histogram maps used for the higher dimension(s); and
25  * -# distance operator.
26  *
27  * The number of dimensions of this histogram object is equal to the length of
28  * the given map list plus the extra dimensions of the first histogram object.
29  */
30  template<class JHistogram_t,
31  class JMaplist_t,
34  public JMultiMap<typename JHistogram_t::abscissa_type, JHistogram_t, JMaplist_t, JDistance_t>
35  {
36  public:
37 
38  typedef JMultiMap<typename JHistogram_t::abscissa_type,
39  JHistogram_t,
40  JMaplist_t,
41  JDistance_t> multimap_type;
42 
43  enum { NUMBER_OF_DIMENSIONS = JMapLength<JMaplist_t>::value + JHistogram_t::NUMBER_OF_DIMENSIONS };
44 
45  typedef typename multimap_type::abscissa_type abscissa_type;
46  typedef typename multimap_type::ordinate_type ordinate_type;
47 
48  typedef typename multimap_type::const_iterator const_iterator;
49  typedef typename multimap_type::const_reverse_iterator const_reverse_iterator;
50  typedef typename multimap_type::iterator iterator;
51  typedef typename multimap_type::reverse_iterator reverse_iterator;
52 
53  typedef typename multimap_type::super_iterator super_iterator;
54  typedef typename multimap_type::super_const_iterator super_const_iterator;
55 
56  typedef typename JHistogram_t::contents_type contents_type;
57 
58 
59  /**
60  * Default constructor.
61  */
63  {}
64 
65 
66  /**
67  * Get multidimensional histogram.
68  *
69  * \return this multidimensional histogram
70  */
72  {
73  return static_cast<const JMultiHistogram&>(*this);
74  }
75 
76 
77  /**
78  * Get multidimensional histogram.
79  *
80  * \return this multidimensional histogram
81  */
83  {
84  return static_cast<JMultiHistogram&>(*this);
85  }
86 
87 
88  /**
89  * Multi-dimensional fill method call.
90  *
91  * \param args comma seperated list of abscissa values and weight
92  */
93  template<class ...Args>
94  void fill(const Args& ...args)
95  {
96  __fill__(0, args...);
97  }
98 
99 
100  protected:
101  /**
102  * Recursive method for filling histogram.
103  *
104  * \param i index
105  * \param x0 value at given index
106  * \param x1 value at following index
107  * \param args remaining values and weight
108  */
109  template<class ...Args>
110  void __fill__(const int i, const abscissa_type x0, const abscissa_type x1, const Args& ...args)
111  {
112  this->buffer[i] = x0;
113 
114  __fill__(i + 1, x1, args...);
115  }
116 
117  /**
118  * Termination method for filling histogram.
119  *
120  * \param i index
121  * \param x value at given index
122  * \param w weight
123  */
124  virtual void __fill__(const int i, const abscissa_type x, const contents_type w)
125  {
126  this->buffer[i] = x;
127 
128  this->evaluate(this->buffer.data(), w);
129  }
130 
132  };
133 }
134 
135 #endif
JMultiHistogram & getMultiHistogram()
Get multidimensional histogram.
data_type w[N+1][M+1]
Definition: JPolint.hh:757
General purpose multidimensional map based on a type list of maps.
void fill(const Args &...args)
Multi-dimensional fill method call.
Template class for distance evaluation.
Definition: JDistance.hh:24
void __fill__(const int i, const abscissa_type x0, const abscissa_type x1, const Args &...args)
Recursive method for filling histogram.
Length of map list.
Definition: JMapList.hh:45
multimap_type::super_iterator super_iterator
JMultiMap< typename JHistogram_t::abscissa_type, JHistogram_t, JMaplist_t, JDistance_t > multimap_type
multimap_type::super_const_iterator super_const_iterator
const JMultiHistogram & getMultiHistogram() const
Get multidimensional histogram.
JMultiHistogram()
Default constructor.
multimap_type::const_reverse_iterator const_reverse_iterator
virtual void __fill__(const int i, const abscissa_type x, const contents_type w)
Termination method for filling histogram.
JArray< NUMBER_OF_DIMENSIONS, abscissa_type > buffer
JHistogram_t::contents_type contents_type
multimap_type::const_iterator const_iterator
multimap_type::abscissa_type abscissa_type
Multidimensional histogram.
multimap_type::reverse_iterator reverse_iterator
multimap_type::ordinate_type ordinate_type
multimap_type::iterator iterator
const_pointer data() const
Get pointer to data.
Definition: JArray.hh:284
Multidimensional map.
Definition: JMultiMap.hh:52