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 =
52 ATH_MSG_ERROR(
"Neither pixel nor strip layers are enabled, there is "
53 "nothing to seed on.");
54 return StatusCode::FAILURE;
57 std::vector<Acts::Experimental::GbtsLayerConnection> connections;
58 float etaBinWidth = 0.0f;
73 auto gbtsGeo = std::make_shared<Acts::Experimental::GbtsGeometry>(
74 layers, connections, etaBinWidth, Acts::Experimental::GbtsZ0Range{},
logger());
76 m_finder = Acts::Experimental::GraphBasedTrackSeeder(
77 Acts::Experimental::GraphBasedTrackSeeder::DerivedConfig(
m_finderCfg),
78 gbtsGeo,
logger().cloneWithSuffix(
"gbtsFinder"));
82 return StatusCode::SUCCESS;
87 const EventContext& ctx,
88 const std::vector<const xAOD::SpacePointContainer*>& spacePointCollections,
89 const Eigen::Vector3f& beamSpotPos,
float bFieldInZ,
95 const Acts::Experimental::GraphBasedTrackSeeder::Options options{
96 .bFieldInZ = bFieldInZ};
99 std::vector<const xAOD::SpacePoint*> tmpSpacePoints;
104 tmpSpacePoints.emplace_back(
sp);
110 Acts::Experimental::GbtsNodeStorage nodeStorage =
m_finder->makeNodeStorage();
113 const float offsetX =
m_finderCfg.beamSpotCorrection ? beamSpotPos[0] : 0.0f;
114 const float offsetY =
m_finderCfg.beamSpotCorrection ? beamSpotPos[1] : 0.0f;
116 std::size_t nPixelNodes = 0;
117 std::size_t nStripNodes = 0;
121 std::size_t nUnmappedHashes = 0;
122 std::size_t nUngroupedModules = 0;
125 for(std::size_t idx = 0; idx < tmpSpacePoints.size(); ++idx){
128 const std::vector<xAOD::DetectorIDHashType>& elementlist =
sp->elementIdList();
131 const bool isPixel(elementlist.size() == 1);
137 const std::vector<short>& hashToLayer =
139 const auto hash =
static_cast<std::size_t
>(elementlist[0]);
140 if (hash >= hashToLayer.size()) [[
unlikely]] {
145 const short layer = hashToLayer[hash];
152 float clusterWidth = 0.0f;
153 float localPositionY = 0.0f;
162 Acts::OuterStripSpacePointCalibrationDetails stripDetails{};
163 const Acts::OuterStripSpacePointCalibrationDetails*
strip =
nullptr;
166 Eigen::Map<Eigen::Vector3f>(stripDetails.outerCenter.data()) =
167 sp->topStripCenter() - Eigen::Vector3f(offsetX, offsetY, 0.0f);
168 Eigen::Map<Eigen::Vector3f>(stripDetails.innerToOuterSeparation.data()) =
169 sp->stripCenterDistance();
170 Eigen::Map<Eigen::Vector3f>(stripDetails.outerHalfVector.data()) =
171 sp->topHalfStripLength() *
sp->topStripDirection();
172 Eigen::Map<Eigen::Vector3f>(stripDetails.innerHalfVector.data()) =
173 sp->bottomHalfStripLength() *
sp->bottomStripDirection();
174 strip = &stripDetails;
177 const float x =
static_cast<float>(
sp->x()) - offsetX;
178 const float y =
static_cast<float>(
sp->y()) - offsetY;
179 const std::optional<std::uint32_t>
bin = nodeStorage.insert(
180 static_cast<Acts::SpacePointIndex
>(idx),
x,
y,
181 static_cast<float>(
sp->z()), std::hypot(
x,
y), std::atan2(
y,
x),
182 static_cast<Acts::Experimental::GbtsLayerIndex
>(layer), clusterWidth,
183 localPositionY,
strip);
185 if (
bin.has_value()) {
186 ++(isPixel ? nPixelNodes : nStripNodes);
190 ATH_MSG_DEBUG(
"Inserted " << nPixelNodes <<
" pixel and " << nStripNodes
191 <<
" strip nodes; the graph "
192 << (nodeStorage.hasStrips() ?
"carries" :
"does not carry")
195 if (nUnmappedHashes != 0) [[
unlikely]] {
196 ATH_MSG_WARNING(nUnmappedHashes <<
" space points sit on a wafer hash "
197 "outside the GBTS layer map and were dropped");
199 if (nUngroupedModules != 0) {
200 ATH_MSG_DEBUG(nUngroupedModules <<
" space points sit on a wafer GBTS "
201 "does not group into a layer");
205 nodeStorage.finalize();
209 Acts::SeedContainer seeds;
213 seedContainer.
reserve(seedContainer.
size() + seeds.size(), 7.0f);
214 for (
auto seed : seeds) {
217 [&](
const Acts::SpacePointIndex spIndex) {
218 return tmpSpacePoints[spIndex];
223 return StatusCode::SUCCESS;
230 const std::vector<Acts::Experimental::GbtsLayerDescription>& layers,
231 std::vector<Acts::Experimental::GbtsLayerConnection>& connections,
232 float& etaBinWidth)
const
235 if (!connectionStream.is_open()) {
238 return StatusCode::FAILURE;
244 }
catch (
const std::exception& e) {
247 return StatusCode::FAILURE;
251 std::unordered_map<Acts::Experimental::GbtsExperimentLayerId,
252 Acts::Experimental::GbtsLayerTechnology>
254 layerTechnologies.reserve(layers.size());
255 for (
const Acts::Experimental::GbtsLayerDescription& layer : layers) {
256 layerTechnologies.emplace(layer.id, layer.technology);
259 etaBinWidth = table.etaBinWidth;
262 std::vector<std::pair<std::uint32_t, Acts::Experimental::GbtsLayerConnection>> staged;
263 staged.reserve(table.connections.size());
265 std::size_t nOtherTechnology = 0;
266 std::size_t nUnknownLayer = 0;
270 const auto src = layerTechnologies.find(connection.
src);
271 const auto dst = layerTechnologies.find(connection.
dst);
272 if (src == layerTechnologies.end() || dst == layerTechnologies.end()) {
278 const bool wanted = src->second == dst->second &&
280 Acts::Experimental::GbtsLayerTechnology::Pixel
288 staged.emplace_back(connection.
stage,
289 Acts::Experimental::GbtsLayerConnection{connection.src,
293 std::ranges::stable_sort(staged, {}, [](
const auto& entry) {
return entry.first; });
296 connections.reserve(staged.size());
297 for (
const auto& entry : staged) {
298 connections.push_back(entry.second);
300 const std::size_t nKept = connections.size();
302 if (nUnknownLayer != 0) {
310 "does not match the detector this job is reconstructing");
311 return StatusCode::FAILURE;
313 ATH_MSG_DEBUG(
"Kept " << nKept <<
" GBTS layer connections, dropping "
314 << nOtherTechnology <<
" of a technology not asked for, eta bin width "
317 return StatusCode::SUCCESS;
321 Acts::Experimental::detail::GbtsTauLookupTable& tauLookupTable)
const
323 std::ifstream lutStream(
m_lutFile.value());
324 if (!lutStream.is_open()) {
326 return StatusCode::FAILURE;
329 tauLookupTable.clear();
333 float clusterWidth = 0.0f;
334 Acts::Experimental::detail::GbtsTauBounds bounds;
335 while (lutStream >> clusterWidth >> bounds.minTau >> bounds.maxTau >>
336 bounds.minTauNearEdge >> bounds.maxTauNearEdge) {
337 tauLookupTable.push_back(bounds);
340 if (!lutStream.eof()) {
343 return StatusCode::FAILURE;
345 if (tauLookupTable.empty()) {
347 return StatusCode::FAILURE;
350 ATH_MSG_DEBUG(
"Read " << tauLookupTable.size() <<
" rows of the GBTS tau lookup table "
353 return StatusCode::SUCCESS;
405 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