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"
12
13namespace ActsTrk {
14
16 const std::string& name,
17 const IInterface* parent)
18 : base_class(type, name, parent)
19 {}
20
22
23
24 ATH_CHECK(m_layerNumberTool.retrieve());
25 ATH_MSG_DEBUG("Initializing " << name() << "...");
26
27 // Make the logger And Propagate to ACTS routines
28 m_logger = makeActsAthenaLogger(this, "Acts");
29
32
33 // layer geometry creation
34 const std::vector<TrigInDetSiLayer>* pVL = m_layerNumberTool->layerGeometry();
35
36 m_layerGeometry.clear();
37 m_layerGeometry.reserve(pVL->size());
38
39 //convert from trigindetsilayer to acts::experimental::trigindetsilayer
40
41 for (const TrigInDetSiLayer& s : *pVL) {
42 m_layerGeometry.emplace_back(s.m_subdet, s.m_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 //initiliase connection file
52 std::ifstream input_ifstream(m_finderCfg.ConnectorInputFile.c_str(), std::ifstream::in);
53
54 //check to see if file exists and add custom eta binning (if needed)
55 // connector
56 if (input_ifstream.peek() == std::ifstream::traits_type::eof()) {
57
58 ATH_MSG_FATAL("Cannot find layer connections file ");
59 throw std::runtime_error("connection file not found"); //not sure if this is the right thing to do
60
61 }
62
63 //create the connection objects
64 else {
65
66 m_connector = std::make_unique<Acts::Experimental::GbtsConnector>(input_ifstream, m_finderCfg.LRTmode);
67
68 // option that allows for adding custom eta binning (default is at 0.2)
69 if (m_finderCfg.etaBinOverride != 0.0f) {
70
71 m_connector->m_etaBin = m_finderCfg.etaBinOverride;
72 }
73 }
74
75 //create geoemtry object that holds allowed pairing of allowed eta regions in each layer
76 m_gbtsGeo = std::make_unique<Acts::Experimental::GbtsGeometry>( m_layerGeometry, m_connector);
77
78 return StatusCode::SUCCESS;
79 }
80
81 //create seeds
83 StatusCode
84 GbtsSeedingTool::createSeeds(const EventContext& ctx,
85 const Acts::SpacePointContainer<ActsTrk::SpacePointCollector, Acts::detail::RefHolder>& spContainer,
86 const Acts::Vector3& beamSpotPos,
87 const Acts::Vector3& bField,
88 ActsTrk::SeedContainer& seedContainer ) const
89 {
90 //to avoid compile issues with unused veriables
91 (void) ctx;
92 (void) bField;
93 //define new custom spacepoint container
94 Acts::SpacePointContainer2 coreSpacePoints(
95 Acts::SpacePointColumns::SourceLinks |
96 Acts::SpacePointColumns::X |
97 Acts::SpacePointColumns::Y |
98 Acts::SpacePointColumns::Z |
99 Acts::SpacePointColumns::R |
100 Acts::SpacePointColumns::Phi
101 );
102
103 //add new coloumn for layer ID and clusterwidth
104 auto LayerColoumn = coreSpacePoints.createColumn<int>("LayerID");
105 auto ClusterWidthColoumn = coreSpacePoints.createColumn<float>("Cluster_Width");
106 coreSpacePoints.reserve(spContainer.size());
107
108 //add spacepoints to new container and seedContainer
109 seedContainer.spacePoints().reserve(spContainer.size());
110 for(size_t idx=0; idx<spContainer.size(); idx++){
111 //obtain module hash for spacepoint
112 const auto & sp = spContainer.at(idx);
113 const auto & extSP = sp.externalSpacePoint();
114 seedContainer.spacePoints().push_back(&extSP);
115 const std::vector<xAOD::DetectorIDHashType>& elementlist = extSP.elementIdList() ;
116
117 bool isPixel(elementlist.size() == 1);
118 if(isPixel == false) continue; //as currently strip hits are not used for seeding
119
120 short layer = (isPixel ? m_pix_h2l : m_sct_h2l)->at(static_cast<int>(elementlist[0]));
121 //obtain coordinates
122 const auto& pos = extSP.globalPosition();
123
124 auto newSp = coreSpacePoints.createSpacePoint();
125
126 //assign link to original spacepoint (needed for seed container)
127 newSp.assignSourceLinks(
128 std::array<Acts::SourceLink, 1>{Acts::SourceLink(&extSP)});
129
130 //apply beamspot corrections if needed
131 if(m_finderCfg.BeamSpotCorrection){
132
133 newSp.x() = pos.x() - beamSpotPos[0];
134 newSp.y() = pos.y() - beamSpotPos[1];
135 newSp.z() = pos.z();
136
137
138 }else{
139
140 newSp.x() = pos.x();
141 newSp.y() = pos.y();
142 newSp.z() = pos.z();
143
144 }
145 newSp.r() = std::sqrt(std::pow(pos.x(), 2) + std::pow(pos.y(), 2));
146 newSp.phi() = std::atan2(pos.y(), pos.x());
147 newSp.extra(LayerColoumn) = layer;
148
149 if(m_finderCfg.useML){
150
151 assert(dynamic_cast<const xAOD::PixelCluster*>(extSP.measurements().front())!=nullptr);
152 const xAOD::PixelCluster* pCL = static_cast<const xAOD::PixelCluster*>(extSP.measurements().front());
153 newSp.extra(ClusterWidthColoumn) = pCL->widthInEta();
154
155 }else{
156 newSp.extra(ClusterWidthColoumn) = 0 ;
157
158 }
159 }
160 ATH_MSG_VERBOSE("Spacepoints successfully added to new container");
161
162 //collect all spacepoint containers objects so they can be passed into the seedfinder
163 auto SPContainerComponents = std::make_tuple(std::move(coreSpacePoints), LayerColoumn.asConst(), ClusterWidthColoumn.asConst());
164
165 //define ACTS core algorithm
166 Acts::Experimental::SeedFinderGbts finder(m_finderCfg, m_gbtsGeo.get(), &m_layerGeometry);
167
168 //compute seeds
169 int max_layers = m_are_pixels.size();
170 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)
171 Acts::SeedContainer2 seeds = finder.CreateSeeds(internalRoi, SPContainerComponents, max_layers);
172
173
174 //add seeds to the output container
175 seedContainer.reserve(seeds.size(), 7.0f);
176 for (Acts::MutableSeedProxy2 seed : seeds) {
177
178 seedContainer.push_back(seed);
179 }
180 ATH_MSG_VERBOSE("Number of seeds created is" << seedContainer.size());
181 return StatusCode::SUCCESS;
182 }
183
184
185 //this is called in initialise
186 //adds all veriables that may have been changed in the gaudi properties defined in headerfile
187 StatusCode
189 {
190
191 m_finderCfg.LRTmode = m_LRTmode;
192 m_finderCfg.useML = m_useML;
193 m_finderCfg.matchBeforeCreate = m_matchBeforeCreate;
194 m_finderCfg.useOldTunings = m_useOldTunings;
195 m_finderCfg.etaBinOverride = m_etaBinOverride;
196 m_finderCfg.BeamSpotCorrection = m_BeamSpotCorrection;
197 m_finderCfg.sigma_t = m_sigma_t;
198 m_finderCfg.sigma_w = m_sigma_w;
199 m_finderCfg.sigmaMS = m_sigmaMS;
200 m_finderCfg.sigma_x = m_sigma_x;
201 m_finderCfg.sigma_y = m_sigma_y;
202 m_finderCfg.weight_x = m_weight_x;
203 m_finderCfg.weight_y = m_weight_y;
204 m_finderCfg.maxDChi2_x = m_maxDChi2_x;
205 m_finderCfg.maxDChi2_y = m_maxDChi2_y;
206 m_finderCfg.add_hit = m_add_hit;
207 m_finderCfg.minPt = m_minPt;
208 m_finderCfg.phiSliceWidth = m_phiSliceWidth ;
209 m_finderCfg.nMaxPhiSlice = m_nMaxPhiSlice;
210 m_finderCfg.useML = m_useML;
211 m_finderCfg.ConnectorInputFile = m_ConnectorInputFile;
212 m_finderCfg.useEtaBinning = m_useEtaBinning;
213 m_finderCfg.doubletFilterRZ = m_doubletFilterRZ ;
214 m_finderCfg.minDeltaRadius = m_minDeltaRadius;
215 m_finderCfg.nMaxEdges = m_nMaxEdges;
216 m_finderCfg.tau_ratio_cut = m_tau_ratio_cut;
217 m_finderCfg.ptCoeff = m_ptCoeff;
218 m_finderCfg = m_finderCfg.toInternalUnits();
219
220
221 return StatusCode::SUCCESS;
222 }
223 //called in initialise, used to make sure all config settings look sensible
224 void GbtsSeedingTool::printSeedFinderGbtsConfig(const Acts::Experimental::SeedFinderGbtsConfig& cfg) {
225 ATH_MSG_DEBUG("===== SeedFinderGbtsConfig =====");
226 ATH_MSG_DEBUG( "BeamSpotCorrection: " << cfg.BeamSpotCorrection << " (default: false)");
227 ATH_MSG_DEBUG( "ConnectorInputFile: " << cfg.ConnectorInputFile << " (default: empty string)");
228 ATH_MSG_DEBUG( "LRTmode: " << cfg.LRTmode << " (default: false)");
229 ATH_MSG_DEBUG( "useML: " << cfg.useML << " (default: false)");
230 ATH_MSG_DEBUG( "matchBeforeCreate: " << cfg.matchBeforeCreate << " (default: false)");
231 ATH_MSG_DEBUG( "useOldTunings: " << cfg.useOldTunings << " (default: false)");
232 ATH_MSG_DEBUG( "tau_ratio_cut: " << cfg.tau_ratio_cut << " (default: 0.007)");
233 ATH_MSG_DEBUG( "etaBinOverride: " << cfg.etaBinOverride << " (default: 0.0)");
234 ATH_MSG_DEBUG( "nMaxPhiSlice: " << cfg.nMaxPhiSlice << " (default: 53)");
235 ATH_MSG_DEBUG( "minPt: " << cfg.minPt << " (default: 1000. MeV)");
236 ATH_MSG_DEBUG( "phiSliceWidth: " << cfg.phiSliceWidth << " (default: null)");
237 ATH_MSG_DEBUG( "ptCoeff: " << cfg.ptCoeff << " (default: 0.29955)");
238 ATH_MSG_DEBUG( "useEtaBinning: " << cfg.useEtaBinning << " (default: true)");
239 ATH_MSG_DEBUG( "doubletFilterRZ: " << cfg.doubletFilterRZ << " (default: true)");
240 ATH_MSG_DEBUG( "nMaxEdges: " << cfg.nMaxEdges << " (default: 2000000)");
241 ATH_MSG_DEBUG( "minDeltaRadius: " << cfg.minDeltaRadius << " (default: 2.0)");
242 ATH_MSG_DEBUG( "sigma_t: " << cfg.sigma_t << " (default: 0.0003)");
243 ATH_MSG_DEBUG( "sigma_w: " << cfg.sigma_w << " (default: 0.00009)");
244 ATH_MSG_DEBUG( "sigmaMS: " << cfg.sigmaMS << " (default: 0.016)");
245 ATH_MSG_DEBUG( "sigma_x: " << cfg.sigma_x << " (default: 0.25)");
246 ATH_MSG_DEBUG( "sigma_y: " << cfg.sigma_y << " (default: 2.5)");
247 ATH_MSG_DEBUG( "weight_x: " << cfg.weight_x << " (default: 0.5)");
248 ATH_MSG_DEBUG( "weight_y: " << cfg.weight_y << " (default: 0.5)");
249 ATH_MSG_DEBUG( "maxDChi2_x: " << cfg.maxDChi2_x << " (default: 60.0)");
250 ATH_MSG_DEBUG( "maxDChi2_y: " << cfg.maxDChi2_y << " (default: 60.0)");
251 ATH_MSG_DEBUG( "add_hit: " << cfg.add_hit << " (default: 14.0)");
252
253
254}
255
256} // namespace ActsTrk
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
#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)
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_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< bool > m_LRTmode
std::unique_ptr< const Acts::Logger > m_logger
logging instance
Gaudi::Property< float > m_nMaxPhiSlice
Gaudi::Property< bool > m_useOldTunings
Gaudi::Property< float > m_sigma_y
std::vector< Acts::Experimental::TrigInDetSiLayer > m_layerGeometry
const std::vector< short > * m_pix_h2l
Gaudi::Property< float > m_weight_x
Gaudi::Property< float > m_sigma_t
Gaudi::Property< bool > m_useML
Gaudi::Property< float > m_minDeltaRadius
Gaudi::Property< float > m_weight_y
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
Gaudi::Property< std::string > m_ConnectorInputFile
Gaudi::Property< float > m_sigma_w
ToolHandle< ITrigL2LayerNumberTool > m_layerNumberTool
Gaudi::Property< float > m_etaBinOverride
Gaudi::Property< float > m_maxDChi2_y
GbtsSeedingTool(const std::string &type, const std::string &name, const IInterface *parent)
float widthInEta() const
Returns the width of the cluster in phi (x) and eta (y) directions, respectively.
#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