ATLAS Offline Software
Loading...
Searching...
No Matches
GbtsSeedingTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5#if defined(FLATTEN) && defined(__GNUC__)
6// Avoid warning in dbg build
7#pragma GCC optimize "-fno-var-tracking-assignments"
8#endif
9
10#include "src/GbtsSeedingTool.h"
11
13
14namespace ActsTrk {
15
17 const std::string& name,
18 const IInterface* parent)
19 : base_class(type, name, parent)
20 {}
21
23 ATH_CHECK(m_layerNumberTool.retrieve());
24 ATH_MSG_DEBUG("Initializing " << name() << "...");
25
26 // Make the logger And Propagate to ACTS routines
27 m_logger = makeActsAthenaLogger(this, "Acts");
28
29 // eta,etaMinus,etaPlus,phi,phiMinus,Phiplus,z,zMinus,zPlus
30 m_internalRoi.emplace(0, -4.5, 4.5, 0, -std::numbers::pi, std::numbers::pi, 0, -150.0,150.0);
31
34
35 // layer geometry creation
36 const std::vector<TrigInDetSiLayer>* pVL = m_layerNumberTool->layerGeometry();
37
38 // layer objects used by GBTS
39 std::vector<Acts::Experimental::GbtsLayerDescription> layers;
40 layers.reserve(pVL->size());
41
42 // convert from trigindetsilayer to acts::experimental::trigindetsilayer
43 for (const TrigInDetSiLayer&s : *pVL) {
44 const Acts::Experimental::GbtsLayerType type = s.m_type == 0 ? Acts::Experimental::GbtsLayerType::Barrel : Acts::Experimental::GbtsLayerType::Endcap;
45 layers.emplace_back(s.m_subdet, type, s.m_refCoord, s.m_minBound, s.m_maxBound);
46 }
47
48 // fill which has id for each module belongs to what layer
49 m_sct_h2l = m_layerNumberTool->sctLayers();
50 m_pix_h2l = m_layerNumberTool->pixelLayers();
51 m_are_pixels.resize(m_layerNumberTool->maxNumberOfUniqueLayers(), true);
52 for(const auto& l : *m_sct_h2l) m_are_pixels[l] = false;
53
54 // parse connection
55 auto layerConnectionMap = Acts::Experimental::GbtsLayerConnectionMap::fromFile(m_finderCfg.connectorInputFile, m_finderCfg.lrtMode);
56
57 // option that allows for adding custom eta binning (default is at 0.2)
58 if (m_finderCfg.etaBinWidthOverride != 0.0f) {
59 layerConnectionMap.etaBinWidth = m_finderCfg.etaBinWidthOverride;
60 }
61
62 // create geoemtry object that holds allowed pairing of allowed eta regions in each layer
63 // holds all geometry information (m_layergeomtry and connection table)
64 auto gbtsGeo = std::make_shared<Acts::Experimental::GbtsGeometry>(layers, layerConnectionMap);
65
66 m_finder = Acts::Experimental::GraphBasedTrackSeeder(
67 Acts::Experimental::GraphBasedTrackSeeder::DerivedConfig(m_finderCfg),
68 gbtsGeo, logger().cloneWithSuffix("gbtsFinder"));
69
70 m_filter = Acts::Experimental::GbtsTrackingFilter(m_filterCfg, gbtsGeo);
71
72 return StatusCode::SUCCESS;
73 }
74
77 const EventContext& ctx,
78 const std::vector<const xAOD::SpacePointContainer*>& spacePointCollections,
79 const Eigen::Vector3f& beamSpotPos, float bFieldInZ,
80 ActsTrk::SeedContainer& seedContainer) const
81 {
82 // to avoid compile issues with unused veriables
83 (void) ctx;
84
85 const Acts::Experimental::GraphBasedTrackSeeder::Options options(bFieldInZ);
86
87
88 std::vector<const xAOD::SpacePoint*> tmpSpacePoints;
89
90 // add spacepoint pointers to singel container, this makes indexing them easier
91 for (const xAOD::SpacePointContainer* spacePoints : spacePointCollections) {
92 for (const xAOD::SpacePoint* sp : *spacePoints) {
93 tmpSpacePoints.emplace_back(sp);
94 }
95 }
96
97
98 // create node storage manually
99 std::vector<std::vector<Acts::Experimental::GbtsNode>> nodeStorage{};
100 nodeStorage.resize(m_are_pixels.size());
101 //reasonable size for reservation
102 for (auto& v : nodeStorage) {
103 v.reserve(10000);
104 }
105
106 // add spacepoints to node storage
107 for(std::size_t idx = 0; idx < tmpSpacePoints.size(); ++idx){
108 // obtain module hash for spacepoint
109 const xAOD::SpacePoint* sp = tmpSpacePoints[idx];
110 const std::vector<xAOD::DetectorIDHashType>& elementlist = sp->elementIdList();
111
112 const bool isPixel(elementlist.size() == 1);
113
114 const short layer = (isPixel ? m_pix_h2l : m_sct_h2l)->operator[](static_cast<int>(elementlist[0]));
115
116 Acts::Experimental::GbtsNode& node = nodeStorage[layer].emplace_back(layer);
117 if (m_finderCfg.beamSpotCorrection) {
118 const float new_x = static_cast<float>(sp->x() - beamSpotPos[0]);
119 const float new_y = static_cast<float>(sp->y() - beamSpotPos[1]);
120 node.x = new_x;
121 node.y = new_y;
122 node.z = static_cast<float>(sp->z());
123 node.r = std::hypot(new_x, new_y);
124 node.phi = std::atan2(new_y, new_x);
125 node.idx = idx;
126 } else {
127 const float new_x = static_cast<float>(sp->x());
128 const float new_y = static_cast<float>(sp->y());
129 node.x = static_cast<float>(sp->x());
130 node.y = static_cast<float>(sp->y());
131 node.z = static_cast<float>(sp->z());
132 node.r = std::hypot(new_x, new_y);
133 node.phi = std::atan2(sp->y(), sp->x());
134 node.idx = idx;
135 }
136
137 if (m_finderCfg.useMl && isPixel) {
138 assert(dynamic_cast<const xAOD::PixelCluster*>(sp->measurements().front())!=nullptr);
139 const xAOD::PixelCluster* pCL = static_cast<const xAOD::PixelCluster*>(sp->measurements().front());
140 node.pcw = pCL->widthInEta();
141 node.locPosY = pCL->localPosition<2>().y();
142 }
143 }
144
145 ATH_MSG_VERBOSE("Spacepoints successfully added to node storage");
146
147 Acts::SeedContainer2 seeds;
148 m_finder->createSeeds(nodeStorage, m_are_pixels, m_internalRoi.value(), *m_filter, options, seeds);
149
150 // add seeds to the output container
151 seedContainer.reserve(seedContainer.size() + seeds.size(), 7.0f);
152 for (auto seed : seeds) {
153 seedContainer.push_back(
154 seed.asConst(),
155 [&](const Acts::SpacePointIndex2 spIndex) {
156 return tmpSpacePoints[spIndex];
157 });
158 }
159
160 ATH_MSG_VERBOSE("Number of seeds created is " << seedContainer.size());
161 return StatusCode::SUCCESS;
162 }
163
164 // this is called in initialise
165 // adds all veriables that may have been changed in the gaudi properties defined in headerfile
166
168 m_finderCfg.lrtMode = m_LRTmode;
169 m_finderCfg.useMl = m_useML;
170 m_finderCfg.matchBeforeCreate = m_matchBeforeCreate;
171 m_finderCfg.useOldTunings = m_useOldTunings;
172 m_finderCfg.etaBinWidthOverride = m_etaBinWidthOverride;
173 m_finderCfg.beamSpotCorrection = m_beamSpotCorrection;
174 m_finderCfg.minPt = m_minPt;
175 m_finderCfg.nMaxPhiSlice = m_nMaxPhiSlice;
176 m_finderCfg.connectorInputFile = m_connectorInputFile;
177 m_finderCfg.lutInputFile = m_lutFile;
178 m_finderCfg.useEtaBinning = m_useEtaBinning;
179 m_finderCfg.doubletFilterRZ = m_doubletFilterRZ;
180 m_finderCfg.minDeltaRadius = m_minDeltaRadius;
181 m_finderCfg.nMaxEdges = m_nMaxEdges;
182 m_finderCfg.tauRatioCut = m_tauRatioCut;
183 m_finderCfg.tauRatioPrecut = m_tauRatioPrecut;
184 m_finderCfg.edgeMaskMinEta = m_edgeMaskMinEta;
185 m_finderCfg.hitShareThreshold = m_hitShareThreshold;
186 m_finderCfg.maxEndcapClusterWidth = m_maxEndcapClusterwidth;
187 m_finderCfg.d0Max = m_d0Max;
188
189 //use roi for pixel and given value for strip
190 m_finderCfg.maxZ0 = m_LRTmode ? m_maxZ0.value() : m_internalRoi->zMax();
191 m_finderCfg.minZ0 = m_LRTmode ? m_minZ0.value() : m_internalRoi->zMin();
192
193 m_finderCfg.validateTriplets = m_validateTriplets;
194 m_finderCfg.useAdaptiveCuts = m_useAdaptiveCuts;
195 m_finderCfg.tauRatioCorr = m_tauRatioCorr;
196 m_finderCfg.addTriplets = m_addTriplets;
197 m_finderCfg.maxAbsEtaAddTripelts = m_maxEtaAddTriplets;
198 m_finderCfg.cutDPhiMax = m_cutDPhiMax;
199 m_finderCfg.cutDCurvMax = m_cutDCurvMax;
200 m_finderCfg.minDeltaPhi = m_minDeltaPhi;
201 m_finderCfg.maxOuterRadius = m_maxOuterRadius;
202
203 m_filterCfg.sigmaMS = m_sigmaMS;
204 m_filterCfg.radLen = m_radLen;
205 m_filterCfg.sigmaX = m_sigmaX;
206 m_filterCfg.sigmaY = m_sigmaY;
207 m_filterCfg.weightX = m_weightX;
208 m_filterCfg.weightY = m_weightY;
209 m_filterCfg.maxDChi2X = m_maxDChi2X;
210 m_filterCfg.maxDChi2Y = m_maxDChi2Y;
211 m_filterCfg.addHit = m_addHit;
212 m_filterCfg.maxCurvature = m_maxCurvature;
214
215 return StatusCode::SUCCESS;
216 }
217
218 // called in initialise, used to make sure all config settings look sensible
220 ATH_MSG_DEBUG("===== GBTS finder config =====");
221 ATH_MSG_DEBUG( "beamSpotCorrection: " << m_finderCfg.beamSpotCorrection);
222 ATH_MSG_DEBUG( "connectorInputFile: " << m_finderCfg.connectorInputFile);
223 ATH_MSG_DEBUG( "lutInputFile: " << m_finderCfg.lutInputFile);
224 ATH_MSG_DEBUG( "lrtMode: " << m_finderCfg.lrtMode);
225 ATH_MSG_DEBUG( "useMl: " << m_finderCfg.useMl);
226 ATH_MSG_DEBUG( "matchBeforeCreate: " << m_finderCfg.matchBeforeCreate);
227 ATH_MSG_DEBUG( "useOldTunings: " << m_finderCfg.useOldTunings);
228 ATH_MSG_DEBUG( "tauRatioPrecut: " << m_finderCfg.tauRatioPrecut);
229 ATH_MSG_DEBUG( "tauRatioCut: " << m_finderCfg.tauRatioCut);
230 ATH_MSG_DEBUG( "tauRatioCorr: " << m_finderCfg.tauRatioCorr);
231 ATH_MSG_DEBUG( "etaBinWidthOverride: " << m_finderCfg.etaBinWidthOverride);
232 ATH_MSG_DEBUG( "nMaxPhiSlice: " << m_finderCfg.nMaxPhiSlice);
233 ATH_MSG_DEBUG( "minPt: " << m_finderCfg.minPt);
234 ATH_MSG_DEBUG( "useEtaBinning: " << m_finderCfg.useEtaBinning);
235 ATH_MSG_DEBUG( "doubletFilterRZ: " << m_finderCfg.doubletFilterRZ);
236 ATH_MSG_DEBUG( "nMaxEdges: " << m_finderCfg.nMaxEdges);
237 ATH_MSG_DEBUG( "minDeltaRadius: " << m_finderCfg.minDeltaRadius);
238 ATH_MSG_DEBUG( "edgeMaskMinEta: " << m_finderCfg.edgeMaskMinEta);
239 ATH_MSG_DEBUG( "hitShareThreshold: " << m_finderCfg.hitShareThreshold);
240 ATH_MSG_DEBUG( "maxEndcapClusterWidth: " << m_finderCfg.maxEndcapClusterWidth);
241 ATH_MSG_DEBUG( "d0Max: " << m_finderCfg.d0Max);
242 ATH_MSG_DEBUG("maxZ0: " << m_finderCfg.maxZ0);
243 ATH_MSG_DEBUG("minZ0: " << m_finderCfg.minZ0);
244 ATH_MSG_DEBUG( "validateTriplets: " << m_finderCfg.validateTriplets);
245 ATH_MSG_DEBUG( "useAdaptiveCuts: " << m_finderCfg.useAdaptiveCuts);
246 ATH_MSG_DEBUG( "addTriplets: " << m_finderCfg.addTriplets);
247 ATH_MSG_DEBUG( "maxEtaAddTriplets: " << m_finderCfg.maxAbsEtaAddTripelts);
248 ATH_MSG_DEBUG("cutDphiMax: " << m_finderCfg.cutDPhiMax);
249 ATH_MSG_DEBUG("cutDCurvMax: " << m_finderCfg.cutDCurvMax);
250 ATH_MSG_DEBUG("minDeltaPhi: " << m_finderCfg.minDeltaPhi);
251 ATH_MSG_DEBUG("maxOuterRadius: " << m_finderCfg.maxOuterRadius);
252
253 ATH_MSG_DEBUG("===== GBTS filter config =====");
254 ATH_MSG_DEBUG( "sigmaMS: " << m_filterCfg.sigmaMS);
255 ATH_MSG_DEBUG( "radLen: " << m_filterCfg.radLen);
256 ATH_MSG_DEBUG( "sigmaX: " << m_filterCfg.sigmaX);
257 ATH_MSG_DEBUG( "sigmaY: " << m_filterCfg.sigmaY);
258 ATH_MSG_DEBUG( "weightX: " << m_filterCfg.weightX);
259 ATH_MSG_DEBUG( "weightY: " << m_filterCfg.weightY);
260 ATH_MSG_DEBUG( "maxDChi2X: " << m_filterCfg.maxDChi2X);
261 ATH_MSG_DEBUG( "maxDChi2Y: " << m_filterCfg.maxDChi2Y);
262 ATH_MSG_DEBUG( "addHit: " << m_filterCfg.addHit);
263 ATH_MSG_DEBUG( "maxCurvature: " << m_filterCfg.maxCurvature);
264 ATH_MSG_DEBUG( "filterMaxZ0: " << m_filterCfg.maxZ0);
265}
266
267} // namespace ActsTrk
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
static Double_t sp
std::unique_ptr< const Acts::Logger > makeActsAthenaLogger(IMessageSvc *svc, const std::string &name, int level, std::optional< std::string > parent_name)
#define y
Gaudi::Property< bool > m_doubletFilterRZ
Gaudi::Property< float > m_maxZ0
Gaudi::Property< int > m_nMaxEdges
Gaudi::Property< float > m_maxEtaAddTriplets
Gaudi::Property< float > m_filterMaxZ0
Gaudi::Property< float > m_minPt
Gaudi::Property< bool > m_useAdaptiveCuts
Gaudi::Property< float > m_maxDChi2X
Gaudi::Property< float > m_weightX
std::vector< bool > m_are_pixels
Gaudi::Property< float > m_sigmaMS
virtual StatusCode initialize() override
Gaudi::Property< float > m_cutDPhiMax
const std::vector< short > * m_sct_h2l
lists of layers that pixel and strip modules are apart of (index defines hash ID of module),...
Gaudi::Property< bool > m_validateTriplets
Gaudi::Property< float > m_sigmaY
Gaudi::Property< bool > m_LRTmode
std::optional< Acts::Experimental::GbtsRoiDescriptor > m_internalRoi
region of interest for pixel seeding
Gaudi::Property< float > m_edgeMaskMinEta
Gaudi::Property< float > m_addHit
std::unique_ptr< const Acts::Logger > m_logger
logging instance
StatusCode createSeeds(const EventContext &ctx, const std::vector< const xAOD::SpacePointContainer * > &spacePointCollections, const Eigen::Vector3f &beamSpotPos, float bFieldInZ, ActsTrk::SeedContainer &seedContainer) const override
Gaudi::Property< float > m_nMaxPhiSlice
Gaudi::Property< float > m_maxCurvature
Gaudi::Property< float > m_maxOuterRadius
Gaudi::Property< float > m_etaBinWidthOverride
Gaudi::Property< bool > m_useOldTunings
Gaudi::Property< float > m_minZ0
const Acts::Logger & logger() const
Private access to the logger.
Acts::Experimental::GbtsTrackingFilter::Config m_filterCfg
steering for track filter
void printGbtsConfig() const
prints all current config settings used either with default settings or properties changed by the gau...
Gaudi::Property< float > m_maxDChi2Y
Gaudi::Property< std::string > m_connectorInputFile
Acts::Experimental::GraphBasedTrackSeeder::Config m_finderCfg
steering for seeding algorithm
const std::vector< short > * m_pix_h2l
Gaudi::Property< float > m_cutDCurvMax
Gaudi::Property< float > m_minDeltaPhi
Gaudi::Property< bool > m_useML
Gaudi::Property< float > m_minDeltaRadius
std::optional< Acts::Experimental::GbtsTrackingFilter > m_filter
the seed filter
Gaudi::Property< float > m_tauRatioPrecut
Gaudi::Property< bool > m_useEtaBinning
Gaudi::Property< bool > m_matchBeforeCreate
std::optional< Acts::Experimental::GraphBasedTrackSeeder > m_finder
the actual seed fining algorithm
StatusCode prepareConfiguration()
sets configs based on gaudi properties defined below
Gaudi::Property< float > m_maxEndcapClusterwidth
Gaudi::Property< float > m_tauRatioCorr
Gaudi::Property< float > m_hitShareThreshold
Gaudi::Property< float > m_sigmaX
Gaudi::Property< bool > m_beamSpotCorrection
Gaudi::Property< float > m_weightY
ToolHandle< ITrigL2LayerNumberTool > m_layerNumberTool
used to create the detector layers and which modules correspond to pixels and strips
Gaudi::Property< float > m_tauRatioCut
Gaudi::Property< float > m_d0Max
Gaudi::Property< bool > m_addTriplets
Gaudi::Property< std::string > m_lutFile
GbtsSeedingTool(const std::string &type, const std::string &name, const IInterface *parent)
Gaudi::Property< float > m_radLen
Definition node.h:24
float widthInEta() const
Returns the width of the cluster in phi (x) and eta (y) directions, respectively.
ConstVectorMap< N > localPosition() const
Returns the local position of the measurement.
#define ATH_FLATTEN
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
SpacePointContainer_v1 SpacePointContainer
Define the version of the space point container.
PixelCluster_v1 PixelCluster
Define the version of the pixel cluster class.
Seed push_back(SpacePointRange spacePoints, float quality, float vertexZ)
void reserve(std::size_t size, float averageSpacePoints=3) noexcept
std::size_t size() const noexcept