File indexing completed on 2024-04-06 12:19:22
0001 #ifndef NPSTAT_UNIFORMAXIS_HH_
0002 #define NPSTAT_UNIFORMAXIS_HH_
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #include <vector>
0016 #include <utility>
0017 #include <string>
0018 #include <iostream>
0019
0020 #include "Alignment/Geners/interface/ClassId.hh"
0021
0022 namespace npstat {
0023
0024
0025
0026
0027 class UniformAxis {
0028 public:
0029
0030 UniformAxis(unsigned nCoords, double min, double max, const char* label = nullptr);
0031
0032
0033 inline unsigned nCoords() const { return npt_; }
0034 inline double min() const { return min_; }
0035 inline double max() const { return max_; }
0036 inline const std::string& label() const { return label_; }
0037 inline bool usesLogSpace() const { return false; }
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050 std::pair<unsigned, double> getInterval(double coordinate) const;
0051
0052
0053
0054 std::pair<unsigned, double> linearInterval(double coordinate) const;
0055
0056
0057 std::vector<double> coords() const;
0058 double coordinate(unsigned i) const;
0059 inline double length() const { return max_ - min_; }
0060 inline bool isUniform() const { return true; }
0061 inline unsigned nIntervals() const { return npt_ - 1; }
0062 inline double intervalWidth(unsigned) const { return bw_; }
0063
0064 bool operator==(const UniformAxis& r) const;
0065 inline bool operator!=(const UniformAxis& r) const { return !(*this == r); }
0066
0067
0068 bool isClose(const UniformAxis& r, double tol) const;
0069
0070
0071 inline void setLabel(const char* newlabel) { label_ = newlabel ? newlabel : ""; }
0072
0073
0074 inline gs::ClassId classId() const { return gs::ClassId(*this); }
0075 bool write(std::ostream& of) const;
0076
0077 static inline const char* classname() { return "npstat::UniformAxis"; }
0078 static inline unsigned version() { return 1; }
0079 static UniformAxis* read(const gs::ClassId& id, std::istream& in);
0080
0081 private:
0082 double min_;
0083 double max_;
0084 double bw_;
0085 std::string label_;
0086 unsigned npt_;
0087
0088 inline UniformAxis() : min_(0.), max_(0.), bw_(0.), npt_(0) {}
0089 };
0090 }
0091
0092 #endif