ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
EFTracking
FPGATrackSim
FPGATrackSimSeeding
src
FPGATrackSimSeedingAlg.cxx
Go to the documentation of this file.
1
// Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
2
3
#include "
src/FPGATrackSimSeedingAlg.h
"
4
#include <array>
5
#include <map>
6
#include "
xAODInDetMeasurement/SpacePoint.h
"
7
8
namespace
FPGATrackSim
{
9
10
FPGATrackSim::FPGATrackSimSeedingAlg::FPGATrackSimSeedingAlg
(
const
std::string& name, ISvcLocator* pSvcLocator) :
AthReentrantAlgorithm
(name, pSvcLocator) {
11
}
12
StatusCode
FPGATrackSimSeedingAlg::initialize
() {
13
ATH_CHECK
(
m_FPGATrackCollectionKey
.initialize());
14
ATH_CHECK
(
m_pixelClusterContainerKey
.initialize());
15
ATH_CHECK
(
m_spacePointContainerKey
.initialize());
16
ATH_CHECK
(
m_seedKey
.initialize());
17
18
return
StatusCode::SUCCESS;
19
}
20
21
StatusCode
FPGATrackSimSeedingAlg::execute
(
const
EventContext& ctx)
const
{
22
23
SG::ReadHandle<FPGATrackSimTrackCollection>
tracksHandle{
m_FPGATrackCollectionKey
, ctx};
24
SG::ReadHandle<xAOD::PixelClusterContainer>
pixelClustersHandle{
m_pixelClusterContainerKey
, ctx};
25
SG::ReadHandle<xAOD::SpacePointContainer>
spacePointsHandle{
m_spacePointContainerKey
, ctx};
26
27
ATH_CHECK
(tracksHandle.
isValid
());
28
ATH_CHECK
(pixelClustersHandle.
isValid
());
29
ATH_CHECK
(spacePointsHandle.
isValid
());
30
31
SG::WriteHandle<ActsTrk::SeedContainer>
seedHandle{
m_seedKey
, ctx};
32
ATH_CHECK
(seedHandle.
record
(std::make_unique<ActsTrk::SeedContainer>()));
33
ActsTrk::SeedContainer
* seeds = seedHandle.
ptr
();
34
35
// Use a map since identifiers are unique
36
std::map<Identifier::value_type, const xAOD::SpacePoint*> spacePointMap;
37
38
// Populate the map with pixel cluster identifier (rdoID) as key.
39
// Only space points with one measurement are considered (i.e. pixels). In case strips are needed the code should not be based on the one-measurement-per-space-point assumption.
40
for
(
const
xAOD::SpacePoint
* spacePoint : *spacePointsHandle) {
41
if
(!spacePoint->measurements().empty()) {
42
const
auto
identifier = spacePoint->measurements().at(0)->identifier();
43
44
// Check for duplicates (shouldn't happen if all works as expected)
45
auto
[it, inserted] = spacePointMap.emplace(identifier, spacePoint);
46
if
(!inserted) {
47
ATH_MSG_ERROR
(
"Duplicate identifier 0x"
<< std::hex << identifier << std::dec
48
<<
" found for space point. Keeping first occurrence."
);
49
}
50
}
51
}
52
53
seeds->
reserve
(tracksHandle->size());
54
// loop over the tracks and make seeds based on the hits in FPGATrackSimTracks
55
for
(
const
auto
& track : *tracksHandle) {
56
std::vector<const xAOD::SpacePoint*> spacePointsToStoreInSeed;
57
for
(
const
auto
&
hit
: track.getFPGATrackSimHitPtrs()) {
58
if
(!
hit
)
continue
;
59
if
(
hit
->isReal() &&
hit
->isPixel()) {
60
ATH_MSG_DEBUG
(
"Hit coordinates in module "
<<
hit
->getRdoIdentifier()
61
<<
": ("
<<
hit
->getPhiCoord() <<
", "
<<
hit
->getEtaCoord() <<
")"
);
62
63
// map lookup
64
auto
it = spacePointMap.find(
hit
->getRdoIdentifier());
65
if
(it != spacePointMap.end()) {
66
spacePointsToStoreInSeed.push_back(it->second);
67
}
else
{
68
ATH_MSG_ERROR
(
"No SP found for hit identifier 0x"
69
<< std::hex <<
hit
->getRdoIdentifier() << std::dec);
70
}
71
72
// stop in case we reach the maximum number of space points allowed
73
if
(spacePointsToStoreInSeed.size() ==
m_maxSpacePointsPerSeed
)
break
;
74
}
75
}
76
77
// Construct seed based on the space points stored in the vector
78
if
(spacePointsToStoreInSeed.size() >=
m_minSpacePointsPerSeed
) {
// check that seeds contains at least the minimum number of desired space points
79
// TODO: validate if this is correct. (technically the larger the value, the better the quality of the seed)
80
// or another default value? TODO: check if that's fine
81
const
float
quality = track.getChi2ndof() != 0.0 ? 1.0 / track.getChi2ndof() : 0.0;
82
83
seeds->
push_back
(spacePointsToStoreInSeed, quality, track.getZ0());
84
}
85
}
86
87
ATH_MSG_DEBUG
(
"Recorded "
<< seeds->
size
() <<
" seeds"
);
88
return
StatusCode::SUCCESS;
89
}
90
}
// namespace FPGATrackSim
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x,...)
Definition
AthMsgStreamMacros.h:43
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x,...)
Definition
AthMsgStreamMacros.h:47
SpacePoint.h
FPGATrackSimSeedingAlg.h
hit
bool hit(const Container &ids, int pdgId)
Definition
JetIRCSafeLabelTool.cxx:64
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition
AthReentrantAlgorithm.h:74
FPGATrackSim::FPGATrackSimSeedingAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override final
Definition
FPGATrackSimSeedingAlg.cxx:21
FPGATrackSim::FPGATrackSimSeedingAlg::m_pixelClusterContainerKey
SG::ReadHandleKey< xAOD::PixelClusterContainer > m_pixelClusterContainerKey
Definition
FPGATrackSimSeedingAlg.h:41
FPGATrackSim::FPGATrackSimSeedingAlg::m_maxSpacePointsPerSeed
Gaudi::Property< size_t > m_maxSpacePointsPerSeed
Definition
FPGATrackSimSeedingAlg.h:37
FPGATrackSim::FPGATrackSimSeedingAlg::m_FPGATrackCollectionKey
SG::ReadHandleKey< FPGATrackSimTrackCollection > m_FPGATrackCollectionKey
Definition
FPGATrackSimSeedingAlg.h:40
FPGATrackSim::FPGATrackSimSeedingAlg::m_spacePointContainerKey
SG::ReadHandleKey< xAOD::SpacePointContainer > m_spacePointContainerKey
Definition
FPGATrackSimSeedingAlg.h:42
FPGATrackSim::FPGATrackSimSeedingAlg::initialize
virtual StatusCode initialize() override final
Definition
FPGATrackSimSeedingAlg.cxx:12
FPGATrackSim::FPGATrackSimSeedingAlg::FPGATrackSimSeedingAlg
FPGATrackSimSeedingAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition
FPGATrackSimSeedingAlg.cxx:10
FPGATrackSim::FPGATrackSimSeedingAlg::m_minSpacePointsPerSeed
Gaudi::Property< size_t > m_minSpacePointsPerSeed
Definition
FPGATrackSimSeedingAlg.h:36
FPGATrackSim::FPGATrackSimSeedingAlg::m_seedKey
SG::WriteHandleKey< ActsTrk::SeedContainer > m_seedKey
Definition
FPGATrackSimSeedingAlg.h:45
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
SG::WriteHandle
Definition
StoreGate/StoreGate/WriteHandle.h:73
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
SG::WriteHandle::ptr
pointer_type ptr()
Dereference the pointer.
FPGATrackSim
Definition
FPGATrackSimRegionMergingAlg.h:24
xAOD::SpacePoint
SpacePoint_v1 SpacePoint
Definition
Event/xAOD/xAODInDetMeasurement/xAODInDetMeasurement/SpacePoint.h:12
ActsTrk::SeedContainer
Definition
SeedContainer.h:67
ActsTrk::SeedContainer::push_back
Seed push_back(SpacePointRange spacePoints, float quality, float vertexZ)
Definition
SeedContainer.h:113
ActsTrk::SeedContainer::reserve
void reserve(std::size_t size, float averageSpacePoints=3) noexcept
Definition
SeedContainer.h:73
ActsTrk::SeedContainer::size
std::size_t size() const noexcept
Definition
SeedContainer.h:71
Generated on
for ATLAS Offline Software by
1.17.0