ATLAS Offline Software
HGTD_OverlapDescriptor.cxx
Go to the documentation of this file.
1 
2 /*
3  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
4 */
5 
7 // HGTD_OverlapDescriptor.cxx, (c) ATLAS Detector software
9 
10 #include "HGTD_OverlapDescriptor.h"
11 
13 // HGTD
15 // Trk
16 #include "TrkSurfaces/Surface.h"
17 //
18 #include "StoreGate/StoreGateSvc.h"
19 #include "Identifier/Identifier.h"
20 
21 #include <utility>
22 
23 
25  std::vector < float > valuesR,
26  std::vector < std::vector< float> > valuesPhi,
27  int nStepsR, int nStepsPhi):
28  m_binnedArray(bin_array),
29  m_valuesR(std::move(valuesR)),
30  m_valuesPhi(std::move(valuesPhi)),
31  m_nStepsR(nStepsR),
32  m_nStepsPhi(nStepsPhi)
33 {}
34 
36 bool HGTD_OverlapDescriptor::reachableSurfaces(std::vector<Trk::SurfaceIntersection>& surfaces,
37  const Trk::Surface& tsf,
38  const Amg::Vector3D& pos,
39  const Amg::Vector3D&) const
40 
41 {
42  surfaces.emplace_back(Trk::Intersection(pos, 0., true),&tsf);
43 
44  // add the other targets
45  // use the center of this surface in (x,y) global coordinates and look for
46  // adjactent ones in the binutiliy
47 
48  float centerR = tsf.center().perp();
49  float centerPhi = tsf.center().phi();
50 
51  std::vector<const Trk::Surface*> allSurfaces = {};
52 
53  const auto rBoundVal = std::lower_bound(m_valuesR.begin(), m_valuesR.end(), centerR);
54  int rIndex = std::distance(m_valuesR.begin(), rBoundVal);
55 
56  for (int stepR=-m_nStepsR; stepR<=m_nStepsR; stepR++) {
57  int index_r = rIndex+stepR;
58  if (index_r>=0 and index_r<int(m_valuesR.size()-1)) {
59  const auto phiBoundVal = std::lower_bound(m_valuesPhi.at(index_r).begin(), m_valuesPhi.at(index_r).end(), centerPhi);
60  int phiIndex = std::distance(m_valuesPhi.at(index_r).begin(), phiBoundVal);
61  for (int stepPhi=-m_nStepsPhi; stepPhi<=m_nStepsPhi; stepPhi++) {
62  int index_phi = phiIndex+stepPhi;
63  if (index_phi<0)
64  index_phi = int(m_valuesPhi.at(index_r).size())+index_phi;
65  else if (index_phi>int(m_valuesPhi.at(index_r).size()-1))
66  index_phi = index_phi-int(m_valuesPhi.at(index_r).size());
67  float pos_r = 0.5*(m_valuesR.at(index_r)+m_valuesR.at(index_r+1));
68  float pos_phi = 0.;
69  if (index_phi == int(m_valuesPhi.at(index_r).size()-1))
70  pos_phi = 0.5*(m_valuesPhi.at(index_r).at(index_phi)+M_PI);
71  else
72  pos_phi = 0.5*(m_valuesPhi.at(index_r).at(index_phi)+m_valuesPhi.at(index_r).at(index_phi+1));
73  const Trk::Surface* surf = m_binnedArray->object(Amg::Vector2D(pos_r, pos_phi));
74  if (surf and std::find(allSurfaces.begin(), allSurfaces.end(), surf) == allSurfaces.end()) {
75  allSurfaces.push_back(surf);
76  }
77  }
78  }
79  }
80 
81  for (auto& surface : allSurfaces)
82  surfaces.emplace_back(Trk::Intersection(Amg::Vector3D(0.,0.,0.),0.,true),surface);
83 
84  return false;
85 }
86 
87 
88 bool HGTD_OverlapDescriptor::dumpSurfaces(std::vector<Trk::SurfaceIntersection>& surfaces) const {
89 
90  if (m_hgtdIdHelper==nullptr) {
91  // Get Storegate, ID helpers, and so on
92  ISvcLocator* svcLocator = Gaudi::svcLocator();
93 
94  // get DetectorStore service
95  SmartIF<StoreGateSvc> detStore{svcLocator->service("DetectorStore")};
96  if (!detStore) {
97  return false;
98  }
99 
100  const HGTD_ID* hgtdIdHelper = nullptr;
101  if (detStore->retrieve(hgtdIdHelper, "HGTD_ID").isFailure()) {
102  return false;
103  }
104  m_hgtdIdHelper = hgtdIdHelper;
105  }
106 
107  std::cout << "Dumping Surfaces for HGTD with size = " << surfaces.size() << std::endl;
108  for (auto & surface : surfaces) {
109  Identifier hitId = (surface.object)->associatedDetectorElementIdentifier();
110  std::cout << "barrel_ec " << m_hgtdIdHelper.load()->endcap(hitId) << ", layer_disk " << m_hgtdIdHelper.load()->layer(hitId) << ", phi_module " << m_hgtdIdHelper.load()->phi_module(hitId) << ", eta_module " << m_hgtdIdHelper.load()->eta_module(hitId) << std::endl;
111  }
112  return true;
113 }
HGTD_OverlapDescriptor::m_valuesR
std::vector< float > m_valuesR
Definition: HGTD_OverlapDescriptor.h:75
Trk::Intersection
Definition: Intersection.h:24
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
Surface.h
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
Amg::Vector2D
Eigen::Matrix< double, 2, 1 > Vector2D
Definition: GeoPrimitives.h:48
HGTD_OverlapDescriptor::m_nStepsPhi
int m_nStepsPhi
Definition: HGTD_OverlapDescriptor.h:78
HGTD_OverlapDescriptor::dumpSurfaces
bool dumpSurfaces(std::vector< Trk::SurfaceIntersection > &surfaces) const
Definition: HGTD_OverlapDescriptor.cxx:88
HGTD_OverlapDescriptor::m_valuesPhi
std::vector< std::vector< float > > m_valuesPhi
Definition: HGTD_OverlapDescriptor.h:76
M_PI
#define M_PI
Definition: ActiveFraction.h:11
Trk::BinnedArray::object
virtual T * object(const Amg::Vector2D &lp) const =0
Returns the pointer to the templated class object from the BinnedArray, it returns 0 if not defined,...
Trk::Surface::center
const Amg::Vector3D & center() const
Returns the center position of the Surface.
HGTD_OverlapDescriptor::HGTD_OverlapDescriptor
HGTD_OverlapDescriptor(const Trk::BinnedArray< Trk::Surface > *bin_array=nullptr, std::vector< float > valuesR={}, std::vector< std::vector< float > > valuesPhi={}, int nStepsR=3, int nStepsPhi=10)
Constructor.
Definition: HGTD_OverlapDescriptor.cxx:24
GeoPrimitives.h
HGTD_OverlapDescriptor.h
HGTD_ID
Definition: HGTD_ID.h:47
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
HGTD_OverlapDescriptor::m_hgtdIdHelper
std::atomic< const HGTD_ID * > m_hgtdIdHelper
Definition: HGTD_OverlapDescriptor.h:79
HGTD_ID.h
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
eflowRec::phiIndex
unsigned int phiIndex(float phi, float binsize)
calculate phi index for a given phi
Definition: EtaPhiLUT.cxx:23
HGTD_OverlapDescriptor::m_nStepsR
int m_nStepsR
Definition: HGTD_OverlapDescriptor.h:77
Trk::BinnedArray< Trk::Surface >
Trk::Surface
Definition: Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/Surface.h:75
Amg::distance
float distance(const Amg::Vector3D &p1, const Amg::Vector3D &p2)
calculates the distance between two point in 3D space
Definition: GeoPrimitivesHelpers.h:54
StoreGateSvc.h
HGTD_OverlapDescriptor::m_binnedArray
const Trk::BinnedArray< Trk::Surface > * m_binnedArray
Definition: HGTD_OverlapDescriptor.h:74
HGTD_OverlapDescriptor::reachableSurfaces
bool reachableSurfaces(std::vector< Trk::SurfaceIntersection > &surfaces, const Trk::Surface &sf, const Amg::Vector3D &pos, const Amg::Vector3D &dir) const override
get the compatible surfaces
Definition: HGTD_OverlapDescriptor.cxx:36
Identifier
Definition: IdentifierFieldParser.cxx:14