1 #ifndef __JHISTOGRAM1D__
2 #define __JHISTOGRAM1D__
29 template<
class JElement_t>
68 template<
class JElement_t>
94 return (first.getY() + second.getY() <
__y);
108 template<
class JElement_t,
109 template<
class,
class>
class JContainer_t,
112 public JContainer_t<JElement_t, JDistance_t>,
113 public JHistogram<typename JElement_t::abscissa_type, typename JElement_t::ordinate_type>,
114 public JMath< JHistogram1D<JElement_t, JContainer_t, JDistance_t> >
128 typedef typename collection_type::iterator
iterator;
175 for (
iterator i = this->begin(); i != this->end(); ++i) {
205 iterator p = this->lower_bound(
x);
207 if (p == this->begin())
209 else if (p == this->end())
221 template<
class JRebin_t>
224 if (this->size() > 1u) {
232 while (++i != this->end() && merge(*out,*i)) {
233 out->getY() += i->getY();
241 if (this->
getDistance(__rbegin->getX(), this->rbegin()->getX()) > 0.0) {
243 *out = *(this->rbegin());
291 collection_type::mul(value);
306 collection_type::div(value);
338 out << static_cast<const histogram_type&> (
object);
339 out << static_cast<const collection_type&>(
object);
351 template<
class JAbscissa_t,
353 template<
class,
class>
class JContainer_t,
356 public JContainer_t<JBin2D<JAbscissa_t, JContents_t>, JDistance_t>,
358 public JMath< JHistogram1D<JBin2D<JAbscissa_t, JContents_t>, JContainer_t, JDistance_t> >
373 typedef typename collection_type::iterator
iterator;
426 iterator p = this->lower_bound(
x);
428 if (p == this->begin())
430 else if (p == this->end())
442 template<
class JRebin_t>
445 if (this->size() > 1u) {
453 while (++i != this->end() && merge(*out,*i)) {
462 if (
getDistance(__rbegin->getX(), this->rbegin()->getX()) > 0.0) {
464 *out = *(this->rbegin());
481 for (
iterator i = this->begin(); i != this->end(); ++i) {
498 for (
iterator i = this->begin(); i != this->end(); ++i) {
533 out << static_cast<const histogram_type&> (
object);
534 out << static_cast<const collection_type&>(
object);
556 template<
class JElement_t,
557 template<
class,
class>
class JContainer_t,
562 typedef typename JElement_t::abscissa_type abscissa_type;
563 typedef typename JElement_t::ordinate_type ordinate_type;
566 if (input.getSize() > 1) {
568 for (const_iterator
j = input.begin(), i =
j++;
j != input.end(); ++i, ++
j) {
570 const abscissa_type
x = 0.5 * (i->getX() +
j->getX());
571 const ordinate_type
y = i->getY();
572 const double w = input.getDistance(i->getX(),
j->getX());
588 template<
class JAbscissa_t,
590 template<
class,
class>
class JContainer_t,
595 typedef JAbscissa_t abscissa_type;
596 typedef JContents_t contents_type;
599 if (input.getSize() > 1) {
601 for (const_iterator
j = input.begin(), i =
j++;
j != input.end(); ++i, ++
j) {
603 const abscissa_type
x = i->getBinCenter();
604 const contents_type
y = i->getY();
605 const double w = input.getDistance(i->getX(),
j->getX());
622 template<
class JElement_t,
623 template<
class,
class>
class JContainer_t,
625 inline typename JElement_t::ordinate_type
629 typedef typename JElement_t::ordinate_type ordinate_type;
634 if (input.getSize() > 1) {
636 output.
put(input.begin()->getX(), V);
638 for (const_iterator
j = input.begin(), i =
j++;
j != input.end(); ++i, ++
j) {
642 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.
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
Interface for binary input.
Interface for binary output.
collection_type::reverse_iterator reverse_iterator
collection_type::ordinate_type ordinate_type
JHistogram1D(const JAbstractCollection< abscissa_type > &bounds)
Constructor.
JHistogram1D()
Default constructor.
virtual void evaluate(const abscissa_type *pX, typename JClass< contents_type >::argument_type w)
Fill histogram.
JHistogram1D & div(const double value)
Scale contents.
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.
histogram_type::contents_type contents_type
JTOOLS::JContent< value_type > JContent
collection_type::abscissa_type abscissa_type
collection_type::value_type value_type
collection_type::const_reverse_iterator const_reverse_iterator
JTOOLS::JRebin< value_type > JRebin
friend JWriter & operator<<(JWriter &out, const JHistogram1D &object)
Write histogram to output.
JHistogram1D & sub(const JHistogram1D &histogram)
subtraction not allowed with bin centering
JContainer_t< element_type, JDistance_t > collection_type
JHistogram1D & mul(const double value)
Scale contents.
collection_type::iterator iterator
void rebin(JRebin_t merge)
Rebin histogram.
JHistogram1D & add(const JHistogram1D &histogram)
Make methods inaccessible.
collection_type::const_iterator const_iterator
JHistogram< abscissa_type, ordinate_type > histogram_type
JBin2D< JAbscissa_t, JContents_t > element_type
static const JZero zero
Function object to assign zero value.
double getDistance(const JFirst_t &first, const JSecond_t &second)
Get distance between objects.
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.
bool operator()(const value_type &first, const value_type &second) const
Test whether bins should be merged.
JElement_t::ordinate_type contents_type
JContent(const contents_type y)
Constructor.