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#include <memory>
6#if defined(FLATTEN) && defined(__GNUC__)
7// Avoid warning in dbg build
8#pragma GCC optimize "-fno-var-tracking-assignments"
9#endif
10
11#include "src/GbtsSeedingTool.h"
13
14
15namespace ActsTrk {
16
18 const std::string& name,
19 const IInterface* parent)
20 : base_class(type, name, parent)
21 {}
22
24
25
26 ATH_CHECK(m_layerNumberTool.retrieve());
27 ATH_MSG_DEBUG("Initializing " << name() << "...");
28
29 // Make the logger And Propagate to ACTS routines
30 m_logger = makeActsAthenaLogger(this, "Acts");
31
34
35 // layer geometry creation
36 const std::vector<TrigInDetSiLayer>* pVL = m_layerNumberTool->layerGeometry();
37
38 m_layerGeometry.clear();
39 m_layerGeometry.reserve(pVL->size());
40
41 //convert from trigindetsilayer to acts::experimental::trigindetsilayer
42
43 for (const TrigInDetSiLayer& s : *pVL) {
44 m_layerGeometry.emplace_back(s.m_subdet, s.m_type, s.m_refCoord, s.m_minBound, s.m_maxBound);
45 }
46
47 //fill which has id for each module belongs to what layer
48 m_sct_h2l = m_layerNumberTool->sctLayers();
49 m_pix_h2l = m_layerNumberTool->pixelLayers();
50 m_are_pixels.resize(m_layerNumberTool->maxNumberOfUniqueLayers(), true);
51 for(const auto& l : *m_sct_h2l) m_are_pixels[l] = false;
52
53 //parse connection
54
55 m_connector = std::make_unique<Acts::Experimental::GbtsConnector>(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.etaBinOverride != 0.0f) {
59
60 m_connector->m_etaBin = m_finderCfg.etaBinOverride;
61 }
62
63 //create geoemtry object that holds allowed pairing of allowed eta regions in each layer
64 m_gbtsGeo = std::make_unique<Acts::Experimental::GbtsGeometry>( m_layerGeometry, m_connector);
65
66 m_finder = std::make_unique<Acts::Experimental::SeedFinderGbts>(m_finderCfg, std::move(m_gbtsGeo), &m_layerGeometry, logger().cloneWithSuffix("gbtsFinder"));
67
68 return StatusCode::SUCCESS;
69}
70
71 //create seeds
73 StatusCode
74 GbtsSeedingTool::createSeeds(const EventContext& ctx,
75 const Acts::SpacePointContainer<ActsTrk::SpacePointCollector, Acts::detail::RefHolder>& spContainer,
76 const Acts::Vector3& beamSpotPos,
77 const Acts::Vector3& bField,
78 ActsTrk::SeedContainer& seedContainer ) const
79 {
80 //to avoid compile issues with unused veriables
81 (void) ctx;
82 (void) bField;
83 //define new custom spacepoint container
84 Acts::SpacePointContainer2 coreSpacePoints(
85 Acts::SpacePointColumns::SourceLinks |
86 Acts::SpacePointColumns::X |
87 Acts::SpacePointColumns::Y |
88 Acts::SpacePointColumns::Z |
89 Acts::SpacePointColumns::R |
90 Acts::SpacePointColumns::Phi
91 );
92
93 //add new coloumn for layer ID and clusterwidth
94 auto LayerColoumn = coreSpacePoints.createColumn<int>("LayerID");
95 auto ClusterWidthColoumn = coreSpacePoints.createColumn<float>("Cluster_Width");
96 auto LocalPositionColoumn = coreSpacePoints.createColumn<float>("LocalPositionY");
97 coreSpacePoints.reserve(spContainer.size());
98
99 //add spacepoints to new container and seedContainer
100 seedContainer.spacePoints().reserve(spContainer.size());
101 for(size_t idx=0; idx<spContainer.size(); idx++){
102 //obtain module hash for spacepoint
103 const auto & sp = spContainer.at(idx);
104 const auto & extSP = sp.externalSpacePoint();
105 seedContainer.spacePoints().push_back(&extSP);
106 const std::vector<xAOD::DetectorIDHashType>& elementlist = extSP.elementIdList() ;
107
108 bool isPixel(elementlist.size() == 1);
109 if(isPixel == false) continue; //as currently strip hits are not used for seeding
110
111 short layer = (isPixel ? m_pix_h2l : m_sct_h2l)->at(static_cast<int>(elementlist[0]));
112 //obtain coordinates
113
114 auto newSp = coreSpacePoints.createSpacePoint();
115
116 //apply beamspot corrections if needed
117 if(m_finderCfg.BeamSpotCorrection){
118
119 float new_x = static_cast<float>(extSP.x() - beamSpotPos[0]);
120 float new_y = static_cast<float>(extSP.y() - beamSpotPos[1]);
121 newSp.x() = new_x;
122 newSp.y() = new_y;
123 newSp.z() = static_cast<float>(extSP.z());
124 newSp.r() = std::hypot(new_x, new_y);
125 newSp.phi() = std::atan2(new_y, new_x);
126
127 }else{
128 float new_x = static_cast<float>(extSP.x());
129 float new_y = static_cast<float>(extSP.y());
130 newSp.x() = static_cast<float>(extSP.x());
131 newSp.y() = static_cast<float>(extSP.y());
132 newSp.z() = static_cast<float>(extSP.z());
133 newSp.r() = std::hypot(new_x, new_y);
134 newSp.phi() = std::atan2(extSP.y(), extSP.x());
135 }
136
137 newSp.extra(LayerColoumn) = layer;
138
139 if(m_finderCfg.useML){
140
141 assert(dynamic_cast<const xAOD::PixelCluster*>(extSP.measurements().front())!=nullptr);
142 const xAOD::PixelCluster* pCL = static_cast<const xAOD::PixelCluster*>(extSP.measurements().front());
143 newSp.extra(ClusterWidthColoumn) = pCL->widthInEta();
144 newSp.extra(LocalPositionColoumn) = pCL->localPosition<2>().y();
145
146 }else{
147 newSp.extra(ClusterWidthColoumn) = 0;
148 newSp.extra(LocalPositionColoumn) = 0;
149
150 }
151 }
152 ATH_MSG_VERBOSE("Spacepoints successfully added to new container");
153
154 //collect all spacepoint containers objects so they can be passed into the seedfinder
155 auto SPContainerComponents = std::make_tuple(std::move(coreSpacePoints), LayerColoumn.asConst(), ClusterWidthColoumn.asConst(), LocalPositionColoumn.asConst());
156
157 //compute seeds
158 int max_layers = m_are_pixels.size();
159 Acts::Experimental::RoiDescriptor internalRoi(0, -4.5, 4.5, 0, -std::numbers::pi, std::numbers::pi, 0, -150.0,150.0); //(eta,etaMinus,etaPlus,phi,phiMinus,Phiplus,z,zMinus,zPlus)
160 Acts::SeedContainer2 seeds = m_finder->createSeeds(internalRoi, SPContainerComponents, max_layers);
161
162
163 //add seeds to the output container
164 seedContainer.reserve(seeds.size(), 7.0f);
165 for (Acts::MutableSeedProxy2 seed : seeds) {
166
167 seedContainer.push_back(seed);
168 }
169 ATH_MSG_VERBOSE("Number of seeds created is" << seedContainer.size());
170 return StatusCode::SUCCESS;
171 }
172
173
174 //this is called in initialise
175 //adds all veriables that may have been changed in the gaudi properties defined in headerfile
176 //TO DO: ADD NEW VERIABLES, DELETE OLD ONES AND CHANGE CURRENT ONES TO NEW VALUES
177 StatusCode
179 {
180
181 m_finderCfg.LRTmode = m_LRTmode;
182 m_finderCfg.useML = m_useML;
183 m_finderCfg.matchBeforeCreate = m_matchBeforeCreate;
184 m_finderCfg.useOldTunings = m_useOldTunings;
185 m_finderCfg.etaBinOverride = m_etaBinOverride;
186 m_finderCfg.BeamSpotCorrection = m_BeamSpotCorrection;
187 m_finderCfg.sigmaMS = m_sigmaMS;
188 m_finderCfg.radLen = m_radLen;
189 m_finderCfg.sigma_x = m_sigma_x;
190 m_finderCfg.sigma_y = m_sigma_y;
191 m_finderCfg.weight_x = m_weight_x;
192 m_finderCfg.weight_y = m_weight_y;
193 m_finderCfg.maxDChi2_x = m_maxDChi2_x;
194 m_finderCfg.maxDChi2_y = m_maxDChi2_y;
195 m_finderCfg.add_hit = m_add_hit;
196 m_finderCfg.minPt = m_minPt;
197 m_finderCfg.phiSliceWidth = m_phiSliceWidth ;
198 m_finderCfg.nMaxPhiSlice = m_nMaxPhiSlice;
199 m_finderCfg.useML = m_useML;
200 m_finderCfg.connectorInputFile = m_connectorInputFile;
201 m_finderCfg.lutInputFile = m_lutFile;
202 m_finderCfg.useEtaBinning = m_useEtaBinning;
203 m_finderCfg.doubletFilterRZ = m_doubletFilterRZ ;
204 m_finderCfg.minDeltaRadius = m_minDeltaRadius;
205 m_finderCfg.nMaxEdges = m_nMaxEdges;
206 m_finderCfg.tau_ratio_cut = m_tau_ratio_cut;
207 m_finderCfg.tau_ratio_precut = m_tau_ratio_precut;
208 m_finderCfg.ptCoeff = m_ptCoeff;
209 m_finderCfg.max_curvature = m_max_curvature;
210 m_finderCfg.max_z0 = m_max_z0;
211 m_finderCfg.edge_mask_min_eta = m_edge_mask_min_eta;
212 m_finderCfg.hit_share_threshold = m_hit_share_threshold;
213 m_finderCfg.max_endcap_clusterwidth = m_max_endcap_clusterwidth;
214 m_finderCfg = m_finderCfg.toInternalUnits();
215
216
217
218 return StatusCode::SUCCESS;
219 }
220 //called in initialise, used to make sure all config settings look sensible
221 void GbtsSeedingTool::printSeedFinderGbtsConfig(const Acts::Experimental::SeedFinderGbtsConfig& cfg) {
222 ATH_MSG_DEBUG("===== SeedFinderGbtsConfig =====");
223 ATH_MSG_DEBUG( "BeamSpotCorrection: " << cfg.BeamSpotCorrection << " (default: false)");
224 ATH_MSG_DEBUG( "connectorInputFile: " << cfg.connectorInputFile << " (default: empty string)");
225 ATH_MSG_DEBUG( "lutInputFile: " << cfg.lutInputFile << " (default: empty string)");
226 ATH_MSG_DEBUG( "LRTmode: " << cfg.LRTmode << " (default: false)");
227 ATH_MSG_DEBUG( "useML: " << cfg.useML << " (default: false)");
228 ATH_MSG_DEBUG( "matchBeforeCreate: " << cfg.matchBeforeCreate << " (default: false)");
229 ATH_MSG_DEBUG( "useOldTunings: " << cfg.useOldTunings << " (default: false)");
230 ATH_MSG_DEBUG( "tau_ratio_precut: " << cfg.tau_ratio_precut << " (default: 0.009f)");
231 ATH_MSG_DEBUG( "tau_ratio_cut: " << cfg.tau_ratio_cut << " (default: 0.007)");
232 ATH_MSG_DEBUG( "etaBinOverride: " << cfg.etaBinOverride << " (default: 0.0)");
233 ATH_MSG_DEBUG( "nMaxPhiSlice: " << cfg.nMaxPhiSlice << " (default: 53)");
234 ATH_MSG_DEBUG( "minPt: " << cfg.minPt << " (default: 1000. MeV)");
235 ATH_MSG_DEBUG( "phiSliceWidth: " << cfg.phiSliceWidth << " (default: null)");
236 ATH_MSG_DEBUG( "ptCoeff: " << cfg.ptCoeff << " (default: 0.29955)");
237 ATH_MSG_DEBUG( "useEtaBinning: " << cfg.useEtaBinning << " (default: true)");
238 ATH_MSG_DEBUG( "doubletFilterRZ: " << cfg.doubletFilterRZ << " (default: true)");
239 ATH_MSG_DEBUG( "nMaxEdges: " << cfg.nMaxEdges << " (default: 2000000)");
240 ATH_MSG_DEBUG( "minDeltaRadius: " << cfg.minDeltaRadius << " (default: 2.0)");
241 ATH_MSG_DEBUG( "sigmaMS: " << cfg.sigmaMS << " (default: 0.016)");
242 ATH_MSG_DEBUG( "radLen: " << cfg.radLen << " (default: 0.025)");
243 ATH_MSG_DEBUG( "sigma_x: " << cfg.sigma_x << " (default: 0.08)");
244 ATH_MSG_DEBUG( "sigma_y: " << cfg.sigma_y << " (default: 0.25)");
245 ATH_MSG_DEBUG( "weight_x: " << cfg.weight_x << " (default: 0.5)");
246 ATH_MSG_DEBUG( "weight_y: " << cfg.weight_y << " (default: 0.5)");
247 ATH_MSG_DEBUG( "maxDChi2_x: " << cfg.maxDChi2_x << " (default: 5.0)");
248 ATH_MSG_DEBUG( "maxDChi2_y: " << cfg.maxDChi2_y << " (default: 6.0)");
249 ATH_MSG_DEBUG( "add_hit: " << cfg.add_hit << " (default: 14.0)");
250 ATH_MSG_DEBUG( "max_curvature: " << cfg.max_curvature << " (default: 1e-3f)");
251 ATH_MSG_DEBUG( "max_z0: " << cfg.max_z0 << " (default: 170.0)");
252 ATH_MSG_DEBUG( "edge_mask_min_eta: " << cfg.edge_mask_min_eta << " (default: 1.5)");
253 ATH_MSG_DEBUG( "hit_share_threshold: " << cfg.hit_share_threshold << " (default: 0.49)");
254 ATH_MSG_DEBUG( "max_endcap_clusterwidth: " << cfg.max_endcap_clusterwidth << " (default: 0.35)");
255
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
std::unique_ptr< Acts::Experimental::GbtsConnector > m_connector
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
virtual StatusCode createSeeds(const EventContext &ctx, const Acts::SpacePointContainer< ActsTrk::SpacePointCollector, Acts::detail::RefHolder > &spContainer, const Acts::Vector3 &beamSpotPos, const Acts::Vector3 &bField, ActsTrk::SeedContainer &seedContainer) const override
Acts::Experimental::SeedFinderGbtsConfig m_finderCfg
Gaudi::Property< bool > m_BeamSpotCorrection
Gaudi::Property< double > m_ptCoeff
std::vector< bool > m_are_pixels
Gaudi::Property< float > m_sigmaMS
virtual StatusCode initialize() override
const std::vector< short > * m_sct_h2l
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
std::unique_ptr< Acts::Experimental::SeedFinderGbts > m_finder
Gaudi::Property< float > m_nMaxPhiSlice
Gaudi::Property< bool > m_useOldTunings
Gaudi::Property< float > m_sigma_y
const Acts::Logger & logger() const
Private access to the logger.
Gaudi::Property< float > m_max_endcap_clusterwidth
Gaudi::Property< std::string > m_connectorInputFile
std::vector< Acts::Experimental::TrigInDetSiLayer > m_layerGeometry
const std::vector< short > * m_pix_h2l
Gaudi::Property< float > m_weight_x
Gaudi::Property< bool > m_useML
Gaudi::Property< float > m_minDeltaRadius
Gaudi::Property< float > m_weight_y
Gaudi::Property< float > m_tau_ratio_precut
Gaudi::Property< bool > m_useEtaBinning
Gaudi::Property< bool > m_matchBeforeCreate
void printSeedFinderGbtsConfig(const Acts::Experimental::SeedFinderGbtsConfig &cfg)
Gaudi::Property< float > m_phiSliceWidth
std::unique_ptr< Acts::Experimental::GbtsGeometry > m_gbtsGeo
ToolHandle< ITrigL2LayerNumberTool > m_layerNumberTool
Gaudi::Property< float > m_etaBinOverride
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...
PixelCluster_v1 PixelCluster
Define the version of the pixel cluster class.
Acts::MutableSeedProxy2 push_back(Acts::SpacePointIndexSubset2 sp)
const SpacePointContainer & spacePoints() const noexcept