test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
KDTreeLinkerToolsT.h
Go to the documentation of this file.
1 #ifndef KDTreeLinkerToolsTemplated_h
2 #define KDTreeLinkerToolsTemplated_h
3 
4 #include <array>
5 
6 // Box structure used to define 2D field.
7 // It's used in KDTree building step to divide the detector
8 // space (ECAL, HCAL...) and in searching step to create a bounding
9 // box around the demanded point (Track collision point, PS projection...).
10 template<unsigned DIM>
11 struct KDTreeBoxT
12 {
13  std::array<float,DIM> dimmin, dimmax;
14 
15  template<typename... Ts>
16  KDTreeBoxT(Ts... dimargs) {
17  static_assert(sizeof...(dimargs) == 2*DIM,"Constructor requires 2*DIM args");
18  std::vector<float> dims = {dimargs...};
19  for( unsigned i = 0; i < DIM; ++i ) {
20  dimmin[i] = dims[2*i];
21  dimmax[i] = dims[2*i+1];
22  }
23  }
24 
26 };
27 
30 
31 
32 // Data stored in each KDTree node.
33 // The dim1/dim2 fields are usually the duplication of some PFRecHit values
34 // (eta/phi or x/y). But in some situations, phi field is shifted by +-2.Pi
35 template<typename DATA,unsigned DIM>
37 {
39  std::array<float,DIM> dims;
40 
41 public:
43  {}
44 
45  template<typename... Ts>
46  KDTreeNodeInfoT(const DATA& d,Ts... dimargs)
47  : data(d), dims{ {dimargs...} }
48  {}
49  template<typename... Ts>
50  bool operator > (const KDTreeNodeInfoT& rhs) const {
51  return (data > rhs.data);
52  }
53 };
54 
55 // KDTree node.
56 template <typename DATA, unsigned DIM>
58 {
59  // Data
61 
62  // Right/left sons.
64 
65  // Region bounding box.
67 
68  public:
70  : left(0), right(0)
71  {}
72 
73  void setAttributs(const KDTreeBoxT<DIM>& regionBox,
74  const KDTreeNodeInfoT<DATA,DIM>& infoToStore)
75  {
76  info = infoToStore;
77  region = regionBox;
78  }
79 
80  void setAttributs(const KDTreeBoxT<DIM>& regionBox)
81  {
82  region = regionBox;
83  }
84 };
85 
86 #endif
int i
Definition: DBlmapReader.cc:9
KDTreeBoxT< 3 > KDTreeCube
KDTreeNodeT< DATA, DIM > * right
KDTreeNodeT< DATA, DIM > * left
std::array< float, DIM > dimmin
tuple d
Definition: ztail.py:151
bool operator>(View< T > const &, View< T > const &)
Definition: View.h:377
KDTreeBoxT< DIM > region
KDTreeBoxT< 2 > KDTreeBox
std::array< float, DIM > dims
void setAttributs(const KDTreeBoxT< DIM > &regionBox)
#define DIM
KDTreeNodeInfoT< DATA, DIM > info
KDTreeBoxT(Ts...dimargs)
std::array< float, DIM > dimmax
void setAttributs(const KDTreeBoxT< DIM > &regionBox, const KDTreeNodeInfoT< DATA, DIM > &infoToStore)
KDTreeNodeInfoT(const DATA &d, Ts...dimargs)