ATLAS Offline Software
SCT_OverlapDescriptor.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // SCT_OverlapDescriptor.cxx, (c) ATLAS Detector software
8 
9 // Amg
11 // InDet
14 #include "InDetIdentifier/SCT_ID.h"
15 // Trk
16 #include "TrkSurfaces/Surface.h"
17 //
18 #include "StoreGate/StoreGateSvc.h"
19 
20 InDet::SCT_OverlapDescriptor::SCT_OverlapDescriptor(bool addMoreSurfaces, int eta_slices)
21  : m_robustMode(true),
22  m_addMoreSurfaces(addMoreSurfaces),
23  m_etaSlices(eta_slices)
24 {}
25 
27 bool
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 
141 bool InDet::SCT_OverlapDescriptor::dumpSurfaces(std::vector<Trk::SurfaceIntersection>& surfaces) const {
142 
143  if (m_sctIdHelper==nullptr) {
144  ISvcLocator* svcLocator = Gaudi::svcLocator();
145 
146  // get DetectorStore service
147  StoreGateSvc* detStore = nullptr;
148  if (svcLocator->service("DetectorStore", detStore).isFailure()) {
149  return false;
150  }
151 
152  const SCT_ID* sctIdHelper = nullptr;
153  if (detStore->retrieve(sctIdHelper, "SCT_ID").isFailure()) {
154  return false;
155  }
156  m_sctIdHelper = sctIdHelper;
157  }
158 
159  std::cout << "Dumping Surfaces for SCT with size = " << surfaces.size() << std::endl;
160  for (auto & surface : surfaces) {
161  Identifier hitId = (surface.object)->associatedDetectorElementIdentifier();
162  std::cout << "barrel_ec " << m_sctIdHelper.load()->barrel_ec(hitId)
163  << ", layer_disk " << m_sctIdHelper.load()->layer_disk(hitId) << ", phi_module " << m_sctIdHelper.load()->phi_module(hitId)
164  << ", eta_module " << m_sctIdHelper.load()->eta_module(hitId) << ", side " << m_sctIdHelper.load()->side(hitId) <<std::endl;
165  }
166  return true;
167 }
168 
addPrevInPhiOS
#define addPrevInPhiOS(cur, surfaces)
Definition: SCT_OverlapDescriptor.h:39
SCT_ID.h
This is an Identifier helper class for the SCT subdetector. This class is a factory for creating comp...
Trk::Intersection
Definition: Intersection.h:24
Trk::Surface::associatedDetectorElement
const TrkDetElementBase * associatedDetectorElement() const
return associated Detector Element
InDet::SCT_OverlapDescriptor::dumpSurfaces
bool dumpSurfaces(std::vector< Trk::SurfaceIntersection > &surfaces) const
Definition: SCT_OverlapDescriptor.cxx:141
Surface.h
InDet::SCT_OverlapDescriptor::m_addMoreSurfaces
bool m_addMoreSurfaces
Definition: SCT_OverlapDescriptor.h:94
M_PI
#define M_PI
Definition: ActiveFraction.h:11
InDet::SCT_OverlapDescriptor::SCT_OverlapDescriptor
SCT_OverlapDescriptor(bool addMoreSurfaces=false, int eta_slices=4)
Constructor.
Definition: SCT_OverlapDescriptor.cxx:20
InDet::SCT_OverlapDescriptor::m_robustMode
bool m_robustMode
Definition: SCT_OverlapDescriptor.h:93
Trk::Surface::center
const Amg::Vector3D & center() const
Returns the center position of the Surface.
TRT::Hit::side
@ side
Definition: HitInfo.h:83
Trk::DetectorElemType::Silicon
@ Silicon
GeoPrimitives.h
StoreGateSvc
The Athena Transient Store API.
Definition: StoreGateSvc.h:128
InDetDD::SiDetectorElement::prevInEta
const SiDetectorElement * prevInEta() const
InDet::SCT_OverlapDescriptor::m_sctIdHelper
std::atomic< const SCT_ID * > m_sctIdHelper
Definition: SCT_OverlapDescriptor.h:96
fillPileUpNoiseLumi.next
next
Definition: fillPileUpNoiseLumi.py:52
InDet::SCT_OverlapDescriptor::reachableSurfaces
bool reachableSurfaces(std::vector< Trk::SurfaceIntersection > &cSurfaces, const Trk::Surface &sf, const Amg::Vector3D &pos, const Amg::Vector3D &dir) const
get the compatible surfaces
Definition: SCT_OverlapDescriptor.cxx:28
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
addPrevInEtaOS
#define addPrevInEtaOS(cur, surfaces)
Definition: SCT_OverlapDescriptor.h:47
SCT_OverlapDescriptor.h
InDetDD::SiDetectorElement::nextInPhi
const SiDetectorElement * nextInPhi() const
DeMoUpdate.tmp
string tmp
Definition: DeMoUpdate.py:1167
InDetDD::SiDetectorElement::prevInPhi
const SiDetectorElement * prevInPhi() const
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
InDetDD::SiDetectorElement
Definition: SiDetectorElement.h:109
InDetDD::SiDetectorElement::isBarrel
bool isBarrel() const
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
SiDetectorElement.h
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
InDetDD::SiDetectorElement::nextInEta
const SiDetectorElement * nextInEta() const
addNextInEtaOS
#define addNextInEtaOS(cur, surfaces)
Definition: SCT_OverlapDescriptor.h:43
SCT_ID
Definition: SCT_ID.h:68
addOtherSide
#define addOtherSide(cur, surfaces)
Definition: PixelOverlapDescriptor.h:30
Trk::Surface
Definition: Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/Surface.h:75
StoreGateSvc.h
InDet::SCT_OverlapDescriptor::m_etaSlices
int m_etaSlices
Definition: SCT_OverlapDescriptor.h:95
addNextInPhiOS
#define addNextInPhiOS(cur, surfaces)
Definition: SCT_OverlapDescriptor.h:35