CMS 3D CMS Logo

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

npstat::DualAxis Class Reference

#include <DualAxis.h>

List of all members.

Public Member Functions

double coordinate (const unsigned i) const
std::vector< double > coords () const
 DualAxis (const UniformAxis &u)
 DualAxis (const std::vector< double > &coords, const bool useLogSpace=false)
 DualAxis (const std::vector< double > &coords, const char *label, const bool useLogSpace=false)
 DualAxis (const GridAxis &g)
 DualAxis (unsigned nCoords, double min, double max, const char *label=0)
std::pair< unsigned, double > getInterval (const double x) const
double intervalWidth (const unsigned i=0) const
bool isUniform () const
const std::string & label () const
double length () const
std::pair< unsigned, double > linearInterval (const double x) const
double max () const
double min () const
unsigned nCoords () const
unsigned nIntervals () const
bool operator!= (const DualAxis &r) const
bool operator== (const DualAxis &r) const
void setLabel (const char *newlabel)
bool usesLogSpace () const
const GridAxisgetGridAxis () const
const UniformAxisgetUniformAxis () const
gs::ClassId classId () const
bool write (std::ostream &of) const

Static Public Member Functions

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

Private Member Functions

 DualAxis ()

Static Private Member Functions

static std::vector< double > dummy_vec ()

Private Attributes

GridAxis a_
UniformAxis u_
bool uniform_

Detailed Description

Rectangular grid axis which can be either uniform or non-uniform. Will work a little bit slower than either GridAxis or UniformAxis, but can be used in place of either one of them.

Definition at line 24 of file DualAxis.h.


Constructor & Destructor Documentation

npstat::DualAxis::DualAxis ( const GridAxis g) [inline]

Definition at line 28 of file DualAxis.h.

            : a_(g), u_(2, 0.0, 1.0), uniform_(false) {}
npstat::DualAxis::DualAxis ( const UniformAxis u) [inline]

Definition at line 31 of file DualAxis.h.

            : a_(dummy_vec()), u_(u), uniform_(true) {}
npstat::DualAxis::DualAxis ( unsigned  nCoords,
double  min,
double  max,
const char *  label = 0 
) [inline]

Definition at line 34 of file DualAxis.h.

            : a_(dummy_vec()), u_(nCoords, min, max, label), uniform_(true) {}
npstat::DualAxis::DualAxis ( const std::vector< double > &  coords,
const bool  useLogSpace = false 
) [inline]

Definition at line 38 of file DualAxis.h.

            : a_(coords, useLogSpace), u_(2, 0.0, 1.0), uniform_(false) {}
npstat::DualAxis::DualAxis ( const std::vector< double > &  coords,
const char *  label,
const bool  useLogSpace = false 
) [inline]

Definition at line 42 of file DualAxis.h.

            : a_(coords, label, useLogSpace), u_(2,0.0,1.0), uniform_(false) {}
npstat::DualAxis::DualAxis ( ) [inline, private]

Definition at line 119 of file DualAxis.h.

Referenced by read().

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

Member Function Documentation

gs::ClassId npstat::DualAxis::classId ( ) const [inline]

Method related to "geners" I/O

Definition at line 110 of file DualAxis.h.

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

Definition at line 114 of file DualAxis.h.

{return "npstat::DualAxis";}
double npstat::DualAxis::coordinate ( const unsigned  i) const [inline]

Definition at line 70 of file DualAxis.h.

References a_, npstat::UniformAxis::coordinate(), npstat::GridAxis::coordinate(), u_, and uniform_.

            {return uniform_ ? u_.coordinate(i) : a_.coordinate(i);}
std::vector<double> npstat::DualAxis::coords ( ) const [inline]

Definition at line 82 of file DualAxis.h.

References a_, npstat::GridAxis::coords(), npstat::UniformAxis::coords(), u_, and uniform_.

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

Definition at line 126 of file DualAxis.h.

        {
            std::vector<double> vec(2, 0.0);
            vec[1] = 1.0;
            return vec;
        }
const GridAxis* npstat::DualAxis::getGridAxis ( ) 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 97 of file DualAxis.h.

References a_, and uniform_.

            {return uniform_ ? static_cast<const GridAxis*>(0) : &a_;}
std::pair<unsigned,double> npstat::DualAxis::getInterval ( const double  x) const [inline]

Definition at line 64 of file DualAxis.h.

References a_, npstat::UniformAxis::getInterval(), npstat::GridAxis::getInterval(), u_, and uniform_.

            {return uniform_ ? u_.getInterval(x) : a_.getInterval(x);}
const UniformAxis* npstat::DualAxis::getUniformAxis ( ) const [inline]

Definition at line 100 of file DualAxis.h.

References u_, and uniform_.

            {return uniform_ ? &u_ : static_cast<const UniformAxis*>(0);}
double npstat::DualAxis::intervalWidth ( const unsigned  i = 0) const [inline]

Definition at line 79 of file DualAxis.h.

References a_, i, npstat::GridAxis::intervalWidth(), npstat::UniformAxis::intervalWidth(), u_, and uniform_.

            {return uniform_ ? u_.intervalWidth(i) : a_.intervalWidth(i);}
bool npstat::DualAxis::isUniform ( ) const [inline]

Definition at line 47 of file DualAxis.h.

References uniform_.

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

Definition at line 58 of file DualAxis.h.

References a_, npstat::GridAxis::label(), npstat::UniformAxis::label(), u_, and uniform_.

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

Definition at line 73 of file DualAxis.h.

References a_, npstat::GridAxis::length(), npstat::UniformAxis::length(), u_, and uniform_.

            {return uniform_ ? u_.length() : a_.length();}
std::pair<unsigned,double> npstat::DualAxis::linearInterval ( const double  x) const [inline]

Definition at line 67 of file DualAxis.h.

References a_, npstat::GridAxis::linearInterval(), npstat::UniformAxis::linearInterval(), u_, and uniform_.

            {return uniform_ ? u_.linearInterval(x) : a_.linearInterval(x);}
double npstat::DualAxis::max ( ) const [inline]

Definition at line 55 of file DualAxis.h.

References a_, npstat::GridAxis::max(), npstat::UniformAxis::max(), u_, and uniform_.

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

Definition at line 52 of file DualAxis.h.

References a_, npstat::GridAxis::min(), npstat::UniformAxis::min(), u_, and uniform_.

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

Definition at line 49 of file DualAxis.h.

References a_, npstat::UniformAxis::nCoords(), npstat::GridAxis::nCoords(), u_, and uniform_.

            {return uniform_ ? u_.nCoords() : a_.nCoords();}
unsigned npstat::DualAxis::nIntervals ( ) const [inline]

Definition at line 76 of file DualAxis.h.

References a_, npstat::GridAxis::nIntervals(), npstat::UniformAxis::nIntervals(), u_, and uniform_.

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

Definition at line 88 of file DualAxis.h.

References alignCSCRings::r.

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

Definition at line 85 of file DualAxis.h.

References a_, u_, and uniform_.

            {return uniform_ == r.uniform_ && a_ == r.a_ && u_ == r.u_;}
DualAxis * npstat::DualAxis::read ( const gs::ClassId &  id,
std::istream &  in 
) [static]

Definition at line 18 of file DualAxis.cc.

References trackerHits::c, cond::rpcobimon::current, DualAxis(), npstat::GridAxis::read(), and npstat::UniformAxis::read().

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

        unsigned char c;
        gs::read_pod(in, &c);
        gs::ClassId clid(in, 1);
        if (in.fail())
            throw gs::IOReadFailure("In npstat::DualAxis::read: "
                                    "input stream failure");
        if (c)
        {
            CPP11_auto_ptr<UniformAxis> axis(UniformAxis::read(clid, in));
            return new DualAxis(*axis);
        }
        else
        {
            CPP11_auto_ptr<GridAxis> axis(GridAxis::read(clid, in));
            return new DualAxis(*axis);
        }
    }
void npstat::DualAxis::setLabel ( const char *  newlabel) [inline]

Modify the axis label

Definition at line 105 of file DualAxis.h.

References a_, npstat::GridAxis::setLabel(), npstat::UniformAxis::setLabel(), u_, and uniform_.

            {uniform_ ? u_.setLabel(newlabel) : a_.setLabel(newlabel);}
bool npstat::DualAxis::usesLogSpace ( ) const [inline]

Definition at line 61 of file DualAxis.h.

References a_, u_, uniform_, npstat::GridAxis::usesLogSpace(), and npstat::UniformAxis::usesLogSpace().

            {return uniform_ ? u_.usesLogSpace() : a_.usesLogSpace();}
static unsigned npstat::DualAxis::version ( ) [inline, static]

Definition at line 115 of file DualAxis.h.

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

Definition at line 8 of file DualAxis.cc.

References a_, trackerHits::c, npstat::UniformAxis::classId(), npstat::GridAxis::classId(), u_, uniform_, npstat::UniformAxis::write(), and npstat::GridAxis::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);
    }

Member Data Documentation