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, Acts::SpacePointIndex2> spacePointMap;
36 seeds->spacePoints().reserve(spacePointsHandle->size());
37 // Populate the multimap with Pixel cluster hashID as key.
38 // Only space points with one measurement are considered (i.e. pixels)
39 for (const xAOD::SpacePoint* spacePoint : *spacePointsHandle) {
40 if (!spacePoint->measurements().empty()) {
41 seeds->spacePoints().push_back(spacePoint);
42 spacePointMap.emplace(spacePoint->measurements().at(0)->identifierHash(), seeds->spacePoints().size()-1ul);
43 }
44 }
45
46 seeds->reserve(trackOutput->size());
47 // first three works are header, so skip them for now
48 for(unsigned int i = 3; i < trackOutput->size(); i++)
49 {
50 // Check if the flags track header
52 {
53 auto gtrack_w1 = FPGADataFormatUtilities::get_bitfields_GTRACK_HDR_w1(trackOutput->at(i));
54 auto gtrack_w2 = FPGADataFormatUtilities::get_bitfields_GTRACK_HDR_w2(trackOutput->at(++i));
55 auto gtrack_w3 = FPGADataFormatUtilities::get_bitfields_GTRACK_HDR_w3(trackOutput->at(++i));
56
57 std::vector<Acts::SpacePointIndex2> spacePointsToStoreInSeed;
58 //Look for GHITz, till we have a last hit
59 bool isLast = false;
60 unsigned int hitsInTrack = 0;
61 while(!isLast)
62 {
63 hitsInTrack++;
64 auto Ghit_w1 = FPGADataFormatUtilities::get_bitfields_GHITZ_w1(trackOutput->at(++i));
65 // decode information from the hit
68 float x = r * std::cos(phi);
69 float y = r * std::sin(phi);
71 isLast = Ghit_w1.last;
72
73 auto Ghit_w2 = FPGADataFormatUtilities::get_bitfields_GHITZ_w2(trackOutput->at(++i));
74 auto identifierHashW2 = Ghit_w2.cluster1;
75
76 // find in the multimap the SP that matches this globalPosition
77 auto range = spacePointMap.equal_range(identifierHashW2);
78 for (auto it = range.first; it != range.second; ++it) {
79 constexpr float kEpsilon = 0.1;
80 const xAOD::SpacePoint* spacePoint = seeds->spacePoints().at(it->second);
81 if (std::abs(x - spacePoint->x()) < kEpsilon &&
82 std::abs(y - spacePoint->y()) < kEpsilon&&
83 std::abs(z - spacePoint->z()) < kEpsilon) {
84 spacePointsToStoreInSeed.push_back(it->second);
85 if (spacePointsToStoreInSeed.size() == m_maxSpacePointsPerSeed) break; // stop if max reached
86 }
87 }
88 if (spacePointsToStoreInSeed.size() == m_maxSpacePointsPerSeed) break; // stop in case we reach the maximum number of space points allowed
89 }
90
91 if(hitsInTrack != spacePointsToStoreInSeed.size())
92 {
93 ATH_MSG_WARNING("Track does not have the same number of hits in the output as the seed container hitsInTrack: "<<hitsInTrack<<" spacePointsToStoreInSeed: "<<spacePointsToStoreInSeed.size());
94 }
95 // construct seed based on the space points stored in the vector
96 if (spacePointsToStoreInSeed.size() >= m_minSpacePointsPerSeed) { // check that seeds contains at least the minimum number of desired space points
97 auto seed = seeds->push_back(spacePointsToStoreInSeed);
98 seed.vertexZ() = gtrack_w2.z0/FPGADataFormatUtilities::GTRACK_HDR_W2_Z0_mf;
99 auto chiSquare = gtrack_w2.score/FPGADataFormatUtilities::GTRACK_HDR_W2_SCORE_mf;
100 if (chiSquare != 0.0) {
101 seed.quality() = 1.0 / chiSquare;
102 } else {
103 seed.quality() = 0.0;
104 }
105 }
106
107 }
108
109 }
110
111 ATH_MSG_INFO("HW Recorded " << seeds->size() << " seeds");
112
113 return StatusCode::SUCCESS;
114 }
115
116} // 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.
Acts::MutableSeedProxy2 push_back(Acts::SpacePointIndexSubset2 sp)
const SpacePointContainer & spacePoints() const noexcept