CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes
npstat::DualAxis Class Reference

#include <DualAxis.h>

Public Member Functions

gs::ClassId classId () const
 
double coordinate (const unsigned i) const
 
std::vector< double > coords () const
 
 DualAxis (const GridAxis &g)
 
 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 UniformAxis &u)
 
 DualAxis (unsigned nCoords, double min, double max, const char *label=nullptr)
 
const GridAxisgetGridAxis () const
 
std::pair< unsigned, double > getInterval (const double x) const
 
const UniformAxisgetUniformAxis () 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
 
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

◆ DualAxis() [1/6]

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

Definition at line 27 of file DualAxis.h.

27 : a_(g), u_(2, 0.0, 1.0), uniform_(false) {}

◆ DualAxis() [2/6]

npstat::DualAxis::DualAxis ( const UniformAxis u)
inline

Definition at line 29 of file DualAxis.h.

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

◆ DualAxis() [3/6]

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

Definition at line 31 of file DualAxis.h.

32  : a_(dummy_vec()), u_(nCoords, min, max, label), uniform_(true) {}

◆ DualAxis() [4/6]

npstat::DualAxis::DualAxis ( const std::vector< double > &  coords,
const bool  useLogSpace = false 
)
inlineexplicit

Definition at line 34 of file DualAxis.h.

35  : a_(coords, useLogSpace), u_(2, 0.0, 1.0), uniform_(false) {}

◆ DualAxis() [5/6]

npstat::DualAxis::DualAxis ( const std::vector< double > &  coords,
const char *  label,
const bool  useLogSpace = false 
)
inline

Definition at line 37 of file DualAxis.h.

38  : a_(coords, label, useLogSpace), u_(2, 0.0, 1.0), uniform_(false) {}

◆ DualAxis() [6/6]

npstat::DualAxis::DualAxis ( )
inlineprivate

Definition at line 114 of file DualAxis.h.

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

Referenced by read().

Member Function Documentation

◆ classId()

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

Method related to "geners" I/O

Definition at line 95 of file DualAxis.h.

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

◆ classname()

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

Definition at line 99 of file DualAxis.h.

99 { return "npstat::DualAxis"; }

◆ coordinate()

double npstat::DualAxis::coordinate ( const unsigned  i) const
inline

◆ coords()

std::vector<double> npstat::DualAxis::coords ( ) const
inline

Definition at line 71 of file DualAxis.h.

71 { return uniform_ ? u_.coords() : a_.coords(); }

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

◆ dummy_vec()

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

Definition at line 108 of file DualAxis.h.

108  {
109  std::vector<double> vec(2, 0.0);
110  vec[1] = 1.0;
111  return vec;
112  }

◆ getGridAxis()

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 83 of file DualAxis.h.

83 { return uniform_ ? static_cast<const GridAxis*>(nullptr) : &a_; }

References a_, and uniform_.

◆ getInterval()

std::pair<unsigned, double> npstat::DualAxis::getInterval ( const double  x) const
inline

Definition at line 53 of file DualAxis.h.

53  {
54  return uniform_ ? u_.getInterval(x) : a_.getInterval(x);
55  }

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

◆ getUniformAxis()

const UniformAxis* npstat::DualAxis::getUniformAxis ( ) const
inline

Definition at line 85 of file DualAxis.h.

85  {
86  return uniform_ ? &u_ : static_cast<const UniformAxis*>(nullptr);
87  }

References u_, and uniform_.

◆ intervalWidth()

double npstat::DualAxis::intervalWidth ( const unsigned  i = 0) const
inline

Definition at line 67 of file DualAxis.h.

67  {
69  }

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

◆ isUniform()

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

Definition at line 41 of file DualAxis.h.

41 { return uniform_; }

References uniform_.

◆ label()

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

Definition at line 49 of file DualAxis.h.

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

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

◆ length()

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

Definition at line 63 of file DualAxis.h.

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

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

◆ linearInterval()

std::pair<unsigned, double> npstat::DualAxis::linearInterval ( const double  x) const
inline

Definition at line 57 of file DualAxis.h.

57  {
59  }

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

◆ max()

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

Definition at line 47 of file DualAxis.h.

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

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

◆ min()

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

Definition at line 45 of file DualAxis.h.

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

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

◆ nCoords()

unsigned npstat::DualAxis::nCoords ( ) const
inline

Definition at line 43 of file DualAxis.h.

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

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

◆ nIntervals()

unsigned npstat::DualAxis::nIntervals ( ) const
inline

Definition at line 65 of file DualAxis.h.

65 { return uniform_ ? u_.nIntervals() : a_.nIntervals(); }

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

◆ operator!=()

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

Definition at line 75 of file DualAxis.h.

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

References alignCSCRings::r.

◆ operator==()

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

Definition at line 73 of file DualAxis.h.

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

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

◆ read()

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

Definition at line 17 of file DualAxis.cc.

17  {
18  static const gs::ClassId current(gs::ClassId::makeId<DualAxis>());
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::DualAxis::read: "
27  "input stream failure");
28  if (c) {
29  CPP11_auto_ptr<UniformAxis> axis(UniformAxis::read(clid, in));
30  return new DualAxis(*axis);
31  } else {
32  CPP11_auto_ptr<GridAxis> axis(GridAxis::read(clid, in));
33  return new DualAxis(*axis);
34  }
35  }

References HltBtagPostValidation_cff::c, DualAxis(), recoMuon::in, npstat::UniformAxis::read(), and npstat::GridAxis::read().

Referenced by edmIntegrityCheck.PublishToFileSystem::get().

◆ setLabel()

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

Modify the axis label

Definition at line 91 of file DualAxis.h.

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

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

◆ usesLogSpace()

bool npstat::DualAxis::usesLogSpace ( ) const
inline

Definition at line 51 of file DualAxis.h.

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

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

◆ version()

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

Definition at line 100 of file DualAxis.h.

100 { return 1; }

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

◆ write()

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

Definition at line 8 of file DualAxis.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_, HltBtagPostValidation_cff::c, npstat::UniformAxis::classId(), npstat::GridAxis::classId(), u_, uniform_, npstat::UniformAxis::write(), and npstat::GridAxis::write().

Member Data Documentation

◆ a_

GridAxis npstat::DualAxis::a_
private

◆ u_

UniformAxis npstat::DualAxis::u_
private

◆ uniform_

bool npstat::DualAxis::uniform_
private
npstat::UniformAxis::coords
std::vector< double > coords() const
Definition: UniformAxis.cc:64
npstat::UniformAxis::max
double max() const
Definition: UniformAxis.h:35
mps_fire.i
i
Definition: mps_fire.py:355
npstat::UniformAxis::length
double length() const
Definition: UniformAxis.h:59
npstat::DualAxis::a_
GridAxis a_
Definition: DualAxis.h:104
npstat::GridAxis::coords
const std::vector< double > & coords() const
Definition: GridAxis.h:43
npstat::DualAxis::nCoords
unsigned nCoords() const
Definition: DualAxis.h:43
npstat::DualAxis::label
const std::string & label() const
Definition: DualAxis.h:49
npstat::DualAxis::coords
std::vector< double > coords() const
Definition: DualAxis.h:71
npstat::GridAxis::usesLogSpace
bool usesLogSpace() const
Definition: GridAxis.h:45
npstat::GridAxis::nIntervals
unsigned nIntervals() const
Definition: GridAxis.h:87
DDAxes::x
npstat::UniformAxis::coordinate
double coordinate(unsigned i) const
Definition: UniformAxis.cc:74
npstat::UniformAxis::label
const std::string & label() const
Definition: UniformAxis.h:36
npstat::UniformAxis::getInterval
std::pair< unsigned, double > getInterval(double coordinate) const
Definition: UniformAxis.cc:28
npstat::GridAxis::length
double length() const
Definition: GridAxis.h:85
npstat::GridAxis::linearInterval
std::pair< unsigned, double > linearInterval(double coordinate) const
Definition: GridAxis.cc:71
npstat::DualAxis::uniform_
bool uniform_
Definition: DualAxis.h:106
npstat::UniformAxis::read
static UniformAxis * read(const gs::ClassId &id, std::istream &in)
Definition: UniformAxis.cc:100
npstat::GridAxis::read
static GridAxis * read(const gs::ClassId &id, std::istream &in)
Definition: GridAxis.cc:117
npstat::UniformAxis::classId
gs::ClassId classId() const
Definition: UniformAxis.h:74
npstat::UniformAxis::nCoords
unsigned nCoords() const
Definition: UniformAxis.h:33
npstat::GridAxis::classId
gs::ClassId classId() const
Definition: GridAxis.h:108
npstat::DualAxis::DualAxis
DualAxis()
Definition: DualAxis.h:114
npstat::GridAxis::intervalWidth
double intervalWidth(const unsigned i=0) const
Definition: GridAxis.h:88
npstat::GridAxis::max
double max() const
Definition: GridAxis.h:84
npstat::GridAxis::min
double min() const
Definition: GridAxis.h:83
npstat::UniformAxis::setLabel
void setLabel(const char *newlabel)
Definition: UniformAxis.h:71
npstat::GridAxis::coordinate
double coordinate(const unsigned i) const
Definition: GridAxis.h:82
recoMuon::in
Definition: RecoMuonEnumerators.h:6
npstat::GridAxis::setLabel
void setLabel(const char *newlabel)
Definition: GridAxis.h:104
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
npstat::UniformAxis::write
bool write(std::ostream &of) const
Definition: UniformAxis.cc:92
npstat::DualAxis::max
double max() const
Definition: DualAxis.h:47
alignCSCRings.r
r
Definition: alignCSCRings.py:93
npstat::GridAxis::getInterval
std::pair< unsigned, double > getInterval(double coordinate) const
Definition: GridAxis.cc:48
npstat::UniformAxis::intervalWidth
double intervalWidth(unsigned) const
Definition: UniformAxis.h:62
npstat::DualAxis::u_
UniformAxis u_
Definition: DualAxis.h:105
npstat::DualAxis::min
double min() const
Definition: DualAxis.h:45
npstat::UniformAxis::linearInterval
std::pair< unsigned, double > linearInterval(double coordinate) const
Definition: UniformAxis.cc:46
npstat::UniformAxis::nIntervals
unsigned nIntervals() const
Definition: UniformAxis.h:61
npstat::UniformAxis::min
double min() const
Definition: UniformAxis.h:34
npstat::GridAxis::write
bool write(std::ostream &of) const
Definition: GridAxis.cc:108
npstat::GridAxis::nCoords
unsigned nCoords() const
Definition: GridAxis.h:81
npstat::DualAxis::dummy_vec
static std::vector< double > dummy_vec()
Definition: DualAxis.h:108
npstat::UniformAxis::usesLogSpace
bool usesLogSpace() const
Definition: UniformAxis.h:37
g
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
Definition: Activities.doc:4
npstat::GridAxis::label
const std::string & label() const
Definition: GridAxis.h:44