CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Friends
npstat::DualHistoAxis Class Reference

#include <DualHistoAxis.h>

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 (const NUHistoAxis &a)
 
 DualHistoAxis (const HistoAxis &u)
 
 DualHistoAxis (const std::vector< double > &binEdges, const char *label=0)
 
 DualHistoAxis (unsigned nBins, double min, double max, 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
 
DualHistoAxis rebin (const unsigned newBins) 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

template<typename Numeric , class Axis >
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.

28  : a_(a), u_(1U, 0.0, 1.0), uniform_(false) {}
double a
Definition: hdecay.h:121
npstat::DualHistoAxis::DualHistoAxis ( const HistoAxis u)
inline

Definition at line 30 of file DualHistoAxis.h.

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

Definition at line 33 of file DualHistoAxis.h.

35  : a_(binEdges, label), u_(1U, 0.0, 1.0), uniform_(false) {}
const std::string & label() const
Definition: DualHistoAxis.h:62
npstat::DualHistoAxis::DualHistoAxis ( unsigned  nBins,
double  min,
double  max,
const char *  label = 0 
)
inline

Definition at line 37 of file DualHistoAxis.h.

39  : a_(dummy_vec()), u_(nBins, min, max, label), uniform_(true) {}
const std::string & label() const
Definition: DualHistoAxis.h:62
double min() const
Definition: DualHistoAxis.h:44
double max() const
Definition: DualHistoAxis.h:47
unsigned nBins() const
Definition: DualHistoAxis.h:56
static std::vector< double > dummy_vec()
npstat::DualHistoAxis::DualHistoAxis ( )
inlineprivate

Definition at line 165 of file DualHistoAxis.h.

Referenced by read(), and rebin().

166  : a_(dummy_vec()), u_(1U, 0.0, 1.0), uniform_(true) {}
static std::vector< double > dummy_vec()

Member Function Documentation

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

Definition at line 65 of file DualHistoAxis.h.

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

66  {return uniform_ ? u_.binCenter(binNum) : a_.binCenter(binNum);}
double binCenter(const int binNum) const
Definition: NUHistoAxis.h:60
double binCenter(const int binNum) const
Definition: HistoAxis.h:54
Interval<double> npstat::DualHistoAxis::binInterval ( const int  binNum) const
inline

Definition at line 74 of file DualHistoAxis.h.

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

75  {return uniform_ ? u_.binInterval(binNum) : a_.binInterval(binNum);}
Interval< double > binInterval(const int binNum) const
Definition: HistoAxis.h:66
Interval< double > binInterval(const int binNum) const
Definition: NUHistoAxis.h:64
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::NUHistoAxis::binNumber(), npstat::HistoAxis::binNumber(), u_, and uniform_.

99  {return uniform_ ? u_.binNumber(x) : a_.binNumber(x);}
int binNumber(double x) const
Definition: NUHistoAxis.cc:78
int binNumber(double x) const
Definition: HistoAxis.cc:51
Definition: DDAxes.h:10
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_.

60  {return uniform_ ? u_.binWidth(binNum) : a_.binWidth(binNum);}
double binWidth(const int=0) const
Definition: HistoAxis.h:48
double binWidth(const int binNum) const
Definition: NUHistoAxis.h:45
gs::ClassId npstat::DualHistoAxis::classId ( ) const
inline

Definition at line 136 of file DualHistoAxis.h.

136 {return gs::ClassId(*this);}
static const char* npstat::DualHistoAxis::classname ( )
inlinestatic

Definition at line 140 of file DualHistoAxis.h.

140 {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::HistoAxis::closestValidBin(), npstat::NUHistoAxis::closestValidBin(), u_, and uniform_.

unsigned closestValidBin(double x) const
Definition: NUHistoAxis.cc:150
Definition: DDAxes.h:10
unsigned closestValidBin(double x) const
Definition: HistoAxis.cc:77
static std::vector<double> npstat::DualHistoAxis::dummy_vec ( )
inlinestaticprivate

Definition at line 158 of file DualHistoAxis.h.

159  {
160  std::vector<double> vec(2, 0.0);
161  vec[1] = 1.0;
162  return vec;
163  }
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_.

107  {
108  return uniform_ ? u_.fltBinNumber(x, mapLeftEdgeTo0) :
109  a_.fltBinNumber(x, mapLeftEdgeTo0);
110  }
double fltBinNumber(double x, bool mapLeftEdgeTo0=true) const
Definition: NUHistoAxis.cc:85
Definition: DDAxes.h:10
double fltBinNumber(const double x, const bool mapLeftEdgeTo0=true) const
Definition: HistoAxis.h:99
const HistoAxis* npstat::DualHistoAxis::getHistoAxis ( ) const
inline

Definition at line 86 of file DualHistoAxis.h.

References u_, and uniform_.

87  {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_.

84  {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::NUHistoAxis::interval(), npstat::HistoAxis::interval(), u_, and uniform_.

51  {return uniform_ ? u_.interval() : a_.interval();}
Interval< double > interval() const
Definition: HistoAxis.h:44
Interval< double > interval() const
Definition: NUHistoAxis.h:41
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_.

124  {
125  return uniform_ == r.uniform_ &&
126  a_.isClose(r.a_, tol) &&
127  u_.isClose(r.u_, tol);
128  }
bool isClose(const HistoAxis &, double tol) const
Definition: HistoAxis.cc:30
bool isClose(const NUHistoAxis &, double tol) const
Definition: NUHistoAxis.cc:49
bool npstat::DualHistoAxis::isUniform ( ) const
inline

Definition at line 42 of file DualHistoAxis.h.

References uniform_.

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

Definition at line 62 of file DualHistoAxis.h.

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

Referenced by rebin().

63  {return uniform_ ? u_.label() : a_.label();}
const std::string & label() const
Definition: HistoAxis.h:49
const std::string & label() const
Definition: NUHistoAxis.h:47
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_.

69  {return uniform_ ? u_.leftBinEdge(binNum) : a_.leftBinEdge(binNum);}
double leftBinEdge(const int binNum) const
Definition: HistoAxis.h:58
double leftBinEdge(const int binNum) const
Definition: NUHistoAxis.h:52
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_.

54  {return uniform_ ? u_.length() : a_.length();}
double length() const
Definition: HistoAxis.h:46
double length() const
Definition: NUHistoAxis.h:43
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_.

Referenced by rebin().

48  {return uniform_ ? u_.max() : a_.max();}
double max() const
Definition: HistoAxis.h:43
double max() const
Definition: NUHistoAxis.h:40
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_.

Referenced by rebin().

45  {return uniform_ ? u_.min() : a_.min();}
double min() const
Definition: NUHistoAxis.h:39
double min() const
Definition: HistoAxis.h:42
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_.

57  {return uniform_ ? u_.nBins() : a_.nBins();}
unsigned nBins() const
Definition: NUHistoAxis.h:44
unsigned nBins() const
Definition: HistoAxis.h:47
bool npstat::DualHistoAxis::operator!= ( const DualHistoAxis r) const
inline

Definition at line 119 of file DualHistoAxis.h.

References alignCSCRings::r.

120  {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_.

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

Definition at line 151 of file DualHistoAxis.h.

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

153  {
154  return uniform_ ? u_.overflowIndex(x, binNumber) :
156  }
int binNumber(const double x) const
Definition: DualHistoAxis.h:98
unsigned overflowIndex(const double x, unsigned *binNum) const
Definition: NUHistoAxis.h:123
unsigned overflowIndex(const double x, unsigned *binNumber) const
Definition: HistoAxis.h:140
Definition: DDAxes.h:10
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().

19  {
20  static const gs::ClassId current(gs::ClassId::makeId<DualHistoAxis>());
21  current.ensureSameId(id);
22 
23  unsigned char c;
24  gs::read_pod(in, &c);
25  gs::ClassId clid(in, 1);
26  if (in.fail())
27  throw gs::IOReadFailure("In npstat::DualHistoAxis::read: "
28  "input stream failure");
29  if (c)
30  {
31  CPP11_auto_ptr<HistoAxis> axis(HistoAxis::read(clid, in));
32  return new DualHistoAxis(*axis);
33  }
34  else
35  {
36  CPP11_auto_ptr<NUHistoAxis> axis(NUHistoAxis::read(clid, in));
37  return new DualHistoAxis(*axis);
38  }
39  }
static HistoAxis * read(const gs::ClassId &id, std::istream &in)
Definition: HistoAxis.cc:152
static NUHistoAxis * read(const gs::ClassId &id, std::istream &in)
Definition: NUHistoAxis.cc:171
DualHistoAxis npstat::DualHistoAxis::rebin ( const unsigned  newBins) const
inline

Return uniformly rebinned axis

Definition at line 131 of file DualHistoAxis.h.

References DualHistoAxis(), label(), max(), and min().

132  {return DualHistoAxis(newBins, min(), max(), label().c_str());}
const std::string & label() const
Definition: DualHistoAxis.h:62
double min() const
Definition: DualHistoAxis.h:44
double max() const
Definition: DualHistoAxis.h:47
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_.

72  {return uniform_ ? u_.rightBinEdge(binNum) : a_.rightBinEdge(binNum);}
double rightBinEdge(const int binNum) const
Definition: NUHistoAxis.h:56
double rightBinEdge(const int binNum) const
Definition: HistoAxis.h:62
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_.

92  {uniform_ ? u_.setLabel(newlabel) : a_.setLabel(newlabel);}
void setLabel(const char *newlabel)
Definition: NUHistoAxis.h:69
void setLabel(const char *newlabel)
Definition: HistoAxis.h:70
static unsigned npstat::DualHistoAxis::version ( )
inlinestatic

Definition at line 141 of file DualHistoAxis.h.

141 {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().

9  {
10  unsigned char c = uniform_;
11  gs::write_pod(of, c);
12  if (uniform_)
13  return !of.fail() && u_.classId().write(of) && u_.write(of);
14  else
15  return !of.fail() && a_.classId().write(of) && a_.write(of);
16  }
bool write(std::ostream &of) const
Definition: NUHistoAxis.cc:162
bool write(std::ostream &of) const
Definition: HistoAxis.cc:143
gs::ClassId classId() const
Definition: HistoAxis.h:122
gs::ClassId classId() const
Definition: NUHistoAxis.h:101

Friends And Related Function Documentation

template<typename Numeric , class Axis >
friend class HistoND
friend

Definition at line 149 of file DualHistoAxis.h.

Member Data Documentation

NUHistoAxis npstat::DualHistoAxis::a_
private
HistoAxis npstat::DualHistoAxis::u_
private
bool npstat::DualHistoAxis::uniform_
private