ATLAS Offline Software
Loading...
Searching...
No Matches
TrigTrackSeedGenerator.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef TRIGINDETPATTRECOTOOLS_TRIGTRACKSEEDGENERATOR_H
6#define TRIGINDETPATTRECOTOOLS_TRIGTRACKSEEDGENERATOR_H
7
8#include<vector>
9#include<algorithm>
10
13
15
16typedef struct IndexedSP {
17public :
18IndexedSP() : m_pSP(0), m_idx(-1) {};
19IndexedSP(const TrigSiSpacePointBase* p, int idx) : m_pSP(p), m_idx(idx) {};
20IndexedSP(const IndexedSP& isp) : m_pSP(isp.m_pSP), m_idx(isp.m_idx) {};
21
22 void set(const TrigSiSpacePointBase* p, int idx) {
23 m_pSP = p;
24 m_idx = idx;
25 }
26
28 int m_idx;
29
31
32typedef struct LPhiSector {
33
34public:
35
36 struct compareZ {
37 bool operator()(const INDEXED_SP* p1, const INDEXED_SP* p2) {
38 return p1->m_pSP->z()<p2->m_pSP->z();
39 }
40 };
41
42 struct compareR {
43 bool operator()(const INDEXED_SP* p1, const INDEXED_SP* p2) {
44 return p1->m_pSP->r()<p2->m_pSP->r();
45 }
46 };
47
48 struct compareRless {
49 bool operator()(const INDEXED_SP* p1, const INDEXED_SP* p2) {
50 return p1->m_pSP->r()>p2->m_pSP->r();
51 }
52 };
53
54 struct greaterThanZ {
55 bool operator()(float z, const INDEXED_SP* const& p) const {
56 return z < p->m_pSP->z();
57 }
58 };
59
60 struct smallerThanZ {
61 bool operator()(const INDEXED_SP* const& p, float z) const {
62 return p->m_pSP->z() < z;
63 }
64 };
65
66 struct greaterThanR {
67 bool operator()(float r, const INDEXED_SP* const& p) const {
68 return r < p->m_pSP->r();
69 }
70 };
71
73 bool operator()(const INDEXED_SP* const& p, float r) const {
74 return r < p->m_pSP->r();
75 }
76 };
77
78 struct smallerThanR {
79 bool operator()(const INDEXED_SP* const& p, float r) const {
80 return p->m_pSP->r() < r;
81 }
82 };
83
85 bool operator()(float r, const INDEXED_SP* const& p) const {
86 return p->m_pSP->r() < r;
87 }
88 };
89
90 //LPhiSector() : m_nSP(0) {m_phiSlices.clear();}
91LPhiSector(int nPhiSlices) : m_nSP(0) {
92 std::vector<const INDEXED_SP*> d;
93 m_phiSlices.resize(nPhiSlices, d);
94 m_phiThreeSlices.resize(nPhiSlices, d);
95 if(nPhiSlices == 1) {//special case
96 m_threeIndices[1].push_back(0);
97 m_threeIndices[0].push_back(-1);
98 m_threeIndices[2].push_back(-1);
99 }
100 if(nPhiSlices == 2) {//special case
101 m_threeIndices[1].push_back(0);
102 m_threeIndices[0].push_back(-1);
103 m_threeIndices[2].push_back(1);
104 m_threeIndices[1].push_back(1);
105 m_threeIndices[0].push_back(0);
106 m_threeIndices[2].push_back(-1);
107 }
108 if(nPhiSlices > 2) {
109 for(int phiIdx=0;phiIdx<nPhiSlices;phiIdx++) {
110 m_threeIndices[1].push_back(phiIdx);
111 if(phiIdx>0) m_threeIndices[0].push_back(phiIdx-1);
112 else m_threeIndices[0].push_back(nPhiSlices-1);
113 if(phiIdx<nPhiSlices-1) m_threeIndices[2].push_back(phiIdx+1);
114 else m_threeIndices[2].push_back(0);
115 }
116 }
117}
118
120 for(int i=0;i<3;i++) {
121 m_threeIndices[i] = ps.m_threeIndices[i];
122 }
123}
124
126 m_nSP = ps.m_nSP;
127 m_phiSlices = ps.m_phiSlices;
128 m_phiThreeSlices = ps.m_phiThreeSlices;
129 for(int i=0;i<3;i++) {
130 m_threeIndices[i] = ps.m_threeIndices[i];
131 }
132 return *this;
133 }
134
135 void reset() {
136 for(std::vector<std::vector<const INDEXED_SP*> >::iterator it = m_phiSlices.begin();it!=m_phiSlices.end();++it) {
137 (*it).clear();
138 }
139 for(std::vector<std::vector<const INDEXED_SP*> >::iterator it = m_phiThreeSlices.begin();it!=m_phiThreeSlices.end();++it) {
140 (*it).clear();
141 }
142 m_nSP = 0;
143 }
144
145 void addSpacePoint(int phiIndex, const INDEXED_SP* p) {
146 m_nSP++;
147 m_phiSlices[phiIndex].push_back(p);
148 for(int i=0;i<3;i++) {
149 if(m_threeIndices[i][phiIndex]==-1) continue;//to account for special cases nPhiSlices=1,2
150 m_phiThreeSlices[m_threeIndices[i][phiIndex]].push_back(p);
151 }
152 }
153
154 void sortSpacePoints(bool isBarrel) {
155 for(std::vector<std::vector<const INDEXED_SP*> >::iterator it=m_phiSlices.begin();it!=m_phiSlices.end();++it) {
156 if((*it).empty()) continue;
157 if(isBarrel) std::sort(it->begin(), it->end(), compareZ());
158 else std::sort(it->begin(), it->end(), compareR());
159 }
160 for(std::vector<std::vector<const INDEXED_SP*> >::iterator it=m_phiThreeSlices.begin();it!=m_phiThreeSlices.end();++it) {
161 if((*it).empty()) continue;
162 if(isBarrel) std::sort(it->begin(), it->end(), compareZ());
163 else std::sort(it->begin(), it->end(), compareR());
164 }
165 }
166
167 void sortSpacePoints(bool isBarrel, bool isPositive) {
168 for(std::vector<std::vector<const INDEXED_SP*> >::iterator it=m_phiSlices.begin();it!=m_phiSlices.end();++it) {
169 if((*it).empty()) continue;
170 if(isBarrel) std::sort(it->begin(), it->end(), compareZ());
171 else {
172 if(isPositive) std::sort(it->begin(), it->end(), compareRless());
173 else std::sort(it->begin(), it->end(), compareR());
174 }
175 }
176 for(std::vector<std::vector<const INDEXED_SP*> >::iterator it=m_phiThreeSlices.begin();it!=m_phiThreeSlices.end();++it) {
177 if((*it).empty()) continue;
178 if(isBarrel) std::sort(it->begin(), it->end(), compareZ());
179 else {
180 if(isPositive) std::sort(it->begin(), it->end(), compareRless());
181 else std::sort(it->begin(), it->end(), compareR());
182 }
183 }
184 }
185
186 int size() const { return m_nSP; }
187
188 int m_nSP;
189 std::vector<std::vector<const INDEXED_SP*> > m_phiSlices;
190 std::vector<std::vector<const INDEXED_SP*> > m_phiThreeSlices;
191 std::vector<int> m_threeIndices[3];
192
193private:
195
197
198typedef struct LPhi_Storage {
199
200public:
201
202 LPhi_Storage(int nPhiSectors, int nLayers) {
203 m_layers.reserve(nLayers);
204 for(int i = 0;i<nLayers;i++) m_layers.push_back(L_PHI_SECTOR(nPhiSectors));
205 }
206
207 void addSpacePoint(int phiIdx, int layerId, const INDEXED_SP* p) {
208 m_layers[layerId].addSpacePoint(phiIdx, p);
209 }
210
211 void reset() {
212 for(std::vector<L_PHI_SECTOR>::iterator it=m_layers.begin();it!=m_layers.end();++it) {
213 if((*it).m_nSP==0) continue;
214 (*it).reset();
215 }
216 }
217
218 void sortSpacePoints(const std::vector<TrigInDetSiLayer>& layerGeometry) {
219 int layerId = 0;
220 for(std::vector<L_PHI_SECTOR>::iterator it=m_layers.begin();it!=m_layers.end();++it,layerId++) {
221 if((*it).m_nSP==0) continue;
222 (*it).sortSpacePoints(layerGeometry[layerId].m_type==0);
223 }
224 }
225
226 void sortSpacePoints2(const std::vector<TrigInDetSiLayer>& layerGeometry) {
227 int layerId = 0;
228 for(std::vector<L_PHI_SECTOR>::iterator it=m_layers.begin();it!=m_layers.end();++it,layerId++) {
229 if((*it).m_nSP==0) continue;
230 (*it).sortSpacePoints(layerGeometry[layerId].m_type==0, layerGeometry[layerId].m_refCoord > 0);
231 }
232 }
233
234 std::vector<L_PHI_SECTOR> m_layers;
235
237
238typedef struct InternalSoA {
239
240public:
241
242InternalSoA() : m_spi(0), m_spo(0), m_r(0), m_u(0), m_v(0), m_t(0), m_ti(0), m_to(0), m_tCov(0), m_sorted_sp(0),
244 m_sorted_sp_t(0) {}
245
247 }
248
249 void clear() {
250 delete[] m_spi;
251 delete[] m_spo;
252 delete[] m_r;
253 delete[] m_u;
254 delete[] m_v;
255 delete[] m_t;
256 delete[] m_ti;
257 delete[] m_to;
258 delete[] m_tCov;
259 delete[] m_sorted_sp;
260 delete[] m_sorted_sp_type;
261 delete[] m_sorted_sp_t;
262 m_spi = 0;
263 m_spo = 0;
264 m_r = 0;
265 m_u = 0;
266 m_v = 0;
267 m_t = 0;
268 m_ti = 0;
269 m_to = 0;
270 m_tCov = 0;
271 m_sorted_sp = 0;
273 m_sorted_sp_t = 0;
274 }
275
276 void resize(const int spSize) {
277
278 m_spi = new const TrigSiSpacePointBase*[spSize];
279 m_spo = new const TrigSiSpacePointBase*[spSize];
280 m_r = new double[spSize];
281 m_u = new double[spSize];
282 m_v = new double[spSize];
283 m_t = new double[spSize];
284 m_ti = new double[spSize];
285 m_to = new double[spSize];
286 m_tCov = new double[spSize];
287 m_sorted_sp = new const TrigSiSpacePointBase*[spSize];
288 m_sorted_sp_type = new int[spSize];
289 m_sorted_sp_t = new double[spSize];
290 }
291
294 double* m_r;
295 double* m_u;
296 double* m_v;
297 double* m_t;
298 double* m_ti;
299 double* m_to;
300 double* m_tCov;
304
306
307
308typedef std::pair<std::vector<const INDEXED_SP*>::const_iterator, std::vector<const INDEXED_SP*>::const_iterator> SP_RANGE;
309
311
312 public:
313
316
319
320 void loadSpacePoints(const std::vector<TrigSiSpacePointBase>&);
321 void createSeeds(const IRoiDescriptor*);
322 void createSeeds(const IRoiDescriptor*, const std::vector<float>& vZv);
323 void getSeeds(std::vector<TrigInDetTriplet>&);
324
325private:
326
327 std::vector<INDEXED_SP> m_spStorage;
328 std::vector<float> m_minTau;
329 std::vector<float> m_maxTau;
330
331 bool validateLayerPairNew(int, int, float, float);
332 bool getSpacepointRange(int, const std::vector<const INDEXED_SP*>&, SP_RANGE&);
333 int processSpacepointRange(int, const INDEXED_SP*, bool, const SP_RANGE&, const IRoiDescriptor*);
334 int processSpacepointRangeZv(const INDEXED_SP*, bool, const SP_RANGE&, bool, const float&, const float&);
335 void createTriplets(const TrigSiSpacePointBase*, int, int, std::vector<TrigInDetTriplet>&, const IRoiDescriptor*);
336 void createTripletsNew(const TrigSiSpacePointBase*, int, int, std::vector<TrigInDetTriplet>&, const IRoiDescriptor*);
337 void createConfirmedTriplets(const TrigSiSpacePointBase*, int, int, std::vector<TrigInDetTriplet>&, const IRoiDescriptor*);
338 void storeTriplets(std::vector<TrigInDetTriplet>&);
339
343
345
347
349
350 std::vector<TrigInDetTriplet> m_triplets;
351
353
357
358#endif // not TRIGINDETPATTRECOTOOLS_TRIGTRACKSEEDGENERATOR_H
struct InternalSoA INTERNAL_SOA
struct LPhiSector L_PHI_SECTOR
struct IndexedSP INDEXED_SP
class TrigTrackSeedGenerator TRIG_TRACK_SEED_GENERATOR
struct LPhi_Storage L_PHI_STORAGE
std::pair< std::vector< const INDEXED_SP * >::const_iterator, std::vector< const INDEXED_SP * >::const_iterator > SP_RANGE
#define z
Describes the API of the Region of Ineterest geometry.
TrigTrackSeedGenerator & operator=(const TrigTrackSeedGenerator &)=delete
const TrigCombinatorialSettings & m_settings
void loadSpacePoints(const std::vector< TrigSiSpacePointBase > &)
std::vector< float > m_maxTau
void createTripletsNew(const TrigSiSpacePointBase *, int, int, std::vector< TrigInDetTriplet > &, const IRoiDescriptor *)
void storeTriplets(std::vector< TrigInDetTriplet > &)
TrigTrackSeedGenerator(const TrigTrackSeedGenerator &)=delete
std::vector< float > m_minTau
bool getSpacepointRange(int, const std::vector< const INDEXED_SP * > &, SP_RANGE &)
void createSeeds(const IRoiDescriptor *)
void getSeeds(std::vector< TrigInDetTriplet > &)
std::vector< INDEXED_SP > m_spStorage
void createTriplets(const TrigSiSpacePointBase *, int, int, std::vector< TrigInDetTriplet > &, const IRoiDescriptor *)
int processSpacepointRangeZv(const INDEXED_SP *, bool, const SP_RANGE &, bool, const float &, const float &)
std::vector< int > m_innerMarkers
std::vector< TrigInDetTriplet > m_triplets
void createConfirmedTriplets(const TrigSiSpacePointBase *, int, int, std::vector< TrigInDetTriplet > &, const IRoiDescriptor *)
TrigTrackSeedGenerator(const TrigCombinatorialSettings &)
bool validateLayerPairNew(int, int, float, float)
std::vector< int > m_outerMarkers
int processSpacepointRange(int, const INDEXED_SP *, bool, const SP_RANGE &, const IRoiDescriptor *)
int r
Definition globals.cxx:22
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
const TrigSiSpacePointBase * m_pSP
IndexedSP(const TrigSiSpacePointBase *p, int idx)
void set(const TrigSiSpacePointBase *p, int idx)
IndexedSP(const IndexedSP &isp)
const TrigSiSpacePointBase ** m_sorted_sp
const TrigSiSpacePointBase ** m_spo
void resize(const int spSize)
const TrigSiSpacePointBase ** m_spi
bool operator()(const INDEXED_SP *p1, const INDEXED_SP *p2)
bool operator()(const INDEXED_SP *p1, const INDEXED_SP *p2)
bool operator()(const INDEXED_SP *p1, const INDEXED_SP *p2)
bool operator()(const INDEXED_SP *const &p, float r) const
bool operator()(float r, const INDEXED_SP *const &p) const
bool operator()(float z, const INDEXED_SP *const &p) const
bool operator()(float r, const INDEXED_SP *const &p) const
bool operator()(const INDEXED_SP *const &p, float r) const
bool operator()(const INDEXED_SP *const &p, float z) const
const LPhiSector & operator=(const LPhiSector &ps)
std::vector< std::vector< const INDEXED_SP * > > m_phiThreeSlices
LPhiSector(int nPhiSlices)
std::vector< int > m_threeIndices[3]
void sortSpacePoints(bool isBarrel)
std::vector< std::vector< const INDEXED_SP * > > m_phiSlices
void addSpacePoint(int phiIndex, const INDEXED_SP *p)
void sortSpacePoints(bool isBarrel, bool isPositive)
LPhiSector(const LPhiSector &ps)
LPhi_Storage(int nPhiSectors, int nLayers)
std::vector< L_PHI_SECTOR > m_layers
void addSpacePoint(int phiIdx, int layerId, const INDEXED_SP *p)
void sortSpacePoints(const std::vector< TrigInDetSiLayer > &layerGeometry)
void sortSpacePoints2(const std::vector< TrigInDetSiLayer > &layerGeometry)