CMS 3D CMS Logo

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
 
gs::ClassId classId () const
 
unsigned closestValidBin (const double x) const
 
 DualHistoAxis (const HistoAxis &u)
 
 DualHistoAxis (const NUHistoAxis &a)
 
 DualHistoAxis (const std::vector< double > &binEdges, const char *label=nullptr)
 
 DualHistoAxis (unsigned nBins, double min, double max, const char *label=nullptr)
 
double fltBinNumber (const double x, const bool mapLeftEdgeTo0=true) const
 
const HistoAxisgetHistoAxis () const
 
const NUHistoAxisgetNUHistoAxis () 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)
 
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

◆ DualHistoAxis() [1/5]

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

Definition at line 26 of file DualHistoAxis.h.

26 : a_(a), u_(1U, 0.0, 1.0), uniform_(false) {}

◆ DualHistoAxis() [2/5]

npstat::DualHistoAxis::DualHistoAxis ( const HistoAxis u)
inline

Definition at line 28 of file DualHistoAxis.h.

28 : a_(dummy_vec()), u_(u), uniform_(true) {}

◆ DualHistoAxis() [3/5]

npstat::DualHistoAxis::DualHistoAxis ( const std::vector< double > &  binEdges,
const char *  label = nullptr 
)
inline

Definition at line 30 of file DualHistoAxis.h.

31  : a_(binEdges, label), u_(1U, 0.0, 1.0), uniform_(false) {}

◆ DualHistoAxis() [4/5]

npstat::DualHistoAxis::DualHistoAxis ( unsigned  nBins,
double  min,
double  max,
const char *  label = nullptr 
)
inline

Definition at line 33 of file DualHistoAxis.h.

34  : a_(dummy_vec()), u_(nBins, min, max, label), uniform_(true) {}

◆ DualHistoAxis() [5/5]

npstat::DualHistoAxis::DualHistoAxis ( )
inlineprivate

Definition at line 144 of file DualHistoAxis.h.

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

Referenced by read(), and rebin().

Member Function Documentation

◆ binCenter()

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

Definition at line 53 of file DualHistoAxis.h.

53 { return uniform_ ? u_.binCenter(binNum) : a_.binCenter(binNum); }

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

◆ binInterval()

Interval<double> npstat::DualHistoAxis::binInterval ( const int  binNum) const
inline

Definition at line 63 of file DualHistoAxis.h.

63  {
64  return uniform_ ? u_.binInterval(binNum) : a_.binInterval(binNum);
65  }

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

◆ binNumber()

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 87 of file DualHistoAxis.h.

87 { return uniform_ ? u_.binNumber(x) : a_.binNumber(x); }

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

Referenced by overflowIndex().

◆ binWidth()

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

Definition at line 49 of file DualHistoAxis.h.

49 { return uniform_ ? u_.binWidth(binNum) : a_.binWidth(binNum); }

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

◆ classId()

gs::ClassId npstat::DualHistoAxis::classId ( ) const
inline

Definition at line 118 of file DualHistoAxis.h.

118 { return gs::ClassId(*this); }

◆ classname()

static const char* npstat::DualHistoAxis::classname ( )
inlinestatic

Definition at line 122 of file DualHistoAxis.h.

122 { return "npstat::DualHistoAxis"; }

◆ closestValidBin()

unsigned npstat::DualHistoAxis::closestValidBin ( const double  x) const
inline

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

Definition at line 98 of file DualHistoAxis.h.

98  {
100  }

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

◆ dummy_vec()

static std::vector<double> npstat::DualHistoAxis::dummy_vec ( )
inlinestaticprivate

Definition at line 138 of file DualHistoAxis.h.

138  {
139  std::vector<double> vec(2, 0.0);
140  vec[1] = 1.0;
141  return vec;
142  }

◆ fltBinNumber()

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 93 of file DualHistoAxis.h.

93  {
94  return uniform_ ? u_.fltBinNumber(x, mapLeftEdgeTo0) : a_.fltBinNumber(x, mapLeftEdgeTo0);
95  }

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

◆ getHistoAxis()

const HistoAxis* npstat::DualHistoAxis::getHistoAxis ( ) const
inline

Definition at line 77 of file DualHistoAxis.h.

77 { return uniform_ ? &u_ : static_cast<const HistoAxis*>(nullptr); }

References u_, and uniform_.

◆ getNUHistoAxis()

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 73 of file DualHistoAxis.h.

73  {
74  return uniform_ ? static_cast<const NUHistoAxis*>(nullptr) : &a_;
75  }

References a_, and uniform_.

◆ interval()

Interval<double> npstat::DualHistoAxis::interval ( ) const
inline

Definition at line 43 of file DualHistoAxis.h.

43 { return uniform_ ? u_.interval() : a_.interval(); }

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

◆ isClose()

bool npstat::DualHistoAxis::isClose ( const DualHistoAxis r,
const double  tol 
) const
inline

Comparison within given tolerance

Definition at line 107 of file DualHistoAxis.h.

107  {
108  return uniform_ == r.uniform_ && a_.isClose(r.a_, tol) && u_.isClose(r.u_, tol);
109  }

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

◆ isUniform()

bool npstat::DualHistoAxis::isUniform ( ) const
inline

Definition at line 37 of file DualHistoAxis.h.

37 { return uniform_; }

References uniform_.

◆ label()

const std::string& npstat::DualHistoAxis::label ( ) const
inline

Definition at line 51 of file DualHistoAxis.h.

51 { return uniform_ ? u_.label() : a_.label(); }

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

Referenced by rebin().

◆ leftBinEdge()

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

Definition at line 55 of file DualHistoAxis.h.

55  {
56  return uniform_ ? u_.leftBinEdge(binNum) : a_.leftBinEdge(binNum);
57  }

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

◆ length()

double npstat::DualHistoAxis::length ( ) const
inline

Definition at line 45 of file DualHistoAxis.h.

45 { return uniform_ ? u_.length() : a_.length(); }

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

◆ max()

double npstat::DualHistoAxis::max ( ) const
inline

Definition at line 41 of file DualHistoAxis.h.

41 { return uniform_ ? u_.max() : a_.max(); }

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

Referenced by rebin().

◆ min()

double npstat::DualHistoAxis::min ( ) const
inline

Definition at line 39 of file DualHistoAxis.h.

39 { return uniform_ ? u_.min() : a_.min(); }

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

Referenced by rebin().

◆ nBins()

unsigned npstat::DualHistoAxis::nBins ( ) const
inline

Definition at line 47 of file DualHistoAxis.h.

47 { return uniform_ ? u_.nBins() : a_.nBins(); }

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

◆ operator!=()

bool npstat::DualHistoAxis::operator!= ( const DualHistoAxis r) const
inline

Definition at line 104 of file DualHistoAxis.h.

104 { return !(*this == r); }

References alignCSCRings::r.

◆ operator==()

bool npstat::DualHistoAxis::operator== ( const DualHistoAxis r) const
inline

Definition at line 102 of file DualHistoAxis.h.

102 { return uniform_ == r.uniform_ && a_ == r.a_ && u_ == r.u_; }

References a_, alignCSCRings::r, u_, and uniform_.

◆ overflowIndex()

unsigned npstat::DualHistoAxis::overflowIndex ( const double  x,
unsigned *  binNumber 
) const
inlineprivate

◆ read()

DualHistoAxis * npstat::DualHistoAxis::read ( const gs::ClassId &  id,
std::istream &  in 
)
static

Definition at line 17 of file DualHistoAxis.cc.

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

References c, DualHistoAxis(), recoMuon::in, npstat::NUHistoAxis::read(), and npstat::HistoAxis::read().

Referenced by edmIntegrityCheck.PublishToFileSystem::get().

◆ rebin()

DualHistoAxis npstat::DualHistoAxis::rebin ( const unsigned  newBins) const
inline

Return uniformly rebinned axis

Definition at line 112 of file DualHistoAxis.h.

112  {
113  return DualHistoAxis(newBins, min(), max(), label().c_str());
114  }

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

◆ rightBinEdge()

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

Definition at line 59 of file DualHistoAxis.h.

59  {
60  return uniform_ ? u_.rightBinEdge(binNum) : a_.rightBinEdge(binNum);
61  }

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

◆ setLabel()

void npstat::DualHistoAxis::setLabel ( const char *  newlabel)
inline

Modify the axis label

Definition at line 81 of file DualHistoAxis.h.

81 { uniform_ ? u_.setLabel(newlabel) : a_.setLabel(newlabel); }

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

◆ version()

static unsigned npstat::DualHistoAxis::version ( )
inlinestatic

Definition at line 123 of file DualHistoAxis.h.

123 { return 1; }

Referenced by validation.Sample::datasetpattern(), and validation.Sample::filename().

◆ write()

bool npstat::DualHistoAxis::write ( std::ostream &  of) const

Definition at line 8 of file DualHistoAxis.cc.

8  {
9  unsigned char c = uniform_;
10  gs::write_pod(of, c);
11  if (uniform_)
12  return !of.fail() && u_.classId().write(of) && u_.write(of);
13  else
14  return !of.fail() && a_.classId().write(of) && a_.write(of);
15  }

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

Friends And Related Function Documentation

◆ HistoND

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

Definition at line 132 of file DualHistoAxis.h.

Member Data Documentation

◆ a_

NUHistoAxis npstat::DualHistoAxis::a_
private

◆ u_

HistoAxis npstat::DualHistoAxis::u_
private

◆ uniform_

bool npstat::DualHistoAxis::uniform_
private
npstat::DualHistoAxis::u_
HistoAxis u_
Definition: DualHistoAxis.h:128
npstat::HistoAxis::nBins
unsigned nBins() const
Definition: HistoAxis.h:45
npstat::NUHistoAxis::binNumber
int binNumber(double x) const
Definition: NUHistoAxis.cc:62
npstat::HistoAxis::isClose
bool isClose(const HistoAxis &, double tol) const
Definition: HistoAxis.cc:26
npstat::HistoAxis::binInterval
Interval< double > binInterval(const int binNum) const
Definition: HistoAxis.h:61
npstat::HistoAxis::min
double min() const
Definition: HistoAxis.h:41
npstat::NUHistoAxis::length
double length() const
Definition: NUHistoAxis.h:42
npstat::DualHistoAxis::uniform_
bool uniform_
Definition: DualHistoAxis.h:129
npstat::NUHistoAxis::overflowIndex
unsigned overflowIndex(const double x, unsigned *binNum) const
Definition: NUHistoAxis.h:117
npstat::HistoAxis::fltBinNumber
double fltBinNumber(const double x, const bool mapLeftEdgeTo0=true) const
Definition: HistoAxis.h:94
npstat::NUHistoAxis::rightBinEdge
double rightBinEdge(const int binNum) const
Definition: NUHistoAxis.h:53
npstat::NUHistoAxis::nBins
unsigned nBins() const
Definition: NUHistoAxis.h:43
DDAxes::x
npstat::HistoAxis::setLabel
void setLabel(const char *newlabel)
Definition: HistoAxis.h:66
npstat::HistoAxis::classId
gs::ClassId classId() const
Definition: HistoAxis.h:117
npstat::HistoAxis::interval
Interval< double > interval() const
Definition: HistoAxis.h:43
npstat::NUHistoAxis::read
static NUHistoAxis * read(const gs::ClassId &id, std::istream &in)
Definition: NUHistoAxis.cc:142
npstat::HistoAxis::length
double length() const
Definition: HistoAxis.h:44
npstat::NUHistoAxis::write
bool write(std::ostream &of) const
Definition: NUHistoAxis.cc:134
npstat::DualHistoAxis::max
double max() const
Definition: DualHistoAxis.h:41
npstat::DualHistoAxis::dummy_vec
static std::vector< double > dummy_vec()
Definition: DualHistoAxis.h:138
npstat::HistoAxis::write
bool write(std::ostream &of) const
Definition: HistoAxis.cc:113
npstat::HistoAxis::rightBinEdge
double rightBinEdge(const int binNum) const
Definition: HistoAxis.h:58
npstat::NUHistoAxis::classId
gs::ClassId classId() const
Definition: NUHistoAxis.h:95
npstat::NUHistoAxis::leftBinEdge
double leftBinEdge(const int binNum) const
Definition: NUHistoAxis.h:50
npstat::HistoAxis::max
double max() const
Definition: HistoAxis.h:42
mitigatedMETSequence_cff.U
U
Definition: mitigatedMETSequence_cff.py:36
npstat::DualHistoAxis::binNumber
int binNumber(const double x) const
Definition: DualHistoAxis.h:87
npstat::HistoAxis::label
const std::string & label() const
Definition: HistoAxis.h:47
npstat::NUHistoAxis::label
const std::string & label() const
Definition: NUHistoAxis.h:45
npstat::NUHistoAxis::max
double max() const
Definition: NUHistoAxis.h:40
a
double a
Definition: hdecay.h:119
npstat::NUHistoAxis::min
double min() const
Definition: NUHistoAxis.h:39
npstat::NUHistoAxis::closestValidBin
unsigned closestValidBin(double x) const
Definition: NUHistoAxis.cc:124
recoMuon::in
Definition: RecoMuonEnumerators.h:6
npstat::NUHistoAxis::binInterval
Interval< double > binInterval(const int binNum) const
Definition: NUHistoAxis.h:59
npstat::DualHistoAxis::label
const std::string & label() const
Definition: DualHistoAxis.h:51
npstat::HistoAxis::read
static HistoAxis * read(const gs::ClassId &id, std::istream &in)
Definition: HistoAxis.cc:121
npstat::NUHistoAxis::isClose
bool isClose(const NUHistoAxis &, double tol) const
Definition: NUHistoAxis.cc:45
npstat::HistoAxis::closestValidBin
unsigned closestValidBin(double x) const
Definition: HistoAxis.cc:56
npstat::NUHistoAxis::fltBinNumber
double fltBinNumber(double x, bool mapLeftEdgeTo0=true) const
Definition: NUHistoAxis.cc:67
alignCSCRings.r
r
Definition: alignCSCRings.py:93
npstat::NUHistoAxis::interval
Interval< double > interval() const
Definition: NUHistoAxis.h:41
npstat::HistoAxis::leftBinEdge
double leftBinEdge(const int binNum) const
Definition: HistoAxis.h:55
npstat::DualHistoAxis::min
double min() const
Definition: DualHistoAxis.h:39
npstat::NUHistoAxis::binWidth
double binWidth(const int binNum) const
Definition: NUHistoAxis.h:44
npstat::NUHistoAxis::binCenter
double binCenter(const int binNum) const
Definition: NUHistoAxis.h:56
npstat::HistoAxis::binCenter
double binCenter(const int binNum) const
Definition: HistoAxis.h:52
npstat::NUHistoAxis::setLabel
void setLabel(const char *newlabel)
Definition: NUHistoAxis.h:64
npstat::HistoAxis::overflowIndex
unsigned overflowIndex(const double x, unsigned *binNumber) const
Definition: HistoAxis.h:136
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:56
npstat::DualHistoAxis::a_
NUHistoAxis a_
Definition: DualHistoAxis.h:127
npstat::DualHistoAxis::nBins
unsigned nBins() const
Definition: DualHistoAxis.h:47
npstat::HistoAxis::binWidth
double binWidth(const int=0) const
Definition: HistoAxis.h:46
npstat::DualHistoAxis::DualHistoAxis
DualHistoAxis()
Definition: DualHistoAxis.h:144
npstat::HistoAxis::binNumber
int binNumber(double x) const
Definition: HistoAxis.cc:37