Jpp test-rotations-new
the software that should make you happy
Loading...
Searching...
No Matches
JHistogramMap.hh
Go to the documentation of this file.
1#ifndef __JTOOLS__JHISTOGRAMMAP__
2#define __JTOOLS__JHISTOGRAMMAP__
3
4#include "JLang/JClass.hh"
6#include "JTools/JDistance.hh"
7
8
9/**
10 * \author mdejong
11 */
12
13namespace JTOOLS {}
14namespace JPP { using namespace JTOOLS; }
15
16namespace 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> >
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
37 typedef typename collection_type::abscissa_type abscissa_type;
38 typedef typename collection_type::ordinate_type ordinate_type;
39 typedef typename collection_type::value_type value_type;
40
41 typedef typename collection_type::const_iterator const_iterator;
42 typedef typename collection_type::const_reverse_iterator const_reverse_iterator;
43 typedef typename collection_type::iterator iterator;
44 typedef typename collection_type::reverse_iterator reverse_iterator;
45
46 //typedef typename histogram_type::abscissa_type abscissa_type;
48
49
50 /**
51 * Default constructor.
52 */
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
Interface for binary input.
Interface for binary output.
virtual void evaluate(const abscissa_type *pX, typename JLANG::JClass< contents_type >::argument_type w)
Fill histogram.
JHistogramMap & div(typename JLANG::JClass< contents_type >::argument_type factor)
Scale contents.
histogram_type::contents_type contents_type
JMap_t< JAbscissa_t, JContents_t, JDistance_t > collection_type
JHistogram< JAbscissa_t, typename JContents_t::contents_type > histogram_type
collection_type::iterator iterator
collection_type::const_iterator const_iterator
collection_type::const_reverse_iterator const_reverse_iterator
friend JWriter & operator<<(JWriter &out, const JHistogramMap &object)
Write histogram map to output.
JHistogramMap()
Default constructor.
collection_type::value_type value_type
friend JReader & operator>>(JReader &in, JHistogramMap &object)
Read histogram map from input.
collection_type::reverse_iterator reverse_iterator
collection_type::abscissa_type abscissa_type
JHistogramMap & mul(typename JLANG::JClass< contents_type >::argument_type factor)
Scale contents.
collection_type::ordinate_type ordinate_type
Template definition of histogram object interface.
Definition JHistogram.hh:28
JContents_t contents_type
Definition JHistogram.hh:43
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary classes and methods for multi-dimensional interpolations and histograms.
JArgument< T >::argument_type argument_type
Definition JClass.hh:82
Template class for distance evaluation.
Definition JDistance.hh:24