25 #include "GaudiKernel/IEventProcessor.h"
27 #ifdef BENCHMARK_LOGICALHITSALG
29 t_1 = std::chrono::steady_clock::now(); \
30 (name) += std::chrono::duration_cast<std::chrono::microseconds>(t_1 - t_0).count(); \
33 size_t m_tread = 0, m_tprocess = 0, m_troads = 0, m_troad_filter = 0, m_tlrt = 0, m_ttracks = 0, m_tOR = 0, m_t2ndStage = 0, m_tmon = 0, m_tfin = 0;
54 while (std::getline(
ss,
line,
'\n')) {
97 return StatusCode::SUCCESS;
107 #ifdef BENCHMARK_LOGICALHITSALG
108 std::chrono::time_point<std::chrono::steady_clock> t_0, t_1;
111 const EventContext& ctx = getContext();
119 ATH_MSG_WARNING(
"Didn't receive FPGAHits_1st on first event; assuming no input events.");
121 SmartIF<IEventProcessor> appMgr{service(
"ApplicationMgr")};
123 ATH_MSG_ERROR(
"Failed to retrieve ApplicationMgr as IEventProcessor");
124 return StatusCode::FAILURE;
126 return appMgr->stopRun();
133 ATH_CHECK( FPGARoads_1st.
record (std::make_unique<FPGATrackSimRoadCollection>()));
134 ATH_CHECK( FPGAHitsInRoads_1st.
record (std::make_unique<FPGATrackSimHitContainer>()));
137 ATH_CHECK(FPGATracks_1stHandle.
record (std::make_unique<FPGATrackSimTrackCollection>()));
140 ATH_CHECK( FPGAHitsFiltered_1st.
record (std::make_unique<FPGATrackSimHitCollection>()));
143 if (!
m_evtSel->getSelectedEvent()) {
145 return StatusCode::SUCCESS;
152 std::vector<std::shared_ptr<const FPGATrackSimHit>> phits_1st;
153 phits_1st.reserve(FPGAHits->size());
154 for (
const auto& hit : *FPGAHits) {
155 phits_1st.push_back(std::make_shared<const FPGATrackSimHit>(hit));
160 if (!FPGATruthTracks.
isValid()) {
161 ATH_MSG_ERROR(
"Could not find FPGA Truth Track Collection with key " << FPGATruthTracks.
key());
162 return StatusCode::FAILURE;
167 if (!FPGAOfflineTracks.
isValid()) {
168 ATH_MSG_ERROR(
"Could not find FPGA Offline Track Collection with key " << FPGAOfflineTracks.
key());
169 return StatusCode::FAILURE;
173 std::vector<std::shared_ptr<const FPGATrackSimRoad>> prefilter_roads;
174 std::vector<std::shared_ptr<const FPGATrackSimRoad>> roads_1st = prefilter_roads;
178 for (
auto const &road : roads_1st) {
179 unsigned bitmask = road->getHitLayers();
181 if (bitmask & (1 <<
l)) {
191 std::vector<std::shared_ptr<const FPGATrackSimRoad>> postfilter_roads;
195 roads_1st = postfilter_roads;
199 std::vector<std::shared_ptr<const FPGATrackSimRoad>> postfilter2_roads;
202 roads_1st = postfilter2_roads;
208 TIME(m_troad_filter);
210 std::vector<FPGATrackSimTrack> tracks_1st;
219 float bestchi2 = 1.e15;
222 if (
chi2 < bestchi2) bestchi2 =
chi2;
233 for (
const std::shared_ptr<const FPGATrackSimRoad>& road : roads_1st) {
234 ntrackDummy += road->getNHitCombos();
236 tracks_1st.resize(ntrackDummy);
240 for (
auto const &road:roads_1st){
241 std::vector<FPGATrackSimHit> road_hits;
242 ATH_MSG_DEBUG(
"Hough Road X Y: " << road->getX() <<
" " << road->getY());
243 for (
size_t l = 0;
l < road->getNLayers(); ++
l) {
244 for (
const auto &layerH : road->getHits(
l)) {
245 road_hits.push_back(*layerH);
248 FPGAHitsInRoads_1st->push_back(road_hits);
249 FPGARoads_1st->push_back(*road);
260 unsigned ntrackOLRChi2 = 0;
264 if (
track.passedOR()) {
269 float chi2olr =
track.getChi2ndof();
282 std::vector<FPGATrackSimTruthTrack> truthtracks = *FPGATruthTracks;
283 std::vector<FPGATrackSimOfflineTrack> offlineTracks = *FPGAOfflineTracks;
284 if (truthtracks.size() > 0) {
295 bool passchi2 =
false;
296 bool passchi2OLR =
false;
297 if (tracks_1st.size() > 0) {
299 for (
const auto&
track : tracks_1st) {
300 if (
track.getChi2ndof() < 10) {
302 if (
track.passedOR()) {
321 std::vector<std::shared_ptr<const FPGATrackSimRoad>> roadsLRT;
322 std::vector<FPGATrackSimTrack> tracksLRT;
325 std::vector<std::shared_ptr<const FPGATrackSimHit>> remainingHits;
328 ATH_MSG_DEBUG(
"Doing hit filtering based on prompt tracks.");
331 for (
const auto &
Hit : remainingHits) FPGAHitsFiltered_1st->push_back(*
Hit);
334 ATH_MSG_DEBUG(
"No hit filtering requested; using all hits for LRT.");
335 remainingHits = phits_1st;
345 auto dataFlowInfo = std::make_unique<FPGATrackSimDataFlowInfo>();
363 return StatusCode::SUCCESS;
372 std::vector<FPGATrackSimTrack>
const& tracks_1st,
377 ATH_MSG_DEBUG(
"NFPGATrackSimRoads_1st = " << roads_1st.size() <<
", NFPGATrackSimTracks_1st = " << tracks_1st.size());
397 return StatusCode::SUCCESS;
406 #ifdef BENCHMARK_LOGICALHITSALG
408 "\nroads: " << std::setw(10) << m_troads <<
409 "\nroad filter: " << std::setw(10) << m_troad_filter <<
410 "\nllp: " << std::setw(10) << m_tlrt <<
411 "\ntracks: " << std::setw(10) << m_ttracks <<
412 "\nOR: " << std::setw(10) << m_tOR <<
413 (m_runSecondStage ? : (
"\n2ndStage: " << std::setw(10) << m_t2ndStage) :
"") <<
414 "\nmon: " << std::setw(10) << m_tmon <<
415 "\nfin: " << std::setw(10) << m_tfin
421 ATH_MSG_INFO(
"========================================================================================");
432 ATH_MSG_INFO(
"========================================================================================");
434 return StatusCode::SUCCESS;
444 for (
auto hit :
hits)
447 std::stringstream
ss;
448 for (
auto r : regions)