Jpp 20.0.0-rc.2
the software that should make you happy
Loading...
Searching...
No Matches
JTOOLS::JHistogram1D< JElement_t, JContainer_t, JDistance_t > Class Template Referenceabstract

Histogram in 1D. More...

#include <JHistogram1D.hh>

Inheritance diagram for JTOOLS::JHistogram1D< JElement_t, JContainer_t, JDistance_t >:
JTOOLS::JHistogram< JElement_t::abscissa_type, JElement_t::ordinate_type > JMATH::JMath< JFirst_t, JSecond_t >

Public Types

enum  { NUMBER_OF_DIMENSIONS = 1 }
 
typedef JContainer_t< JElement_t, JDistance_t > collection_type
 
typedef collection_type::collection_type base_collection_type
 
typedef collection_type::abscissa_type abscissa_type
 
typedef collection_type::ordinate_type ordinate_type
 
typedef collection_type::value_type value_type
 
typedef collection_type::const_iterator const_iterator
 
typedef collection_type::const_reverse_iterator const_reverse_iterator
 
typedef collection_type::iterator iterator
 
typedef collection_type::reverse_iterator reverse_iterator
 
typedef JHistogram< abscissa_type, ordinate_typehistogram_type
 
typedef histogram_type::contents_type contents_type
 
typedef JTOOLS::JRebin< value_typeJRebin
 
typedef JTOOLS::JContent< value_typeJContent
 

Public Member Functions

 JHistogram1D ()
 Default constructor.
 
 JHistogram1D (const JAbstractHistogram< abscissa_type > &bounds)
 Constructor.
 
 JHistogram1D (const JAbstractCollection< abscissa_type > &bounds)
 Constructor.
 
void reset ()
 Reset.
 
virtual void evaluate (const abscissa_type *pX, typename JClass< contents_type >::argument_type w)
 Fill histogram.
 
void fill (typename JClass< abscissa_type >::argument_type x, typename JClass< contents_type >::argument_type w)
 Fill histogram.
 
template<class JRebin_t >
void rebin (JRebin_t merge)
 Rebin histogram.
 
JHistogram1Dadd (const JHistogram1D &histogram)
 Add histogram.
 
JHistogram1Dsub (const JHistogram1D &histogram)
 Subtract histogram.
 
JHistogram1Dmul (const double value)
 Scale contents.
 
JHistogram1Ddiv (const double value)
 Scale contents.
 
virtual void evaluate (const abscissa_type *pX, typename JLANG::JClass< contents_type >::argument_type w)=0
 Histogram filling.
 
JHistogramadd (const JHistogram &histogram)
 Add histogram.
 
JHistogramsub (const JHistogram &histogram)
 Subtract histogram.
 
const contents_typegetUnderflow () const
 Get contents below lower limit.
 
const contents_typegetOverflow () const
 Get contents above upper limit.
 
const contents_typegetIntegral () const
 Get contents above upper limit.
 
JFirst_t & mul (const JSecond_t &object)
 Multiply with object.
 

Protected Attributes

contents_type underflow
 
contents_type overflow
 
contents_type integral
 

Friends

JReaderoperator>> (JReader &in, JHistogram1D &object)
 Read histogram from input.
 
JWriteroperator<< (JWriter &out, const JHistogram1D &object)
 Write histogram to output.
 

Detailed Description

template<class JElement_t, template< class, class > class JContainer_t, class JDistance_t = JDistance<typename JElement_t::abscissa_type>>
class JTOOLS::JHistogram1D< JElement_t, JContainer_t, JDistance_t >

Histogram in 1D.

This class implements the JHistogram interface.

Definition at line 110 of file JHistogram1D.hh.

Member Typedef Documentation

◆ collection_type

template<class JElement_t , template< class, class > class JContainer_t, class JDistance_t = JDistance<typename JElement_t::abscissa_type>>
JContainer_t<JElement_t, JDistance_t> JTOOLS::JHistogram1D< JElement_t, JContainer_t, JDistance_t >::collection_type

Definition at line 119 of file JHistogram1D.hh.

◆ base_collection_type

template<class JElement_t , template< class, class > class JContainer_t, class JDistance_t = JDistance<typename JElement_t::abscissa_type>>
collection_type::collection_type JTOOLS::JHistogram1D< JElement_t, JContainer_t, JDistance_t >::base_collection_type

Definition at line 121 of file JHistogram1D.hh.

◆ abscissa_type

template<class JElement_t , template< class, class > class JContainer_t, class JDistance_t = JDistance<typename JElement_t::abscissa_type>>
collection_type::abscissa_type JTOOLS::JHistogram1D< JElement_t, JContainer_t, JDistance_t >::abscissa_type

Definition at line 123 of file JHistogram1D.hh.

◆ ordinate_type

template<class JElement_t , template< class, class > class JContainer_t, class JDistance_t = JDistance<typename JElement_t::abscissa_type>>
collection_type::ordinate_type JTOOLS::JHistogram1D< JElement_t, JContainer_t, JDistance_t >::ordinate_type

Definition at line 124 of file JHistogram1D.hh.

◆ value_type

template<class JElement_t , template< class, class > class JContainer_t, class JDistance_t = JDistance<typename JElement_t::abscissa_type>>
collection_type::value_type JTOOLS::JHistogram1D< JElement_t, JContainer_t, JDistance_t >::value_type

Definition at line 125 of file JHistogram1D.hh.

◆ const_iterator

template<class JElement_t , template< class, class > class JContainer_t, class JDistance_t = JDistance<typename JElement_t::abscissa_type>>
collection_type::const_iterator JTOOLS::JHistogram1D< JElement_t, JContainer_t, JDistance_t >::const_iterator

Definition at line 127 of file JHistogram1D.hh.

◆ const_reverse_iterator

template<class JElement_t , template< class, class > class JContainer_t, class JDistance_t = JDistance<typename JElement_t::abscissa_type>>
collection_type::const_reverse_iterator JTOOLS::JHistogram1D< JElement_t, JContainer_t, JDistance_t >::const_reverse_iterator

Definition at line 128 of file JHistogram1D.hh.

◆ iterator

template<class JElement_t , template< class, class > class JContainer_t, class JDistance_t = JDistance<typename JElement_t::abscissa_type>>
collection_type::iterator JTOOLS::JHistogram1D< JElement_t, JContainer_t, JDistance_t >::iterator

Definition at line 129 of file JHistogram1D.hh.

◆ reverse_iterator

template<class JElement_t , template< class, class > class JContainer_t, class JDistance_t = JDistance<typename JElement_t::abscissa_type>>
collection_type::reverse_iterator JTOOLS::JHistogram1D< JElement_t, JContainer_t, JDistance_t >::reverse_iterator

Definition at line 130 of file JHistogram1D.hh.

◆ histogram_type

template<class JElement_t , template< class, class > class JContainer_t, class JDistance_t = JDistance<typename JElement_t::abscissa_type>>
JHistogram<abscissa_type, ordinate_type> JTOOLS::JHistogram1D< JElement_t, JContainer_t, JDistance_t >::histogram_type

Definition at line 132 of file JHistogram1D.hh.

◆ contents_type

template<class JElement_t , template< class, class > class JContainer_t, class JDistance_t = JDistance<typename JElement_t::abscissa_type>>
histogram_type::contents_type JTOOLS::JHistogram1D< JElement_t, JContainer_t, JDistance_t >::contents_type

Definition at line 134 of file JHistogram1D.hh.

◆ JRebin

template<class JElement_t , template< class, class > class JContainer_t, class JDistance_t = JDistance<typename JElement_t::abscissa_type>>
JTOOLS::JRebin<value_type> JTOOLS::JHistogram1D< JElement_t, JContainer_t, JDistance_t >::JRebin

Definition at line 136 of file JHistogram1D.hh.

◆ JContent

template<class JElement_t , template< class, class > class JContainer_t, class JDistance_t = JDistance<typename JElement_t::abscissa_type>>
JTOOLS::JContent<value_type> JTOOLS::JHistogram1D< JElement_t, JContainer_t, JDistance_t >::JContent

Definition at line 137 of file JHistogram1D.hh.

Member Enumeration Documentation

◆ anonymous enum

template<class JElement_t , template< class, class > class JContainer_t, class JDistance_t = JDistance<typename JElement_t::abscissa_type>>
anonymous enum
Enumerator
NUMBER_OF_DIMENSIONS 

Definition at line 117 of file JHistogram1D.hh.

Constructor & Destructor Documentation

◆ JHistogram1D() [1/3]

template<class JElement_t , template< class, class > class JContainer_t, class JDistance_t = JDistance<typename JElement_t::abscissa_type>>
JTOOLS::JHistogram1D< JElement_t, JContainer_t, JDistance_t >::JHistogram1D ( )
inline

Default constructor.

Definition at line 143 of file JHistogram1D.hh.

144 {}

◆ JHistogram1D() [2/3]

template<class JElement_t , template< class, class > class JContainer_t, class JDistance_t = JDistance<typename JElement_t::abscissa_type>>
JTOOLS::JHistogram1D< JElement_t, JContainer_t, JDistance_t >::JHistogram1D ( const JAbstractHistogram< abscissa_type > & bounds)
inline

Constructor.

Parameters
boundsbounds

Definition at line 152 of file JHistogram1D.hh.

153 {
154 this->configure(bounds);
155 }
void configure(const T &value, const JAbstractCollection< JAbscissa_t > &bounds, JBool< false > option)
Configuration of value.

◆ JHistogram1D() [3/3]

template<class JElement_t , template< class, class > class JContainer_t, class JDistance_t = JDistance<typename JElement_t::abscissa_type>>
JTOOLS::JHistogram1D< JElement_t, JContainer_t, JDistance_t >::JHistogram1D ( const JAbstractCollection< abscissa_type > & bounds)
inline

Constructor.

Parameters
boundsbounds

Definition at line 163 of file JHistogram1D.hh.

164 {
165 this->configure(bounds);
166 }

Member Function Documentation

◆ reset()

template<class JElement_t , template< class, class > class JContainer_t, class JDistance_t = JDistance<typename JElement_t::abscissa_type>>
void JTOOLS::JHistogram1D< JElement_t, JContainer_t, JDistance_t >::reset ( )
inline

Reset.

Definition at line 172 of file JHistogram1D.hh.

173 {
175
176 for (iterator i = this->begin(); i != this->end(); ++i) {
177 i->getY() = JMATH::zero;
178 }
179 }
collection_type::iterator iterator
void reset()
Reset.
Definition JHistogram.hh:64
static const JZero zero
Function object to assign zero value.
Definition JZero.hh:105

◆ evaluate() [1/2]

template<class JElement_t , template< class, class > class JContainer_t, class JDistance_t = JDistance<typename JElement_t::abscissa_type>>
virtual void JTOOLS::JHistogram1D< JElement_t, JContainer_t, JDistance_t >::evaluate ( const abscissa_type * pX,
typename JClass< contents_type >::argument_type w )
inlinevirtual

Fill histogram.

Parameters
pXpointer to abscissa values
wweight

Definition at line 188 of file JHistogram1D.hh.

190 {
191 this->fill(*pX, w);
192 }
void fill(typename JClass< abscissa_type >::argument_type x, typename JClass< contents_type >::argument_type w)
Fill histogram.

◆ fill()

template<class JElement_t , template< class, class > class JContainer_t, class JDistance_t = JDistance<typename JElement_t::abscissa_type>>
void JTOOLS::JHistogram1D< JElement_t, JContainer_t, JDistance_t >::fill ( typename JClass< abscissa_type >::argument_type x,
typename JClass< contents_type >::argument_type w )
inline

Fill histogram.

Parameters
xabscissa value
wweight

Definition at line 201 of file JHistogram1D.hh.

203 {
204 this->integral += w;
205
206 iterator p = this->lower_bound(x);
207
208 if (p == this->begin())
209 this->underflow += w;
210 else if (p == this->end())
211 this->overflow += w;
212 else
213 (--p)->getY() += w;
214 }

◆ rebin()

template<class JElement_t , template< class, class > class JContainer_t, class JDistance_t = JDistance<typename JElement_t::abscissa_type>>
template<class JRebin_t >
void JTOOLS::JHistogram1D< JElement_t, JContainer_t, JDistance_t >::rebin ( JRebin_t merge)
inline

Rebin histogram.

Parameters
mergerebin evaluator

Definition at line 223 of file JHistogram1D.hh.

224 {
225 if (this->size() > 1u) {
226
227 iterator out = this->begin();
228
229 for (const_iterator i = this->begin(); i != this->end(); ) {
230
231 *out = *i;
232
233 while (++i != this->end() && merge(*out,*i)) {
234 out->getY() += i->getY();
235 }
236
237 ++out;
238 }
239
240 const_reverse_iterator __rbegin(out);
241
242 if (this->getDistance(__rbegin->getX(), this->rbegin()->getX()) > 0.0) {
243
244 *out = *(this->rbegin());
245
246 ++out;
247 }
248
249 this->resize(std::distance(this->begin(), out));
250 }
251 }
collection_type::const_reverse_iterator const_reverse_iterator
collection_type::const_iterator const_iterator

◆ add() [1/2]

template<class JElement_t , template< class, class > class JContainer_t, class JDistance_t = JDistance<typename JElement_t::abscissa_type>>
JHistogram1D & JTOOLS::JHistogram1D< JElement_t, JContainer_t, JDistance_t >::add ( const JHistogram1D< JElement_t, JContainer_t, JDistance_t > & histogram)
inline

Add histogram.

Parameters
histogramhistogram
Returns
this histogram

Definition at line 260 of file JHistogram1D.hh.

261 {
262 collection_type::add(static_cast<const base_collection_type&>(histogram));
263 histogram_type ::add(static_cast<const histogram_type&> (histogram));
264
265 return *this;
266 }
JHistogram< abscissa_type, ordinate_type > histogram_type
collection_type::collection_type base_collection_type

◆ sub() [1/2]

template<class JElement_t , template< class, class > class JContainer_t, class JDistance_t = JDistance<typename JElement_t::abscissa_type>>
JHistogram1D & JTOOLS::JHistogram1D< JElement_t, JContainer_t, JDistance_t >::sub ( const JHistogram1D< JElement_t, JContainer_t, JDistance_t > & histogram)
inline

Subtract histogram.

Parameters
histogramhistogram
Returns
this histogram

Definition at line 275 of file JHistogram1D.hh.

276 {
277 collection_type::sub(static_cast<const base_collection_type&>(histogram));
278 histogram_type ::sub(static_cast<const histogram_type&> (histogram));
279
280 return *this;
281 }

◆ mul() [1/2]

template<class JElement_t , template< class, class > class JContainer_t, class JDistance_t = JDistance<typename JElement_t::abscissa_type>>
JHistogram1D & JTOOLS::JHistogram1D< JElement_t, JContainer_t, JDistance_t >::mul ( const double value)
inline

Scale contents.

Parameters
valuemultiplication factor
Returns
this histogram

Definition at line 290 of file JHistogram1D.hh.

291 {
292 collection_type::mul(value);
293 histogram_type ::mul(value);
294
295 return *this;
296 }

◆ div()

template<class JElement_t , template< class, class > class JContainer_t, class JDistance_t = JDistance<typename JElement_t::abscissa_type>>
JHistogram1D & JTOOLS::JHistogram1D< JElement_t, JContainer_t, JDistance_t >::div ( const double value)
inline

Scale contents.

Parameters
valuedivision factor
Returns
this histogram

Definition at line 305 of file JHistogram1D.hh.

306 {
307 collection_type::div(value);
308 histogram_type ::div(value);
309
310 return *this;
311 }

◆ evaluate() [2/2]

virtual void JTOOLS::JHistogram< JElement_t::abscissa_type, JElement_t::ordinate_type >::evaluate ( const abscissa_type * pX,
typename JLANG::JClass< contents_type >::argument_type w )
pure virtualinherited

Histogram filling.

Parameters
pXpointer to abscissa values
wweight

◆ add() [2/2]

JHistogram & JTOOLS::JHistogram< JElement_t::abscissa_type, JElement_t::ordinate_type >::add ( const JHistogram< JElement_t::abscissa_type, JElement_t::ordinate_type > & histogram)
inlineinherited

Add histogram.

Parameters
histogramhistogram
Returns
this histogram

Definition at line 88 of file JHistogram.hh.

89 {
90 this->underflow += histogram.underflow;
91 this->overflow += histogram.overflow;
92 this->integral += histogram.integral;
93
94 return *this;
95 }

◆ sub() [2/2]

JHistogram & JTOOLS::JHistogram< JElement_t::abscissa_type, JElement_t::ordinate_type >::sub ( const JHistogram< JElement_t::abscissa_type, JElement_t::ordinate_type > & histogram)
inlineinherited

Subtract histogram.

Parameters
histogramhistogram
Returns
this histogram

Definition at line 104 of file JHistogram.hh.

105 {
106 this->underflow -= histogram.underflow;
107 this->overflow -= histogram.overflow;
108 this->integral -= histogram.integral;
109
110 return *this;
111 }

◆ getUnderflow()

const contents_type & JTOOLS::JHistogram< JElement_t::abscissa_type, JElement_t::ordinate_type >::getUnderflow ( ) const
inlineinherited

Get contents below lower limit.

Returns
contents

Definition at line 151 of file JHistogram.hh.

152 {
153 return underflow;
154 }

◆ getOverflow()

const contents_type & JTOOLS::JHistogram< JElement_t::abscissa_type, JElement_t::ordinate_type >::getOverflow ( ) const
inlineinherited

Get contents above upper limit.

Returns
contents

Definition at line 162 of file JHistogram.hh.

163 {
164 return overflow;
165 }

◆ getIntegral()

const contents_type & JTOOLS::JHistogram< JElement_t::abscissa_type, JElement_t::ordinate_type >::getIntegral ( ) const
inlineinherited

Get contents above upper limit.

Returns
contents

Definition at line 173 of file JHistogram.hh.

174 {
175 return integral;
176 }

◆ mul() [2/2]

template<class JFirst_t , class JSecond_t >
JFirst_t & JMATH::JMath< JFirst_t, JSecond_t >::mul ( const JSecond_t & object)
inlineinherited

Multiply with object.

Parameters
objectobject
Returns
result object

Definition at line 354 of file JMath.hh.

355 {
356 return static_cast<JFirst_t&>(*this) = JFirst_t().mul(static_cast<const JFirst_t&>(*this), object);
357 }

Friends And Related Symbol Documentation

◆ operator>>

template<class JElement_t , template< class, class > class JContainer_t, class JDistance_t = JDistance<typename JElement_t::abscissa_type>>
JReader & operator>> ( JReader & in,
JHistogram1D< JElement_t, JContainer_t, JDistance_t > & object )
friend

Read histogram from input.

Parameters
inreader
objecthistogram
Returns
reader

Definition at line 321 of file JHistogram1D.hh.

322 {
323 in >> static_cast<histogram_type&> (object);
324 in >> static_cast<collection_type&>(object);
325
326 return in;
327 }
JContainer_t< JElement_t, JDistance_t > collection_type

◆ operator<<

template<class JElement_t , template< class, class > class JContainer_t, class JDistance_t = JDistance<typename JElement_t::abscissa_type>>
JWriter & operator<< ( JWriter & out,
const JHistogram1D< JElement_t, JContainer_t, JDistance_t > & object )
friend

Write histogram to output.

Parameters
outwriter
objecthistogram
Returns
writer

Definition at line 337 of file JHistogram1D.hh.

338 {
339 out << static_cast<const histogram_type&> (object);
340 out << static_cast<const collection_type&>(object);
341
342 return out;
343 }

Member Data Documentation

◆ underflow

contents_type JTOOLS::JHistogram< JElement_t::abscissa_type, JElement_t::ordinate_type >::underflow
protectedinherited

Definition at line 223 of file JHistogram.hh.

◆ overflow

contents_type JTOOLS::JHistogram< JElement_t::abscissa_type, JElement_t::ordinate_type >::overflow
protectedinherited

Definition at line 224 of file JHistogram.hh.

◆ integral

contents_type JTOOLS::JHistogram< JElement_t::abscissa_type, JElement_t::ordinate_type >::integral
protectedinherited

Definition at line 225 of file JHistogram.hh.


The documentation for this class was generated from the following file: