Jpp
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
JTOOLS::JMultiMap
Multidimensional map.
Definition: JMultiMap.hh:46
JTOOLS::JMultiHistogram::contents_type
JHistogram_t::contents_type contents_type
Definition: JMultiHistogram.hh:58
JTOOLS::JArray::begin
const_iterator begin() const
get iterator to begin of data
Definition: JArray.hh:188
JHistogram.hh
JTOOLS::w
data_type w[N+1][M+1]
Definition: JPolint.hh:708
JTOOLS::JMultiHistogram::JMultiHistogram
JMultiHistogram()
Default constructor.
Definition: JMultiHistogram.hh:64
JTOOLS::JMultiHistogram::NUMBER_OF_DIMENSIONS
Definition: JMultiHistogram.hh:45
JTOOLS::JMultiHistogram::getMultiHistogram
JMultiHistogram & getMultiHistogram()
Get multidimensional histogram.
Definition: JMultiHistogram.hh:84
JTOOLS::JArray< NUMBER_OF_DIMENSIONS, abscissa_type >
JTOOLS::JMultiHistogram::abscissa_type
multimap_type::abscissa_type abscissa_type
Definition: JMultiHistogram.hh:47
JTOOLS::JMapLength
Length of map list.
Definition: JMapList.hh:45
JTOOLS::JMultiHistogram::multimap_type
JMultiMap< typename JHistogram_t::abscissa_type, JHistogram_t, JMaplist_t, JDistance_t > multimap_type
Definition: JMultiHistogram.hh:43
JTOOLS::JMultiHistogram::super_iterator
multimap_type::super_iterator super_iterator
Definition: JMultiHistogram.hh:55
JTOOLS::JMultiHistogram::super_const_iterator
multimap_type::super_const_iterator super_const_iterator
Definition: JMultiHistogram.hh:56
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JAAnetToolkit.hh:37
JTOOLS::JMultiHistogram::getMultiHistogram
const JMultiHistogram & getMultiHistogram() const
Get multidimensional histogram.
Definition: JMultiHistogram.hh:73
JTOOLS::JMultiHistogram::const_reverse_iterator
multimap_type::const_reverse_iterator const_reverse_iterator
Definition: JMultiHistogram.hh:51
JTOOLS::JMultiHistogram::ordinate_type
multimap_type::ordinate_type ordinate_type
Definition: JMultiHistogram.hh:48
JTOOLS::JMultiHistogram
Multidimensional histogram.
Definition: JMultiHistogram.hh:35
JMultiMap.hh
JTOOLS::JMultiHistogram::const_iterator
multimap_type::const_iterator const_iterator
Definition: JMultiHistogram.hh:50
JTOOLS::JDistance
Template class for distance evaluation.
Definition: JDistance.hh:24
JTOOLS::JMultiHistogram::reverse_iterator
multimap_type::reverse_iterator reverse_iterator
Definition: JMultiHistogram.hh:53
JTOOLS
Auxiliary classes and methods for multi-dimensional interpolations and histograms.
Definition: JAbstractCollection.hh:9
JTOOLS::JMultiHistogram::fill
void fill(const abscissa_type x,...)
Multi-dimensional fill method call.
Definition: JMultiHistogram.hh:95
JTOOLS::JMultiHistogram::ap
va_list ap
Definition: JMultiHistogram.hh:114
JTOOLS::JMultiHistogram::iterator
multimap_type::iterator iterator
Definition: JMultiHistogram.hh:52
JTOOLS::JMultiHistogram::buffer
JArray< NUMBER_OF_DIMENSIONS, abscissa_type > buffer
Definition: JMultiHistogram.hh:115
JArray.hh