Jpp
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_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. 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 JSecond_t &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

◆ collection_type

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.

◆ abscissa_type

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.

◆ ordinate_type

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.

◆ value_type

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.

◆ const_iterator

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.

◆ const_reverse_iterator

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.

◆ iterator

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.

◆ reverse_iterator

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.

◆ histogram_type

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.

◆ contents_type

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.

◆ JRebin

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.

◆ JContent

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

◆ 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.

117 { NUMBER_OF_DIMENSIONS = 1 };

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

142  {}

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

151  {
152  this->configure(bounds);
153  }

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

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

Member Function Documentation

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

175  {
176  this->fill(*pX, w);
177  }

◆ 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 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  }

◆ 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 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  }

◆ 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 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  }

◆ 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 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  }

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

276  {
277  collection_type::mul(value);
278  histogram_type ::mul(value);
279 
280  return *this;
281  }

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

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

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

70  {
71  this->underflow += histogram.underflow;
72  this->overflow += histogram.overflow;
73  this->integral += histogram.integral;
74 
75  return *this;
76  }

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

86  {
87  this->underflow -= histogram.underflow;
88  this->overflow -= histogram.overflow;
89  this->integral -= histogram.integral;
90 
91  return *this;
92  }

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

133  {
134  return underflow;
135  }

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

144  {
145  return overflow;
146  }

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

155  {
156  return integral;
157  }

◆ mul() [2/2]

JHistogram1D< JElement_t, JContainer_t, JDistance_t > & JMATH::JMath< JHistogram1D< JElement_t, JContainer_t, JDistance_t > , JSecond_t >::mul ( const JSecond_t &  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  }

Friends And Related Function 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 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  }

◆ 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 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

◆ underflow

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

Definition at line 195 of file JHistogram.hh.

◆ overflow

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

Definition at line 196 of file JHistogram.hh.

◆ integral

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:
JTOOLS::JHistogram1D::const_iterator
collection_type::const_iterator const_iterator
Definition: JHistogram1D.hh:125
JTOOLS::JHistogram::add
JHistogram & add(const JHistogram &histogram)
Add histogram.
Definition: JHistogram.hh:69
JTOOLS::pX
pX
Definition: JPolint.hh:625
JTOOLS::w
data_type w[N+1][M+1]
Definition: JPolint.hh:708
JTOOLS::JHistogram::div
JHistogram & div(double value)
Scale histogram.
Definition: JHistogram.hh:117
JTOOLS::JHistogram< JElement_t::abscissa_type, JElement_t::ordinate_type >::overflow
contents_type overflow
Definition: JHistogram.hh:196
JTOOLS::JHistogram< JElement_t::abscissa_type, JElement_t::ordinate_type >::integral
contents_type integral
Definition: JHistogram.hh:197
JTOOLS::u
double u[N+1]
Definition: JPolint.hh:706
JTOOLS::JHistogram1D::NUMBER_OF_DIMENSIONS
Definition: JHistogram1D.hh:117
JTOOLS::JHistogram1D::fill
void fill(typename JClass< abscissa_type >::argument_type x, typename JClass< contents_type >::argument_type w)
Fill histogram.
Definition: JHistogram1D.hh:186
distance
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
Definition: PhysicsEvent.hh:434
JTOOLS::JHistogram1D::const_reverse_iterator
collection_type::const_reverse_iterator const_reverse_iterator
Definition: JHistogram1D.hh:126
JMATH::getDistance
double getDistance(const JFirst_t &first, const JSecond_t &second)
Get distance between objects.
Definition: JMathToolkit.hh:116
JTOOLS::JHistogram::sub
JHistogram & sub(const JHistogram &histogram)
Subtract histogram.
Definition: JHistogram.hh:85
JTOOLS::JHistogram::mul
JHistogram & mul(const double value)
Scale histogram.
Definition: JHistogram.hh:101
JTOOLS::JHistogram1D::iterator
collection_type::iterator iterator
Definition: JHistogram1D.hh:127
JMATH::JCalculator
Auxiliary class for arithmetic operations on objects.
Definition: JCalculator.hh:18
JTOOLS::JHistogram< JElement_t::abscissa_type, JElement_t::ordinate_type >::underflow
contents_type underflow
Definition: JHistogram.hh:195
JTOOLS::configure
void configure(const T &value, const JAbstractCollection< JAbscissa_t > &bounds, JBool< false > option)
Configuration of value.
Definition: JToolsToolkit.hh:285