5#if defined(FLATTEN) && defined(__GNUC__)
7#pragma GCC optimize "-fno-var-tracking-assignments"
19#include <unordered_map>
25 const std::string& name,
26 const IInterface* parent)
27 : base_class(
type, name, parent)
45 const std::vector<Acts::Experimental::GbtsLayerDescription>& layers =
47 const std::vector<GbtsTechnology>& technologies =
53 std::vector<Acts::Experimental::GbtsLayerConnection> connections;
54 float etaBinWidth = 0.0f;
69 auto gbtsGeo = std::make_shared<Acts::Experimental::GbtsGeometry>(
70 layers, connections, etaBinWidth, Acts::Experimental::GbtsZ0Range{},
logger());
72 m_finder = Acts::Experimental::GraphBasedTrackSeeder(
73 Acts::Experimental::GraphBasedTrackSeeder::DerivedConfig(
m_finderCfg),
74 gbtsGeo,
logger().cloneWithSuffix(
"gbtsFinder"));
78 return StatusCode::SUCCESS;
83 const EventContext& ctx,
84 const std::vector<const xAOD::SpacePointContainer*>& spacePointCollections,
85 const Eigen::Vector3f& beamSpotPos,
float bFieldInZ,
91 const Acts::Experimental::GraphBasedTrackSeeder::Options options(bFieldInZ);
94 std::vector<const xAOD::SpacePoint*> tmpSpacePoints;
99 tmpSpacePoints.emplace_back(
sp);
105 Acts::Experimental::GbtsNodeStorage nodeStorage =
m_finder->makeNodeStorage();
109 std::size_t nUnmappedHashes = 0;
110 std::size_t nUngroupedModules = 0;
113 for(std::size_t idx = 0; idx < tmpSpacePoints.size(); ++idx){
116 const std::vector<xAOD::DetectorIDHashType>& elementlist =
sp->elementIdList();
118 const bool isPixel(elementlist.size() == 1);
120 const std::vector<short>& hashToLayer =
122 const auto hash =
static_cast<std::size_t
>(elementlist[0]);
123 if (hash >= hashToLayer.size()) [[
unlikely]] {
128 const short layer = hashToLayer[hash];
135 float clusterWidth = 0.0f;
136 float localPositionY = 0.0f;
145 const float new_x =
static_cast<float>(
sp->x() - beamSpotPos[0]);
146 const float new_y =
static_cast<float>(
sp->y() - beamSpotPos[1]);
147 nodeStorage.insert(
static_cast<Acts::SpacePointIndex
>(idx), new_x, new_y,
static_cast<float>(
sp->z()),
148 std::hypot(new_x, new_y), std::atan2(new_y, new_x),
149 static_cast<std::uint32_t
>(layer), clusterWidth, localPositionY);
151 const float new_x =
static_cast<float>(
sp->x());
152 const float new_y =
static_cast<float>(
sp->y());
153 nodeStorage.insert(
static_cast<Acts::SpacePointIndex
>(idx), new_x, new_y,
static_cast<float>(
sp->z()),
154 std::hypot(new_x, new_y),
static_cast<float>(std::atan2(
sp->y(),
sp->x())),
155 static_cast<std::uint32_t
>(layer), clusterWidth, localPositionY);
159 if (nUnmappedHashes != 0) [[
unlikely]] {
160 ATH_MSG_WARNING(nUnmappedHashes <<
" space points sit on a wafer hash "
161 "outside the GBTS layer map and were dropped");
163 if (nUngroupedModules != 0) {
164 ATH_MSG_DEBUG(nUngroupedModules <<
" space points sit on a wafer GBTS "
165 "does not group into a layer");
169 nodeStorage.finalize();
173 Acts::SeedContainer seeds;
177 seedContainer.
reserve(seedContainer.
size() + seeds.size(), 7.0f);
178 for (
auto seed : seeds) {
181 [&](
const Acts::SpacePointIndex spIndex) {
182 return tmpSpacePoints[spIndex];
187 return StatusCode::SUCCESS;
194 const std::vector<Acts::Experimental::GbtsLayerDescription>& layers,
195 const std::vector<GbtsTechnology>& technologies,
196 std::vector<Acts::Experimental::GbtsLayerConnection>& connections,
197 float& etaBinWidth)
const
200 if (!connectionStream.is_open()) {
203 return StatusCode::FAILURE;
209 }
catch (
const std::exception& e) {
212 return StatusCode::FAILURE;
216 std::unordered_map<std::uint32_t, GbtsTechnology> layerTechnologies;
217 layerTechnologies.reserve(layers.size());
218 for (std::size_t layer = 0; layer < layers.size(); ++layer) {
219 layerTechnologies.emplace(
static_cast<std::uint32_t
>(layers[layer].
id),
220 technologies[layer]);
223 etaBinWidth = table.etaBinWidth;
226 std::vector<std::pair<std::uint32_t, Acts::Experimental::GbtsLayerConnection>> staged;
227 staged.reserve(table.connections.size());
229 std::size_t nOtherTechnology = 0;
230 std::size_t nUnknownLayer = 0;
234 const auto src = layerTechnologies.find(connection.
src);
235 const auto dst = layerTechnologies.find(connection.
dst);
236 if (src == layerTechnologies.end() || dst == layerTechnologies.end()) {
242 const bool wanted = src->second == dst->second &&
251 staged.emplace_back(connection.
stage,
252 Acts::Experimental::GbtsLayerConnection{connection.src,
256 std::ranges::stable_sort(staged, {}, [](
const auto& entry) {
return entry.first; });
259 connections.reserve(staged.size());
260 for (
const auto& entry : staged) {
261 connections.push_back(entry.second);
263 const std::size_t nKept = connections.size();
265 if (nUnknownLayer != 0) {
273 "does not match the detector this job is reconstructing");
274 return StatusCode::FAILURE;
276 ATH_MSG_DEBUG(
"Kept " << nKept <<
" GBTS layer connections, dropping "
277 << nOtherTechnology <<
" of a technology not asked for, eta bin width "
280 return StatusCode::SUCCESS;
284 Acts::Experimental::detail::GbtsTauLookupTable& tauLookupTable)
const
286 std::ifstream lutStream(
m_lutFile.value());
287 if (!lutStream.is_open()) {
289 return StatusCode::FAILURE;
292 tauLookupTable.clear();
296 float clusterWidth = 0.0f;
297 Acts::Experimental::detail::GbtsTauBounds bounds;
298 while (lutStream >> clusterWidth >> bounds.minTau >> bounds.maxTau >>
299 bounds.minTauNearEdge >> bounds.maxTauNearEdge) {
300 tauLookupTable.push_back(bounds);
303 if (!lutStream.eof()) {
306 return StatusCode::FAILURE;
308 if (tauLookupTable.empty()) {
310 return StatusCode::FAILURE;
313 ATH_MSG_DEBUG(
"Read " << tauLookupTable.size() <<
" rows of the GBTS tau lookup table "
316 return StatusCode::SUCCESS;
360 m_finderCfg.oldTuningsCurvatureHighEtaFraction = 1.f;
361 m_finderCfg.oldTuningsCurvatureLowEtaFraction = 1.f;
379 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_WARNING(x,...)
#define ATH_MSG_VERBOSE(x,...)
std::unique_ptr< const Acts::Logger > makeActsAthenaLogger(IMessageSvc *svc, const std::string &name, int level, std::optional< std::string > parent_name)
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.
ReadResult read(std::istream &inputStream)
Read the GBTS layer connection table.
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.
One row of the table: the two layers it connects, and the stage it is in.
The table as it is on file.
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