26 static inline int quant(
double min,
double max,
unsigned nSteps,
double val);
27 static inline double unquant(
double min,
double max,
unsigned nSteps,
int step);
29 static inline std::string
to_string(std::vector<T>
v);
30 static inline std::string instance_name(std::string
const &
s);
39 m_name(instance_name(
name)),
40 m_monitorFile((m_name +
".root").c_str(),
"RECREATE")
42 declareInterface<IFPGATrackSimRoadFinderTool>(
this);
57 ATH_MSG_INFO(
"Convolution: " << to_string(
const_cast<std::vector<int>&
>(
m_conv.value())));
68 ATH_MSG_FATAL(
"initialize() Image size must be greater than 0");
74 ATH_MSG_FATAL(
"initialize() Hit extentsion list must have size == nLayers");
81 ATH_MSG_FATAL(
"initialize() The imagesize is not divisible by scale");
85 if (!ok)
return StatusCode::FAILURE;
89 ATH_MSG_WARNING(
"initialize() localMaxWindowSize requires tracing hits, turning on automatically");
95 ATH_MSG_WARNING(
"initialize() idealGeoRoads conflicts with useSectors, switching off FPGATrackSim sector matching");
100 ATH_MSG_WARNING(
"initialize() idealGeoRoads requires tracing hits, turning on automatically");
128 std::vector<size_t> yBins_scaled;
129 for (
unsigned i = 0;
i <= new_size_y;
i++) {
130 yBins_scaled.push_back(
scale *
i);
136 return StatusCode::SUCCESS;
143 return StatusCode::SUCCESS;
175 return StatusCode::SUCCESS;
184 for (
auto const & hit :
hits) {
186 bool belong1 =
false, belong2 =
false;
187 for (
auto layer : combine_layers) {
188 if (belong1 || belong2)
break;
189 if (hit->getLayer() ==
layer)
191 if (hit->getLayer() ==
layer + 1)
200 else if (
m_stereo && !(hit->getLayer() > 1 && (hit->getLayer() % 2 == 1 && belong2))) {
208 for (
unsigned y_ = 0; y_ < new_size_y; y_++) {
215 for (
int y = y_bin_min;
y < y_bin_max;
y++) {
236 if (layerImage(
y,
x).
first > 0) {
285 if (
i == 0 && j == 0)
continue;
291 && j <= 0 &&
i <= 0)
return false;
304 static inline int quant(
double min,
double max,
unsigned nSteps,
double val)
310 static inline double unquant(
double min,
double max,
unsigned nSteps,
int step)
315 template <
typename T>
316 static inline std::string
to_string(std::vector<T>
v)
318 std::ostringstream oss;
321 std::copy(
v.begin(),
v.end()-1, std::ostream_iterator<T>(oss,
", "));
328 static inline std::string instance_name(std::string
const &
s)
330 size_t pos =
s.find_last_of(
'.');
331 if (
pos != std::string::npos)
332 return s.substr(
pos + 1);
341 double r = hit->
getR();
342 double phi_hit = hit->
getGPhi();
346 ATH_MSG_ERROR(
"yToX() not defined for the current m_par selection");
359 if (x_min > x_max)
std::swap(x_min, x_max);
372 if (x_bin_min < 0) x_bin_min = 0;
375 return { x_bin_min, x_bin_max };
380 float pt =
r.getY()*0.001;
385 if (sectorbin < 0) sectorbin = 0;
387 std::vector<module_t> modules;
389 for (
unsigned int il = 0;
il <
r.getNLayers();
il++) {
390 if (
r.getNHits_layer()[
il] == 0) {
391 modules.push_back(-1);
393 wc_layers |= (0x1 <<
il);
394 r.setWCLayers(wc_layers);
396 std::unique_ptr<FPGATrackSimHit> wcHit = std::unique_ptr<FPGATrackSimHit>(
new FPGATrackSimHit());
400 r.setHits(
il,std::vector<std::shared_ptr<const FPGATrackSimHit>>({std::move(wcHit)}));
404 modules.push_back(sectorbin);
413 std::vector<std::shared_ptr<const FPGATrackSimHit>> road_hits;
415 for (
const auto &hit :
hits) {
416 road_hits.push_back(hit);
417 hitLayers |= 1 << hit->getLayer();
427 r.setHitLayers(hitLayers);
428 r.setHits(std::move(sorted_hits));
443 r.setHitLayers(hitLayers);
444 r.setHits(std::move(
hits));
457 for (
auto const & hit :
hits) {
458 hitLayers |= 1 << hit->getLayer();
470 std::vector<std::shared_ptr<const FPGATrackSimHit>> road_hits;
472 for (
const auto &hit :
hits) {
476 unsigned bin_scale = 0;
479 if (hit->getLayer() ==
layer) {
484 if (bin_scale == 0) bin_scale = 1;
485 unsigned y_bin_min = floor(1.0 *
y / bin_scale) * bin_scale;
486 unsigned y_bin_max = ceil(1.0 *
y / bin_scale) * bin_scale;
487 if (y_bin_min == y_bin_max) y_bin_max++;
492 if (
x >=
xBins.first && x < xBins.second && y >= y_bin_min &&
y < y_bin_max) {
493 road_hits.push_back(hit);
494 hitLayers |= 1 << hit->getLayer();
510 TH2I
h(
name.c_str(),
"Hough Transform;phi;d0 (mm)",