ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Tracking
Acts
ActsPatternRecognition
src
GenericSeedingAlg.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
src/GenericSeedingAlg.h
"
6
7
// ACTS
8
#include "Acts/Definitions/Units.hpp"
9
#include "Acts/EventData/SeedContainer.hpp"
10
#include "Acts/EventData/SpacePointContainer.hpp"
11
#include "Acts/MagneticField/MagneticFieldContext.hpp"
12
#include "Acts/Seeding/BinnedGroup.hpp"
13
#include "
ActsGeometry/ATLASMagneticFieldWrapper.h
"
14
15
// Other
16
#include "
ActsInterop/TableUtils.h
"
17
#include "
AthenaMonitoringKernel/Monitored.h
"
18
#include "
InDetReadoutGeometry/SiDetectorElement.h
"
19
#include "
InDetReadoutGeometry/SiDetectorElementCollection.h
"
20
#include "
SiSPSeededTrackFinderData/ITkSiSpacePointForSeed.h
"
21
#include "
SiSPSeededTrackFinderData/SiSpacePointForSeed.h
"
22
#include "
TrkSpacePoint/SpacePointCollection.h
"
23
24
namespace
ActsTrk
{
25
26
GenericSeedingAlg::GenericSeedingAlg
(
const
std::string& name,
27
ISvcLocator* pSvcLocator)
28
:
AthReentrantAlgorithm
(name, pSvcLocator) {}
29
30
StatusCode
GenericSeedingAlg::initialize
() {
31
ATH_MSG_INFO
(
"Initializing "
<< name() <<
" ... "
);
32
if
(
m_fastTracking
)
33
ATH_MSG_INFO
(
" using fast tracking configuration."
);
34
35
// Retrieve seed tool
36
ATH_CHECK
(
m_seedsTool
.retrieve());
37
38
// Cond
39
ATH_CHECK
(
m_beamSpotKey
.initialize());
40
ATH_CHECK
(
m_fieldCondObjInputKey
.initialize());
41
42
// Read and Write handles
43
ATH_CHECK
(
m_spacePointKey
.initialize());
44
ATH_CHECK
(
m_seedKey
.initialize());
45
46
ATH_CHECK
(
m_monTool
.retrieve(EnableTool{not m_monTool.empty()}));
47
48
return
StatusCode::SUCCESS;
49
}
50
51
StatusCode
GenericSeedingAlg::finalize
() {
52
ATH_MSG_INFO
(
"Seed statistics"
<< std::endl
53
<<
makeTable
(m_stat,
54
std::array<std::string, kNStat>{
55
"Spacepoints"
,
"Seeds"
})
56
.columnWidth(10));
57
return
StatusCode::SUCCESS;
58
}
59
60
StatusCode
GenericSeedingAlg::execute
(
const
EventContext& ctx)
const
{
61
ATH_MSG_DEBUG
(
"Executing "
<< name() <<
" ... "
);
62
63
auto
timer =
Monitored::Timer<std::chrono::milliseconds>
(
"TIME_execute"
);
64
auto
time_seedCreation =
65
Monitored::Timer<std::chrono::milliseconds>
(
"TIME_seedCreation"
);
66
auto
mon_nSeeds =
Monitored::Scalar<int>
(
"nSeeds"
);
67
auto
mon =
Monitored::Group
(
m_monTool
, timer, time_seedCreation, mon_nSeeds);
68
69
// ================================================== //
70
// ===================== OUTPUTS ==================== //
71
// ================================================== //
72
73
SG::WriteHandle<ActsTrk::SeedContainer>
seedHandle =
74
SG::makeHandle
(
m_seedKey
, ctx);
75
ATH_MSG_DEBUG
(
" \\__ Seed Container `"
<<
m_seedKey
.key()
76
<<
"` created ..."
);
77
ATH_CHECK
(seedHandle.
record
(std::make_unique<ActsTrk::SeedContainer>()));
78
ActsTrk::SeedContainer
* seedPtrs = seedHandle.
ptr
();
79
80
// ================================================== //
81
// ===================== INPUTS ===================== //
82
// ================================================== //
83
84
// Read the Beam Spot information
85
const
InDet::BeamSpotData
* beamSpotData{
nullptr
};
86
ATH_CHECK
(
SG::get
(beamSpotData,
m_beamSpotKey
, ctx));
87
// Beam Spot Position
88
Acts::Vector3 beamPos(beamSpotData->
beamPos
().x() * Acts::UnitConstants::mm,
89
beamSpotData->
beamPos
().y() * Acts::UnitConstants::mm,
90
beamSpotData->
beamPos
().z() * Acts::UnitConstants::mm);
91
92
ATH_MSG_DEBUG
(
"Retrieving elements from "
<<
m_spacePointKey
.size()
93
<<
" input collections..."
);
94
std::vector<const xAOD::SpacePointContainer*> allInputCollections;
95
allInputCollections.reserve(
m_spacePointKey
.size());
96
97
for
(
const
auto
& spacePointKey :
m_spacePointKey
) {
98
ATH_MSG_DEBUG
(
"Retrieving from Input Collection '"
<< spacePointKey.key()
99
<<
"' ..."
);
100
const
xAOD::SpacePointContainer
* spCont{
nullptr
};
101
ATH_CHECK
(
SG::get
(spCont, spacePointKey, ctx));
102
allInputCollections.push_back(spCont);
103
ATH_MSG_DEBUG
(
" \\__ "
<< spCont->
size
() <<
" elements!"
);
104
}
105
106
std::size_t totalSpacePoints = 0;
107
for
(
const
xAOD::SpacePointContainer
* collection : allInputCollections) {
108
totalSpacePoints += collection->size();
109
}
110
111
ATH_MSG_DEBUG
(
" \\__ Total input space points: "
<< totalSpacePoints);
112
m_stat[
kNSpacepoints
] += totalSpacePoints;
113
114
// Early Exit in case no space points at this stage
115
if
(totalSpacePoints == 0) {
116
ATH_MSG_DEBUG
(
"No input space points found, we stop seeding"
);
117
return
StatusCode::SUCCESS;
118
}
119
120
// ================================================== //
121
// ===================== CONDS ====================== //
122
// ================================================== //
123
124
// Read the b-field information
125
const
AtlasFieldCacheCondObj
* fieldCondObj{
nullptr
};
126
ATH_CHECK
(
SG::get
(fieldCondObj,
m_fieldCondObjInputKey
, ctx));
127
128
// Get the magnetic field
129
// Using ACTS classes in order to be sure we are consistent
130
Acts::MagneticFieldContext magFieldContext(fieldCondObj);
131
ATLASMagneticFieldWrapper
magneticField;
132
Acts::MagneticFieldProvider::Cache magFieldCache =
133
magneticField.
makeCache
(magFieldContext);
134
Acts::Vector3 bField = *magneticField.
getField
(
135
Acts::Vector3(beamPos.x(), beamPos.y(), 0), magFieldCache);
136
137
// ================================================== //
138
// ===================== COMPUTATION ================ //
139
// ================================================== //
140
141
ATH_MSG_DEBUG
(
"Running Grid Triplet Seed Finding ..."
);
142
time_seedCreation.start();
143
try
{
144
ATH_CHECK
(
m_seedsTool
->createSeeds(ctx, allInputCollections,
145
beamPos.cast<
float
>(), bField.z(),
146
*seedPtrs));
147
}
catch
(
const
std::exception& e) {
148
ATH_MSG_ERROR
(
"Exception caught during seed creation: "
<< e.what());
149
return
StatusCode::FAILURE;
150
}
151
time_seedCreation.stop();
152
153
ATH_MSG_DEBUG
(
" \\__ Created "
<< seedPtrs->
size
() <<
" seeds"
);
154
m_stat[
kNSeeds
] += seedPtrs->
size
();
155
156
mon_nSeeds = seedPtrs->
size
();
157
158
return
StatusCode::SUCCESS;
159
}
160
161
}
// namespace ActsTrk
ATLASMagneticFieldWrapper.h
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
GenericSeedingAlg.h
ITkSiSpacePointForSeed.h
Monitored.h
Header file to be included by clients of the Monitored infrastructure.
SiDetectorElementCollection.h
SiDetectorElement.h
SiSpacePointForSeed.h
SpacePointCollection.h
TableUtils.h
makeTable
TableUtils::StatTable< T > makeTable(const std::array< T, N > &counter, const std::array< std::string, N > &label)
Definition
TableUtils.h:544
ATLASMagneticFieldWrapper
Definition
ATLASMagneticFieldWrapper.h:15
ATLASMagneticFieldWrapper::getField
Acts::Result< Acts::Vector3 > getField(const Acts::Vector3 &position, Acts::MagneticFieldProvider::Cache &gcache) const override
Definition
ATLASMagneticFieldWrapper.h:39
ATLASMagneticFieldWrapper::makeCache
MagneticFieldProvider::Cache makeCache(const Acts::MagneticFieldContext &mctx) const override
Definition
ATLASMagneticFieldWrapper.h:34
ActsTrk::GenericSeedingAlg::GenericSeedingAlg
GenericSeedingAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition
GenericSeedingAlg.cxx:26
ActsTrk::GenericSeedingAlg::m_fieldCondObjInputKey
SG::ReadCondHandleKey< AtlasFieldCacheCondObj > m_fieldCondObjInputKey
Definition
GenericSeedingAlg.h:54
ActsTrk::GenericSeedingAlg::finalize
virtual StatusCode finalize() override
Definition
GenericSeedingAlg.cxx:51
ActsTrk::GenericSeedingAlg::m_spacePointKey
SG::ReadHandleKeyArray< xAOD::SpacePointContainer > m_spacePointKey
Definition
GenericSeedingAlg.h:58
ActsTrk::GenericSeedingAlg::m_seedKey
SG::WriteHandleKey< ActsTrk::SeedContainer > m_seedKey
Definition
GenericSeedingAlg.h:60
ActsTrk::GenericSeedingAlg::m_monTool
ToolHandle< GenericMonitoringTool > m_monTool
Definition
GenericSeedingAlg.h:48
ActsTrk::GenericSeedingAlg::m_beamSpotKey
SG::ReadCondHandleKey< InDet::BeamSpotData > m_beamSpotKey
Definition
GenericSeedingAlg.h:52
ActsTrk::GenericSeedingAlg::initialize
virtual StatusCode initialize() override
Definition
GenericSeedingAlg.cxx:30
ActsTrk::GenericSeedingAlg::kNSeeds
@ kNSeeds
Definition
GenericSeedingAlg.h:67
ActsTrk::GenericSeedingAlg::kNSpacepoints
@ kNSpacepoints
Definition
GenericSeedingAlg.h:67
ActsTrk::GenericSeedingAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition
GenericSeedingAlg.cxx:60
ActsTrk::GenericSeedingAlg::m_fastTracking
Gaudi::Property< bool > m_fastTracking
Definition
GenericSeedingAlg.h:63
ActsTrk::GenericSeedingAlg::m_seedsTool
ToolHandle< ActsTrk::ISeedingTool > m_seedsTool
Definition
GenericSeedingAlg.h:46
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition
AthReentrantAlgorithm.h:74
AtlasFieldCacheCondObj
Definition
AtlasFieldCacheCondObj.h:19
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
InDet::BeamSpotData
Definition
BeamSpotData.h:21
InDet::BeamSpotData::beamPos
const Amg::Vector3D & beamPos() const noexcept
Definition
BeamSpotData.h:68
Monitored::Group
Group of local monitoring quantities and retain correlation when filling histograms
Definition
MonitoredGroup.h:53
Monitored::Scalar
Declare a monitored scalar variable.
Definition
MonitoredScalar.h:34
Monitored::Timer
A monitored timer.
Definition
MonitoredTimer.h:32
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.
ActsTrk
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
Definition
MdtCalibInput.h:31
SG::get
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
Definition
ReadCondHandle.h:282
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition
ReadCondHandle.h:269
xAOD::SpacePointContainer
SpacePointContainer_v1 SpacePointContainer
Define the version of the space point container.
Definition
Event/xAOD/xAODInDetMeasurement/xAODInDetMeasurement/SpacePointContainer.h:14
ActsTrk::SeedContainer
Definition
SeedContainer.h:67
ActsTrk::SeedContainer::size
std::size_t size() const noexcept
Definition
SeedContainer.h:71
Generated on
for ATLAS Offline Software by
1.17.0