ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
EFTracking
FPGATrackSim
FPGATrackSimAlgorithms
src
FPGATrackSimLayerStudyAlg.cxx
Go to the documentation of this file.
1
// Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
2
3
#include "
FPGATrackSimLayerStudyAlg.h
"
4
5
#include "
AthenaBaseComps/AthMsgStreamMacros.h
"
6
#include "
FPGATrackSimBinning/FPGATrackSimBinUtil.h
"
7
#include "
FPGATrackSimObjects/FPGATrackSimCluster.h
"
8
#include "
FPGATrackSimObjects/FPGATrackSimHit.h
"
9
#include "
FPGATrackSimObjects/FPGATrackSimDataFlowInfo.h
"
10
#include "
FPGATrackSimObjects/FPGATrackSimRoad.h
"
11
#include "
FPGATrackSimObjects/FPGATrackSimTrack.h
"
12
#include "
FPGATrackSimObjects/FPGATrackSimLogicalEventOutputHeader.h
"
13
#include "
FPGATrackSimObjects/FPGATrackSimLogicalEventInputHeader.h
"
14
#include "
FPGATrackSimObjects/FPGATrackSimTrackPars.h
"
15
16
#include "
FPGATrackSimAlgorithms/FPGATrackSimNNTrackTool.h
"
17
#include "
FPGATrackSimAlgorithms/FPGATrackSimOverlapRemovalTool.h
"
18
#include "
FPGATrackSimAlgorithms/FPGATrackSimTrackFitterTool.h
"
19
20
#include "
FPGATrackSimConfTools/FPGATrackSimRegionSlices.h
"
21
22
#include "
FPGATrackSimInput/FPGATrackSimRawToLogicalHitsTool.h
"
23
#include "
FPGATrackSimInput/FPGATrackSimReadRawRandomHitsTool.h
"
24
25
#include "
FPGATrackSimMaps/FPGATrackSimRegionMap.h
"
26
27
#include "GaudiKernel/IEventProcessor.h"
28
29
constexpr
bool
enableBenchmark
=
30
#ifdef BENCHMARK_LAYERSTUDYALG
31
true
;
32
#else
33
false
;
34
#endif
35
37
// Initialize
38
39
FPGATrackSimLayerStudyAlg::FPGATrackSimLayerStudyAlg
(
const
std::string& name, ISvcLocator* pSvcLocator) :
40
AthAlgorithm
(name, pSvcLocator)
41
{
42
}
43
44
45
StatusCode
FPGATrackSimLayerStudyAlg::initialize
()
46
{
47
std::stringstream
ss
(
m_description
);
48
std::string line;
49
ATH_MSG_INFO
(
"Tag config:"
);
50
if
(!
m_description
.empty()) {
51
while
(std::getline(
ss
, line,
'\n'
)) {
52
ATH_MSG_INFO
(
'\t'
<< line);
53
}
54
}
55
56
ATH_CHECK
(
m_hitBinningTool
.retrieve());
57
ATH_CHECK
(
m_binMonitoring
.retrieve());
58
ATH_CHECK
(
m_FPGATrackSimMapping
.retrieve());
59
ATH_CHECK
(
m_evtSel
.retrieve());
60
61
// TODO add this here
62
ATH_MSG_DEBUG
(
"initialize() Instantiating output layer study tree"
);
63
64
// Setup layer configuration if not already set from layerMap
65
if
(
m_hitBinningTool
->getNLayers()==0) {
66
m_hitBinningTool
->setNLayers(
m_FPGATrackSimMapping
->PlaneMap_1st(0)->getNLogiLayers());
67
}
68
69
// Set up the histograms. Use the event selection service to test whether or not this is single particle.
70
// It may be better to not use a separate tool for this, and just fold it into this algorithm.
71
// The reason to keep a separate tool would be is if we eventually want to migrate *all* of GenScanMonitoring -> BinMonitoring,
72
// but that can't happen until GenScan is fully converted to use the new binning.
73
ATH_CHECK
(
m_binMonitoring
->registerHistograms(
m_hitBinningTool
.get(), (
m_evtSel
->getSampleType() ==
SampleType::skipTruth
)));
74
75
// Retrieve truth tracks.
76
ATH_CHECK
(
m_FPGAHitKey
.initialize());
77
ATH_CHECK
(
m_FPGATruthTrackKey
.initialize());
78
79
ATH_CHECK
(
m_chrono
.retrieve());
80
ATH_MSG_DEBUG
(
"initialize() Finished"
);
81
82
return
StatusCode::SUCCESS;
83
}
84
85
87
// MAIN EXECUTE ROUTINE //
89
90
StatusCode
FPGATrackSimLayerStudyAlg::execute
(
const
EventContext& ctx)
91
{
92
93
// Get reference to hits from StoreGate.
94
SG::ReadHandle<FPGATrackSimHitCollection>
FPGAHits(
m_FPGAHitKey
, ctx);
95
if
(!FPGAHits.
isValid
()) {
96
if
(
m_evt
== 0) {
97
ATH_MSG_WARNING
(
"Didn't receive "
<< FPGAHits.
key
() <<
" on first event; assuming no input events."
);
98
}
99
SmartIF<IEventProcessor> appMgr{service(
"ApplicationMgr"
)};
100
if
(!appMgr) {
101
ATH_MSG_ERROR
(
"Failed to retrieve ApplicationMgr as IEventProcessor"
);
102
return
StatusCode::FAILURE;
103
}
104
return
appMgr->stopRun();
105
}
106
107
// Query the event selection service to make sure this event passed cuts.
108
if
(!
m_evtSel
->getSelectedEvent()) {
109
ATH_MSG_DEBUG
(
"Event skipped by: "
<<
m_evtSel
->name());
110
return
StatusCode::SUCCESS;
111
}
112
113
// Event passes cuts, count it. technically, DataPrep does this now.
114
m_evt
++;
115
116
if
constexpr
(
enableBenchmark
)
m_chrono
->chronoStart(
"Layer Study: Split hits to 1st and 2nd stage"
);
117
118
// It shouldn't matter which slice we use; there should really only be one here
119
const
FPGATrackSimPlaneMap
* pmap_2nd =
m_FPGATrackSimMapping
->PlaneMap_2nd(0);
120
121
std::vector<FPGATrackSimHit> hits;
122
std::vector<std::shared_ptr<const FPGATrackSimHit>> phits;
123
const
FPGATrackSimRegionMap
* rmap_1st =
m_FPGATrackSimMapping
->SubRegionMap();
124
phits.reserve(FPGAHits->size());
125
hits.reserve(FPGAHits->size());
126
127
// For stage = 0, we'll run over all of them. Otherwise only look at first or second stage.
128
for
(
const
FPGATrackSimHit
*
hit
: *FPGAHits) {
129
// Acquire a non-constant copy of the hit, this is messy, but we have to map them.
130
FPGATrackSimHit
hitCopy = *
hit
;
131
pmap_2nd->
map
(hitCopy);
132
hits.push_back(hitCopy);
133
134
switch
(
m_stage
) {
135
case
0:
136
phits.push_back(std::make_shared<FPGATrackSimHit>(hitCopy));
137
break
;
138
case
1:
139
// For first stage hits, require that they are also pixel hits. This is a safe assumption because
140
// the inside out algorithm will only ever run on pixels.
141
if
(rmap_1st->
getRegions
(*hit).size() > 0 &&
hit
->isPixel()) phits.push_back(std::make_shared<FPGATrackSimHit>(hitCopy));
142
break
;
143
case
2:
144
if
(rmap_1st->
getRegions
(*hit).size() == 0) phits.push_back(std::make_shared<FPGATrackSimHit>(hitCopy));
145
break
;
146
default
:
147
ATH_MSG_FATAL
(
"Unrecognized stage: "
<<
m_stage
<<
", will exit layer study"
);
148
break
;
149
}
150
}
151
152
if
constexpr
(
enableBenchmark
)
m_chrono
->chronoStop(
"Layer Study: Split hits to 1st and 2nd stage"
);
153
154
// Get truth tracks from DataPrep as well.
155
SG::ReadHandle<FPGATrackSimTruthTrackCollection>
FPGATruthTracks(
m_FPGATruthTrackKey
, ctx);
156
if
(!FPGATruthTracks.
isValid
()) {
157
ATH_MSG_ERROR
(
"Could not find FPGA Truth Track Collection with key "
<< FPGATruthTracks.
key
());
158
return
StatusCode::FAILURE;
159
}
160
161
// Update truth information in output layer study tree.
162
m_binMonitoring
->parseTruthInfo(*FPGATruthTracks);
163
m_hitBinningTool
->getBinTool().binDesc()->setTruthBin(
m_binMonitoring
->truthBin());
164
165
// Make hit level plots
166
for
(
auto
&
hit
: phits) {
167
m_binMonitoring
->fillHitLevelInput(
hit
.get());
168
}
169
170
// Bin the hits, depending on m_stage we either use phits_1st, phits_2nd, or all the hits.
171
ATH_CHECK
(
m_hitBinningTool
->fill(phits));
172
173
// scan over image building pairs for bins over threshold
174
for
(
FPGATrackSimBinArray<FPGATrackSimBinnedHits::BinEntry>::ConstIterator
&
bin
:
m_hitBinningTool
->lastStepBinnedHits()) {
175
bool
isTruthBin = (
FPGATrackSimBinUtil::IdxSet
(
bin
.idx())==
m_binMonitoring
->truthBin(
m_hitBinningTool
->getBinTool().lastStep()->stepNum()));
176
177
// Apply threshold, of course if threshold is 0 then use all bins
178
if
(
bin
.data().hitCnt <
m_threshold
) {
179
if
(isTruthBin) {
180
ATH_MSG_DEBUG
(
"Truth bin failed threshold "
<<
bin
.data().hitCnt <<
" thr="
<<
m_threshold
<<
" "
<<
bin
.idx());}
181
continue
;
182
}
183
ATH_MSG_DEBUG
(
"Bin passes threshold "
<<
bin
.data().hitCnt <<
" "
<<
bin
.idx());
184
185
// Monitor contents of bins passing threshold
186
if
(
m_requireTruth
and not isTruthBin)
continue
;
187
188
m_binMonitoring
->fillBinLevelOutput(
bin
.idx(),
bin
.data());
189
}
190
m_binMonitoring
->fillBinningSummary(phits);
191
192
193
// Reset the hit binning tool.
194
m_hitBinningTool
->resetBins();
195
196
return
StatusCode::SUCCESS;
197
}
198
200
// Finalize
201
202
StatusCode
FPGATrackSimLayerStudyAlg::finalize
()
203
{
204
ATH_MSG_INFO
(
"PRINTING FPGATRACKSIM SIMPLE STATS"
);
205
ATH_MSG_INFO
(
"========================================================================================"
);
206
ATH_MSG_INFO
(
"Ran on events = "
<<
m_evt
);
207
208
return
StatusCode::SUCCESS;
209
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
AthMsgStreamMacros.h
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition
AthMsgStreamMacros.h:34
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition
AthMsgStreamMacros.h:32
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
FPGATrackSimBinUtil.h
Binning Utilities for GenScanTool.
FPGATrackSimCluster.h
FPGATrackSimDataFlowInfo.h
Structs that store the data flow information per event.
FPGATrackSimHit.h
: FPGATrackSim-specific class to represent an hit in the detector.
FPGATrackSimLayerStudyAlg.h
FPGATrackSimLogicalEventInputHeader.h
FPGATrackSimLogicalEventOutputHeader.h
FPGATrackSimNNTrackTool.h
Utilize NN score to build track candidates.
FPGATrackSimOverlapRemovalTool.h
Overlap removal tool for FPGATrackSimTrack.
FPGATrackSimRawToLogicalHitsTool.h
FPGATrackSimReadRawRandomHitsTool.h
FPGATrackSimRegionMap.h
Maps ITK module indices to FPGATrackSim regions.
FPGATrackSimRegionSlices.h
Stores slice definitions for FPGATrackSim regions.
FPGATrackSimRoad.h
Defines a class for roads.
FPGATrackSimTrackFitterTool.h
FPGATrackSimTrackPars.h
Structs that store the 5 track parameters.
FPGATrackSimTrack.h
SampleType::skipTruth
@ skipTruth
Definition
FPGATrackSimTypes.h:40
hit
bool hit(const Container &ids, int pdgId)
Definition
JetIRCSafeLabelTool.cxx:64
ss
static Double_t ss
Definition
LArPhysWaveHECTool.cxx:37
AthAlgorithm::AthAlgorithm
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition
AthAlgorithm.cxx:10
FPGATrackSimHit
Definition
FPGATrackSimHit.h:42
FPGATrackSimLayerStudyAlg::m_description
std::string m_description
Definition
FPGATrackSimLayerStudyAlg.h:59
FPGATrackSimLayerStudyAlg::initialize
virtual StatusCode initialize() override
Definition
FPGATrackSimLayerStudyAlg.cxx:45
FPGATrackSimLayerStudyAlg::finalize
virtual StatusCode finalize() override
Definition
FPGATrackSimLayerStudyAlg.cxx:202
FPGATrackSimLayerStudyAlg::m_evtSel
ServiceHandle< IFPGATrackSimEventSelectionSvc > m_evtSel
Definition
FPGATrackSimLayerStudyAlg.h:66
FPGATrackSimLayerStudyAlg::FPGATrackSimLayerStudyAlg
FPGATrackSimLayerStudyAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition
FPGATrackSimLayerStudyAlg.cxx:39
FPGATrackSimLayerStudyAlg::m_evt
double m_evt
Definition
FPGATrackSimLayerStudyAlg.h:80
FPGATrackSimLayerStudyAlg::m_stage
Gaudi::Property< int > m_stage
Definition
FPGATrackSimLayerStudyAlg.h:72
FPGATrackSimLayerStudyAlg::m_requireTruth
Gaudi::Property< bool > m_requireTruth
Definition
FPGATrackSimLayerStudyAlg.h:74
FPGATrackSimLayerStudyAlg::m_FPGAHitKey
SG::ReadHandleKey< FPGATrackSimHitCollection > m_FPGAHitKey
Definition
FPGATrackSimLayerStudyAlg.h:83
FPGATrackSimLayerStudyAlg::m_hitBinningTool
ToolHandle< FPGATrackSimBinnedHits > m_hitBinningTool
Definition
FPGATrackSimLayerStudyAlg.h:62
FPGATrackSimLayerStudyAlg::m_FPGATrackSimMapping
ServiceHandle< IFPGATrackSimMappingSvc > m_FPGATrackSimMapping
Definition
FPGATrackSimLayerStudyAlg.h:65
FPGATrackSimLayerStudyAlg::m_binMonitoring
ToolHandle< FPGATrackSimLayerStudyTool > m_binMonitoring
Definition
FPGATrackSimLayerStudyAlg.h:63
FPGATrackSimLayerStudyAlg::execute
virtual StatusCode execute(const EventContext &ctx) override
Execute method.
Definition
FPGATrackSimLayerStudyAlg.cxx:90
FPGATrackSimLayerStudyAlg::m_FPGATruthTrackKey
SG::ReadHandleKey< FPGATrackSimTruthTrackCollection > m_FPGATruthTrackKey
Definition
FPGATrackSimLayerStudyAlg.h:86
FPGATrackSimLayerStudyAlg::m_threshold
Gaudi::Property< unsigned > m_threshold
Definition
FPGATrackSimLayerStudyAlg.h:73
FPGATrackSimLayerStudyAlg::m_chrono
ServiceHandle< IChronoStatSvc > m_chrono
Definition
FPGATrackSimLayerStudyAlg.h:69
FPGATrackSimPlaneMap
Definition
FPGATrackSimPlaneMap.h:62
FPGATrackSimPlaneMap::map
void map(FPGATrackSimHit &hit) const
Definition
FPGATrackSimPlaneMap.cxx:234
FPGATrackSimRegionMap
Definition
FPGATrackSimRegionMap.h:62
FPGATrackSimRegionMap::getRegions
std::vector< uint32_t > getRegions(const FPGATrackSimHit &hit) const
Definition
FPGATrackSimRegionMap.cxx:305
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
SG::VarHandleBase::key
virtual const std::string & key() const override final
Return the StoreGate ID for the referenced object.
Definition
AthToolSupport/AsgDataHandles/Root/VarHandleBase.cxx:64
bin
Definition
BinsDiffFromStripMedian.h:43
FPGATrackSimBinArray::ConstIterator
Definition
FPGATrackSimBinArray.h:137
FPGATrackSimBinUtil::IdxSet
Definition
FPGATrackSimBinUtil.h:41
enableBenchmark
constexpr bool enableBenchmark
Definition
xAODClusterMaker.cxx:13
Generated on
for ATLAS Offline Software by
1.17.0