Jpp - the software that should make you happy
 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< 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_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...
 
JFirst_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 111 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 120 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 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::ordinate_type JTOOLS::JHistogram1D< JElement_t, JContainer_t, JDistance_t >::ordinate_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::value_type JTOOLS::JHistogram1D< JElement_t, JContainer_t, JDistance_t >::value_type

Definition at line 124 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 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::const_reverse_iterator JTOOLS::JHistogram1D< JElement_t, JContainer_t, JDistance_t >::const_reverse_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::iterator JTOOLS::JHistogram1D< JElement_t, JContainer_t, JDistance_t >::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 collection_type::reverse_iterator JTOOLS::JHistogram1D< JElement_t, JContainer_t, JDistance_t >::reverse_iterator

Definition at line 129 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 131 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 133 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 135 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 136 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 118 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 142 of file JHistogram1D.hh.

143  {}
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.
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  }
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 174 of file JHistogram1D.hh.

176  {
177  this->fill(*pX, w);
178  }
data_type w[N+1][M+1]
Definition: JPolint.hh:741
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 187 of file JHistogram1D.hh.

189  {
190  this->integral += w;
191 
192  iterator p = this->lower_bound(x);
193 
194  if (p == this->begin())
195  this->underflow += w;
196  else if (p == this->end())
197  this->overflow += w;
198  else
199  (--p)->getY() += w;
200  }
data_type w[N+1][M+1]
Definition: JPolint.hh:741
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 209 of file JHistogram1D.hh.

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

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

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

277  {
278  collection_type::mul(value);
279  histogram_type ::mul(value);
280 
281  return *this;
282  }
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 291 of file JHistogram1D.hh.

292  {
293  collection_type::div(value);
294  histogram_type ::div(value);
295 
296  return *this;
297  }
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.

template<class JFirst_t, class JSecond_t = JNullType>
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 357 of file JMath.hh.

358  {
359  return static_cast<JFirst_t&>(*this) = JCalculator<JFirst_t>::calculator.mul(static_cast<const JFirst_t&>(*this), object);
360  }
Auxiliary class for arithmetic operations on 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 307 of file JHistogram1D.hh.

308  {
309  in >> static_cast<histogram_type&> (object);
310  in >> static_cast<collection_type&>(object);
311 
312  return in;
313  }
JContainer_t< JElement_t, JDistance_t > collection_type
JHistogram< abscissa_type, ordinate_type > histogram_type
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY source JAcoustics sh $DETECTOR_ID CHECK_EXIT_CODE typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
Definition: JCanberra.sh:38
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 323 of file JHistogram1D.hh.

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

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: