CMS 3D CMS Logo

GridAxis.h
Go to the documentation of this file.
1 #ifndef NPSTAT_GRIDAXIS_HH_
2 #define NPSTAT_GRIDAXIS_HH_
3 
15 #include <vector>
16 #include <utility>
17 #include <string>
18 #include <iostream>
19 
20 #include "Alignment/Geners/interface/ClassId.hh"
21 
22 namespace npstat {
30  class GridAxis {
31  public:
33 
37  explicit GridAxis(const std::vector<double>& coords, bool useLogSpace = false);
38  GridAxis(const std::vector<double>& coords, const char* label, bool useLogSpace = false);
40 
42 
43  inline const std::vector<double>& coords() const { return coords_; }
44  inline const std::string& label() const { return label_; }
45  inline bool usesLogSpace() const { return useLogSpace_; }
47 
61  std::pair<unsigned, double> getInterval(double coordinate) const;
62 
77  std::pair<unsigned, double> linearInterval(double coordinate) const;
78 
80 
81  inline unsigned nCoords() const { return npt_; }
82  inline double coordinate(const unsigned i) const { return coords_.at(i); }
83  inline double min() const { return coords_.front(); }
84  inline double max() const { return coords_.back(); }
85  inline double length() const { return coords_.back() - coords_.front(); }
86  inline bool isUniform() const { return false; }
87  inline unsigned nIntervals() const { return coords_.size() - 1; }
88  inline double intervalWidth(const unsigned i = 0) const { return coords_.at(i + 1) - coords_.at(i); }
90 
92  bool operator==(const GridAxis& r) const;
93 
95  inline bool operator!=(const GridAxis& r) const { return !(*this == r); }
96 
101  bool isClose(const GridAxis& r, double tol) const;
102 
104  inline void setLabel(const char* newlabel) { label_ = newlabel ? newlabel : ""; }
105 
107 
108  inline gs::ClassId classId() const { return gs::ClassId(*this); }
109  bool write(std::ostream& of) const;
111 
112  static inline const char* classname() { return "npstat::GridAxis"; }
113  static inline unsigned version() { return 2; }
114  static GridAxis* read(const gs::ClassId& id, std::istream& in);
115 
116  private:
117  void initialize();
118 
119  std::vector<double> coords_;
120  std::vector<double> logs_;
122  unsigned npt_;
124 
125  inline GridAxis() : npt_(0), useLogSpace_(false) {}
126  };
127 } // namespace npstat
128 
129 #endif // NPSTAT_GRIDAXIS_HH_
mps_fire.i
i
Definition: mps_fire.py:428
funct::false
false
Definition: Factorize.h:29
npstat::GridAxis::npt_
unsigned npt_
Definition: GridAxis.h:122
npstat::GridAxis::operator==
bool operator==(const GridAxis &r) const
Definition: GridAxis.cc:137
npstat::GridAxis::coords
const std::vector< double > & coords() const
Definition: GridAxis.h:43
npstat::GridAxis::operator!=
bool operator!=(const GridAxis &r) const
Definition: GridAxis.h:95
npstat::GridAxis::classname
static const char * classname()
Definition: GridAxis.h:112
npstat::GridAxis::usesLogSpace
bool usesLogSpace() const
Definition: GridAxis.h:45
npstat::GridAxis::initialize
void initialize()
Definition: GridAxis.cc:12
npstat::GridAxis::nIntervals
unsigned nIntervals() const
Definition: GridAxis.h:87
npstat::GridAxis::length
double length() const
Definition: GridAxis.h:85
npstat
Definition: AbsArrayProjector.h:14
npstat::GridAxis::linearInterval
std::pair< unsigned, double > linearInterval(double coordinate) const
Definition: GridAxis.cc:71
npstat::GridAxis::read
static GridAxis * read(const gs::ClassId &id, std::istream &in)
Definition: GridAxis.cc:117
npstat::GridAxis::classId
gs::ClassId classId() const
Definition: GridAxis.h:108
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
npstat::GridAxis::intervalWidth
double intervalWidth(const unsigned i=0) const
Definition: GridAxis.h:88
npstat::GridAxis::max
double max() const
Definition: GridAxis.h:84
npstat::GridAxis::min
double min() const
Definition: GridAxis.h:83
npstat::GridAxis::coordinate
double coordinate(const unsigned i) const
Definition: GridAxis.h:82
npstat::GridAxis::useLogSpace_
bool useLogSpace_
Definition: GridAxis.h:123
npstat::GridAxis::isUniform
bool isUniform() const
Definition: GridAxis.h:86
recoMuon::in
Definition: RecoMuonEnumerators.h:6
npstat::GridAxis::setLabel
void setLabel(const char *newlabel)
Definition: GridAxis.h:104
npstat::GridAxis::label_
std::string label_
Definition: GridAxis.h:121
alignCSCRings.r
r
Definition: alignCSCRings.py:93
npstat::GridAxis::getInterval
std::pair< unsigned, double > getInterval(double coordinate) const
Definition: GridAxis.cc:48
npstat::GridAxis::isClose
bool isClose(const GridAxis &r, double tol) const
Definition: GridAxis.cc:141
npstat::GridAxis::coords_
std::vector< double > coords_
Definition: GridAxis.h:119
npstat::GridAxis::write
bool write(std::ostream &of) const
Definition: GridAxis.cc:108
npstat::GridAxis::nCoords
unsigned nCoords() const
Definition: GridAxis.h:81
npstat::GridAxis::GridAxis
GridAxis()
Definition: GridAxis.h:125
npstat::GridAxis::version
static unsigned version()
Definition: GridAxis.h:113
npstat::GridAxis::logs_
std::vector< double > logs_
Definition: GridAxis.h:120
npstat::GridAxis::label
const std::string & label() const
Definition: GridAxis.h:44
npstat::GridAxis
Definition: GridAxis.h:30