CMS 3D CMS Logo

Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Friends

npstat::DualHistoAxis Class Reference

#include <DualHistoAxis.h>

List of all members.

Public Member Functions

double binCenter (const int binNum) const
Interval< double > binInterval (const int binNum) const
int binNumber (const double x) const
double binWidth (const int binNum) const
unsigned closestValidBin (const double x) const
 DualHistoAxis (unsigned nBins, double min, double max, const char *label=0)
 DualHistoAxis (const NUHistoAxis &a)
 DualHistoAxis (const HistoAxis &u)
 DualHistoAxis (const std::vector< double > &binEdges, const char *label=0)
double fltBinNumber (const double x, const bool mapLeftEdgeTo0=true) const
Interval< double > interval () const
bool isClose (const DualHistoAxis &r, const double tol) const
bool isUniform () const
const std::string & label () const
double leftBinEdge (const int binNum) const
double length () const
double max () const
double min () const
unsigned nBins () const
bool operator!= (const DualHistoAxis &r) const
bool operator== (const DualHistoAxis &r) const
double rightBinEdge (const int binNum) const
void setLabel (const char *newlabel)
const NUHistoAxisgetNUHistoAxis () const
const HistoAxisgetHistoAxis () const
gs::ClassId classId () const
bool write (std::ostream &of) const

Static Public Member Functions

static const char * classname ()
static DualHistoAxisread (const gs::ClassId &id, std::istream &in)
static unsigned version ()

Private Member Functions

 DualHistoAxis ()
unsigned overflowIndex (const double x, unsigned *binNumber) const

Static Private Member Functions

static std::vector< double > dummy_vec ()

Private Attributes

NUHistoAxis a_
HistoAxis u_
bool uniform_

Friends

class HistoND

Detailed Description

Histogram axis which can be either uniform or non-uniform. Will work a little bit slower than either HistoAxis or NUHistoAxis, but can be used in place of either one of them.

Definition at line 23 of file DualHistoAxis.h.


Constructor & Destructor Documentation

npstat::DualHistoAxis::DualHistoAxis ( const NUHistoAxis a) [inline]

Definition at line 27 of file DualHistoAxis.h.

            : a_(a), u_(1U, 0.0, 1.0), uniform_(false) {}
npstat::DualHistoAxis::DualHistoAxis ( const HistoAxis u) [inline]

Definition at line 30 of file DualHistoAxis.h.

            : a_(dummy_vec()), u_(u), uniform_(true) {}
npstat::DualHistoAxis::DualHistoAxis ( const std::vector< double > &  binEdges,
const char *  label = 0 
) [inline]

Definition at line 33 of file DualHistoAxis.h.

            : a_(binEdges, label), u_(1U, 0.0, 1.0), uniform_(false) {}
npstat::DualHistoAxis::DualHistoAxis ( unsigned  nBins,
double  min,
double  max,
const char *  label = 0 
) [inline]

Definition at line 37 of file DualHistoAxis.h.

            : a_(dummy_vec()), u_(nBins, min, max, label), uniform_(true) {}
npstat::DualHistoAxis::DualHistoAxis ( ) [inline, private]

Definition at line 141 of file DualHistoAxis.h.

Referenced by read().

            : a_(dummy_vec()), u_(1U, 0.0, 1.0), uniform_(true) {}

Member Function Documentation

double npstat::DualHistoAxis::binCenter ( const int  binNum) const [inline]

Definition at line 65 of file DualHistoAxis.h.

References a_, npstat::NUHistoAxis::binCenter(), npstat::HistoAxis::binCenter(), u_, and uniform_.

            {return uniform_ ? u_.binCenter(binNum) : a_.binCenter(binNum);}
Interval<double> npstat::DualHistoAxis::binInterval ( const int  binNum) const [inline]

Definition at line 74 of file DualHistoAxis.h.

References a_, npstat::HistoAxis::binInterval(), npstat::NUHistoAxis::binInterval(), u_, and uniform_.

            {return uniform_ ? u_.binInterval(binNum) : a_.binInterval(binNum);}
int npstat::DualHistoAxis::binNumber ( const double  x) const [inline]

This method returns arbitrary integer bin number. Possible output depends on whether the axis is uniform or not.

Definition at line 98 of file DualHistoAxis.h.

References a_, npstat::HistoAxis::binNumber(), npstat::NUHistoAxis::binNumber(), u_, and uniform_.

            {return uniform_ ? u_.binNumber(x) : a_.binNumber(x);}
double npstat::DualHistoAxis::binWidth ( const int  binNum) const [inline]

Definition at line 59 of file DualHistoAxis.h.

References a_, npstat::NUHistoAxis::binWidth(), npstat::HistoAxis::binWidth(), u_, and uniform_.

            {return uniform_ ? u_.binWidth(binNum) : a_.binWidth(binNum);}
gs::ClassId npstat::DualHistoAxis::classId ( ) const [inline]

Definition at line 132 of file DualHistoAxis.h.

{return gs::ClassId(*this);}
static const char* npstat::DualHistoAxis::classname ( ) [inline, static]

Definition at line 136 of file DualHistoAxis.h.

{return "npstat::DualHistoAxis";}
unsigned npstat::DualHistoAxis::closestValidBin ( const double  x) const [inline]

Return the closest valid bin number (above 0 and below nBins() )

Definition at line 113 of file DualHistoAxis.h.

References a_, npstat::NUHistoAxis::closestValidBin(), npstat::HistoAxis::closestValidBin(), u_, and uniform_.

            {return uniform_ ? u_.closestValidBin(x) : a_.closestValidBin(x);}
static std::vector<double> npstat::DualHistoAxis::dummy_vec ( ) [inline, static, private]

Definition at line 157 of file DualHistoAxis.h.

        {
            std::vector<double> vec(2, 0.0);
            vec[1] = 1.0;
            return vec;
        }
double npstat::DualHistoAxis::fltBinNumber ( const double  x,
const bool  mapLeftEdgeTo0 = true 
) const [inline]

Floating point bin number given the coordinate. Useful for interpolation methods and such.

Definition at line 105 of file DualHistoAxis.h.

References a_, npstat::NUHistoAxis::fltBinNumber(), npstat::HistoAxis::fltBinNumber(), u_, and uniform_.

        {
            return uniform_ ? u_.fltBinNumber(x, mapLeftEdgeTo0) :
                              a_.fltBinNumber(x, mapLeftEdgeTo0);
        }
const HistoAxis* npstat::DualHistoAxis::getHistoAxis ( ) const [inline]

Definition at line 86 of file DualHistoAxis.h.

References u_, and uniform_.

            {return uniform_ ? &u_ : static_cast<const HistoAxis*>(0);}
const NUHistoAxis* npstat::DualHistoAxis::getNUHistoAxis ( ) const [inline]

Return a pointer to the underlying axis. This will be a null pointer if the axis does not correspond to the constructed type.

Definition at line 83 of file DualHistoAxis.h.

References a_, and uniform_.

            {return uniform_ ? static_cast<const NUHistoAxis*>(0) : &a_;}
Interval<double> npstat::DualHistoAxis::interval ( ) const [inline]

Definition at line 50 of file DualHistoAxis.h.

References a_, npstat::HistoAxis::interval(), npstat::NUHistoAxis::interval(), u_, and uniform_.

            {return uniform_ ? u_.interval() : a_.interval();}
bool npstat::DualHistoAxis::isClose ( const DualHistoAxis r,
const double  tol 
) const [inline]

Comparison within given tolerance

Definition at line 123 of file DualHistoAxis.h.

References a_, npstat::NUHistoAxis::isClose(), npstat::HistoAxis::isClose(), u_, and uniform_.

        {
            return uniform_ == r.uniform_ &&
                   a_.isClose(r.a_, tol) && 
                   u_.isClose(r.u_, tol);
        }
bool npstat::DualHistoAxis::isUniform ( ) const [inline]

Definition at line 42 of file DualHistoAxis.h.

References uniform_.

{return uniform_;}
const std::string& npstat::DualHistoAxis::label ( ) const [inline]

Definition at line 62 of file DualHistoAxis.h.

References a_, npstat::HistoAxis::label(), npstat::NUHistoAxis::label(), u_, and uniform_.

            {return uniform_ ? u_.label() : a_.label();}
double npstat::DualHistoAxis::leftBinEdge ( const int  binNum) const [inline]

Definition at line 68 of file DualHistoAxis.h.

References a_, npstat::NUHistoAxis::leftBinEdge(), npstat::HistoAxis::leftBinEdge(), u_, and uniform_.

            {return uniform_ ? u_.leftBinEdge(binNum) : a_.leftBinEdge(binNum);}
double npstat::DualHistoAxis::length ( ) const [inline]

Definition at line 53 of file DualHistoAxis.h.

References a_, npstat::NUHistoAxis::length(), npstat::HistoAxis::length(), u_, and uniform_.

            {return uniform_ ? u_.length() : a_.length();}
double npstat::DualHistoAxis::max ( ) const [inline]

Definition at line 47 of file DualHistoAxis.h.

References a_, npstat::NUHistoAxis::max(), npstat::HistoAxis::max(), u_, and uniform_.

            {return uniform_ ? u_.max() : a_.max();}
double npstat::DualHistoAxis::min ( ) const [inline]

Definition at line 44 of file DualHistoAxis.h.

References a_, npstat::NUHistoAxis::min(), npstat::HistoAxis::min(), u_, and uniform_.

            {return uniform_ ? u_.min() : a_.min();}
unsigned npstat::DualHistoAxis::nBins ( ) const [inline]

Definition at line 56 of file DualHistoAxis.h.

References a_, npstat::NUHistoAxis::nBins(), npstat::HistoAxis::nBins(), u_, and uniform_.

            {return uniform_ ? u_.nBins() : a_.nBins();}
bool npstat::DualHistoAxis::operator!= ( const DualHistoAxis r) const [inline]

Definition at line 119 of file DualHistoAxis.h.

References alignCSCRings::r.

            {return !(*this == r);}
bool npstat::DualHistoAxis::operator== ( const DualHistoAxis r) const [inline]

Definition at line 116 of file DualHistoAxis.h.

References a_, u_, and uniform_.

            {return uniform_ == r.uniform_ && a_ == r.a_ && u_ == r.u_;}
unsigned npstat::DualHistoAxis::overflowIndex ( const double  x,
unsigned *  binNumber 
) const [inline, private]

Definition at line 150 of file DualHistoAxis.h.

References a_, npstat::NUHistoAxis::overflowIndex(), npstat::HistoAxis::overflowIndex(), u_, and uniform_.

        {
            return uniform_ ? u_.overflowIndex(x, binNumber) : 
                              a_.overflowIndex(x, binNumber);
        }
DualHistoAxis * npstat::DualHistoAxis::read ( const gs::ClassId &  id,
std::istream &  in 
) [static]

Definition at line 18 of file DualHistoAxis.cc.

References trackerHits::c, cond::rpcobimon::current, DualHistoAxis(), npstat::NUHistoAxis::read(), and npstat::HistoAxis::read().

    {
        static const gs::ClassId current(gs::ClassId::makeId<DualHistoAxis>());
        current.ensureSameId(id);

        unsigned char c;
        gs::read_pod(in, &c);
        gs::ClassId clid(in, 1);
        if (in.fail())
            throw gs::IOReadFailure("In npstat::DualHistoAxis::read: "
                                    "input stream failure");
        if (c)
        {
            CPP11_auto_ptr<HistoAxis> axis(HistoAxis::read(clid, in));
            return new DualHistoAxis(*axis);
        }
        else
        {
            CPP11_auto_ptr<NUHistoAxis> axis(NUHistoAxis::read(clid, in));
            return new DualHistoAxis(*axis);
        }
    }
double npstat::DualHistoAxis::rightBinEdge ( const int  binNum) const [inline]

Definition at line 71 of file DualHistoAxis.h.

References a_, npstat::NUHistoAxis::rightBinEdge(), npstat::HistoAxis::rightBinEdge(), u_, and uniform_.

            {return uniform_ ? u_.rightBinEdge(binNum) : a_.rightBinEdge(binNum);}
void npstat::DualHistoAxis::setLabel ( const char *  newlabel) [inline]

Modify the axis label

Definition at line 91 of file DualHistoAxis.h.

References a_, npstat::NUHistoAxis::setLabel(), npstat::HistoAxis::setLabel(), u_, and uniform_.

            {uniform_ ? u_.setLabel(newlabel) : a_.setLabel(newlabel);}
static unsigned npstat::DualHistoAxis::version ( ) [inline, static]

Definition at line 137 of file DualHistoAxis.h.

{return 1;}
bool npstat::DualHistoAxis::write ( std::ostream &  of) const

Definition at line 8 of file DualHistoAxis.cc.

References a_, trackerHits::c, npstat::NUHistoAxis::classId(), npstat::HistoAxis::classId(), u_, uniform_, npstat::NUHistoAxis::write(), and npstat::HistoAxis::write().

    {
        unsigned char c = uniform_;
        gs::write_pod(of, c);
        if (uniform_)
            return !of.fail() && u_.classId().write(of) && u_.write(of);
        else
            return !of.fail() && a_.classId().write(of) && a_.write(of);
    }

Friends And Related Function Documentation

friend class HistoND [friend]

Definition at line 148 of file DualHistoAxis.h.


Member Data Documentation