1 #ifndef __JHISTOGRAM1D__
2 #define __JHISTOGRAM1D__
18 namespace JPP {
using namespace JTOOLS; }
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;
194 if (p == this->begin())
196 else if (p == this->end())
208 template<
class JRebin_t>
211 if (this->size() > 1
u) {
219 while (++i != this->end() && merge(*out,*i)) {
220 out->getY() += i->getY();
228 if (this->
getDistance(__rbegin->getX(), this->rbegin()->getX()) > 0.0) {
230 *out = *(this->rbegin());
248 collection_type::add(static_cast<const collection_type&>(histogram));
263 collection_type::sub(static_cast<const collection_type&>(histogram));
278 collection_type::mul(value);
293 collection_type::div(value);
325 out << static_cast<const histogram_type&> (object);
326 out << static_cast<const collection_type&>(object);
338 template<
class JAbscissa_t,
340 template<
class,
class>
class JContainer_t,
343 public JContainer_t<JBin2D<JAbscissa_t, JContents_t>, JDistance_t>,
345 public JMath< JHistogram1D<JBin2D<JAbscissa_t, JContents_t>, JContainer_t, JDistance_t> >
360 typedef typename collection_type::iterator
iterator;
415 if (p == this->begin())
417 else if (p == this->end())
429 template<
class JRebin_t>
432 if (this->size() > 1
u) {
440 while (++i != this->end() && merge(*out,*i)) {
449 if (
getDistance(__rbegin->getX(), this->rbegin()->getX()) > 0.0) {
451 *out = *(this->rbegin());
468 for (
iterator i = this->begin(); i != this->end(); ++i) {
485 for (
iterator i = this->begin(); i != this->end(); ++i) {
520 out << static_cast<const histogram_type&> (object);
521 out << static_cast<const collection_type&>(object);
543 template<
class JElement_t,
544 template<
class,
class>
class JContainer_t,
549 typedef typename JElement_t::abscissa_type abscissa_type;
550 typedef typename JElement_t::ordinate_type ordinate_type;
553 if (input.getSize() > 1) {
555 for (const_iterator
j = input.begin(), i =
j++;
j != input.end(); ++i, ++
j) {
557 const abscissa_type
x = 0.5 * (i->getX() +
j->getX());
558 const ordinate_type y = i->getY();
559 const double w = input.getDistance(i->getX(),
j->getX());
575 template<
class JAbscissa_t,
577 template<
class,
class>
class JContainer_t,
582 typedef JAbscissa_t abscissa_type;
583 typedef JContents_t contents_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 = i->getBinCenter();
591 const contents_type y = i->getY();
592 const double w = input.getDistance(i->getX(),
j->getX());
609 template<
class JElement_t,
610 template<
class,
class>
class JContainer_t,
612 inline typename JElement_t::ordinate_type
616 typedef typename JElement_t::ordinate_type ordinate_type;
621 if (input.getSize() > 1) {
623 output.
put(input.begin()->getX(), V);
625 for (const_iterator
j = input.begin(), i =
j++;
j != input.end(); ++i, ++
j) {
629 output.
put(
j->getX(), V);
Interface for binary output.
friend JReader & operator>>(JReader &in, JHistogram1D &object)
Read histogram from input.
Auxiliary base class for aritmetic operations of derived class types.
JContent(const contents_type y)
Constructor.
The elements in a collection are sorted according to their abscissa values and a given distance opera...
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
JTOOLS::JRebin< value_type > JRebin
JContainer_t< element_type, JDistance_t > collection_type
static const JZero zero
Function object to assign zero value.
then echo The file $DIR KM3NeT_00000001_00000000 root already please rename or remove it first
double getDistance(const JFirst_t &first, const JSecond_t &second)
Get distance between objects.
JHistogram1D(const JAbstractCollection< abscissa_type > &bounds)
Constructor.
JBin2D< JAbscissa_t, JContents_t > element_type
JHistogram< abscissa_type, ordinate_type > histogram_type
JArgument< T >::argument_type argument_type
JElement_t::ordinate_type contents_type
JHistogram1D & mul(const double value)
Scale contents.
virtual void evaluate(const abscissa_type *pX, typename JClass< contents_type >::argument_type w)
Fill histogram.
General purpose class for a collection of sorted elements.
JHistogram1D()
Default constructor.
Interface for binary input.
Auxiliary class for merging of consecutive bins until minimal content is reached. ...
collection_type::ordinate_type ordinate_type
collection_type::const_iterator const_iterator
JHistogram1D & div(const double value)
Scale contents.
Template for generic class types.
collection_type::iterator iterator
collection_type::abscissa_type abscissa_type
collection_type::reverse_iterator reverse_iterator
void fill(typename JClass< abscissa_type >::argument_type x, typename JClass< contents_type >::argument_type w)
Fill histogram.
JTOOLS::JContent< value_type > JContent
Base class for data structures with artithmetic capabilities.
collection_type::const_reverse_iterator const_reverse_iterator
histogram_type::contents_type contents_type
friend JWriter & operator<<(JWriter &out, const JHistogram1D &object)
Write histogram to output.
collection_type::value_type value_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
bool operator()(const value_type &first, const value_type &second) const
Test whether bins should be merged.
void rebin(JRebin_t merge)
Rebin histogram.