ATLAS Offline Software
PixelOverlapDescriptor.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 // PixelOverlapDescriptor.cxx, (c) ATLAS Detector software
8 
9 // Amg
11 // InDet
15 // Trk
16 #include "TrkSurfaces/Surface.h"
17 //
18 #include "StoreGate/StoreGateSvc.h"
19 
20 InDet::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 
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 - 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 
173 bool InDet::PixelOverlapDescriptor::dumpSurfaces(std::vector<Trk::SurfaceIntersection>& surfaces) const {
174 
175  if (m_pixIdHelper==nullptr) {
176  ISvcLocator* svcLocator = Gaudi::svcLocator();
177 
178  // get DetectorStore service
179  StoreGateSvc* detStore = nullptr;
180  if (svcLocator->service("DetectorStore", detStore).isFailure()) {
181  return false;
182  }
183 
184  const PixelID* pixIdHelper = nullptr;
185  if (detStore->retrieve(pixIdHelper, "PixelID").isFailure()) {
186  return false;
187  }
188  m_pixIdHelper = pixIdHelper;
189  }
190 
191  std::cout << "Dumping Surfaces for Pixel with size = " << surfaces.size() << std::endl;
192  for (auto & surface : surfaces) {
193  Identifier hitId = (surface.object)->associatedDetectorElementIdentifier();
194  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;
195  }
196  return true;
197 }
PixelID.h
This is an Identifier helper class for the Pixel subdetector. This class is a factory for creating co...
addNextInPhi
#define addNextInPhi(cur, surfaces)
Definition: PixelOverlapDescriptor.h:36
Trk::Intersection
Definition: Intersection.h:24
Trk::Surface::associatedDetectorElement
const TrkDetElementBase * associatedDetectorElement() const
return associated Detector Element
Surface.h
M_PI
#define M_PI
Definition: ActiveFraction.h:11
InDet::PixelOverlapDescriptor::m_robustMode
bool m_robustMode
Definition: PixelOverlapDescriptor.h:101
InDet::PixelOverlapDescriptor::m_etaSlices
int m_etaSlices
Definition: PixelOverlapDescriptor.h:103
Trk::Surface::center
const Amg::Vector3D & center() const
Returns the center position of the Surface.
InDet::PixelOverlapDescriptor::PixelOverlapDescriptor
PixelOverlapDescriptor(bool addMoreSurfaces=false, int eta_slices=3, int phi_slices=1)
Constructor (area restriction, LC check)
Definition: PixelOverlapDescriptor.cxx:20
Trk::DetectorElemType::Silicon
@ Silicon
GeoPrimitives.h
addNextInEta
#define addNextInEta(cur, surfaces)
Definition: PixelOverlapDescriptor.h:44
StoreGateSvc
The Athena Transient Store API.
Definition: StoreGateSvc.h:128
InDet::PixelOverlapDescriptor::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: PixelOverlapDescriptor.cxx:28
InDetDD::SiDetectorElement::prevInEta
const SiDetectorElement * prevInEta() const
fillPileUpNoiseLumi.next
next
Definition: fillPileUpNoiseLumi.py:52
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
InDetDD::SiDetectorElement::nextInPhi
const SiDetectorElement * nextInPhi() const
addPrevInEta
#define addPrevInEta(cur, surfaces)
Definition: PixelOverlapDescriptor.h:48
InDet::PixelOverlapDescriptor::m_phiSlices
int m_phiSlices
Definition: PixelOverlapDescriptor.h:104
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
addSurface
#define addSurface(cur, surfaces)
Definition: PixelOverlapDescriptor.h:24
PixelOverlapDescriptor.h
Trk::Surface
Definition: Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/Surface.h:75
PixelID
Definition: PixelID.h:67
StoreGateSvc.h
InDet::PixelOverlapDescriptor::m_addMoreSurfaces
bool m_addMoreSurfaces
Definition: PixelOverlapDescriptor.h:102
addPrevInPhi
#define addPrevInPhi(cur, surfaces)
Definition: PixelOverlapDescriptor.h:40
InDet::PixelOverlapDescriptor::m_pixIdHelper
std::atomic< const PixelID * > m_pixIdHelper
Definition: PixelOverlapDescriptor.h:105
InDet::PixelOverlapDescriptor::dumpSurfaces
bool dumpSurfaces(std::vector< Trk::SurfaceIntersection > &surfaces) const
Definition: PixelOverlapDescriptor.cxx:173