Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Protected Attributes | Friends | List of all members
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< JHistogram1D< JElement_t, JContainer_t, JDistance_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_type
histogram_type
 
typedef
histogram_type::contents_type 
contents_type
 
typedef JTOOLS::JRebin
< value_type
JRebin
 
typedef JTOOLS::JContent
< value_type
JContent
 

Public Member Functions

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

Protected Attributes

contents_type underflow
 
contents_type overflow
 
contents_type integral
 

Friends

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

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

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

Definition at line 119 of file JHistogram1D.hh.

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

Definition at line 121 of file JHistogram1D.hh.

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

Definition at line 122 of file JHistogram1D.hh.

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

Definition at line 123 of file JHistogram1D.hh.

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

Definition at line 125 of file JHistogram1D.hh.

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

Definition at line 126 of file JHistogram1D.hh.

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

Definition at line 127 of file JHistogram1D.hh.

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

Definition at line 128 of file JHistogram1D.hh.

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

Definition at line 130 of file JHistogram1D.hh.

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

Definition at line 132 of file JHistogram1D.hh.

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

Definition at line 134 of file JHistogram1D.hh.

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

Definition at line 135 of file JHistogram1D.hh.

Member Enumeration Documentation

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

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

142  {}
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 150 of file JHistogram1D.hh.

151  {
152  this->configure(bounds);
153  }
void configure(const T &value, const JAbstractCollection< JAbscissa_t > &bounds, JBool< false > option)
Configuration of value.
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 161 of file JHistogram1D.hh.

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

Member Function Documentation

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

175  {
176  this->fill(*pX, w);
177  }
void fill(typename JClass< abscissa_type >::argument_type x, typename JClass< contents_type >::argument_type w)
Fill histogram.
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 186 of file JHistogram1D.hh.

188  {
189  this->integral += w;
190 
191  iterator p = this->lower_bound(x);
192 
193  if (p == this->begin())
194  this->underflow += w;
195  else if (p == this->end())
196  this->overflow += w;
197  else
198  (--p)->getY() += w;
199  }
collection_type::iterator iterator
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 208 of file JHistogram1D.hh.

209  {
210  if (this->size() > 1u) {
211 
212  iterator out = this->begin();
213 
214  for (const_iterator i = this->begin(); i != this->end(); ) {
215 
216  *out = *i;
217 
218  while (++i != this->end() && merge(*out,*i)) {
219  out->getY() += i->getY();
220  }
221 
222  ++out;
223  }
224 
225  const_reverse_iterator __rbegin(out);
226 
227  if (this->getDistance(__rbegin->getX(), this->rbegin()->getX()) > 0.0) {
228 
229  *out = *(this->rbegin());
230 
231  ++out;
232  }
233 
234  this->resize(std::distance(this->begin(), out));
235  }
236  }
double getDistance(const JFirst_t &first, const JSecond_t &second)
Get distance between objects.
Definition: JMathToolkit.hh:98
collection_type::const_iterator const_iterator
collection_type::const_reverse_iterator const_reverse_iterator
collection_type::iterator iterator
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 245 of file JHistogram1D.hh.

246  {
247  collection_type::add(static_cast<const collection_type&>(histogram));
248  histogram_type ::add(static_cast<const histogram_type&> (histogram));
249 
250  return *this;
251  }
JHistogram & add(const JHistogram &histogram)
Add histogram.
Definition: JHistogram.hh:69
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 260 of file JHistogram1D.hh.

261  {
262  collection_type::sub(static_cast<const collection_type&>(histogram));
263  histogram_type ::sub(static_cast<const histogram_type&> (histogram));
264 
265  return *this;
266  }
JHistogram & sub(const JHistogram &histogram)
Subtract histogram.
Definition: JHistogram.hh:85
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 275 of file JHistogram1D.hh.

276  {
277  collection_type::mul(value);
278  histogram_type ::mul(value);
279 
280  return *this;
281  }
JHistogram & mul(const double value)
Scale histogram.
Definition: JHistogram.hh:101
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 290 of file JHistogram1D.hh.

291  {
292  collection_type::div(value);
293  histogram_type ::div(value);
294 
295  return *this;
296  }
JHistogram & div(double value)
Scale histogram.
Definition: JHistogram.hh:117
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
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 69 of file JHistogram.hh.

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

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

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

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

JHistogram1D< JElement_t, JContainer_t, JDistance_t > & JMATH::JMath< JHistogram1D< JElement_t, JContainer_t, JDistance_t > , JNullType >::mul ( const JNullType object)
inlineinherited

Multiply with object.

Parameters
objectobject
Returns
result object

Definition at line 273 of file JMath.hh.

274  {
275  return static_cast<JFirst_t&>(*this) = JCalculator<JFirst_t>::calculator.mul(static_cast<const JFirst_t&>(*this), object);
276  }
Auxiliary class for product evaluation of objects.
Definition: JCalculator.hh:18

Friends And Related Function Documentation

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

307  {
308  in >> static_cast<histogram_type&> (object);
309  in >> static_cast<collection_type&>(object);
310 
311  return in;
312  }
JContainer_t< JElement_t, JDistance_t > collection_type
JHistogram< abscissa_type, ordinate_type > histogram_type
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 322 of file JHistogram1D.hh.

323  {
324  out << static_cast<const histogram_type&> (object);
325  out << static_cast<const collection_type&>(object);
326 
327  return out;
328  }

Member Data Documentation

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

Definition at line 195 of file JHistogram.hh.

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

Definition at line 196 of file JHistogram.hh.

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

Definition at line 197 of file JHistogram.hh.


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