ATLAS Offline Software
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 
6 #include "AthenaKernel/Chrono.h"
8 
10 {
12  {
13 
15  ATH_CHECK(m_spacePointContainerKey.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
66  float r = Ghit_w1.rad/FPGADataFormatUtilities::GHITZ_W1_RAD_mf;
68  float x = r * std::cos(phi);
69  float y = r * std::sin(phi);
70  float z = Ghit_w1.z/FPGADataFormatUtilities::GHITZ_W1_Z_mf;
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;
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
beamspotman.r
def r
Definition: beamspotman.py:672
ActsTrk::SeedContainer
Definition: SeedContainer.h:18
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
EFTrackingFPGAIntegration::F150EDMConversionAlg::m_spacePointContainerKey
SG::ReadHandleKey< xAOD::SpacePointContainer > m_spacePointContainerKey
Definition: F150EDMConversionAlg.h:47
TRT::Track::chiSquare
@ chiSquare
Definition: InnerDetector/InDetCalibEvent/TRT_CalibData/TRT_CalibData/TrackInfo.h:67
FPGADataFormatUtilities::GTRACK_HDR_W2_SCORE_mf
const float GTRACK_HDR_W2_SCORE_mf
Definition: FPGADataFormatUtilities.h:695
FPGADataFormatUtilities::GTRACK_HDR_W2_Z0_mf
const float GTRACK_HDR_W2_Z0_mf
Definition: FPGADataFormatUtilities.h:703
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
EFTrackingFPGAIntegration::F150EDMConversionAlg::execute
StatusCode execute(const EventContext &ctx) const override
Definition: F150EDMConversionAlg.cxx:21
skel.it
it
Definition: skel.GENtoEVGEN.py:407
EFTrackingFPGAIntegration::F150EDMConversionAlg::initialize
virtual StatusCode initialize() override
Definition: F150EDMConversionAlg.cxx:11
xAOD::SpacePoint_v1
Definition: SpacePoint_v1.h:29
FPGADataFormatUtilities::GTRACK_HDR_w1::flag
uint64_t flag
Definition: FPGADataFormatUtilities.h:727
Chrono.h
Exception-safe IChronoSvc caller.
drawFromPickle.cos
cos
Definition: drawFromPickle.py:36
FPGADataFormatUtilities::GHITZ_W1_RAD_mf
const float GHITZ_W1_RAD_mf
Definition: FPGADataFormatUtilities.h:1102
x
#define x
xAOD::SpacePoint_v1::z
float z() const
FPGADataFormatUtilities::get_bitfields_GHITZ_w2
GHITZ_w2 get_bitfields_GHITZ_w2(const uint64_t &in)
Definition: FPGADataFormatUtilities.h:1166
ActsTrk::SeedContainer::push_back
Acts::MutableSeedProxy2 push_back(Acts::SpacePointIndexSubset2 sp)
Definition: SeedContainer.h:35
EFTrackingFPGAIntegration::F150EDMConversionAlg::m_FPGATrackOutput
SG::ReadHandleKey< std::vector< uint64_t > > m_FPGATrackOutput
Definition: F150EDMConversionAlg.h:45
lumiFormat.i
int i
Definition: lumiFormat.py:85
z
#define z
SG::get
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
Definition: ReadCondHandle.h:283
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:194
FPGADataFormatUtilities::get_bitfields_GHITZ_w1
GHITZ_w1 get_bitfields_GHITZ_w1(const uint64_t &in)
Definition: FPGADataFormatUtilities.h:1154
FPGADataFormatUtilities::get_bitfields_GTRACK_HDR_w2
GTRACK_HDR_w2 get_bitfields_GTRACK_HDR_w2(const uint64_t &in)
Definition: FPGADataFormatUtilities.h:764
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
detail::ul
unsigned long ul
Definition: PrimitiveHelpers.h:47
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
EFTrackingFPGAIntegration
The class for enconding RDO to FPGA format.
Definition: F100DataEncodingAlg.h:27
FPGADataFormatUtilities.h
EFTrackingFPGAIntegration::F150EDMConversionAlg::m_minSpacePointsPerSeed
Gaudi::Property< size_t > m_minSpacePointsPerSeed
Definition: F150EDMConversionAlg.h:41
ActsTrk::SeedContainer::spacePoints
const SpacePointContainer & spacePoints() const noexcept
Definition: SeedContainer.h:30
EFTrackingFPGAIntegration::F150EDMConversionAlg::m_maxSpacePointsPerSeed
Gaudi::Property< size_t > m_maxSpacePointsPerSeed
Definition: F150EDMConversionAlg.h:42
FPGADataFormatUtilities::GHITZ_W1_Z_mf
const float GHITZ_W1_Z_mf
Definition: FPGADataFormatUtilities.h:1110
FPGADataFormatUtilities::GHITZ_W1_PHI_mf
const float GHITZ_W1_PHI_mf
Definition: FPGADataFormatUtilities.h:1106
xAOD::SpacePoint_v1::y
float y() const
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:73
y
#define y
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
xAOD::SpacePoint_v1::x
float x() const
FPGADataFormatUtilities::get_bitfields_GTRACK_HDR_w1
GTRACK_HDR_w1 get_bitfields_GTRACK_HDR_w1(const uint64_t &in)
Definition: FPGADataFormatUtilities.h:751
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
EFTrackingFPGAIntegration::F150EDMConversionAlg::m_seedKey
SG::WriteHandleKey< ActsTrk::SeedContainer > m_seedKey
Definition: F150EDMConversionAlg.h:50
FPGADataFormatUtilities::GTRACK_HDR_FLAG
const int GTRACK_HDR_FLAG
Definition: FPGADataFormatUtilities.h:657
F150EDMConversionAlg.h
FPGADataFormatUtilities::get_bitfields_GTRACK_HDR_w3
GTRACK_HDR_w3 get_bitfields_GTRACK_HDR_w3(const uint64_t &in)
Definition: FPGADataFormatUtilities.h:773