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
31
32 // layer geometry creation
33 const std::vector<TrigInDetSiLayer>* pVL = m_layerNumberTool->layerGeometry();
34
35 // layer objects used by GBTS
36 std::vector<Acts::Experimental::GbtsLayerDescription> layers;
37 layers.reserve(pVL->size());
38
39 // convert from trigindetsilayer to acts::experimental::trigindetsilayer
40 for (const TrigInDetSiLayer&s : *pVL) {
41 const Acts::Experimental::GbtsLayerType type = s.m_type == 0 ? Acts::Experimental::GbtsLayerType::Barrel : Acts::Experimental::GbtsLayerType::Endcap;
42 layers.emplace_back(s.m_subdet, type, s.m_refCoord, s.m_minBound, s.m_maxBound);
43 }
44
45 // fill which has id for each module belongs to what layer
46 m_sct_h2l = m_layerNumberTool->sctLayers();
47 m_pix_h2l = m_layerNumberTool->pixelLayers();
48 m_are_pixels.resize(m_layerNumberTool->maxNumberOfUniqueLayers(), true);
49 for(const auto& l : *m_sct_h2l) m_are_pixels[l] = false;
50
51 // parse connection
52 auto layerConnectionMap = Acts::Experimental::GbtsLayerConnectionMap::fromFile(m_finderCfg.connectorInputFile, m_finderCfg.lrtMode);
53
54 // option that allows for adding custom eta binning (default is at 0.2)
55 if (m_finderCfg.etaBinWidthOverride != 0.0f) {
56 layerConnectionMap.etaBinWidth = m_finderCfg.etaBinWidthOverride;
57 }
58
59 // create geoemtry object that holds allowed pairing of allowed eta regions in each layer
60 // holds all geometry information (m_layergeomtry and connection table)
61 auto gbtsGeo = std::make_shared<Acts::Experimental::GbtsGeometry>(layers, layerConnectionMap);
62
63 m_finder = Acts::Experimental::GraphBasedTrackSeeder(
64 Acts::Experimental::GraphBasedTrackSeeder::DerivedConfig(m_finderCfg),
65 gbtsGeo, logger().cloneWithSuffix("gbtsFinder"));
66
67 m_filter = Acts::Experimental::GbtsTrackingFilter(m_filterCfg, gbtsGeo);
68
69 return StatusCode::SUCCESS;
70 }
71
74 const EventContext& ctx,
75 const std::vector<const xAOD::SpacePointContainer*>& spacePointCollections,
76 const Eigen::Vector3f& beamSpotPos, float bFieldInZ,
77 ActsTrk::SeedContainer& seedContainer) const
78 {
79 // to avoid compile issues with unused veriables
80 (void) ctx;
81
82 const Acts::Experimental::GraphBasedTrackSeeder::Options options(bFieldInZ);
83
84 // define new custom spacepoint container
85 Acts::SpacePointContainer2 coreSpacePoints(
86 Acts::SpacePointColumns::CopyFromIndex |
87 Acts::SpacePointColumns::SourceLinks |
88 Acts::SpacePointColumns::X |
89 Acts::SpacePointColumns::Y |
90 Acts::SpacePointColumns::Z |
91 Acts::SpacePointColumns::R |
92 Acts::SpacePointColumns::Phi
93 );
94
95 // add new column for layer ID and clusterwidth
96 auto layerColumn = coreSpacePoints.createColumn<std::uint32_t>("layerId");
97 auto clusterWidthColumn = coreSpacePoints.createColumn<float>("clusterWidth");
98 auto localPositionColumn = coreSpacePoints.createColumn<float>("localPositionY");
99
100 std::vector<const xAOD::SpacePoint*> tmpSpacePoints;
101 std::size_t totalSpacePoints = 0;
102
103 // add spacepoint pointers to singel container, this makes indexing them easier
104 for (const xAOD::SpacePointContainer* spacePoints : spacePointCollections) {
105 for (const xAOD::SpacePoint* sp : *spacePoints) {
106 tmpSpacePoints.emplace_back(sp);
107 }
108 totalSpacePoints += spacePoints->size();
109 }
110
111 coreSpacePoints.reserve(totalSpacePoints);
112
113 // add spacepoints to new container
114 for(std::size_t idx = 0; idx < tmpSpacePoints.size(); ++idx){
115 // obtain module hash for spacepoint
116 const xAOD::SpacePoint* sp = tmpSpacePoints[idx];
117 const std::vector<xAOD::DetectorIDHashType>& elementlist = sp->elementIdList();
118
119 const bool isPixel(elementlist.size() == 1);
120 if (isPixel == false) continue; // as currently strip hits are not used for seeding
121
122 const short layer = (isPixel ? m_pix_h2l : m_sct_h2l)->operator[](static_cast<int>(elementlist[0]));
123
124 auto newSp = coreSpacePoints.createSpacePoint();
125 newSp.copyFromIndex() = idx;
126
127 // apply beamspot corrections if needed
128 if (m_finderCfg.beamSpotCorrection) {
129 const float new_x = static_cast<float>(sp->x() - beamSpotPos[0]);
130 const float new_y = static_cast<float>(sp->y() - beamSpotPos[1]);
131 newSp.x() = new_x;
132 newSp.y() = new_y;
133 newSp.z() = static_cast<float>(sp->z());
134 newSp.r() = std::hypot(new_x, new_y);
135 newSp.phi() = std::atan2(new_y, new_x);
136 } else {
137 const float new_x = static_cast<float>(sp->x());
138 const float new_y = static_cast<float>(sp->y());
139 newSp.x() = static_cast<float>(sp->x());
140 newSp.y() = static_cast<float>(sp->y());
141 newSp.z() = static_cast<float>(sp->z());
142 newSp.r() = std::hypot(new_x, new_y);
143 newSp.phi() = std::atan2(sp->y(), sp->x());
144 }
145
146 newSp.extra(layerColumn) = layer;
147
148 if (m_finderCfg.useMl) {
149 assert(dynamic_cast<const xAOD::PixelCluster*>(sp->measurements().front())!=nullptr);
150 const xAOD::PixelCluster* pCL = static_cast<const xAOD::PixelCluster*>(sp->measurements().front());
151 newSp.extra(clusterWidthColumn) = pCL->widthInEta();
152 newSp.extra(localPositionColumn) = pCL->localPosition<2>().y();
153 }
154 }
155
156 ATH_MSG_VERBOSE("Spacepoints successfully added to new container");
157
158 const int max_layers = m_are_pixels.size();
159 // eta,etaMinus,etaPlus,phi,phiMinus,Phiplus,z,zMinus,zPlus
160 const Acts::Experimental::GbtsRoiDescriptor internalRoi(0, -4.5, 4.5, 0, -std::numbers::pi, std::numbers::pi, 0, -150.0,150.0);
161 Acts::SeedContainer2 seeds;
162 m_finder->createSeeds(coreSpacePoints, internalRoi, max_layers, *m_filter, options, seeds);
163
164 // add seeds to the output container
165 seedContainer.reserve(seedContainer.size() + seeds.size(), 7.0f);
166 for (auto seed : seeds) {
167 seedContainer.push_back(
168 seed.asConst(),
169 [&](const Acts::SpacePointIndex2 spIndex) {
170 return tmpSpacePoints[spIndex];
171 });
172 }
173
174 ATH_MSG_VERBOSE("Number of seeds created is " << seedContainer.size());
175 return StatusCode::SUCCESS;
176 }
177
178 // this is called in initialise
179 // adds all veriables that may have been changed in the gaudi properties defined in headerfile
180 // TODO: ADD NEW VERIABLES, DELETE OLD ONES AND CHANGE CURRENT ONES TO NEW VALUES
182 m_finderCfg.lrtMode = m_LRTmode;
183 m_finderCfg.useMl = m_useML;
184 m_finderCfg.matchBeforeCreate = m_matchBeforeCreate;
185 m_finderCfg.useOldTunings = m_useOldTunings;
186 m_finderCfg.etaBinWidthOverride = m_etaBinWidthOverride;
187 m_finderCfg.beamSpotCorrection = m_beamSpotCorrection;
188 m_finderCfg.minPt = m_minPt;
189 m_finderCfg.nMaxPhiSlice = m_nMaxPhiSlice;
190 m_finderCfg.connectorInputFile = m_connectorInputFile;
191 m_finderCfg.lutInputFile = m_lutFile;
192 m_finderCfg.useEtaBinning = m_useEtaBinning;
193 m_finderCfg.doubletFilterRZ = m_doubletFilterRZ;
194 m_finderCfg.minDeltaRadius = m_minDeltaRadius;
195 m_finderCfg.nMaxEdges = m_nMaxEdges;
196 m_finderCfg.tauRatioCut = m_tau_ratio_cut;
197 m_finderCfg.tauRatioPrecut = m_tau_ratio_precut;
198 m_finderCfg.edgeMaskMinEta = m_edge_mask_min_eta;
199 m_finderCfg.hitShareThreshold = m_hit_share_threshold;
200 m_finderCfg.maxEndcapClusterWidth = m_max_endcap_clusterwidth;
201 m_finderCfg.d0Max = m_d0_max;
202 m_finderCfg.validateTriplets = m_validateTriplets;
203 m_finderCfg.useAdaptiveCuts = m_useAdaptiveCuts;
204 m_finderCfg.tauRatioCorr = m_tau_ratio_corr;
205
206 m_filterCfg.sigmaMS = m_sigmaMS;
207 m_filterCfg.radLen = m_radLen;
208 m_filterCfg.sigmaX = m_sigma_x;
209 m_filterCfg.sigmaY = m_sigma_y;
210 m_filterCfg.weightX = m_weight_x;
211 m_filterCfg.weightY = m_weight_y;
212 m_filterCfg.maxDChi2X = m_maxDChi2_x;
213 m_filterCfg.maxDChi2Y = m_maxDChi2_y;
214 m_filterCfg.addHit = m_add_hit;
215 m_filterCfg.maxCurvature = m_max_curvature;
216 m_filterCfg.maxZ0 = m_max_z0;
217
218 return StatusCode::SUCCESS;
219 }
220
221 // called in initialise, used to make sure all config settings look sensible
223 ATH_MSG_DEBUG("===== GBTS finder config =====");
224 ATH_MSG_DEBUG( "beamSpotCorrection: " << m_finderCfg.beamSpotCorrection);
225 ATH_MSG_DEBUG( "connectorInputFile: " << m_finderCfg.connectorInputFile);
226 ATH_MSG_DEBUG( "lutInputFile: " << m_finderCfg.lutInputFile);
227 ATH_MSG_DEBUG( "lrtMode: " << m_finderCfg.lrtMode);
228 ATH_MSG_DEBUG( "useMl: " << m_finderCfg.useMl);
229 ATH_MSG_DEBUG( "matchBeforeCreate: " << m_finderCfg.matchBeforeCreate);
230 ATH_MSG_DEBUG( "useOldTunings: " << m_finderCfg.useOldTunings);
231 ATH_MSG_DEBUG( "tauRatioPrecut: " << m_finderCfg.tauRatioPrecut);
232 ATH_MSG_DEBUG( "tauRatioCut: " << m_finderCfg.tauRatioCut);
233 ATH_MSG_DEBUG( "etaBinWidthOverride: " << m_finderCfg.etaBinWidthOverride);
234 ATH_MSG_DEBUG( "nMaxPhiSlice: " << m_finderCfg.nMaxPhiSlice);
235 ATH_MSG_DEBUG( "minPt: " << m_finderCfg.minPt);
236 ATH_MSG_DEBUG( "useEtaBinning: " << m_finderCfg.useEtaBinning);
237 ATH_MSG_DEBUG( "doubletFilterRZ: " << m_finderCfg.doubletFilterRZ);
238 ATH_MSG_DEBUG( "nMaxEdges: " << m_finderCfg.nMaxEdges);
239 ATH_MSG_DEBUG( "minDeltaRadius: " << m_finderCfg.minDeltaRadius);
240 ATH_MSG_DEBUG( "edgeMaskMinEta: " << m_finderCfg.edgeMaskMinEta);
241 ATH_MSG_DEBUG( "hitShareThreshold: " << m_finderCfg.hitShareThreshold);
242 ATH_MSG_DEBUG( "maxEndcapClusterWidth: " << m_finderCfg.maxEndcapClusterWidth);
243
244 ATH_MSG_DEBUG("===== GBTS filter config =====");
245 ATH_MSG_DEBUG( "sigmaMS: " << m_filterCfg.sigmaMS);
246 ATH_MSG_DEBUG( "radLen: " << m_filterCfg.radLen);
247 ATH_MSG_DEBUG( "sigmaX: " << m_filterCfg.sigmaX);
248 ATH_MSG_DEBUG( "sigmaY: " << m_filterCfg.sigmaY);
249 ATH_MSG_DEBUG( "weightX: " << m_filterCfg.weightX);
250 ATH_MSG_DEBUG( "weightY: " << m_filterCfg.weightY);
251 ATH_MSG_DEBUG( "maxDChi2X: " << m_filterCfg.maxDChi2X);
252 ATH_MSG_DEBUG( "maxDChi2Y: " << m_filterCfg.maxDChi2Y);
253 ATH_MSG_DEBUG( "addHit: " << m_filterCfg.addHit);
254 ATH_MSG_DEBUG( "maxCurvature: " << m_filterCfg.maxCurvature);
255 ATH_MSG_DEBUG( "maxZ0: " << m_filterCfg.maxZ0);
256 }
257
258} // 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< float > m_tau_ratio_cut
Gaudi::Property< bool > m_doubletFilterRZ
Gaudi::Property< float > m_sigma_x
Gaudi::Property< int > m_nMaxEdges
Gaudi::Property< float > m_add_hit
Gaudi::Property< float > m_maxDChi2_x
Gaudi::Property< float > m_max_z0
Gaudi::Property< float > m_minPt
Gaudi::Property< bool > m_useAdaptiveCuts
std::vector< bool > m_are_pixels
Gaudi::Property< float > m_sigmaMS
virtual StatusCode initialize() override
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_hit_share_threshold
Gaudi::Property< bool > m_LRTmode
Gaudi::Property< float > m_max_curvature
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_tau_ratio_corr
Gaudi::Property< float > m_etaBinWidthOverride
Gaudi::Property< bool > m_useOldTunings
Gaudi::Property< float > m_sigma_y
const Acts::Logger & logger() const
Private access to the logger.
Acts::Experimental::GbtsTrackingFilter::Config m_filterCfg
steering for track filter
Gaudi::Property< float > m_max_endcap_clusterwidth
void printGbtsConfig() const
prints all current config settings used either with default settings or properties changed by the gau...
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_d0_max
Gaudi::Property< float > m_weight_x
Gaudi::Property< bool > m_useML
Gaudi::Property< float > m_minDeltaRadius
Gaudi::Property< float > m_weight_y
std::optional< Acts::Experimental::GbtsTrackingFilter > m_filter
the seed filter
Gaudi::Property< float > m_tau_ratio_precut
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< bool > m_beamSpotCorrection
ToolHandle< ITrigL2LayerNumberTool > m_layerNumberTool
used to create the detector layers and which modules correspond to pixels and strips
Gaudi::Property< float > m_maxDChi2_y
Gaudi::Property< std::string > m_lutFile
Gaudi::Property< float > m_edge_mask_min_eta
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