CMS 3D CMS Logo

FKDPoint.h
Go to the documentation of this file.
1 #ifndef COMMONTOOLS_RECOALGOS_FKDPOINT_H
2 #define COMMONTOOLS_RECOALGOS_FKDPOINT_H
3 #include <array>
4 #include <utility>
5 
6 //a K-dimensional point to interface with the FKDTree class
7 template <class TYPE, int numberOfDimensions>
8 class FKDPoint {
9 public:
10  FKDPoint() : theElements(), theId(0) {}
11 
12  FKDPoint(TYPE x, TYPE y, unsigned int id = 0) {
13  static_assert(numberOfDimensions == 2, "FKDPoint number of arguments does not match the number of dimensions");
14 
15  theId = id;
16  theElements[0] = x;
17  theElements[1] = y;
18  }
19 
20  FKDPoint(TYPE x, TYPE y, TYPE z, unsigned int id = 0) {
21  static_assert(numberOfDimensions == 3, "FKDPoint number of arguments does not match the number of dimensions");
22 
23  theId = id;
24  theElements[0] = x;
25  theElements[1] = y;
26  theElements[2] = z;
27  }
28 
29  FKDPoint(TYPE x, TYPE y, TYPE z, TYPE w, unsigned int id = 0) {
30  static_assert(numberOfDimensions == 4, "FKDPoint number of arguments does not match the number of dimensions");
31  theId = id;
32  theElements[0] = x;
33  theElements[1] = y;
34  theElements[2] = z;
35  theElements[3] = w;
36  }
37 
38  // the user should check that i < numberOfDimensions
39  TYPE& operator[](unsigned int const i) { return theElements[i]; }
40 
41  TYPE const& operator[](unsigned int const i) const { return theElements[i]; }
42 
43  void setDimension(unsigned int i, const TYPE& value) { theElements[i] = value; }
44 
45  void setId(const unsigned int id) { theId = id; }
46 
47  unsigned int getId() const { return theId; }
48 
49 private:
50  std::array<TYPE, numberOfDimensions> theElements;
51  unsigned int theId;
52 };
53 
54 #endif
DDAxes::y
mps_fire.i
i
Definition: mps_fire.py:428
FKDPoint::setId
void setId(const unsigned int id)
Definition: FKDPoint.h:45
FKDPoint::FKDPoint
FKDPoint(TYPE x, TYPE y, TYPE z, TYPE w, unsigned int id=0)
Definition: FKDPoint.h:29
DDAxes::x
w
const double w
Definition: UKUtility.cc:23
FKDPoint::FKDPoint
FKDPoint(TYPE x, TYPE y, TYPE z, unsigned int id=0)
Definition: FKDPoint.h:20
FKDPoint::operator[]
TYPE const & operator[](unsigned int const i) const
Definition: FKDPoint.h:41
DDAxes::z
FKDPoint
Definition: FKDPoint.h:8
FKDPoint::FKDPoint
FKDPoint()
Definition: FKDPoint.h:10
value
Definition: value.py:1
FKDPoint::getId
unsigned int getId() const
Definition: FKDPoint.h:47
FKDPoint::operator[]
TYPE & operator[](unsigned int const i)
Definition: FKDPoint.h:39
FKDPoint::setDimension
void setDimension(unsigned int i, const TYPE &value)
Definition: FKDPoint.h:43
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
relativeConstraints.value
value
Definition: relativeConstraints.py:53
runonSM.TYPE
TYPE
Definition: runonSM.py:21
FKDPoint::theElements
std::array< TYPE, numberOfDimensions > theElements
Definition: FKDPoint.h:50
FKDPoint::theId
unsigned int theId
Definition: FKDPoint.h:51
FKDPoint::FKDPoint
FKDPoint(TYPE x, TYPE y, unsigned int id=0)
Definition: FKDPoint.h:12