CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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_
static std::vector< double > dummy_vec()
Definition: DualAxis.h:108
Uniformly spaced coordinate sets for use in constructing rectangular grids.
unsigned nIntervals() const
Definition: DualAxis.h:65
gs::ClassId classId() const
Definition: DualAxis.h:95
DualAxis(const GridAxis &g)
Definition: DualAxis.h:27
double min() const
Definition: GridAxis.h:83
static const char * classname()
Definition: DualAxis.h:99
std::pair< unsigned, double > getInterval(double coordinate) const
Definition: GridAxis.cc:48
double intervalWidth(const unsigned i=0) const
Definition: GridAxis.h:88
const std::string & label() const
Definition: GridAxis.h:44
double length() const
Definition: DualAxis.h:63
unsigned nCoords() const
Definition: UniformAxis.h:33
double max() const
Definition: DualAxis.h:47
const GridAxis * getGridAxis() const
Definition: DualAxis.h:83
DualAxis(const std::vector< double > &coords, const bool useLogSpace=false)
Definition: DualAxis.h:34
double max() const
Definition: UniformAxis.h:35
double max() const
Definition: GridAxis.h:84
DualAxis(unsigned nCoords, double min, double max, const char *label=nullptr)
Definition: DualAxis.h:31
unsigned nIntervals() const
Definition: GridAxis.h:87
double coordinate(const unsigned i) const
Definition: DualAxis.h:61
double intervalWidth(const unsigned i=0) const
Definition: DualAxis.h:67
double length() const
Definition: GridAxis.h:85
UniformAxis u_
Definition: DualAxis.h:105
DualAxis(const UniformAxis &u)
Definition: DualAxis.h:29
void setLabel(const char *newlabel)
Definition: UniformAxis.h:71
std::pair< unsigned, double > getInterval(const double x) const
Definition: DualAxis.h:53
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
unsigned nIntervals() const
Definition: UniformAxis.h:61
double coordinate(unsigned i) const
Definition: UniformAxis.cc:74
double length() const
Definition: UniformAxis.h:59
double coordinate(const unsigned i) const
Definition: GridAxis.h:82
DualAxis(const std::vector< double > &coords, const char *label, const bool useLogSpace=false)
Definition: DualAxis.h:37
unsigned nCoords() const
Definition: GridAxis.h:81
std::vector< double > coords() const
Definition: DualAxis.h:71
Non-uniformly spaced coordinate sets for use in constructing rectangular grids.
bool operator!=(const DualAxis &r) const
Definition: DualAxis.h:75
const UniformAxis * getUniformAxis() const
Definition: DualAxis.h:85
const std::string & label() const
Definition: UniformAxis.h:36
bool usesLogSpace() const
Definition: GridAxis.h:45
tuple of
Definition: haddnano.py:40
bool usesLogSpace() const
Definition: UniformAxis.h:37
GridAxis a_
Definition: DualAxis.h:104
bool operator==(const DualAxis &r) const
Definition: DualAxis.h:73
static DualAxis * read(const gs::ClassId &id, std::istream &in)
Definition: DualAxis.cc:17
static unsigned version()
Definition: DualAxis.h:100
std::vector< double > coords() const
Definition: UniformAxis.cc:64
void setLabel(const char *newlabel)
Definition: DualAxis.h:91
double min() const
Definition: UniformAxis.h:34
unsigned nCoords() const
Definition: DualAxis.h:43
void setLabel(const char *newlabel)
Definition: GridAxis.h:104
bool usesLogSpace() const
Definition: DualAxis.h:51
bool write(std::ostream &of) const
Definition: DualAxis.cc:8
std::pair< unsigned, double > getInterval(double coordinate) const
Definition: UniformAxis.cc:28
std::pair< unsigned, double > linearInterval(const double x) const
Definition: DualAxis.h:57
const std::string & label() const
Definition: DualAxis.h:49
const std::vector< double > & coords() const
Definition: GridAxis.h:43
bool isUniform() const
Definition: DualAxis.h:41
double intervalWidth(unsigned) const
Definition: UniformAxis.h:62
std::pair< unsigned, double > linearInterval(double coordinate) const
Definition: GridAxis.cc:71
double min() const
Definition: DualAxis.h:45
std::pair< unsigned, double > linearInterval(double coordinate) const
Definition: UniformAxis.cc:46