Jpp test-rotations-old
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::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 111 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 120 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 122 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 123 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 124 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 126 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 127 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 128 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 129 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 131 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 133 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 135 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 136 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 118 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 142 of file JHistogram1D.hh.

143 {}

◆ 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 151 of file JHistogram1D.hh.

152 {
153 this->configure(bounds);
154 }
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 162 of file JHistogram1D.hh.

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

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 171 of file JHistogram1D.hh.

172 {
174
175 for (iterator i = this->begin(); i != this->end(); ++i) {
176 i->getY() = JMATH::zero;
177 }
178 }
collection_type::iterator iterator
void reset()
Reset.
Definition JHistogram.hh:56
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 187 of file JHistogram1D.hh.

189 {
190 this->fill(*pX, w);
191 }
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 200 of file JHistogram1D.hh.

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

◆ 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 222 of file JHistogram1D.hh.

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

260 {
261 collection_type::add(static_cast<const collection_type&>(histogram));
262 histogram_type ::add(static_cast<const histogram_type&> (histogram));
263
264 return *this;
265 }
JHistogram< abscissa_type, ordinate_type > histogram_type
JContainer_t< JElement_t, JDistance_t > 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 274 of file JHistogram1D.hh.

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

◆ 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 289 of file JHistogram1D.hh.

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

◆ 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 304 of file JHistogram1D.hh.

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

◆ 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 80 of file JHistogram.hh.

81 {
82 this->underflow += histogram.underflow;
83 this->overflow += histogram.overflow;
84 this->integral += histogram.integral;
85
86 return *this;
87 }

◆ 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 96 of file JHistogram.hh.

97 {
98 this->underflow -= histogram.underflow;
99 this->overflow -= histogram.overflow;
100 this->integral -= histogram.integral;
101
102 return *this;
103 }

◆ 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 143 of file JHistogram.hh.

144 {
145 return underflow;
146 }

◆ 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 154 of file JHistogram.hh.

155 {
156 return overflow;
157 }

◆ 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 165 of file JHistogram.hh.

166 {
167 return integral;
168 }

◆ 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 320 of file JHistogram1D.hh.

321 {
322 in >> static_cast<histogram_type&> (object);
323 in >> static_cast<collection_type&>(object);
324
325 return in;
326 }

◆ 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 336 of file JHistogram1D.hh.

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

Member Data Documentation

◆ underflow

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

Definition at line 206 of file JHistogram.hh.

◆ overflow

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

Definition at line 207 of file JHistogram.hh.

◆ integral

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

Definition at line 208 of file JHistogram.hh.


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