Go to the documentation of this file.00001 #ifndef NPSTAT_UNIFORMAXIS_HH_
00002 #define NPSTAT_UNIFORMAXIS_HH_
00003
00015 #include <vector>
00016 #include <utility>
00017 #include <string>
00018 #include <iostream>
00019
00020 #include "Alignment/Geners/interface/ClassId.hh"
00021
00022 namespace npstat {
00027 class UniformAxis
00028 {
00029 public:
00030
00031 UniformAxis(unsigned nCoords, double min, double max,
00032 const char* label=0);
00033
00034
00035 inline unsigned nCoords() const {return npt_;}
00036 inline double min() const {return min_;}
00037 inline double max() const {return max_;}
00038 inline const std::string& label() const {return label_;}
00039 inline bool usesLogSpace() const {return false;}
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052 std::pair<unsigned,double> getInterval(double coordinate) const;
00053
00054
00055
00056 std::pair<unsigned,double> linearInterval(double coordinate) const;
00057
00058
00059 std::vector<double> coords() const;
00060 double coordinate(unsigned i) const;
00061 inline double length() const {return max_ - min_;}
00062 inline bool isUniform() const {return true;}
00063 inline unsigned nIntervals() const {return npt_ - 1;}
00064 inline double intervalWidth(unsigned) const {return bw_;}
00065
00066 bool operator==(const UniformAxis& r) const;
00067 inline bool operator!=(const UniformAxis& r) const
00068 {return !(*this == r);}
00069
00070
00071 bool isClose(const UniformAxis& r, double tol) const;
00072
00073
00074 inline void setLabel(const char* newlabel)
00075 {label_ = newlabel ? newlabel : "";}
00076
00077
00078 inline gs::ClassId classId() const {return gs::ClassId(*this);}
00079 bool write(std::ostream& of) const;
00080
00081 static inline const char* classname() {return "npstat::UniformAxis";}
00082 static inline unsigned version() {return 1;}
00083 static UniformAxis* read(const gs::ClassId& id, std::istream& in);
00084
00085 private:
00086 inline UniformAxis() : min_(0.), max_(0.), bw_(0.), npt_(0) {}
00087
00088 double min_;
00089 double max_;
00090 double bw_;
00091 std::string label_;
00092 unsigned npt_;
00093
00094 };
00095 }
00096
00097 #endif // NPSTAT_UNIFORMAXIS_HH_
00098