ATLAS Offline Software
Loading...
Searching...
No Matches
TiledEtaPhiMap.h
Go to the documentation of this file.
1// emacs, this is -*- C++ -*-
2
3/*
4 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
5*/
6
16
17#ifndef JETUTIL_TILEDETAPHIMAP_H
18#define JETUTIL_TILEDETAPHIMAP_H
19
20
21#include <list>
22#include <vector>
23
24#include <cmath>
25
26
28
29namespace JetTiledMap {
30
31 struct utils {
32 static constexpr double DR2(double eta1, double phi1, double eta2,double phi2) {
33 double deta = eta1 - eta2;
34 constexpr double pi = M_PI;
35 constexpr double twopi = 2.0*pi;
36 double dphi = phi1 - phi2;
37 while ( dphi > pi ) dphi -= twopi;
38 while ( dphi <= -pi ) dphi += twopi;
39 return dphi*dphi + deta*deta;
40 }
41 };
42
44 N=0, NE,E,SE,S,SW,W,NW
45 };
46
47
52 template<class POINT, class DIST2>
53 class Tile : public std::list<POINT> {
54 public:
55 typedef typename std::list<POINT> tilecontainerbase_t;
56 typedef typename tilecontainerbase_t::iterator iterator;
57 typedef typename tilecontainerbase_t::const_iterator const_iterator;
58 typedef typename std::vector<POINT> pointvec_t;
59
60 Tile() = default;
61 Tile(POINT tileCenter) : center(tileCenter) {}
62
64 void fillPointsInDr2(POINT &p, double r2, pointvec_t& points ) const;
65
67 static const Tile voidTile;
68 public:
69 const Tile<POINT,DIST2>* m_neighbour[8] = {nullptr};
70 static const DIST2 dr2;
71 POINT center;
72 };
73
74
75
76
84 template<class POINT, class DIST2 = typename POINT::DR2>
86 public:
88
89 public:
91 virtual ~TiledEtaPhiMap(){}
92 void init(double rmax);
93
94 void insert(POINT & p);
95
97 std::vector<POINT> pointsInDr(POINT &p, double r) const ;
98
99 virtual void clear();
100
101 virtual void reset(){m_tiles.clear();m_size=0;}
102
103 unsigned int size()const {return m_size;} ;
104
106
107 protected:
108
109 double m_etarange{} ;
111 double m_rmax{};
112 size_t m_ndivX=1, m_ndivY=1;
113 double m_sizeX{},m_sizeY{};
114
115 unsigned int m_size{};
116
117
119 size_t tileIndex(POINT &p) const {
120
121 int indx = int( (p.x()+m_halfetarange)/m_sizeX) ;
122 if(indx<0) indx=0;
123 if(indx>=static_cast<int>(m_ndivX)) indx=static_cast<int>(m_ndivX)-1;
124 int indy = int((M_PI-p.y())/m_sizeY);
125 if(indy>=static_cast<int>(m_ndivY)) indy=static_cast<int>(m_ndivY)-1;
126
127 return tileIndex_i(indx,indy);
128 }
129
131 size_t tileIndex_i(int ix, int iy) const {return ix*m_ndivY + iy;};
132
133 std::vector<tile_t> m_tiles;
134
135 };
136
137
138}
139
141
142#endif
#define M_PI
#define pi
constexpr double twopi
Tile(POINT tileCenter)
static const Tile voidTile
the void tile never contains any point.
tilecontainerbase_t::iterator iterator
tilecontainerbase_t::const_iterator const_iterator
std::vector< POINT > pointvec_t
std::list< POINT > tilecontainerbase_t
static const DIST2 dr2
const Tile< POINT, DIST2 > * m_neighbour[8]
void fillPointsInDr2(POINT &p, double r2, pointvec_t &points) const
Fill a vector of all points from this tile within deltaR of POINT p. (r2 is R squared)
std::vector< POINT > pointsInDr(POINT &p, double r) const
retrieve all points within deltaR of p. WARNING !! wrong results if r>rmax !
void init(double rmax)
std::vector< tile_t > m_tiles
Tile< POINT, DIST2 > tile_t
size_t tileIndex(POINT &p) const
index of the tile containing p
unsigned int size() const
size_t tileIndex_i(int ix, int iy) const
retrieve the tile index from its integer coordinates.
int r
Definition globals.cxx:22
static constexpr double DR2(double eta1, double phi1, double eta2, double phi2)