ATLAS Offline Software
Loading...
Searching...
No Matches
F150EDMConversionAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4
8
10{
12 {
13
14 ATH_CHECK(m_FPGATrackOutput.initialize());
16 ATH_CHECK(m_seedKey.initialize());
17
18 return StatusCode::SUCCESS;
19 }
20
21 StatusCode F150EDMConversionAlg::execute(const EventContext &ctx) const
22 {
23 ATH_MSG_DEBUG("Executing F150EDMConversionAlg");
24
25 auto trackOutput = SG::get(m_FPGATrackOutput, ctx);
26
27 // Get the space points
29 ATH_CHECK(spacePointsHandle.isValid());
30
32 ATH_CHECK(seedHandle.record(std::make_unique<ActsTrk::SeedContainer>()));
33 ActsTrk::SeedContainer* seeds = seedHandle.ptr();
34
35 std::multimap<xAOD::DetectorIDHashType, const xAOD::SpacePoint*> spacePointMap;
36 // Populate the multimap with Pixel cluster hashID as key.
37 // Only space points with one measurement are considered (i.e. pixels)
38 for (const xAOD::SpacePoint* spacePoint : *spacePointsHandle) {
39 if (!spacePoint->measurements().empty()) {
40 spacePointMap.emplace(spacePoint->measurements().at(0)->identifierHash(), spacePoint);
41 }
42 }
43
44 seeds->reserve(trackOutput->size());
45 // first three works are header, so skip them for now
46 for(unsigned int i = 3; i < trackOutput->size(); i++)
47 {
48 // Check if the flags track header
50 {
51 auto gtrack_w1 = FPGADataFormatUtilities::get_bitfields_GTRACK_HDR_w1(trackOutput->at(i));
52 auto gtrack_w2 = FPGADataFormatUtilities::get_bitfields_GTRACK_HDR_w2(trackOutput->at(++i));
53 auto gtrack_w3 = FPGADataFormatUtilities::get_bitfields_GTRACK_HDR_w3(trackOutput->at(++i));
54
55 std::vector<const xAOD::SpacePoint*> spacePointsToStoreInSeed;
56 //Look for GHITz, till we have a last hit
57 bool isLast = false;
58 unsigned int hitsInTrack = 0;
59 while(!isLast)
60 {
61 hitsInTrack++;
62 auto Ghit_w1 = FPGADataFormatUtilities::get_bitfields_GHITZ_w1(trackOutput->at(++i));
63 // decode information from the hit
66 float x = r * std::cos(phi);
67 float y = r * std::sin(phi);
69 isLast = Ghit_w1.last;
70
71 auto Ghit_w2 = FPGADataFormatUtilities::get_bitfields_GHITZ_w2(trackOutput->at(++i));
72 auto identifierHashW2 = Ghit_w2.cluster1;
73
74 // find in the multimap the SP that matches this globalPosition
75 auto range = spacePointMap.equal_range(identifierHashW2);
76 for (auto it = range.first; it != range.second; ++it) {
77 constexpr float kEpsilon = 0.1;
78 const xAOD::SpacePoint* spacePoint = it->second;
79 if (std::abs(x - spacePoint->x()) < kEpsilon &&
80 std::abs(y - spacePoint->y()) < kEpsilon&&
81 std::abs(z - spacePoint->z()) < kEpsilon) {
82 spacePointsToStoreInSeed.push_back(spacePoint);
83 if (spacePointsToStoreInSeed.size() == m_maxSpacePointsPerSeed) break; // stop if max reached
84 }
85 }
86 if (spacePointsToStoreInSeed.size() == m_maxSpacePointsPerSeed) break; // stop in case we reach the maximum number of space points allowed
87 }
88
89 if(hitsInTrack != spacePointsToStoreInSeed.size())
90 {
91 ATH_MSG_WARNING("Track does not have the same number of hits in the output as the seed container hitsInTrack: "<<hitsInTrack<<" spacePointsToStoreInSeed: "<<spacePointsToStoreInSeed.size());
92 }
93 // construct seed based on the space points stored in the vector
94 if (spacePointsToStoreInSeed.size() >= m_minSpacePointsPerSeed) { // check that seeds contains at least the minimum number of desired space points
95 const float vertexZ = gtrack_w2.z0/FPGADataFormatUtilities::GTRACK_HDR_W2_Z0_mf;
96 const auto chiSquare = gtrack_w2.score/FPGADataFormatUtilities::GTRACK_HDR_W2_SCORE_mf;
97 const float quality = (chiSquare != 0.0) ? 1.0 / chiSquare : 0.0;
98
99 seeds->push_back(spacePointsToStoreInSeed, quality, vertexZ);
100 }
101
102 }
103
104 }
105
106 ATH_MSG_INFO("HW Recorded " << seeds->size() << " seeds");
107
108 return StatusCode::SUCCESS;
109 }
110
111} // namespace EFTrackingFPGAIntegration
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
Exception-safe IChronoSvc caller.
#define y
#define x
#define z
StatusCode execute(const EventContext &ctx) const override
SG::ReadHandleKey< xAOD::SpacePointContainer > m_spacePointContainerKey
SG::ReadHandleKey< std::vector< uint64_t > > m_FPGATrackOutput
SG::WriteHandleKey< ActsTrk::SeedContainer > m_seedKey
virtual bool isValid() override final
Can the handle be successfully dereferenced?
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
pointer_type ptr()
Dereference the pointer.
float z() const
float y() const
float x() const
int r
Definition globals.cxx:22
The class for enconding RDO to FPGA format.
GTRACK_HDR_w3 get_bitfields_GTRACK_HDR_w3(const uint64_t &in)
GTRACK_HDR_w1 get_bitfields_GTRACK_HDR_w1(const uint64_t &in)
GHITZ_w1 get_bitfields_GHITZ_w1(const uint64_t &in)
GTRACK_HDR_w2 get_bitfields_GTRACK_HDR_w2(const uint64_t &in)
GHITZ_w2 get_bitfields_GHITZ_w2(const uint64_t &in)
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
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