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 the node storage and fill it from the xAOD space points
99 Acts::Experimental::GbtsNodeStorage nodeStorage = m_finder->makeNodeStorage(m_are_pixels);
100
101 // add spacepoints to node storage
102 for(std::size_t idx = 0; idx < tmpSpacePoints.size(); ++idx){
103 // obtain module hash for spacepoint
104 const xAOD::SpacePoint* sp = tmpSpacePoints[idx];
105 const std::vector<xAOD::DetectorIDHashType>& elementlist = sp->elementIdList();
106
107 const bool isPixel(elementlist.size() == 1);
108
109 const short layer = (isPixel ? m_pix_h2l : m_sct_h2l)->operator[](static_cast<int>(elementlist[0]));
110
111 float clusterWidth = 0.0f;
112 float localPositionY = 0.0f;
113 if (m_finderCfg.useMl && isPixel) {
114 assert(dynamic_cast<const xAOD::PixelCluster*>(sp->measurements().front())!=nullptr);
115 const xAOD::PixelCluster* pCL = static_cast<const xAOD::PixelCluster*>(sp->measurements().front());
116 clusterWidth = pCL->widthInEta();
117 localPositionY = pCL->localPosition<2>().y();
118 }
119
120 if (m_finderCfg.beamSpotCorrection) {
121 const float new_x = static_cast<float>(sp->x() - beamSpotPos[0]);
122 const float new_y = static_cast<float>(sp->y() - beamSpotPos[1]);
123 nodeStorage.insert(static_cast<Acts::SpacePointIndex>(idx), new_x, new_y, static_cast<float>(sp->z()),
124 std::hypot(new_x, new_y), std::atan2(new_y, new_x),
125 static_cast<std::uint32_t>(layer), clusterWidth, localPositionY);
126 } else {
127 const float new_x = static_cast<float>(sp->x());
128 const float new_y = static_cast<float>(sp->y());
129 nodeStorage.insert(static_cast<Acts::SpacePointIndex>(idx), new_x, new_y, static_cast<float>(sp->z()),
130 std::hypot(new_x, new_y), static_cast<float>(std::atan2(sp->y(), sp->x())),
131 static_cast<std::uint32_t>(layer), clusterWidth, localPositionY);
132 }
133 }
134
135 // order the nodes and build the derived per-node data
136 nodeStorage.finalize();
137
138 ATH_MSG_VERBOSE("Spacepoints successfully added to node storage");
139
140 Acts::SeedContainer seeds;
141 m_finder->createSeeds(nodeStorage, m_internalRoi.value(), *m_filter, options, seeds);
142
143 // add seeds to the output container
144 seedContainer.reserve(seedContainer.size() + seeds.size(), 7.0f);
145 for (auto seed : seeds) {
146 seedContainer.push_back(
147 seed.asConst(),
148 [&](const Acts::SpacePointIndex spIndex) {
149 return tmpSpacePoints[spIndex];
150 });
151 }
152
153 ATH_MSG_VERBOSE("Number of seeds created is " << seedContainer.size());
154 return StatusCode::SUCCESS;
155 }
156
157 // this is called in initialise
158 // adds all veriables that may have been changed in the gaudi properties defined in headerfile
159
161 m_finderCfg.lrtMode = m_LRTmode;
162 m_finderCfg.useMl = m_useML;
163 m_finderCfg.matchBeforeCreate = m_matchBeforeCreate;
164 m_finderCfg.useOldTunings = m_useOldTunings;
165 m_finderCfg.etaBinWidthOverride = m_etaBinWidthOverride;
166 m_finderCfg.beamSpotCorrection = m_beamSpotCorrection;
167 m_finderCfg.minPt = m_minPt;
168 m_finderCfg.nMaxPhiSlice = m_nMaxPhiSlice;
169 m_finderCfg.connectorInputFile = m_connectorInputFile;
170 m_finderCfg.lutInputFile = m_lutFile;
171 m_finderCfg.useEtaBinning = m_useEtaBinning;
172 m_finderCfg.doubletFilterRZ = m_doubletFilterRZ;
173 m_finderCfg.minDeltaRadius = m_minDeltaRadius;
174 m_finderCfg.nMaxEdges = m_nMaxEdges;
175 m_finderCfg.tauRatioCut = m_tauRatioCut;
176 m_finderCfg.tauRatioPrecut = m_tauRatioPrecut;
177 m_finderCfg.edgeMaskMinEta = m_edgeMaskMinEta;
178 m_finderCfg.hitShareThreshold = m_hitShareThreshold;
179 m_finderCfg.maxEndcapClusterWidth = m_maxEndcapClusterwidth;
180 m_finderCfg.d0Max = m_d0Max;
181
182 //use roi for pixel and given value for strip
183 m_finderCfg.maxZ0 = m_LRTmode ? m_maxZ0.value() : m_internalRoi->zMax();
184 m_finderCfg.minZ0 = m_LRTmode ? m_minZ0.value() : m_internalRoi->zMin();
185
186 m_finderCfg.validateTriplets = m_validateTriplets;
187 m_finderCfg.useAdaptiveCuts = m_useAdaptiveCuts;
188 m_finderCfg.tauRatioCorr = m_tauRatioCorr;
189 m_finderCfg.addTriplets = m_addTriplets;
190 m_finderCfg.maxAbsEtaAddTripelts = m_maxEtaAddTriplets;
191 m_finderCfg.cutDPhiMax = m_cutDPhiMax;
192 m_finderCfg.cutDCurvMax = m_cutDCurvMax;
193 m_finderCfg.minDeltaPhi = m_minDeltaPhi;
194 m_finderCfg.maxOuterRadius = m_maxOuterRadius;
195
196 m_filterCfg.sigmaMS = m_sigmaMS;
197 m_filterCfg.radLen = m_radLen;
198 m_filterCfg.sigmaX = m_sigmaX;
199 m_filterCfg.sigmaY = m_sigmaY;
200 m_filterCfg.weightX = m_weightX;
201 m_filterCfg.weightY = m_weightY;
202 m_filterCfg.maxDChi2X = m_maxDChi2X;
203 m_filterCfg.maxDChi2Y = m_maxDChi2Y;
204 m_filterCfg.addHit = m_addHit;
205 m_filterCfg.maxCurvature = m_maxCurvature;
207
208 return StatusCode::SUCCESS;
209 }
210
211 // called in initialise, used to make sure all config settings look sensible
213 ATH_MSG_DEBUG("===== GBTS finder config =====");
214 ATH_MSG_DEBUG( "beamSpotCorrection: " << m_finderCfg.beamSpotCorrection);
215 ATH_MSG_DEBUG( "connectorInputFile: " << m_finderCfg.connectorInputFile);
216 ATH_MSG_DEBUG( "lutInputFile: " << m_finderCfg.lutInputFile);
217 ATH_MSG_DEBUG( "lrtMode: " << m_finderCfg.lrtMode);
218 ATH_MSG_DEBUG( "useMl: " << m_finderCfg.useMl);
219 ATH_MSG_DEBUG( "matchBeforeCreate: " << m_finderCfg.matchBeforeCreate);
220 ATH_MSG_DEBUG( "useOldTunings: " << m_finderCfg.useOldTunings);
221 ATH_MSG_DEBUG( "tauRatioPrecut: " << m_finderCfg.tauRatioPrecut);
222 ATH_MSG_DEBUG( "tauRatioCut: " << m_finderCfg.tauRatioCut);
223 ATH_MSG_DEBUG( "tauRatioCorr: " << m_finderCfg.tauRatioCorr);
224 ATH_MSG_DEBUG( "etaBinWidthOverride: " << m_finderCfg.etaBinWidthOverride);
225 ATH_MSG_DEBUG( "nMaxPhiSlice: " << m_finderCfg.nMaxPhiSlice);
226 ATH_MSG_DEBUG( "minPt: " << m_finderCfg.minPt);
227 ATH_MSG_DEBUG( "useEtaBinning: " << m_finderCfg.useEtaBinning);
228 ATH_MSG_DEBUG( "doubletFilterRZ: " << m_finderCfg.doubletFilterRZ);
229 ATH_MSG_DEBUG( "nMaxEdges: " << m_finderCfg.nMaxEdges);
230 ATH_MSG_DEBUG( "minDeltaRadius: " << m_finderCfg.minDeltaRadius);
231 ATH_MSG_DEBUG( "edgeMaskMinEta: " << m_finderCfg.edgeMaskMinEta);
232 ATH_MSG_DEBUG( "hitShareThreshold: " << m_finderCfg.hitShareThreshold);
233 ATH_MSG_DEBUG( "maxEndcapClusterWidth: " << m_finderCfg.maxEndcapClusterWidth);
234 ATH_MSG_DEBUG( "d0Max: " << m_finderCfg.d0Max);
235 ATH_MSG_DEBUG("maxZ0: " << m_finderCfg.maxZ0);
236 ATH_MSG_DEBUG("minZ0: " << m_finderCfg.minZ0);
237 ATH_MSG_DEBUG( "validateTriplets: " << m_finderCfg.validateTriplets);
238 ATH_MSG_DEBUG( "useAdaptiveCuts: " << m_finderCfg.useAdaptiveCuts);
239 ATH_MSG_DEBUG( "addTriplets: " << m_finderCfg.addTriplets);
240 ATH_MSG_DEBUG( "maxEtaAddTriplets: " << m_finderCfg.maxAbsEtaAddTripelts);
241 ATH_MSG_DEBUG("cutDphiMax: " << m_finderCfg.cutDPhiMax);
242 ATH_MSG_DEBUG("cutDCurvMax: " << m_finderCfg.cutDCurvMax);
243 ATH_MSG_DEBUG("minDeltaPhi: " << m_finderCfg.minDeltaPhi);
244 ATH_MSG_DEBUG("maxOuterRadius: " << m_finderCfg.maxOuterRadius);
245
246 ATH_MSG_DEBUG("===== GBTS filter config =====");
247 ATH_MSG_DEBUG( "sigmaMS: " << m_filterCfg.sigmaMS);
248 ATH_MSG_DEBUG( "radLen: " << m_filterCfg.radLen);
249 ATH_MSG_DEBUG( "sigmaX: " << m_filterCfg.sigmaX);
250 ATH_MSG_DEBUG( "sigmaY: " << m_filterCfg.sigmaY);
251 ATH_MSG_DEBUG( "weightX: " << m_filterCfg.weightX);
252 ATH_MSG_DEBUG( "weightY: " << m_filterCfg.weightY);
253 ATH_MSG_DEBUG( "maxDChi2X: " << m_filterCfg.maxDChi2X);
254 ATH_MSG_DEBUG( "maxDChi2Y: " << m_filterCfg.maxDChi2Y);
255 ATH_MSG_DEBUG( "addHit: " << m_filterCfg.addHit);
256 ATH_MSG_DEBUG( "maxCurvature: " << m_filterCfg.maxCurvature);
257 ATH_MSG_DEBUG( "filterMaxZ0: " << m_filterCfg.maxZ0);
258}
259
260} // 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)
Definition Logger.cxx:64
#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
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