27 #include "GaudiKernel/IEventProcessor.h"
30 #ifdef BENCHMARK_LAYERSTUDYALG
47 std::stringstream
ss(m_description);
50 if (!m_description.empty()) {
51 while (std::getline(
ss,
line,
'\n')) {
58 ATH_CHECK(m_FPGATrackSimMapping.retrieve());
62 ATH_MSG_DEBUG(
"initialize() Instantiating output layer study tree");
65 if (m_hitBinningTool->getNLayers()==0) {
66 m_hitBinningTool->setNLayers(m_FPGATrackSimMapping->PlaneMap_1st(0)->getNLogiLayers());
77 ATH_CHECK(m_FPGATruthTrackKey.initialize());
82 return StatusCode::SUCCESS;
92 const EventContext& ctx = getContext();
96 if (!FPGAHits.isValid()) {
98 ATH_MSG_WARNING(
"Didn't receive " << FPGAHits.key() <<
" on first event; assuming no input events.");
100 SmartIF<IEventProcessor> appMgr{service(
"ApplicationMgr")};
102 ATH_MSG_ERROR(
"Failed to retrieve ApplicationMgr as IEventProcessor");
103 return StatusCode::FAILURE;
105 return appMgr->stopRun();
109 if (!m_evtSel->getSelectedEvent()) {
111 return StatusCode::SUCCESS;
117 if constexpr (
enableBenchmark) m_chrono->chronoStart(
"Layer Study: Split hits to 1st and 2nd stage");
122 std::vector<FPGATrackSimHit>
hits;
123 std::vector<std::shared_ptr<const FPGATrackSimHit>> phits;
125 phits.reserve(FPGAHits->size());
126 hits.reserve(FPGAHits->size());
132 pmap_2nd->
map(hitCopy);
133 hits.push_back(hitCopy);
137 phits.push_back(std::make_shared<FPGATrackSimHit>(hitCopy));
140 if (rmap_1st->
getRegions(hit).size() > 0) phits.push_back(std::make_shared<FPGATrackSimHit>(hitCopy));
143 if (rmap_1st->
getRegions(hit).size() == 0) phits.push_back(std::make_shared<FPGATrackSimHit>(hitCopy));
146 ATH_MSG_FATAL(
"Unrecognized stage: " << m_stage <<
", will exit layer study");
151 if constexpr (
enableBenchmark) m_chrono->chronoStop(
"Layer Study: Split hits to 1st and 2nd stage");
155 if (!FPGATruthTracks.isValid()) {
156 ATH_MSG_ERROR(
"Could not find FPGA Truth Track Collection with key " << FPGATruthTracks.key());
157 return StatusCode::FAILURE;
161 m_binMonitoring->parseTruthInfo(*FPGATruthTracks);
162 m_hitBinningTool->getBinTool().binDesc()->setTruthBin(m_binMonitoring->truthBin());
165 for (
auto &hit : phits) {
166 m_binMonitoring->fillHitLevelInput(hit.get());
170 ATH_CHECK(m_hitBinningTool->fill(phits));
175 if (
bin.data().hitCnt < m_threshold) {
179 ATH_MSG_DEBUG(
"Truth bin failed threshold " <<
bin.data().hitCnt <<
" thr=" << m_threshold <<
" " <<
bin.idx());}
184 m_binMonitoring->fillBinLevelOutput(
bin.idx(),
bin.data());
186 m_binMonitoring->fillBinningSummary(phits);
190 m_hitBinningTool->resetBins();
192 return StatusCode::SUCCESS;
201 ATH_MSG_INFO(
"========================================================================================");
204 return StatusCode::SUCCESS;