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));
142 if (rmap_1st->
getRegions(hit).size() > 0 && hit.isPixel()) phits.push_back(std::make_shared<FPGATrackSimHit>(hitCopy));
145 if (rmap_1st->
getRegions(hit).size() == 0) phits.push_back(std::make_shared<FPGATrackSimHit>(hitCopy));
148 ATH_MSG_FATAL(
"Unrecognized stage: " << m_stage <<
", will exit layer study");
153 if constexpr (
enableBenchmark) m_chrono->chronoStop(
"Layer Study: Split hits to 1st and 2nd stage");
157 if (!FPGATruthTracks.isValid()) {
158 ATH_MSG_ERROR(
"Could not find FPGA Truth Track Collection with key " << FPGATruthTracks.key());
159 return StatusCode::FAILURE;
163 m_binMonitoring->parseTruthInfo(*FPGATruthTracks);
164 m_hitBinningTool->getBinTool().binDesc()->setTruthBin(m_binMonitoring->truthBin());
167 for (
auto &hit : phits) {
168 m_binMonitoring->fillHitLevelInput(hit.get());
172 ATH_CHECK(m_hitBinningTool->fill(phits));
177 if (
bin.data().hitCnt < m_threshold) {
181 ATH_MSG_DEBUG(
"Truth bin failed threshold " <<
bin.data().hitCnt <<
" thr=" << m_threshold <<
" " <<
bin.idx());}
186 m_binMonitoring->fillBinLevelOutput(
bin.idx(),
bin.data());
188 m_binMonitoring->fillBinningSummary(phits);
192 m_hitBinningTool->resetBins();
194 return StatusCode::SUCCESS;
203 ATH_MSG_INFO(
"========================================================================================");
206 return StatusCode::SUCCESS;