Jpp
JHistogramMap.hh
Go to the documentation of this file.
1 #ifndef __JTOOLS__JHISTOGRAMMAP__
2 #define __JTOOLS__JHISTOGRAMMAP__
3 
4 #include "JLang/JClass.hh"
5 #include "JTools/JHistogram.hh"
6 #include "JTools/JDistance.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  * Histogram map.
21  *
22  * This class implements the JHistogram interface.
23  */
24  template<class JAbscissa_t,
25  class JContents_t,
26  template<class, class, class> class JMap_t,
27  class JDistance_t = JDistance<JAbscissa_t> >
28  class JHistogramMap :
29  public JMap_t<JAbscissa_t, JContents_t, JDistance_t>,
30  public JHistogram<JAbscissa_t, typename JContents_t::contents_type>
31  {
32  public:
33 
34  typedef JMap_t<JAbscissa_t, JContents_t, JDistance_t> collection_type;
36 
40 
45 
46  //typedef typename histogram_type::abscissa_type abscissa_type;
48 
49 
50  /**
51  * Default constructor.
52  */
54  {}
55 
56 
57  /**
58  * Fill histogram.
59  *
60  * \param pX pointer to abscissa values
61  * \param w weight
62  */
63  virtual void evaluate(const abscissa_type* pX,
65  {
66  const abscissa_type x = *pX;
67 
68  iterator p = this->lower_bound(x);
69 
70  this->integral += w;
71 
72  if (p == this->begin())
73  this->underflow += w;
74  else if (p == this->end())
75  this->overflow += w;
76  else
77  (--p)->getY().evaluate(++pX, w);
78  }
79 
80 
81  /**
82  * Scale contents.
83  *
84  * \param factor multiplication factor
85  * \return this histogram
86  */
88  {
89  collection_type::mul(factor);
90  histogram_type ::mul(factor);
91 
92  return *this;
93  }
94 
95 
96  /**
97  * Scale contents.
98  *
99  * \param factor division factor
100  * \return this histogram
101  */
103  {
104  collection_type::div(factor);
105  histogram_type ::div(factor);
106 
107  return *this;
108  }
109 
110 
111  /**
112  * Read histogram map from input.
113  *
114  * \param in reader
115  * \param object histogram map
116  * \return reader
117  */
118  friend inline JReader& operator>>(JReader& in, JHistogramMap& object)
119  {
120  in >> static_cast<histogram_type&> (object);
121  in >> static_cast<collection_type&>(object);
122 
123  return in;
124  }
125 
126 
127  /**
128  * Write histogram map to output.
129  *
130  * \param out writer
131  * \param object histogram map
132  * \return writer
133  */
134  friend inline JWriter& operator<<(JWriter& out, const JHistogramMap& object)
135  {
136  out << static_cast<const histogram_type&> (object);
137  out << static_cast<const collection_type&>(object);
138 
139  return out;
140  }
141  };
142 }
143 
144 #endif
JIO::JReader
Interface for binary input.
Definition: JSerialisable.hh:62
JTOOLS::JHistogramMap::operator>>
friend JReader & operator>>(JReader &in, JHistogramMap &object)
Read histogram map from input.
Definition: JHistogramMap.hh:118
JHistogram.hh
JTOOLS::JHistogramMap::reverse_iterator
collection_type::reverse_iterator reverse_iterator
Definition: JHistogramMap.hh:44
JTOOLS::pX
pX
Definition: JPolint.hh:625
JTOOLS::w
data_type w[N+1][M+1]
Definition: JPolint.hh:708
JTOOLS::JHistogramMap::mul
JHistogramMap & mul(typename JLANG::JClass< contents_type >::argument_type factor)
Scale contents.
Definition: JHistogramMap.hh:87
JTOOLS::JHistogram::div
JHistogram & div(double value)
Scale histogram.
Definition: JHistogram.hh:117
JTOOLS::JHistogramMap::div
JHistogramMap & div(typename JLANG::JClass< contents_type >::argument_type factor)
Scale contents.
Definition: JHistogramMap.hh:102
JTOOLS::JHistogram< JAbscissa_t, JContents_t::contents_type >::overflow
contents_type overflow
Definition: JHistogram.hh:196
JTOOLS::JHistogram< JAbscissa_t, JContents_t::contents_type >::integral
contents_type integral
Definition: JHistogram.hh:197
JTOOLS::JHistogramMap::evaluate
virtual void evaluate(const abscissa_type *pX, typename JLANG::JClass< contents_type >::argument_type w)
Fill histogram.
Definition: JHistogramMap.hh:63
JLANG::JClass::argument_type
JArgument< T >::argument_type argument_type
Definition: JClass.hh:82
JTOOLS::JCollection< JElement2D< JKey_t, JHistogram_t >, JDistance_t >::iterator
container_type::iterator iterator
Definition: JCollection.hh:91
JTOOLS::JHistogramMap::const_iterator
collection_type::const_iterator const_iterator
Definition: JHistogramMap.hh:41
JTOOLS::JCollection< JElement2D< JKey_t, JHistogram_t >, JDistance_t >::const_reverse_iterator
container_type::const_reverse_iterator const_reverse_iterator
Definition: JCollection.hh:90
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JAAnetToolkit.hh:37
JTOOLS::JHistogramMap::operator<<
friend JWriter & operator<<(JWriter &out, const JHistogramMap &object)
Write histogram map to output.
Definition: JHistogramMap.hh:134
JTOOLS::JHistogram
Template definition of histogram object interface.
Definition: JHistogram.hh:27
JIO::JWriter
Interface for binary output.
Definition: JSerialisable.hh:130
JTOOLS::JHistogramMap::const_reverse_iterator
collection_type::const_reverse_iterator const_reverse_iterator
Definition: JHistogramMap.hh:42
JTOOLS::JHistogramMap::iterator
collection_type::iterator iterator
Definition: JHistogramMap.hh:43
JTOOLS::JHistogramMap::abscissa_type
collection_type::abscissa_type abscissa_type
Definition: JHistogramMap.hh:37
JTOOLS::JHistogramMap::histogram_type
JHistogram< JAbscissa_t, typename JContents_t::contents_type > histogram_type
Definition: JHistogramMap.hh:35
JTOOLS::JCollection< JElement2D< JKey_t, JHistogram_t >, JDistance_t >::reverse_iterator
container_type::reverse_iterator reverse_iterator
Definition: JCollection.hh:92
JTOOLS::JHistogramMap::value_type
collection_type::value_type value_type
Definition: JHistogramMap.hh:39
JTOOLS::JCollection< JElement2D< JKey_t, JHistogram_t >, JDistance_t >::ordinate_type
JElement2D< JKey_t, JHistogram_t > ::ordinate_type ordinate_type
Definition: JCollection.hh:81
JTOOLS::JHistogram::mul
JHistogram & mul(const double value)
Scale histogram.
Definition: JHistogram.hh:101
JTOOLS::JCollection< JElement2D< JKey_t, JHistogram_t >, JDistance_t >::abscissa_type
JElement2D< JKey_t, JHistogram_t > ::abscissa_type abscissa_type
Definition: JCollection.hh:80
JTOOLS::JHistogramMap::JHistogramMap
JHistogramMap()
Default constructor.
Definition: JHistogramMap.hh:53
JTOOLS::JDistance
Template class for distance evaluation.
Definition: JDistance.hh:24
JTOOLS::JHistogramMap::collection_type
JMap_t< JAbscissa_t, JContents_t, JDistance_t > collection_type
Definition: JHistogramMap.hh:34
JTOOLS::JHistogramMap::contents_type
histogram_type::contents_type contents_type
Definition: JHistogramMap.hh:47
JClass.hh
JTOOLS::JHistogram::contents_type
JContents_t contents_type
Definition: JHistogram.hh:43
JTOOLS::JHistogramMap::ordinate_type
collection_type::ordinate_type ordinate_type
Definition: JHistogramMap.hh:38
JTOOLS::JHistogram< JAbscissa_t, JContents_t::contents_type >::underflow
contents_type underflow
Definition: JHistogram.hh:195
JTOOLS
Auxiliary classes and methods for multi-dimensional interpolations and histograms.
Definition: JAbstractCollection.hh:9
JTOOLS::JElement2D
2D Element.
Definition: JElement.hh:44
JTOOLS::JCollection< JElement2D< JKey_t, JHistogram_t >, JDistance_t >::const_iterator
container_type::const_iterator const_iterator
Definition: JCollection.hh:89
JTOOLS::JHistogramMap
Histogram map.
Definition: JHistogramMap.hh:28
JTOOLS::JAbstractCollection::abscissa_type
JAbscissa_t abscissa_type
Definition: JAbstractCollection.hh:20
JDistance.hh