1#ifndef __JHISTOGRAM1D__
2#define __JHISTOGRAM1D__
29 template<
class JElement_t>
68 template<
class JElement_t>
94 return (first.getY() + second.getY() <
__y);
107 template<
class JElement_t,
108 template<
class,
class>
class JContainer_t,
111 public JContainer_t<JElement_t, JDistance_t>,
112 public JHistogram<typename JElement_t::abscissa_type, typename JElement_t::ordinate_type>,
113 public JMath< JHistogram1D<JElement_t, JContainer_t, JDistance_t> >
129 typedef typename collection_type::iterator
iterator;
136 typedef JTOOLS::JRebin <value_type>
JRebin;
176 for (
iterator i = this->begin(); i != this->end(); ++i) {
208 if (p == this->begin())
210 else if (p == this->end())
222 template<
class JRebin_t>
225 if (this->size() > 1u) {
233 while (++i != this->end() && merge(*out,*i)) {
234 out->getY() += i->getY();
242 if (this->getDistance(__rbegin->getX(), this->rbegin()->getX()) > 0.0) {
244 *out = *(this->rbegin());
249 this->resize(std::distance(this->begin(), out));
263 histogram_type ::add(
static_cast<const histogram_type&
> (histogram));
278 histogram_type ::sub(
static_cast<const histogram_type&
> (histogram));
292 collection_type::mul(value);
293 histogram_type ::mul(value);
307 collection_type::div(value);
308 histogram_type ::div(value);
339 out << static_cast<const histogram_type&> (
object);
340 out << static_cast<const collection_type&>(
object);
352 template<
class JAbscissa_t,
354 template<
class,
class>
class JContainer_t,
357 public JContainer_t<JBin1D<JAbscissa_t, JContents_t>, JDistance_t>,
359 public JMath< JHistogram1D<JBin1D<JAbscissa_t, JContents_t>, JContainer_t, JDistance_t> >
376 typedef typename collection_type::iterator
iterator;
383 typedef JTOOLS::JRebin <value_type>
JRebin;
423 for (
iterator i = this->begin(); i != this->end(); ++i) {
455 if (p == this->begin())
457 else if (p == this->end())
469 template<
class JRebin_t>
472 if (this->size() > 1u) {
480 while (++i != this->end() && merge(*out,*i)) {
489 if (getDistance(__rbegin->getX(), this->rbegin()->getX()) > 0.0) {
491 *out = *(this->rbegin());
496 this->resize(std::distance(this->begin(), out));
508 for (
iterator i = this->begin(); i != this->end(); ++i) {
525 for (
iterator i = this->begin(); i != this->end(); ++i) {
560 out << static_cast<const histogram_type&> (
object);
561 out << static_cast<const collection_type&>(
object);
576 template<
class JElement_t,
577 template<
class,
class>
class JContainer_t,
582 typedef typename JElement_t::abscissa_type abscissa_type;
583 typedef typename JElement_t::ordinate_type ordinate_type;
586 if (input.getSize() > 1) {
588 for (const_iterator
j = input.begin(), i =
j++;
j != input.end(); ++i, ++
j) {
590 const abscissa_type x = 0.5 * (i->getX() +
j->getX());
591 const ordinate_type y = i->getY();
592 const double w = input.getDistance(i->getX(),
j->getX());
608 template<
class JAbscissa_t,
610 template<
class,
class>
class JContainer_t,
615 typedef JAbscissa_t abscissa_type;
616 typedef JContents_t contents_type;
619 if (input.getSize() > 1) {
621 for (const_iterator
j = input.begin(), i =
j++;
j != input.end(); ++i, ++
j) {
623 const abscissa_type x = i->getBinCenter();
624 const contents_type y = i->getY();
625 const double w = input.getDistance(i->getX(),
j->getX());
642 template<
class JElement_t,
643 template<
class,
class>
class JContainer_t,
645 inline typename JElement_t::ordinate_type
649 typedef typename JElement_t::ordinate_type ordinate_type;
654 if (input.getSize() > 1) {
656 output.
put(input.begin()->getX(), V);
658 for (const_iterator
j = input.begin(), i =
j++;
j != input.end(); ++i, ++
j) {
662 output.
put(
j->getX(), V);
General purpose class for a collection of sorted elements.
The elements in a collection are sorted according to their abscissa values and a given distance opera...
Base class for data structures with artithmetic capabilities.
Interface for binary input.
Interface for binary output.
virtual void evaluate(const abscissa_type *pX, typename JClass< contents_type >::argument_type w)
Fill histogram.
JHistogram1D & mul(const double value)
Scale contents.
collection_type::collection_type base_collection_type
collection_type::abscissa_type abscissa_type
JBin1D< JAbscissa_t, JContents_t > element_type
JHistogram1D()
Default constructor.
collection_type::iterator iterator
void rebin(JRebin_t merge)
Rebin histogram.
JTOOLS::JContent< value_type > JContent
collection_type::const_iterator const_iterator
JHistogram1D(const JAbstractHistogram< abscissa_type > &bounds)
Constructor.
JContainer_t< element_type, JDistance_t > collection_type
collection_type::reverse_iterator reverse_iterator
friend JWriter & operator<<(JWriter &out, const JHistogram1D &object)
Write histogram to output.
friend JReader & operator>>(JReader &in, JHistogram1D &object)
Read histogram from input.
void fill(typename JClass< abscissa_type >::argument_type x, typename JClass< contents_type >::argument_type w)
Fill histogram.
collection_type::ordinate_type ordinate_type
JTOOLS::JRebin< value_type > JRebin
collection_type::value_type value_type
JHistogram< abscissa_type, ordinate_type > histogram_type
JHistogram1D & div(const double value)
Scale contents.
JHistogram1D(const JAbstractCollection< abscissa_type > &bounds)
Constructor.
histogram_type::contents_type contents_type
collection_type::const_reverse_iterator const_reverse_iterator
static const JZero zero
Function object to assign zero value.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Template for generic class types.
JArgument< T >::argument_type argument_type
Auxiliary base class for aritmetic operations of derived class types.
Auxiliary class for merging of consecutive bins until minimal content is reached.
JElement_t::ordinate_type contents_type
bool operator()(const value_type &first, const value_type &second) const
Test whether bins should be merged.
JContent(const contents_type y)
Constructor.