14 float perp2(
const std::array<float, 2>&
a) {
return a[0] *
a[0] +
a[1] *
a[1]; }
19 : candidates_(regPSet, iC) {
37 desc.
add<
double>(
"extraPhi", 0.);
38 desc.
add<
double>(
"extraEta", 0.);
40 desc.
add<
double>(
"ptMin", 0.9);
41 desc.
add<
double>(
"originRadius", 0.2);
42 desc.
add<
bool>(
"precise",
true);
47 desc.
add<
bool>(
"searchOpt",
false);
56 builder.setMeasurementTracker(hmte.
product());
63 const Origins& origins,
const std::vector<Area>& areas)
const {
64 std::vector<std::unique_ptr<TrackingRegion> >
result;
68 for (
const auto& origin : origins) {
69 auto reg =
region(origin, areas);
75 LogDebug(
"AreaSeededTrackingRegionsBuilder") <<
"produced " << n_regions <<
" regions";
81 const Origin& origin,
const std::vector<Area>& areas)
const {
82 return regionImpl(origin, areas);
86 return regionImpl(origin, areas);
91 const T& areas)
const {
95 const auto& orig = origin.first;
97 LogDebug(
"AreaSeededTrackingRegionsProducer") <<
"Origin x,y,z " << orig.x() <<
"," << orig.y() <<
"," << orig.z();
99 auto vecFromOrigPlusRadius = [&](
const std::array<float, 2>& vec) {
101 const auto tmp = (1.f - m_conf->m_originRadius * invlen);
102 return std::array<float, 2>{{vec[0] *
tmp, vec[1] *
tmp}};
104 auto tangentVec = [&](
const std::array<float, 2>& vec,
int sign) {
106 const auto r = m_conf->m_originRadius;
109 const auto orthvec =
sign > 0 ? std::array<float, 2>{{-vec[1] *
tmp, vec[0] *
tmp}}
110 : std::array<float, 2>{{vec[1] *
tmp, -vec[0] *
tmp}};
111 return std::array<float, 2>{{vec[0] - orthvec[0], vec[1] - orthvec[1]}};
114 for (
const auto&
area : areas) {
117 LogTrace(
"AreaSeededTrackingRegionsBuilder")
118 <<
" area x,y points " <<
area.x_rmin_phimin() <<
"," <<
area.y_rmin_phimin() <<
" "
119 <<
area.x_rmin_phimax() <<
"," <<
area.y_rmin_phimax() <<
" " <<
area.x_rmax_phimax() <<
","
120 <<
area.y_rmax_phimax() <<
" " <<
area.x_rmax_phimin() <<
"," <<
area.y_rmax_phimin() <<
" "
121 <<
"z " <<
area.zmin() <<
"," <<
area.zmax();
124 const float x_rmin_phimin =
area.x_rmin_phimin() - orig.x();
125 const float x_rmin_phimax =
area.x_rmin_phimax() - orig.x();
126 const float y_rmin_phimin =
area.y_rmin_phimin() - orig.y();
127 const float y_rmin_phimax =
area.y_rmin_phimax() - orig.y();
129 const std::array<float, 2> p_rmin_phimin = {{x_rmin_phimin, y_rmin_phimin}};
130 const std::array<float, 2> p_rmin_phimax = {{x_rmin_phimax, y_rmin_phimax}};
131 const std::array<float, 2> p_rmax_phimin = {{
area.x_rmax_phimin() - orig.x(),
area.y_rmax_phimin() - orig.y()}};
132 const std::array<float, 2> p_rmax_phimax = {{
area.x_rmax_phimax() - orig.x(),
area.y_rmax_phimax() - orig.y()}};
139 const std::array<float, 2> p_rmin =
perp2(p_rmin_phimin) <
perp2(p_rmin_phimax) ? p_rmin_phimin : p_rmin_phimax;
140 const std::array<float, 2> p_rmax =
perp2(p_rmax_phimin) >
perp2(p_rmax_phimax) ? p_rmax_phimin : p_rmax_phimax;
145 const auto p_min = vecFromOrigPlusRadius(p_rmin);
146 const auto p_max = vecFromOrigPlusRadius(p_rmax);
149 const auto etamin =
std::min(etaFromXYZ(p_min[0], p_min[1],
area.zmin() - (orig.z() + origin.second)),
150 etaFromXYZ(p_max[0], p_max[1],
area.zmin() - (orig.z() + origin.second)));
151 const auto etamax =
std::max(etaFromXYZ(p_min[0], p_min[1],
area.zmax() - (orig.z() - origin.second)),
152 etaFromXYZ(p_max[0], p_max[1],
area.zmax() - (orig.z() - origin.second)));
180 const auto phi_ref = std::atan2(y_rmin_phimin + y_rmin_phimax, x_rmin_phimin + x_rmin_phimax);
183 const auto tan_rmin_phimax = tangentVec(p_rmin_phimax, +1);
184 const auto tan_rmax_phimax = tangentVec(p_rmax_phimax, +1);
185 const auto phi_rmin_phimax = std::atan2(tan_rmin_phimax[1], tan_rmin_phimax[0]);
186 const auto phi_rmax_phimax = std::atan2(tan_rmax_phimax[1], tan_rmax_phimax[0]);
193 LogTrace(
"AreaSeededTrackingRegionBuilder")
194 <<
" rmin_phimax vec " << p_rmin_phimax[0] <<
"," << p_rmin_phimax[1] <<
" tangent " << tan_rmin_phimax[0]
195 <<
"," << tan_rmin_phimax[1] <<
" phi " << phi_rmin_phimax <<
"\n"
196 <<
" rmax_phimax vec " << p_rmax_phimax[0] <<
"," << p_rmax_phimax[1] <<
" tangent " << tan_rmax_phimax[0]
197 <<
"," << tan_rmax_phimax[1] <<
" phi " << phi_rmax_phimax <<
"\n"
201 const auto tan_rmin_phimin = tangentVec(p_rmin_phimin, -1);
202 const auto tan_rmax_phimin = tangentVec(p_rmax_phimin, -1);
203 const auto phi_rmin_phimin = std::atan2(tan_rmin_phimin[1], tan_rmin_phimin[0]);
204 const auto phi_rmax_phimin = std::atan2(tan_rmax_phimin[1], tan_rmax_phimin[0]);
211 LogTrace(
"AreaSeededTrackingRegionBuilder")
212 <<
" rmin_phimin vec " << p_rmin_phimin[0] <<
"," << p_rmin_phimin[1] <<
" tangent " << tan_rmin_phimin[0]
213 <<
"," << tan_rmin_phimin[1] <<
" phi " << phi_rmin_phimin <<
"\n"
214 <<
" rmax_phimin vec " << p_rmax_phimin[0] <<
"," << p_rmax_phimin[1] <<
" tangent " << tan_rmax_phimin[0]
215 <<
"," << tan_rmax_phimin[1] <<
" phi " << phi_rmax_phimin <<
"\n"
232 LogTrace(
"AreaSeededTrackingRegionBuilder")
238 const auto dEta =
maxEta - meanEta + m_conf->m_extraEta;
239 const auto dPhi =
maxPhi - meanPhi + m_conf->m_extraPhi;
241 auto useCandidates =
false;
243 useCandidates =
true;
247 for (
const auto&
object : *
candidates.first) {
250 float eta_Cand =
object.eta();
251 float phi_Cand =
object.phi();
252 float dEta_Cand_Point =
std::abs(eta_Cand - meanEta);
255 if (dEta_Cand_Point > (dEta_Cand +
dEta) || dPhi_Cand_Point > (dPhi_Cand +
dPhi))
258 float etaMin_RoI =
std::max(eta_Cand - dEta_Cand, meanEta -
dEta);
259 float etaMax_RoI =
std::min(eta_Cand + dEta_Cand, meanEta +
dEta);
266 float phiMin_RoI =
deltaPhi(phi_Cand_minus, phi_Point_minus) > 0. ? phi_Cand_minus : phi_Point_minus;
267 float phiMax_RoI =
deltaPhi(phi_Cand_plus, phi_Point_plus) < 0. ? phi_Cand_plus : phi_Point_plus;
269 const auto meanEtaTemp = (etaMin_RoI + etaMax_RoI) / 2.
f;
270 auto meanPhiTemp = (phiMin_RoI + phiMax_RoI) / 2.
f;
271 if (phiMax_RoI < phiMin_RoI)
275 const auto dPhiTemp =
deltaPhi(phiMax_RoI, meanPhiTemp);
276 const auto dEtaTemp = etaMax_RoI - meanEtaTemp;
282 LogTrace(
"AreaSeededTrackingRegionsBuilder")
283 <<
"Direction x,y,z " <<
x <<
"," <<
y <<
"," <<
z <<
" eta,phi " << meanEtaTemp <<
"," << meanPhiTemp
284 <<
" window eta " << (meanEtaTemp - dEtaTemp) <<
"," << (meanEtaTemp + dEtaTemp) <<
" phi "
285 << (meanPhiTemp - dPhiTemp) <<
"," << (meanPhiTemp + dPhiTemp);
287 return std::make_unique<RectangularEtaPhiTrackingRegion>(
GlobalVector(
x,
y,
z),
290 m_conf->m_originRadius,
294 m_conf->m_whereToUseMeasurementTracker,
296 m_measurementTracker,
297 m_conf->m_searchOpt);
307 LogTrace(
"AreaSeededTrackingRegionsBuilder")
308 <<
"Direction x,y,z " <<
x <<
"," <<
y <<
"," <<
z <<
" eta,phi " << meanEta <<
"," << meanPhi <<
" window eta "
309 << (meanEta -
dEta) <<
"," << (meanEta +
dEta) <<
" phi " << (meanPhi -
dPhi) <<
"," << (meanPhi +
dPhi);
311 return std::make_unique<RectangularEtaPhiTrackingRegion>(
GlobalVector(
x,
y,
z),
314 m_conf->m_originRadius,
318 m_conf->m_whereToUseMeasurementTracker,
320 m_measurementTracker,
321 m_conf->m_searchOpt);