ATLAS Offline Software
Loading...
Searching...
No Matches
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
11
13// HGTD
15// Trk
16#include "TrkSurfaces/Surface.h"
17//
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
36bool 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
88bool 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}
#define M_PI
This is an Identifier helper class for the HGTD subdetector.
Definition HGTD_ID.h:47
const Trk::BinnedArray< Trk::Surface > * m_binnedArray
bool dumpSurfaces(std::vector< Trk::SurfaceIntersection > &surfaces) const
std::atomic< const HGTD_ID * > m_hgtdIdHelper
std::vector< float > m_valuesR
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
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.
std::vector< std::vector< float > > m_valuesPhi
Binned Array for avoiding map searches/.
Definition BinnedArray.h:36
Abstract Base Class for tracking surfaces.
const Amg::Vector3D & center() const
Returns the center position of the Surface.
Eigen::Matrix< double, 2, 1 > Vector2D
Eigen::Matrix< double, 3, 1 > Vector3D
STL namespace.