ATLAS Offline Software
TiledEtaPhiMap.h
Go to the documentation of this file.
1 // emacs, this is -*- C++ -*-
2 
3 /*
4  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
5 */
6 
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 
29 namespace 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 
43  enum Directions {
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;
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>
85  class TiledEtaPhiMap {
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 
105  void setEtaRange(double r){m_etarange=r; m_halfetarange = r/2;}
106 
107  protected:
108 
109  double m_etarange{} ;
110  double m_halfetarange{};
111  double m_rmax{};
112  size_t m_ndivX{}, m_ndivY{};
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=m_ndivX-1;
124  int indy = int((M_PI-p.y())/m_sizeY);
125  if(indy>=static_cast<int>(m_ndivY)) indy=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
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
beamspotman.r
def r
Definition: beamspotman.py:676
JetTiledMap::TiledEtaPhiMap::insert
void insert(POINT &p)
ParticleGun_SamplingFraction.eta2
eta2
Definition: ParticleGun_SamplingFraction.py:96
JetTiledMap::TiledEtaPhiMap::init
void init(double rmax)
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
xAODP4Helpers.h
JetTiledMap::W
@ W
Definition: TiledEtaPhiMap.h:44
JetTiledMap
Definition: TiledEtaPhiMap.h:29
JetTiledMap::TiledEtaPhiMap::m_sizeY
double m_sizeY
Definition: TiledEtaPhiMap.h:113
JetTiledMap::TiledEtaPhiMap::setEtaRange
void setEtaRange(double r)
Definition: TiledEtaPhiMap.h:105
M_PI
#define M_PI
Definition: ActiveFraction.h:11
JetTiledMap::TiledEtaPhiMap::m_halfetarange
double m_halfetarange
Definition: TiledEtaPhiMap.h:110
xAOD::eta1
setEt setPhi setE277 setWeta2 eta1
Definition: TrigEMCluster_v1.cxx:41
JetTiledMap::Tile::iterator
tilecontainerbase_t::iterator iterator
Definition: TiledEtaPhiMap.h:56
JetTiledMap::N
@ N
Definition: TiledEtaPhiMap.h:44
JetTiledMap::TiledEtaPhiMap::pointsInDr
std::vector< POINT > pointsInDr(POINT &p, double r) const
retrieve all points within deltaR of p. WARNING !! wrong results if r>rmax !
JetTiledMap::Tile::center
POINT center
Definition: TiledEtaPhiMap.h:71
JetTiledMap::S
@ S
Definition: TiledEtaPhiMap.h:44
JetTiledMap::SW
@ SW
Definition: TiledEtaPhiMap.h:44
JetTiledMap::Directions
Directions
Definition: TiledEtaPhiMap.h:43
JetTiledMap::Tile::dr2
static const DIST2 dr2
Definition: TiledEtaPhiMap.h:70
pi
#define pi
Definition: TileMuonFitter.cxx:65
JetTiledMap::TiledEtaPhiMap::size
unsigned int size() const
Definition: TiledEtaPhiMap.h:103
JetTiledMap::TiledEtaPhiMap::tileIndex_i
size_t tileIndex_i(int ix, int iy) const
retrieve the tile index from its integer coordinates.
Definition: TiledEtaPhiMap.h:131
Tile
Definition: TileVolumeBuilder.h:43
JetTiledMap::TiledEtaPhiMap::m_etarange
double m_etarange
Definition: TiledEtaPhiMap.h:109
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
JetTiledMap::TiledEtaPhiMap::TiledEtaPhiMap
TiledEtaPhiMap()
Definition: TiledEtaPhiMap.h:90
JetTiledMap::Tile::Tile
Tile(POINT tileCenter)
Definition: TiledEtaPhiMap.h:61
JetTiledMap::TiledEtaPhiMap::reset
virtual void reset()
Definition: TiledEtaPhiMap.h:101
JetTiledMap::TiledEtaPhiMap::~TiledEtaPhiMap
virtual ~TiledEtaPhiMap()
Definition: TiledEtaPhiMap.h:91
JetTiledMap::Tile::fillPointsInDr2
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)
JetTiledMap::SE
@ SE
Definition: TiledEtaPhiMap.h:44
JetTiledMap::Tile::tilecontainerbase_t
std::list< POINT > tilecontainerbase_t
Definition: TiledEtaPhiMap.h:55
JetTiledMap::E
@ E
Definition: TiledEtaPhiMap.h:44
JetTiledMap::TiledEtaPhiMap::m_ndivX
size_t m_ndivX
Definition: TiledEtaPhiMap.h:112
JetTiledMap::TiledEtaPhiMap::m_sizeX
double m_sizeX
Definition: TiledEtaPhiMap.h:113
JetTiledMap::Tile::pointvec_t
std::vector< POINT > pointvec_t
Definition: TiledEtaPhiMap.h:58
JetTiledMap::TiledEtaPhiMap::m_size
unsigned int m_size
Definition: TiledEtaPhiMap.h:115
histSizes.list
def list(name, path='/')
Definition: histSizes.py:38
twopi
constexpr double twopi
Definition: VertexPointEstimator.cxx:16
JetTiledMap::Tile::m_neighbour
const Tile< POINT, DIST2 > * m_neighbour[8]
Definition: TiledEtaPhiMap.h:69
JetTiledMap::Tile
class Tile
Definition: TiledEtaPhiMap.h:53
JetTiledMap::Tile::const_iterator
tilecontainerbase_t::const_iterator const_iterator
Definition: TiledEtaPhiMap.h:57
JetTiledMap::utils::DR2
static constexpr double DR2(double eta1, double phi1, double eta2, double phi2)
Definition: TiledEtaPhiMap.h:32
JetTiledMap::TiledEtaPhiMap::m_ndivY
size_t m_ndivY
Definition: TiledEtaPhiMap.h:112
JetTiledMap::TiledEtaPhiMap
Definition: TiledEtaPhiMap.h:85
utils
Definition: Trigger/TrigMonitoring/TrigMinBiasMonitoring/python/utils.py:1
JetTiledMap::Tile::voidTile
static const Tile voidTile
the void tile never contains any point.
Definition: TiledEtaPhiMap.h:67
JetTiledMap::Tile::Tile
Tile()=default
JetTiledMap::NE
@ NE
Definition: TiledEtaPhiMap.h:44
TiledEtaPhiMap.icc
JetTiledMap::NW
@ NW
Definition: TiledEtaPhiMap.h:44
JetTiledMap::TiledEtaPhiMap::clear
virtual void clear()
JetTiledMap::TiledEtaPhiMap::tile_t
Tile< POINT, DIST2 > tile_t
Definition: TiledEtaPhiMap.h:87
JetTiledMap::TiledEtaPhiMap::m_tiles
std::vector< tile_t > m_tiles
Definition: TiledEtaPhiMap.h:131
jobOptions.points
points
Definition: jobOptions.GenevaPy8_Zmumu.py:97
JetTiledMap::TiledEtaPhiMap::tileIndex
size_t tileIndex(POINT &p) const
index of the tile containing p
Definition: TiledEtaPhiMap.h:119
JetTiledMap::TiledEtaPhiMap::m_rmax
double m_rmax
Definition: TiledEtaPhiMap.h:111