CMS 3D CMS Logo

DualAxis.h
Go to the documentation of this file.
1 #ifndef NPSTAT_DUALAXIS_HH_
2 #define NPSTAT_DUALAXIS_HH_
3 
17 
18 namespace npstat {
24  class DualAxis {
25  public:
26  // Constructors
27  inline DualAxis(const GridAxis& g) : a_(g), u_(2, 0.0, 1.0), uniform_(false) {}
28 
29  inline DualAxis(const UniformAxis& u) : a_(dummy_vec()), u_(u), uniform_(true) {}
30 
31  inline DualAxis(unsigned nCoords, double min, double max, const char* label = nullptr)
32  : a_(dummy_vec()), u_(nCoords, min, max, label), uniform_(true) {}
33 
34  inline explicit DualAxis(const std::vector<double>& coords, const bool useLogSpace = false)
35  : a_(coords, useLogSpace), u_(2, 0.0, 1.0), uniform_(false) {}
36 
37  inline DualAxis(const std::vector<double>& coords, const char* label, const bool useLogSpace = false)
38  : a_(coords, label, useLogSpace), u_(2, 0.0, 1.0), uniform_(false) {}
39 
40  // Inspectors
41  inline bool isUniform() const { return uniform_; }
42 
43  inline unsigned nCoords() const { return uniform_ ? u_.nCoords() : a_.nCoords(); }
44 
45  inline double min() const { return uniform_ ? u_.min() : a_.min(); }
46 
47  inline double max() const { return uniform_ ? u_.max() : a_.max(); }
48 
49  inline const std::string& label() const { return uniform_ ? u_.label() : a_.label(); }
50 
51  inline bool usesLogSpace() const { return uniform_ ? u_.usesLogSpace() : a_.usesLogSpace(); }
52 
53  inline std::pair<unsigned, double> getInterval(const double x) const {
54  return uniform_ ? u_.getInterval(x) : a_.getInterval(x);
55  }
56 
57  inline std::pair<unsigned, double> linearInterval(const double x) const {
58  return uniform_ ? u_.linearInterval(x) : a_.linearInterval(x);
59  }
60 
61  inline double coordinate(const unsigned i) const { return uniform_ ? u_.coordinate(i) : a_.coordinate(i); }
62 
63  inline double length() const { return uniform_ ? u_.length() : a_.length(); }
64 
65  inline unsigned nIntervals() const { return uniform_ ? u_.nIntervals() : a_.nIntervals(); }
66 
67  inline double intervalWidth(const unsigned i = 0) const {
69  }
70 
71  inline std::vector<double> coords() const { return uniform_ ? u_.coords() : a_.coords(); }
72 
73  inline bool operator==(const DualAxis& r) const { return uniform_ == r.uniform_ && a_ == r.a_ && u_ == r.u_; }
74 
75  inline bool operator!=(const DualAxis& r) const { return !(*this == r); }
76 
78 
83  inline const GridAxis* getGridAxis() const { return uniform_ ? static_cast<const GridAxis*>(nullptr) : &a_; }
84 
85  inline const UniformAxis* getUniformAxis() const {
86  return uniform_ ? &u_ : static_cast<const UniformAxis*>(nullptr);
87  }
89 
91  inline void setLabel(const char* newlabel) { uniform_ ? u_.setLabel(newlabel) : a_.setLabel(newlabel); }
92 
94 
95  inline gs::ClassId classId() const { return gs::ClassId(*this); }
96  bool write(std::ostream& of) const;
98 
99  static inline const char* classname() { return "npstat::DualAxis"; }
100  static inline unsigned version() { return 1; }
101  static DualAxis* read(const gs::ClassId& id, std::istream& in);
102 
103  private:
106  bool uniform_;
107 
108  inline static std::vector<double> dummy_vec() {
109  std::vector<double> vec(2, 0.0);
110  vec[1] = 1.0;
111  return vec;
112  }
113 
114  inline DualAxis() : a_(dummy_vec()), u_(2, 0.0, 1.0), uniform_(true) {}
115  };
116 } // namespace npstat
117 
118 #endif // NPSTAT_DUALAXIS_HH_
UniformAxis.h
Uniformly spaced coordinate sets for use in constructing rectangular grids.
npstat::UniformAxis::coords
std::vector< double > coords() const
Definition: UniformAxis.cc:64
npstat::UniformAxis::max
double max() const
Definition: UniformAxis.h:35
npstat::DualAxis::nIntervals
unsigned nIntervals() const
Definition: DualAxis.h:65
mps_fire.i
i
Definition: mps_fire.py:428
npstat::UniformAxis
Definition: UniformAxis.h:27
npstat::UniformAxis::length
double length() const
Definition: UniformAxis.h:59
npstat::DualAxis::a_
GridAxis a_
Definition: DualAxis.h:104
funct::false
false
Definition: Factorize.h:29
npstat::DualAxis::version
static unsigned version()
Definition: DualAxis.h:100
npstat::DualAxis::getInterval
std::pair< unsigned, double > getInterval(const double x) const
Definition: DualAxis.h:53
GridAxis.h
Non-uniformly spaced coordinate sets for use in constructing rectangular grids.
npstat::GridAxis::coords
const std::vector< double > & coords() const
Definition: GridAxis.h:43
npstat::DualAxis::DualAxis
DualAxis(unsigned nCoords, double min, double max, const char *label=nullptr)
Definition: DualAxis.h:31
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::DualAxis::length
double length() const
Definition: DualAxis.h:63
npstat::DualAxis::coordinate
double coordinate(const unsigned i) const
Definition: DualAxis.h:61
npstat::DualAxis::DualAxis
DualAxis(const std::vector< double > &coords, const char *label, const bool useLogSpace=false)
Definition: DualAxis.h:37
npstat::DualAxis::write
bool write(std::ostream &of) const
Definition: DualAxis.cc:8
npstat::GridAxis::usesLogSpace
bool usesLogSpace() const
Definition: GridAxis.h:45
npstat::GridAxis::nIntervals
unsigned nIntervals() const
Definition: GridAxis.h:87
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
Definition: AbsArrayProjector.h:14
npstat::DualAxis::usesLogSpace
bool usesLogSpace() const
Definition: DualAxis.h:51
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::DualAxis::linearInterval
std::pair< unsigned, double > linearInterval(const double x) const
Definition: DualAxis.h:57
npstat::UniformAxis::nCoords
unsigned nCoords() const
Definition: UniformAxis.h:33
npstat::DualAxis::operator==
bool operator==(const DualAxis &r) const
Definition: DualAxis.h:73
npstat::DualAxis::classname
static const char * classname()
Definition: DualAxis.h:99
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
npstat::DualAxis::DualAxis
DualAxis()
Definition: DualAxis.h:114
npstat::GridAxis::intervalWidth
double intervalWidth(const unsigned i=0) const
Definition: GridAxis.h:88
funct::true
true
Definition: Factorize.h:173
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
npstat::DualAxis::intervalWidth
double intervalWidth(const unsigned i=0) const
Definition: DualAxis.h:67
npstat::DualAxis::getGridAxis
const GridAxis * getGridAxis() const
Definition: DualAxis.h:83
recoMuon::in
Definition: RecoMuonEnumerators.h:6
npstat::GridAxis::setLabel
void setLabel(const char *newlabel)
Definition: GridAxis.h:104
npstat::DualAxis::DualAxis
DualAxis(const UniformAxis &u)
Definition: DualAxis.h:29
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::DualAxis::DualAxis
DualAxis(const std::vector< double > &coords, const bool useLogSpace=false)
Definition: DualAxis.h:34
npstat::DualAxis::getUniformAxis
const UniformAxis * getUniformAxis() const
Definition: DualAxis.h:85
npstat::DualAxis::setLabel
void setLabel(const char *newlabel)
Definition: DualAxis.h:91
npstat::DualAxis
Definition: DualAxis.h:24
npstat::UniformAxis::linearInterval
std::pair< unsigned, double > linearInterval(double coordinate) const
Definition: UniformAxis.cc:46
npstat::DualAxis::isUniform
bool isUniform() const
Definition: DualAxis.h:41
npstat::UniformAxis::nIntervals
unsigned nIntervals() const
Definition: UniformAxis.h:61
npstat::DualAxis::read
static DualAxis * read(const gs::ClassId &id, std::istream &in)
Definition: DualAxis.cc:17
npstat::DualAxis::classId
gs::ClassId classId() const
Definition: DualAxis.h:95
npstat::UniformAxis::min
double min() const
Definition: UniformAxis.h:34
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
npstat::DualAxis::operator!=
bool operator!=(const DualAxis &r) const
Definition: DualAxis.h:75
npstat::DualAxis::DualAxis
DualAxis(const GridAxis &g)
Definition: DualAxis.h:27
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
npstat::GridAxis
Definition: GridAxis.h:30