CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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  {
26  public:
27  // Constructors
28  inline DualAxis(const GridAxis& g)
29  : a_(g), u_(2, 0.0, 1.0), uniform_(false) {}
30 
31  inline DualAxis(const UniformAxis& u)
32  : a_(dummy_vec()), u_(u), uniform_(true) {}
33 
34  inline DualAxis(unsigned nCoords, double min, double max,
35  const char* label=0)
36  : a_(dummy_vec()), u_(nCoords, min, max, label), uniform_(true) {}
37 
38  inline explicit DualAxis(const std::vector<double>& coords,
39  const bool useLogSpace=false)
40  : a_(coords, useLogSpace), u_(2, 0.0, 1.0), uniform_(false) {}
41 
42  inline DualAxis(const std::vector<double>& coords, const char* label,
43  const bool useLogSpace=false)
44  : a_(coords, label, useLogSpace), u_(2,0.0,1.0), uniform_(false) {}
45 
46  // Inspectors
47  inline bool isUniform() const {return uniform_;}
48 
49  inline unsigned nCoords() const
50  {return uniform_ ? u_.nCoords() : a_.nCoords();}
51 
52  inline double min() const
53  {return uniform_ ? u_.min() : a_.min();}
54 
55  inline double max() const
56  {return uniform_ ? u_.max() : a_.max();}
57 
58  inline const std::string& label() const
59  {return uniform_ ? u_.label() : a_.label();}
60 
61  inline bool usesLogSpace() const
62  {return uniform_ ? u_.usesLogSpace() : a_.usesLogSpace();}
63 
64  inline std::pair<unsigned,double> getInterval(const double x) const
65  {return uniform_ ? u_.getInterval(x) : a_.getInterval(x);}
66 
67  inline std::pair<unsigned,double> linearInterval(const double x) const
68  {return uniform_ ? u_.linearInterval(x) : a_.linearInterval(x);}
69 
70  inline double coordinate(const unsigned i) const
71  {return uniform_ ? u_.coordinate(i) : a_.coordinate(i);}
72 
73  inline double length() const
74  {return uniform_ ? u_.length() : a_.length();}
75 
76  inline unsigned nIntervals() const
77  {return uniform_ ? u_.nIntervals() : a_.nIntervals();}
78 
79  inline double intervalWidth(const unsigned i=0) const
80  {return uniform_ ? u_.intervalWidth(i) : a_.intervalWidth(i);}
81 
82  inline std::vector<double> coords() const
83  {return uniform_ ? u_.coords() : a_.coords();}
84 
85  inline bool operator==(const DualAxis& r) const
86  {return uniform_ == r.uniform_ && a_ == r.a_ && u_ == r.u_;}
87 
88  inline bool operator!=(const DualAxis& r) const
89  {return !(*this == r);}
90 
92 
97  inline const GridAxis* getGridAxis() const
98  {return uniform_ ? static_cast<const GridAxis*>(0) : &a_;}
99 
100  inline const UniformAxis* getUniformAxis() const
101  {return uniform_ ? &u_ : static_cast<const UniformAxis*>(0);}
103 
105  inline void setLabel(const char* newlabel)
106  {uniform_ ? u_.setLabel(newlabel) : a_.setLabel(newlabel);}
107 
109 
110  inline gs::ClassId classId() const {return gs::ClassId(*this);}
111  bool write(std::ostream& of) const;
113 
114  static inline const char* classname() {return "npstat::DualAxis";}
115  static inline unsigned version() {return 1;}
116  static DualAxis* read(const gs::ClassId& id, std::istream& in);
117 
118  private:
121  bool uniform_;
122 
123  inline static std::vector<double> dummy_vec()
124  {
125  std::vector<double> vec(2, 0.0);
126  vec[1] = 1.0;
127  return vec;
128  }
129 
130  inline DualAxis()
131  : a_(dummy_vec()), u_(2, 0.0, 1.0), uniform_(true) {}
132  };
133 }
134 
135 #endif // NPSTAT_DUALAXIS_HH_
136 
static std::vector< double > dummy_vec()
Definition: DualAxis.h:123
int i
Definition: DBlmapReader.cc:9
Uniformly spaced coordinate sets for use in constructing rectangular grids.
unsigned nIntervals() const
Definition: DualAxis.h:76
gs::ClassId classId() const
Definition: DualAxis.h:110
DualAxis(const GridAxis &g)
Definition: DualAxis.h:28
double min() const
Definition: GridAxis.h:87
static const char * classname()
Definition: DualAxis.h:114
std::pair< unsigned, double > getInterval(double coordinate) const
Definition: GridAxis.cc:58
double intervalWidth(const unsigned i=0) const
Definition: GridAxis.h:92
const std::string & label() const
Definition: GridAxis.h:47
double length() const
Definition: DualAxis.h:73
DualAxis(unsigned nCoords, double min, double max, const char *label=0)
Definition: DualAxis.h:34
unsigned nCoords() const
Definition: UniformAxis.h:35
double max() const
Definition: DualAxis.h:55
const GridAxis * getGridAxis() const
Definition: DualAxis.h:97
DualAxis(const std::vector< double > &coords, const bool useLogSpace=false)
Definition: DualAxis.h:38
double max() const
Definition: UniformAxis.h:37
double max() const
Definition: GridAxis.h:88
unsigned nIntervals() const
Definition: GridAxis.h:91
double coordinate(const unsigned i) const
Definition: DualAxis.h:70
double intervalWidth(const unsigned i=0) const
Definition: DualAxis.h:79
double length() const
Definition: GridAxis.h:89
UniformAxis u_
Definition: DualAxis.h:120
DualAxis(const UniformAxis &u)
Definition: DualAxis.h:31
void setLabel(const char *newlabel)
Definition: UniformAxis.h:74
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:63
double coordinate(unsigned i) const
Definition: UniformAxis.cc:81
double length() const
Definition: UniformAxis.h:61
double coordinate(const unsigned i) const
Definition: GridAxis.h:85
DualAxis(const std::vector< double > &coords, const char *label, const bool useLogSpace=false)
Definition: DualAxis.h:42
unsigned nCoords() const
Definition: GridAxis.h:84
std::vector< double > coords() const
Definition: DualAxis.h:82
Non-uniformly spaced coordinate sets for use in constructing rectangular grids.
bool operator!=(const DualAxis &r) const
Definition: DualAxis.h:88
const UniformAxis * getUniformAxis() const
Definition: DualAxis.h:100
std::pair< unsigned, double > linearInterval(const double x) const
Definition: DualAxis.h:67
const std::string & label() const
Definition: UniformAxis.h:38
bool usesLogSpace() const
Definition: GridAxis.h:48
bool usesLogSpace() const
Definition: UniformAxis.h:39
GridAxis a_
Definition: DualAxis.h:119
bool operator==(const DualAxis &r) const
Definition: DualAxis.h:85
static DualAxis * read(const gs::ClassId &id, std::istream &in)
Definition: DualAxis.cc:18
static unsigned version()
Definition: DualAxis.h:115
std::vector< double > coords() const
Definition: UniformAxis.cc:70
void setLabel(const char *newlabel)
Definition: DualAxis.h:105
double min() const
Definition: UniformAxis.h:36
unsigned nCoords() const
Definition: DualAxis.h:49
void setLabel(const char *newlabel)
Definition: GridAxis.h:110
bool usesLogSpace() const
Definition: DualAxis.h:61
bool write(std::ostream &of) const
Definition: DualAxis.cc:8
std::pair< unsigned, double > getInterval(double coordinate) const
Definition: UniformAxis.cc:30
const std::string & label() const
Definition: DualAxis.h:58
volatile std::atomic< bool > shutdown_flag false
const std::vector< double > & coords() const
Definition: GridAxis.h:46
bool isUniform() const
Definition: DualAxis.h:47
double intervalWidth(unsigned) const
Definition: UniformAxis.h:64
std::pair< unsigned, double > linearInterval(double coordinate) const
Definition: GridAxis.cc:88
double min() const
Definition: DualAxis.h:52
std::pair< unsigned, double > linearInterval(double coordinate) const
Definition: UniformAxis.cc:50
std::pair< unsigned, double > getInterval(const double x) const
Definition: DualAxis.h:64