26 #include "GaudiKernel/IEventProcessor.h"
28 #ifdef BENCHMARK_LOGICALHITSALG
30 t_1 = std::chrono::steady_clock::now(); \
31 (name) += std::chrono::duration_cast<std::chrono::microseconds>(t_1 - t_0).count(); \
34 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;
55 while (std::getline(
ss,
line,
'\n')) {
119 return StatusCode::SUCCESS;
129 #ifdef BENCHMARK_LOGICALHITSALG
130 std::chrono::time_point<std::chrono::steady_clock> t_0, t_1;
134 const EventContext& ctx = getContext();
140 IEventProcessor* appMgr =
nullptr;
141 ATH_CHECK(service(
"ApplicationMgr",appMgr));
143 ATH_MSG_ERROR(
"Failed to retrieve ApplicationMgr as IEventProcessor");
144 return StatusCode::FAILURE;
146 return appMgr->stopRun();
152 ATH_CHECK( FPGARoads_1st.
record (std::make_unique<FPGATrackSimRoadCollection>()));
153 ATH_CHECK( FPGAHitsInRoads_1st.
record (std::make_unique<FPGATrackSimHitContainer>()));
156 ATH_CHECK(FPGATracks_1stHandle.
record (std::make_unique<FPGATrackSimTrackCollection>()));
159 ATH_CHECK( FPGAHits_1st.
record (std::make_unique<FPGATrackSimHitCollection>()));
162 ATH_CHECK( FPGAHitsFiltered_1st.
record (std::make_unique<FPGATrackSimHitCollection>()));
165 ATH_CHECK( FPGAHitUnmapped_1st.
record (std::make_unique<FPGATrackSimHitCollection>()));
168 ATH_CHECK( FPGAClusters_1st.
record (std::make_unique<FPGATrackSimClusterCollection>()));
171 ATH_CHECK( FPGAClustersFiltered_1st.
record (std::make_unique<FPGATrackSimClusterCollection>()));
174 ATH_CHECK( FPGASpacePoints_1st.
record (std::make_unique<FPGATrackSimClusterCollection>()));
181 return StatusCode::SUCCESS;
193 ATH_CHECK(
processInputs(FPGAHitUnmapped_1st, FPGAClusters_1st, FPGAClustersFiltered_1st, FPGASpacePoints_1st));
195 unsigned regionID =
m_evtSel->getRegionID();
203 std::vector<FPGATrackSimRoad*> prefilter_roads;
204 std::vector<FPGATrackSimRoad*>& roads_1st = prefilter_roads;
205 std::vector<const FPGATrackSimHit*> phits_1st;
211 if (
h.isReal()) phits_1st.push_back(&
h);
223 std::vector<FPGATrackSimHit> road_hits;
224 ATH_MSG_DEBUG(
"Hough Road X Y: " << road->getX() <<
" " << road->getY());
225 for (
size_t l = 0;
l < road->getNLayers(); ++
l) {
227 road_hits.push_back(*layerH);
230 FPGAHitsInRoads_1st->push_back(road_hits);
231 FPGARoads_1st->push_back(*road);
236 unsigned bitmask = road->getHitLayers();
238 if (bitmask & (1 <<
l)) {
248 std::vector<FPGATrackSimRoad*> postfilter_roads;
252 roads_1st = postfilter_roads;
256 std::vector<FPGATrackSimRoad*> postfilter2_roads;
259 roads_1st = postfilter2_roads;
262 std::vector<FPGATrackSimRoad*> postfilter3_roads;
265 roads_1st = postfilter3_roads;
272 TIME(m_troad_filter);
274 std::vector<FPGATrackSimTrack> tracks_1st;
283 float bestchi2 = 1.e15;
286 if (
chi2 < bestchi2) bestchi2 =
chi2;
301 unsigned ntrackOLRChi2 = 0;
302 for (
auto track : tracks_1st) {
303 if (
track.getChi2ndof() < 10) {
305 if (
track.passedOR()) {
319 if (truthtracks.size() > 0) {
330 bool passchi2 =
false;
331 bool passchi2OLR =
false;
332 if (tracks_1st.size() > 0) {
334 for (
auto track : tracks_1st) {
335 if (
track.getChi2ndof() < 10) {
337 if (
track.passedOR()) {
356 std::vector<FPGATrackSimRoad*> roadsLRT;
357 std::vector<FPGATrackSimTrack> tracksLRT;
360 std::vector<const FPGATrackSimHit*> remainingHits;
363 ATH_MSG_DEBUG(
"Doing hit filtering based on prompt tracks.");
369 ATH_MSG_DEBUG(
"No hit filtering requested; using all hits for LRT.");
370 remainingHits = phits_1st;
380 auto dataFlowInfo = std::make_unique<FPGATrackSimDataFlowInfo>();
383 std::vector<FPGATrackSimRoad*> roads_2nd;
384 std::vector<FPGATrackSimTrack> tracks_2nd;
407 << roads_1st.size() <<
" roads";
415 for(
auto &road : roads_1st) {
417 std::vector< std::vector<FPGATrackSimHit> > clusters_in_road;
419 for(
auto &cluster_as_hit : road->getHits(
layer)) {
420 unsigned clusterIndex = (
unsigned)cluster_as_hit->getParentageMask();
427 ATH_MSG_ERROR(
"cluster retrieved from index seems not to match");
429 <<
", cluster index " << clusterIndex <<
"road.getHits(layer): " << cluster_as_hit->getR() <<
" "
430 << cluster_as_hit->getZ() <<
" " << cluster_as_hit->getGPhi());
435 clusters_in_road.push_back(thisCluster.
getHitList());
441 bool firstCluster =
true;
442 for(
auto &clusterHits : clusters_in_road) {
443 if(firstCluster) firstCluster =
false;
445 bool firstHit =
true;
447 for(
auto &hit : clusterHits) {
448 if(firstHit) firstHit =
false;
452 << hit.getEtaIndex() <<
", " << hit.getPhiIndex() <<
"]";
470 return StatusCode::SUCCESS;
485 return StatusCode::SUCCESS;
494 ATH_MSG_INFO(
"Cannot read more events from file, returning");
495 return StatusCode::SUCCESS;
507 ATH_MSG_INFO(
"Cannot read more events from file, returning");
508 return StatusCode::SUCCESS;
514 return StatusCode::SUCCESS;
563 std::vector<int> filter_pixel_physLayers, filter_strip_physLayers;
578 return StatusCode::SUCCESS;
583 std::vector<FPGATrackSimRoad*> & roads_2nd, std::vector<FPGATrackSimTrack> & tracks_2nd)
590 const EventContext& ctx = getContext();
600 ATH_CHECK( FPGAClusters_2nd.
record (std::make_unique<FPGATrackSimClusterCollection>()));
608 ATH_CHECK( FPGASpacePoints_2nd.
record (std::make_unique<FPGATrackSimClusterCollection>()));
614 ATH_MSG_DEBUG(
"Number of second stage hits = " << hits_2nd.size());
616 std::vector<const FPGATrackSimHit*> phits_2nd;
620 ATH_CHECK( FPGAHits_2nd.
record (std::make_unique<FPGATrackSimHitCollection>()));
624 std::vector<FPGATrackSimTrack> tracks_1st_OR;
625 for (
auto track : tracks_1st) {
626 if (
track.passedOR() == 1) tracks_1st_OR.push_back(
track);
629 ATH_MSG_DEBUG(
"Number of roads for second stage fitting " << roads_2nd.size());
639 return StatusCode::SUCCESS;
643 std::vector<FPGATrackSimRoad*>
const & roads_2nd, std::vector<FPGATrackSimTrack>
const & tracks_2nd,
648 ATH_MSG_DEBUG(
"NFPGATrackSimRoads_1st = " << roads_1st.size() <<
", NFPGATrackSimTracks_1st = " << tracks_1st.size() <<
", NFPGATrackSimRoads_2nd = " << roads_2nd.size() <<
", NFPGATrackSimTracks_2nd = " << tracks_2nd.size());
674 return StatusCode::SUCCESS;
685 #ifdef BENCHMARK_LOGICALHITSALG
687 "\nread input: " << std::setw(10) << m_tread <<
688 "\nprocess hits: " << std::setw(10) << m_tprocess <<
689 "\nroads: " << std::setw(10) << m_troads <<
690 "\nroad filter: " << std::setw(10) << m_troad_filter <<
691 "\nllp: " << std::setw(10) << m_tlrt <<
692 "\ntracks: " << std::setw(10) << m_ttracks <<
693 "\nOR: " << std::setw(10) << m_tOR <<
694 (
m_runSecondStage ? : (
"\n2ndStage: " << std::setw(10) << m_t2ndStage) :
"") <<
695 "\nmon: " << std::setw(10) << m_tmon <<
696 "\nfin: " << std::setw(10) << m_tfin
704 ATH_MSG_INFO(
"========================================================================================");
715 ATH_MSG_INFO(
"========================================================================================");
717 return StatusCode::SUCCESS;
727 for (
auto hit :
hits)
730 std::stringstream
ss;
731 for (
auto r : regions)