ATLAS Offline Software
Loading...
Searching...
No Matches
RegSelEtaPhiLUT.cxx
Go to the documentation of this file.
1// emacs: this is -*- c++ -*-
2/*
3 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
4*/
5//
6// @file RegSelEtaPhiLUT.h
7//
8// a look up table for eta-phi space divided up into
9// a set of elements Neta x Nphi.
10//
11// "Modules" are added to the lookup table, and are
12// stored in each element that they overlap with
13//
14// To accelerate the look up when there are a large
15// number of modules, only elements that overlap with
16// the roi are examined.
17//
18// Because RoIs are defined in terms of a z range,
19// without these z positions, eta coordinates are
20// not well defined.
21// As a result, when passed an RoI, this class calculates
22// a virtual RoI, just in eta-phi space, where the eta
23// range corresponds to the maxuimum and minimum eta
24// possible from any z position with the RoI where the
25// object can be completely contained within a user
26// specified radius. The default value is 600mm, chosen
27// to completely contain the outer radius of the SCT
28//
29//
30//
31
33
34
35
39 m_etamin(-3), m_etamax(3), m_Neta(Neta),
40 m_phimin(0), m_phimax(2*M_PI), m_Nphi(Nphi),
42 std::vector< std::vector< map_element > >() )
43{
47
48 std::vector< std::vector< map_element > >& tmap = m_grandmap.payload();
49
50 // std::cout << "RegSelEtaPhiUT::RegSelEtaPhiLUT() Neta " << Neta << "\tNphi " << Nphi << std::endl;
51
52 moduleset empty_set;
53
54 for ( int i=0 ; i<m_Neta ; i++ ) {
55
56 double tetamin = m_etamin+i/m_ideta;
57 double tetamax = m_etamin+(i+1)/m_ideta;
58
59 std::vector< map_element > row;
60
61 for ( int j=0 ; j<m_Nphi ; j++ ) {
62 double tphimin = m_phimin+j/m_idphi;
63 double tphimax = m_phimin+(j+1)/m_idphi;
64
65 map_element m( tetamin, tetamax, tphimin, tphimax, empty_set );
66
67 row.push_back( m );
68
69 }
70
71 tmap.push_back( std::move(row) );
72
73 }
74
75}
76
77
78
81
82
83
84
88
89 // std::cout << "adding... " << m << std::endl;
90
91 std::vector< std::vector< map_element > >& tmap = m_grandmap.payload();
92
93 int first_eta = (m.etamin()-m_etamin)*m_ideta;
94 int last_eta = (m.etamax()-m_etamin)*m_ideta;
95
96 int first_phi = (m.phimin()-m_phimin)*m_idphi;
97 int last_phi = (m.phimax()-m_phimin)*m_idphi;
98
100 if ( !m_grandmap.overlap( m ) ) return false;
101
103 if ( first_eta<0 ) first_eta = 0;
104 if ( last_eta>=m_Neta ) last_eta = m_Neta-1;
105
107 if ( first_phi<0 ) first_phi += m_Nphi;
108 if ( first_phi>=m_Nphi ) first_phi -= m_Nphi;
109
110 if ( last_phi<0 ) last_phi += m_Nphi;
111 if ( last_phi>=m_Nphi ) last_phi -= m_Nphi;
112
113
115 if ( first_phi<last_phi ) {
116 for ( int i=int(first_eta) ; i<=last_eta ; i++ ) {
117 for ( int j=int(first_phi) ; j<=last_phi ; j++ ) tmap[i][j].payload().insert( m );
118 }
119 }
120 else {
121 for ( int i=int(first_eta) ; i<=last_eta ; i++ ) {
122 for ( int j=0 ; j<=int(last_phi) ; j++ ) tmap[i][j].payload().insert( m );
123 for ( int j=first_phi ; j<m_Nphi ; j++ ) tmap[i][j].payload().insert( m );
124 }
125 }
126
127 // std::cout << "added" << std::endl;
128
129 return true;
130}
131
132
133
134
138 std::vector<IdentifierHash>& hashids,
139 double r ) const {
140
141 hashids.clear();
142
143 std::set<EtaPhiModule> modules;
144
145 getElements( roi, modules, r );
146
147 hashids.reserve( modules.size() );
148
149 std::set<EtaPhiModule>::iterator rpitr=modules.begin();
150 std::set<EtaPhiModule>::iterator rpend=modules.end();
151
152 while ( rpitr!=rpend ) {
153 hashids.push_back( rpitr->payload() );
154 ++rpitr;
155 }
156
157}
158
159
160
161
162
166
168 std::set<EtaPhiModule>& modules,
169 double idradius ) const {
170
171 modules.clear();
172
173 // struct timeval timer = simpletimer_start();
174
176 const EtaPhiBase virtual_roi( roi.etaMinLimit(idradius), roi.etaMaxLimit(idradius),
177 roi.getphiMin(), roi.getphiMax() );
178
179 // double time = simpletimer_stop( timer );
180
182 bool inmap = m_grandmap.overlap( virtual_roi );
183
184 if ( !inmap ) return virtual_roi;
185
186 int first_phi = (virtual_roi.phimin()-m_phimin)*m_idphi;
187 int last_phi = (virtual_roi.phimax()-m_phimin)*m_idphi;
188
189 int first_eta = (virtual_roi.etamin()-m_etamin)*m_ideta;
190 int last_eta = (virtual_roi.etamax()-m_etamin)*m_ideta;
191
194 if ( first_eta<0 ) first_eta = 0;
195 if ( last_eta>=m_Neta ) last_eta = m_Neta-1;
196
198 if ( first_phi<0 ) first_phi += m_Nphi;
199 if ( first_phi>=m_Nphi ) first_phi -= m_Nphi;
200
201 if ( last_phi<0 ) last_phi += m_Nphi;
202 if ( last_phi>=m_Nphi ) last_phi -= m_Nphi;
203
204 const std::vector< std::vector< map_element > >& tmap = map();
205
207 if ( first_phi<last_phi ) {
208 for ( int i=first_eta ; i<=last_eta ; i++ ) {
209 getRowElements( virtual_roi, tmap[i], first_phi, last_phi, modules );
210 }
211 }
212 else {
213 for ( int i=first_eta ; i<=last_eta ; i++ ) {
214 getRowElements( virtual_roi, tmap[i], 0, last_phi, modules );
215 getRowElements( virtual_roi, tmap[i], first_phi, m_Nphi-1, modules );
216 }
217 }
218
219 return virtual_roi;
220}
221
222
223
224
225
226
227
228
#define M_PI
base class, with just the eta-phi limits and the overlap functionality
double phimax() const
double etamin() const
accessors
double etamax() const
double phimin() const
bool addModule(EtaPhiModule &m)
add an element, returns true if element added.
double m_ideta
inverse eta element size
const EtaPhiBase getElements(const RegSelRoI &roi, std::set< EtaPhiModule > &modules, double idradius=600) const
get the modules from the elements, returns the virtual eta-phi roi corresponding to the virtual eta -...
void getRowElements(const EtaPhiBase &virtual_roi, const std::vector< map_element > &row, int first_phi, int last_phi, std::set< EtaPhiModule > &modules) const
get the modules from the elements in the phi direction, called for each eta slice processed
const std::vector< std::vector< map_element > > & map() const
access the actual complete map - shouldn't be public really, is only so for the ostream streamer
virtual ~RegSelEtaPhiLUT()
destructor
TRegSelEtaPhiModule< std::vector< std::vector< map_element > > > m_grandmap
overall map, can get the limits from the object, can have different numbers and different ranges for ...
double m_idphi
inverse phi element size
TRegSelEtaPhiModule< IdentifierHash > EtaPhiModule
Concrete data type.
void getModules(const RegSelRoI &roi, std::vector< IdentifierHash > &hashids, double r=600) const
get back a vector of the payload for each of the eta-phi segments that overlap with this roi
TRegSelEtaPhiModule< moduleset > map_element
element type from which the look up table is built
std::set< EtaPhiModule > moduleset
tower of the actual modules assigned to each element of the lookup table
RegSelEtaPhiLUT(int Neta=3, int Nphi=32)
defines the number of elements in the internal eta-phi element storage NB: these numbers of internal ...
double m_etamin
eta and phi ranges and number of internal book keeping elements in eta and phi directions
double etaMinLimit(double r) const
find the min eta limits for an object fully contained within an roi, bounded with the specifed radius
Definition RegSelRoI.h:68
double etaMaxLimit(double r) const
find the max eta limits for an object fully contained within an roi, bounded with the specifed radius
Definition RegSelRoI.h:79
double getphiMin() const
Definition RegSelRoI.h:46
double getphiMax() const
Definition RegSelRoI.h:47
int r
Definition globals.cxx:22
STL namespace.