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')) {
94 return StatusCode::SUCCESS;
104 #ifdef BENCHMARK_LOGICALHITSALG
105 std::chrono::time_point<std::chrono::steady_clock> t_0, t_1;
109 const EventContext& ctx = getContext();
117 ATH_MSG_WARNING(
"Didn't receive FPGAHits_1st on first event; assuming no input events.");
119 SmartIF<IEventProcessor> appMgr{service(
"ApplicationMgr")};
121 ATH_MSG_ERROR(
"Failed to retrieve ApplicationMgr as IEventProcessor");
122 return StatusCode::FAILURE;
124 return appMgr->stopRun();
131 ATH_CHECK( FPGARoads_1st.
record (std::make_unique<FPGATrackSimRoadCollection>()));
132 ATH_CHECK( FPGAHitsInRoads_1st.
record (std::make_unique<FPGATrackSimHitContainer>()));
135 ATH_CHECK(FPGATracks_1stHandle.
record (std::make_unique<FPGATrackSimTrackCollection>()));
138 ATH_CHECK( FPGAHitsFiltered_1st.
record (std::make_unique<FPGATrackSimHitCollection>()));
141 if (!
m_evtSel->getSelectedEvent()) {
143 return StatusCode::SUCCESS;
150 std::vector<std::shared_ptr<const FPGATrackSimHit>> phits_1st;
151 phits_1st.reserve(FPGAHits->size());
152 for (
const auto& hit : *FPGAHits) {
153 phits_1st.push_back(std::make_shared<const FPGATrackSimHit>(hit));
158 if (!FPGATruthTracks.
isValid()) {
159 ATH_MSG_ERROR(
"Could not find FPGA Truth Track Collection with key " << FPGATruthTracks.
key());
160 return StatusCode::FAILURE;
165 if (!FPGAOfflineTracks.
isValid()) {
166 ATH_MSG_ERROR(
"Could not find FPGA Offline Track Collection with key " << FPGAOfflineTracks.
key());
167 return StatusCode::FAILURE;
171 std::vector<std::shared_ptr<const FPGATrackSimRoad>> prefilter_roads;
172 std::vector<std::shared_ptr<const FPGATrackSimRoad>> roads_1st = prefilter_roads;
176 for (
auto const &road : roads_1st) {
177 unsigned bitmask = road->getHitLayers();
179 if (bitmask & (1 <<
l)) {
189 std::vector<std::shared_ptr<const FPGATrackSimRoad>> postfilter_roads;
193 roads_1st = postfilter_roads;
197 std::vector<std::shared_ptr<const FPGATrackSimRoad>> postfilter2_roads;
200 roads_1st = postfilter2_roads;
203 std::vector<std::shared_ptr<const FPGATrackSimRoad>> postfilter3_roads;
206 roads_1st = postfilter3_roads;
209 for (
auto const &road:roads_1st){
210 std::vector<FPGATrackSimHit> road_hits;
211 ATH_MSG_DEBUG(
"Hough Road X Y: " << road->getX() <<
" " << road->getY());
212 for (
size_t l = 0;
l < road->getNLayers(); ++
l) {
213 for (
const auto &layerH : road->getHits(
l)) {
214 road_hits.push_back(*layerH);
217 FPGAHitsInRoads_1st->push_back(road_hits);
218 FPGARoads_1st->push_back(*road);
224 TIME(m_troad_filter);
226 std::vector<FPGATrackSimTrack> tracks_1st;
235 float bestchi2 = 1.e15;
238 if (
chi2 < bestchi2) bestchi2 =
chi2;
248 for (
const std::shared_ptr<const FPGATrackSimRoad>& road : roads_1st) {
249 ntrackDummy += road->getNHitCombos();
251 tracks_1st.resize(ntrackDummy);
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>();
362 return StatusCode::SUCCESS;
371 std::vector<FPGATrackSimTrack>
const& tracks_1st,
376 ATH_MSG_DEBUG(
"NFPGATrackSimRoads_1st = " << roads_1st.size() <<
", NFPGATrackSimTracks_1st = " << tracks_1st.size());
396 return StatusCode::SUCCESS;
405 #ifdef BENCHMARK_LOGICALHITSALG
407 "\nroads: " << std::setw(10) << m_troads <<
408 "\nroad filter: " << std::setw(10) << m_troad_filter <<
409 "\nllp: " << std::setw(10) << m_tlrt <<
410 "\ntracks: " << std::setw(10) << m_ttracks <<
411 "\nOR: " << std::setw(10) << m_tOR <<
412 (m_runSecondStage ? : (
"\n2ndStage: " << std::setw(10) << m_t2ndStage) :
"") <<
413 "\nmon: " << std::setw(10) << m_tmon <<
414 "\nfin: " << std::setw(10) << m_tfin
420 ATH_MSG_INFO(
"========================================================================================");
431 ATH_MSG_INFO(
"========================================================================================");
433 return StatusCode::SUCCESS;
443 for (
auto hit :
hits)
446 std::stringstream
ss;
447 for (
auto r : regions)