ATLAS Offline Software
Loading...
Searching...
No Matches
PixelOverlapDescriptor.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
6// PixelOverlapDescriptor.cxx, (c) ATLAS Detector software
8
9// Amg
11// InDet
15// Trk
16#include "TrkSurfaces/Surface.h"
17//
19
20InDet::PixelOverlapDescriptor::PixelOverlapDescriptor(bool addMoreSurfaces, int eta_slices, int phi_slices):
21 m_robustMode(true),
22 m_addMoreSurfaces(addMoreSurfaces),
23 m_etaSlices(eta_slices),
24 m_phiSlices(phi_slices) {}
25
27bool
29 std::vector<Trk::SurfaceIntersection>& cSurfaces,
30 const Trk::Surface& tsf,
31 const Amg::Vector3D& pos,
32 const Amg::Vector3D&) const
33
34{
35 // first add the target surface - it's always worth
36 cSurfaces.emplace_back(Trk::Intersection(pos, 0., true), &tsf);
37
38 // make sure we have the correct associated element
39 const auto* tmp = tsf.associatedDetectorElement();
40 const InDetDD::SiDetectorElement* sElement =
41 tmp->detectorType() == Trk::DetectorElemType::Silicon
42 ? static_cast<const InDetDD::SiDetectorElement*>(tmp)
43 : nullptr;
44 if (sElement) {
45 size_t newCapacity = cSurfaces.size();
46 if (m_robustMode and m_addMoreSurfaces and sElement->isBarrel()) {
47 // sum up the defined slices to evaluate the new capacity
48 newCapacity += (2*m_phiSlices+ 2*(m_etaSlices*(2*m_phiSlices+1)));
49 } else if (m_robustMode) {
50 newCapacity += 8;
51 } else {
52 newCapacity += 1;
53 if (sElement->isBarrel()) {
54 newCapacity += 2;
55 }
56 }
57 cSurfaces.reserve(newCapacity);
58
59 // now get the overlap options
61 double surfacePhi = tsf.center().phi() + M_PI;
62 double positionPhi = pos.phi() + M_PI;
63 // 8-cell-connectivity depending on track/surface geometry
64 // nPhi - can be jump + or -
65 const InDetDD::SiDetectorElement* nElement = nullptr;
66 // robust mode --> return 9 surfaces
67 if (m_robustMode) {
68 addNextInPhi(sElement, cSurfaces);
69 addNextInEta(sElement, cSurfaces);
70
71 addPrevInPhi(sElement, cSurfaces);
72 addPrevInEta(sElement, cSurfaces);
73
74 nElement = sElement->nextInPhi();
75 addNextInEta(nElement, cSurfaces);
76 addPrevInEta(nElement, cSurfaces);
77
78 nElement = sElement->prevInPhi();
79 addNextInEta(nElement, cSurfaces);
80 addPrevInEta(nElement, cSurfaces);
81
82 if (m_addMoreSurfaces and sElement->isBarrel()) {
83
84 unsigned int next = 1;
85 const InDetDD::SiDetectorElement* currentElement = sElement->nextInEta();
86 while (currentElement and next<(unsigned int)m_etaSlices) {
87 addNextInEta(currentElement,cSurfaces);
88 currentElement = currentElement->nextInEta();
89 if (currentElement) {
90 addNextInPhi(currentElement,cSurfaces);
91 addPrevInPhi(currentElement,cSurfaces);
92 }
93 next++;
94 }
95
96 unsigned int prev = 1;
97 currentElement = sElement->prevInEta();
98 while (currentElement and prev<(unsigned int)m_etaSlices) {
99 addPrevInEta(currentElement,cSurfaces);
100 currentElement = currentElement->prevInEta();
101 if (currentElement) {
102 addNextInPhi(currentElement,cSurfaces);
103 addPrevInPhi(currentElement,cSurfaces);
104 }
105 prev++;
106 }
107
108 unsigned int next_phi = 0;
109 const InDetDD::SiDetectorElement* currentElementNextPhi = sElement->nextInPhi()->nextInPhi();
110 const InDetDD::SiDetectorElement* currentElementPrevPhi = sElement->prevInPhi()->prevInPhi();
111
112 while (next_phi<(unsigned int)m_phiSlices) {
113 addSurface(currentElementNextPhi,cSurfaces);
114 addSurface(currentElementPrevPhi,cSurfaces);
115
116 unsigned int next_eta = 0;
117 const InDetDD::SiDetectorElement* currentElement_nextPhi = currentElementNextPhi;
118 const InDetDD::SiDetectorElement* currentElement_prevPhi = currentElementPrevPhi;
119 while (currentElement_nextPhi and currentElement_prevPhi and next_eta<(unsigned int)m_etaSlices) {
120 addNextInEta(currentElement_nextPhi,cSurfaces);
121 currentElement_nextPhi = currentElement_nextPhi->nextInEta();
122 addNextInEta(currentElement_prevPhi,cSurfaces);
123 currentElement_prevPhi = currentElement_prevPhi->nextInEta();
124 next_eta++;
125 }
126
127 unsigned int prev_eta = 0;
128 currentElement_nextPhi = currentElementNextPhi;
129 currentElement_prevPhi = currentElementPrevPhi;
130 while (currentElement_nextPhi and currentElement_prevPhi and prev_eta<(unsigned int)m_etaSlices) {
131 addPrevInEta(currentElement_nextPhi,cSurfaces);
132 currentElement_nextPhi = currentElement_nextPhi->prevInEta();
133 addPrevInEta(currentElement_prevPhi,cSurfaces);
134 currentElement_prevPhi = currentElement_prevPhi->prevInEta();
135 prev_eta++;
136 }
137
138 currentElementNextPhi = currentElementNextPhi->nextInPhi();
139 currentElementPrevPhi = currentElementPrevPhi->prevInPhi();
140
141 next_phi++;
142 }
143 }
144 } else {
145 // we go next in phi
146 if (surfacePhi < positionPhi) {
147 addNextInPhi(sElement, cSurfaces);
148 nElement = sElement->nextInPhi();
149 } else {
150 addPrevInPhi(sElement, cSurfaces);
151 nElement = sElement->prevInPhi();
152 }
153 if (sElement->isBarrel()) {
154 // get the eta information - also possible
155 double positionEta = pos.eta();
156 double surfaceEta = tsf.center().eta();
157 // check the surface / position eta values
158 if (surfaceEta < positionEta) {
159 // we go next in eta for both, the original and the phi jumped one
160 addNextInEta(sElement, cSurfaces);
161 addNextInEta(nElement, cSurfaces);
162 } else {
163 // opposite direction
164 addPrevInEta(sElement, cSurfaces);
165 addPrevInEta(nElement, cSurfaces);
166 }
167 }
168 }
169 }
170 return false;
171}
172
173bool InDet::PixelOverlapDescriptor::dumpSurfaces(std::vector<Trk::SurfaceIntersection>& surfaces) const {
174
175 if (m_pixIdHelper==nullptr) {
176 // get DetectorStore service
177 SmartIF<StoreGateSvc> detStore{Gaudi::svcLocator()->service("DetectorStore")};
178 if (!detStore.isValid()) {
179 return false;
180 }
181
182 const PixelID* pixIdHelper = nullptr;
183 if (detStore->retrieve(pixIdHelper, "PixelID").isFailure()) {
184 return false;
185 }
186 m_pixIdHelper = pixIdHelper;
187 }
188
189 std::cout << "Dumping Surfaces for Pixel with size = " << surfaces.size() << std::endl;
190 for (auto & surface : surfaces) {
191 Identifier hitId = (surface.object)->associatedDetectorElementIdentifier();
192 std::cout << "barrel_ec " << m_pixIdHelper.load()->barrel_ec(hitId) << ", layer_disk " << m_pixIdHelper.load()->layer_disk(hitId) << ", phi_module " << m_pixIdHelper.load()->phi_module(hitId) << ", eta_module " << m_pixIdHelper.load()->eta_module(hitId) << std::endl;
193 }
194 return true;
195}
#define M_PI
This is an Identifier helper class for the Pixel subdetector.
#define addSurface(cur, surfaces)
#define addPrevInEta(cur, surfaces)
#define addNextInPhi(cur, surfaces)
#define addPrevInPhi(cur, surfaces)
#define addNextInEta(cur, surfaces)
Class to hold geometrical description of a silicon detector element.
const SiDetectorElement * prevInPhi() const
const SiDetectorElement * nextInPhi() const
const SiDetectorElement * prevInEta() const
const SiDetectorElement * nextInEta() const
PixelOverlapDescriptor(bool addMoreSurfaces=false, int eta_slices=3, int phi_slices=1)
Constructor (area restriction, LC check)
bool reachableSurfaces(std::vector< Trk::SurfaceIntersection > &cSurfaces, const Trk::Surface &sf, const Amg::Vector3D &pos, const Amg::Vector3D &dir) const
get the compatible surfaces
bool dumpSurfaces(std::vector< Trk::SurfaceIntersection > &surfaces) const
std::atomic< const PixelID * > m_pixIdHelper
This is an Identifier helper class for the Pixel subdetector.
Definition PixelID.h:67
Abstract Base Class for tracking surfaces.
const TrkDetElementBase * associatedDetectorElement() const
return associated Detector Element
const Amg::Vector3D & center() const
Returns the center position of the Surface.
Eigen::Matrix< double, 3, 1 > Vector3D