Go to the documentation of this file. 1 #ifndef __JHISTOGRAM1D__
2 #define __JHISTOGRAM1D__
28 template<
class JElement_t>
67 template<
class JElement_t>
93 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::JMath< JHistogram1D<JElement_t, JContainer_t, JDistance_t> >
127 typedef typename collection_type::iterator
iterator;
191 iterator p = this->lower_bound(x);
193 if (p == this->begin())
195 else if (p == this->end())
207 template<
class JRebin_t>
210 if (this->size() > 1
u) {
218 while (++i != this->end() && merge(*out,*i)) {
219 out->getY() += i->getY();
227 if (this->
getDistance(__rbegin->getX(), this->rbegin()->getX()) > 0.0) {
229 *out = *(this->rbegin());
247 collection_type::add(static_cast<const collection_type&>(histogram));
262 collection_type::sub(static_cast<const collection_type&>(histogram));
277 collection_type::mul(value);
292 collection_type::div(value);
308 in >> static_cast<histogram_type&> (
object);
309 in >> static_cast<collection_type&>(
object);
324 out << static_cast<const histogram_type&> (
object);
325 out << static_cast<const collection_type&>(
object);
337 template<
class JAbscissa_t,
339 template<
class,
class>
class JContainer_t,
342 public JContainer_t<JBin2D<JAbscissa_t, JContents_t>, JDistance_t>,
344 public JMATH::JMath< JHistogram1D<JBin2D<JAbscissa_t, JContents_t>, JContainer_t, JDistance_t> >
359 typedef typename collection_type::iterator
iterator;
412 iterator p = this->lower_bound(x);
414 if (p == this->begin())
416 else if (p == this->end())
428 template<
class JRebin_t>
431 if (this->size() > 1
u) {
439 while (++i != this->end() && merge(*out,*i)) {
448 if (
getDistance(__rbegin->getX(), this->rbegin()->getX()) > 0.0) {
450 *out = *(this->rbegin());
467 for (
iterator i = this->begin(); i != this->end(); ++i) {
484 for (
iterator i = this->begin(); i != this->end(); ++i) {
503 in >> static_cast<histogram_type&> (
object);
504 in >> static_cast<collection_type&>(
object);
519 out << static_cast<const histogram_type&> (
object);
520 out << static_cast<const collection_type&>(
object);
542 template<
class JElement_t,
543 template<
class,
class>
class JContainer_t,
548 typedef typename JElement_t::abscissa_type abscissa_type;
549 typedef typename JElement_t::ordinate_type ordinate_type;
552 if (input.getSize() > 1) {
554 for (const_iterator
j = input.begin(), i =
j++;
j != input.end(); ++i, ++
j) {
556 const abscissa_type x = 0.5 * (i->getX() +
j->getX());
557 const ordinate_type y = i->getY();
558 const double w = input.getDistance(i->getX(),
j->getX());
574 template<
class JAbscissa_t,
576 template<
class,
class>
class JContainer_t,
581 typedef JAbscissa_t abscissa_type;
582 typedef JContents_t contents_type;
585 if (input.getSize() > 1) {
587 for (const_iterator
j = input.begin(), i =
j++;
j != input.end(); ++i, ++
j) {
589 const abscissa_type x = i->getBinCenter();
590 const contents_type y = i->getY();
591 const double w = input.getDistance(i->getX(),
j->getX());
608 template<
class JElement_t,
609 template<
class,
class>
class JContainer_t,
611 inline typename JElement_t::ordinate_type
615 typedef typename JElement_t::ordinate_type ordinate_type;
620 if (input.getSize() > 1) {
622 output.
put(input.begin()->getX(), V);
624 for (const_iterator
j = input.begin(), i =
j++;
j != input.end(); ++i, ++
j) {
628 output.
put(
j->getX(), V);
histogram_type::contents_type contents_type
Interface for binary input.
void fill(typename JClass< abscissa_type >::argument_type x, typename JClass< contents_type >::argument_type w)
Fill histogram.
friend JWriter & operator<<(JWriter &out, const JHistogram1D &object)
Write histogram to output.
JTOOLS::JRebin< value_type > JRebin
JArgument< T >::argument_type argument_type
Template for generic class types.
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
JHistogram1D & mul(const double value)
Scale contents.
Auxiliary base class for aritmetic operations of derived class types.
collection_type::ordinate_type ordinate_type
collection_type::const_iterator const_iterator
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
friend JReader & operator>>(JReader &in, JHistogram1D &object)
Read histogram from input.
JBin2D< JAbscissa_t, JContents_t > element_type
Interface for binary output.
collection_type::const_reverse_iterator const_reverse_iterator
bool operator()(const value_type &first, const value_type &second) const
Test whether bins should be merged.
double getDistance(const JFirst_t &first, const JSecond_t &second)
Get distance between objects.
Auxiliary class for merging of consecutive bins until minimal content is reached.
collection_type::reverse_iterator reverse_iterator
JContent(const contents_type y)
Constructor.
JTOOLS::JContent< value_type > JContent
JContainer_t< element_type, JDistance_t > collection_type
JHistogram< abscissa_type, ordinate_type > histogram_type
collection_type::iterator iterator
collection_type::value_type value_type
virtual void evaluate(const abscissa_type *pX, typename JClass< contents_type >::argument_type w)
Fill histogram.
void rebin(JRebin_t merge)
Rebin histogram.
static const JZero zero
Function object to assign zero value.
JElement_t::ordinate_type contents_type
JHistogram1D(const JAbstractCollection< abscissa_type > &bounds)
Constructor.
collection_type::abscissa_type abscissa_type
JHistogram1D & div(const double value)
Scale contents.
JHistogram1D()
Default constructor.