ATLAS Offline Software
Loading...
Searching...
No Matches
SCT_OverlapDescriptor.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// SCT_OverlapDescriptor.cxx, (c) ATLAS Detector software
8
9// Amg
11// InDet
15// Trk
16#include "TrkSurfaces/Surface.h"
17//
19
20InDet::SCT_OverlapDescriptor::SCT_OverlapDescriptor(bool addMoreSurfaces, int eta_slices)
21 : m_robustMode(true),
22 m_addMoreSurfaces(addMoreSurfaces),
23 m_etaSlices(eta_slices)
24{}
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 and the backside surface (in the if statement)
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
45 if (sElement) {
46
47 size_t newCapacity = cSurfaces.size() + 2;
48 if (m_robustMode and m_addMoreSurfaces and sElement->isBarrel()) {
49 // sum up the defined slices to evaluate the new capacity
50 // only uses one additional slice in phi
51 newCapacity += (2 + 6*m_etaSlices)*2;
52 } else if (m_robustMode) {
53 newCapacity += 16;
54 } else {
55 newCapacity += 6;
56 }
57 cSurfaces.reserve(newCapacity);
58
60 double surfacePhi = tsf.center().phi() + M_PI;
61 double positionPhi = pos.phi() + M_PI;
62
63 // now get the overlap options
64 addOtherSide(sElement, cSurfaces);
65
66 // 8-cell-connectivity depending on track/surface geometry
67 // nPhi - can be jump + or -
68 const InDetDD::SiDetectorElement* nElement = nullptr;
69
70 // robust mode --> return 9 (*2) surfaces
71 if (m_robustMode) {
72 addNextInPhiOS(sElement, cSurfaces);
73 addNextInEtaOS(sElement, cSurfaces);
74
75 addPrevInPhiOS(sElement, cSurfaces);
76 addPrevInEtaOS(sElement, cSurfaces);
77
78 nElement = sElement->nextInPhi();
79 addNextInEtaOS(nElement, cSurfaces);
80 addPrevInEtaOS(nElement, cSurfaces);
81
82 nElement = sElement->prevInPhi();
83 addNextInEtaOS(nElement, cSurfaces);
84 addPrevInEtaOS(nElement, cSurfaces);
85
86 if (m_addMoreSurfaces and sElement->isBarrel()) {
87 unsigned int next = 1;
88 const InDetDD::SiDetectorElement* currentElement = sElement->nextInEta();
89 while (currentElement and next<(unsigned int)m_etaSlices) {
90 addNextInEtaOS(currentElement,cSurfaces);
91 currentElement = currentElement->nextInEta();
92 if (currentElement) {
93 addNextInPhiOS(currentElement,cSurfaces);
94 addPrevInPhiOS(currentElement,cSurfaces);
95 }
96 next++;
97 }
98
99 unsigned int prev = 1;
100 currentElement = sElement->prevInEta();
101 while (currentElement and prev<(unsigned int)m_etaSlices) {
102 addPrevInEtaOS(currentElement,cSurfaces);
103 currentElement = currentElement->prevInEta();
104 if (currentElement) {
105 addNextInPhiOS(currentElement,cSurfaces);
106 addPrevInPhiOS(currentElement,cSurfaces);
107 }
108 prev++;
109 }
110 }
111
112 } else {
113 // get the phi information
114 if (surfacePhi < positionPhi) {
115 addNextInPhiOS(sElement, cSurfaces);
116 nElement = sElement->nextInPhi();
117 } else {
118 addPrevInPhiOS(sElement, cSurfaces);
119 nElement = sElement->prevInPhi();
120 }
121 // get the eta information - also possible
122 double positionEta = pos.eta();
123 double surfaceEta = tsf.center().eta();
124 int side = (sElement->isBarrel() || surfaceEta > 0.) ? 1 : -1;
125 // check the surface / position eta values
126 if (side * surfaceEta < side * positionEta) {
127 // we go next in eta for both, the original and the phi jumped one
128 addNextInEtaOS(sElement, cSurfaces);
129 addNextInEtaOS(nElement, cSurfaces);
130 } else {
131 // opposite direction
132 addPrevInEtaOS(sElement, cSurfaces);
133 addPrevInEtaOS(nElement, cSurfaces);
134 }
135 }
136 }
137
138 return false;
139}
140
141bool InDet::SCT_OverlapDescriptor::dumpSurfaces(std::vector<Trk::SurfaceIntersection>& surfaces) const {
142
143 if (m_sctIdHelper==nullptr) {
144 // get DetectorStore service
145 SmartIF<StoreGateSvc> detStore{Gaudi::svcLocator()->service("DetectorStore")};
146 if (!detStore.isValid()) {
147 return false;
148 }
149
150 const SCT_ID* sctIdHelper = nullptr;
151 if (detStore->retrieve(sctIdHelper, "SCT_ID").isFailure()) {
152 return false;
153 }
154 m_sctIdHelper = sctIdHelper;
155 }
156
157 std::cout << "Dumping Surfaces for SCT with size = " << surfaces.size() << std::endl;
158 for (auto & surface : surfaces) {
159 Identifier hitId = (surface.object)->associatedDetectorElementIdentifier();
160 std::cout << "barrel_ec " << m_sctIdHelper.load()->barrel_ec(hitId)
161 << ", layer_disk " << m_sctIdHelper.load()->layer_disk(hitId) << ", phi_module " << m_sctIdHelper.load()->phi_module(hitId)
162 << ", eta_module " << m_sctIdHelper.load()->eta_module(hitId) << ", side " << m_sctIdHelper.load()->side(hitId) <<std::endl;
163 }
164 return true;
165}
166
#define M_PI
#define addOtherSide(cur, surfaces)
This is an Identifier helper class for the SCT subdetector.
#define addNextInPhiOS(cur, surfaces)
#define addPrevInEtaOS(cur, surfaces)
#define addPrevInPhiOS(cur, surfaces)
#define addNextInEtaOS(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
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
SCT_OverlapDescriptor(bool addMoreSurfaces=false, int eta_slices=4)
Constructor.
std::atomic< const SCT_ID * > m_sctIdHelper
This is an Identifier helper class for the SCT subdetector.
Definition SCT_ID.h:68
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