Jpp
 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 <stdarg.h>
5 
6 #include "JTools/JMultiMap.hh"
7 #include "JTools/JHistogram.hh"
8 #include "JTools/JArray.hh"
9 
10 
11 /**
12  * \author mdejong
13  */
14 
15 namespace JTOOLS {}
16 namespace JPP { using namespace JTOOLS; }
17 
18 namespace JTOOLS {
19 
20 
21  /**
22  * Multidimensional histogram.
23  *
24  * The template parameters respectively refer to:
25  * -# histogram object used for the lowest dimension(s);
26  * -# list of histogram maps used for the higher dimension(s); and
27  * -# distance operator.
28  *
29  * The number of dimensions of this histogram object is equal to the length of
30  * the given map list plus the extra dimensions of the first histogram object.
31  */
32  template<class JHistogram_t,
33  class JMaplist_t,
36  public JMultiMap<typename JHistogram_t::abscissa_type, JHistogram_t, JMaplist_t, JDistance_t>
37  {
38  public:
39 
40  typedef JMultiMap<typename JHistogram_t::abscissa_type,
41  JHistogram_t,
42  JMaplist_t,
43  JDistance_t> multimap_type;
44 
45  enum { NUMBER_OF_DIMENSIONS = JMapLength<JMaplist_t>::value + JHistogram_t::NUMBER_OF_DIMENSIONS };
46 
47  typedef typename multimap_type::abscissa_type abscissa_type;
48  typedef typename multimap_type::ordinate_type ordinate_type;
49 
50  typedef typename multimap_type::const_iterator const_iterator;
51  typedef typename multimap_type::const_reverse_iterator const_reverse_iterator;
52  typedef typename multimap_type::iterator iterator;
53  typedef typename multimap_type::reverse_iterator reverse_iterator;
54 
55  typedef typename multimap_type::super_iterator super_iterator;
56  typedef typename multimap_type::super_const_iterator super_const_iterator;
57 
58  typedef typename JHistogram_t::contents_type contents_type;
59 
60 
61  /**
62  * Default constructor.
63  */
65  {}
66 
67 
68  /**
69  * Get multidimensional histogram.
70  *
71  * \return this multidimensional histogram
72  */
74  {
75  return static_cast<const JMultiHistogram&>(*this);
76  }
77 
78 
79  /**
80  * Get multidimensional histogram.
81  *
82  * \return this multidimensional histogram
83  */
85  {
86  return static_cast<JMultiHistogram&>(*this);
87  }
88 
89 
90  /**
91  * Multi-dimensional fill method call.
92  *
93  * \param x comma seperated argument list
94  */
95  void fill(const abscissa_type x, ...)
96  {
97  va_start(ap, x);
98 
99  buffer[0] = x;
100 
101  for (int i = 1; i != NUMBER_OF_DIMENSIONS; ++i) {
102  buffer[i] = va_arg(ap, abscissa_type);
103  }
104 
105  const contents_type w = va_arg(ap, contents_type);
106 
107  va_end(ap);
108 
109  this->evaluate(buffer.begin(), w);
110  }
111 
112 
113  protected:
114  mutable va_list ap;
116  };
117 }
118 
119 #endif
JMultiHistogram & getMultiHistogram()
Get multidimensional histogram.
JMultiMap is a general purpose multidimensional map based on a type list of maps. ...
const_iterator begin() const
get iterator to begin of data
Definition: JArray.hh:172
Template class for distance evaluation.
Definition: JDistance.hh:24
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.
void fill(const abscissa_type x,...)
Multi-dimensional fill method call.
multimap_type::const_reverse_iterator const_reverse_iterator
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
Multidimensional map.
Definition: JMultiMap.hh:46