91 const auto& orig = origin.first;
93 LogDebug(
"AreaSeededTrackingRegionsProducer") <<
"Origin x,y,z " << orig.x() <<
"," << orig.y() <<
"," << orig.z();
95 auto vecFromOrigPlusRadius = [&](
const std::array<float, 2>& vec) {
98 return std::array<float, 2>{{vec[0]*
tmp, vec[1]*tmp}};
100 auto tangentVec = [&](
const std::array<float, 2>& vec,
int sign) {
105 const auto orthvec =
sign > 0 ? std::array<float, 2>{{-vec[1]*
tmp, vec[0]*tmp}}
106 : std::array<float, 2>{{ vec[1]*
tmp, -vec[0]*tmp}};
107 return std::array<float, 2>{{vec[0]-orthvec[0], vec[1]-orthvec[1]}};
110 for(
const auto&
area: areas) {
113 LogTrace(
"AreaSeededTrackingRegionsBuilder") <<
" area x,y points " 114 <<
area.x_rmin_phimin() <<
"," <<
area.y_rmin_phimin() <<
" " 115 <<
area.x_rmin_phimax() <<
"," <<
area.y_rmin_phimax() <<
" " 116 <<
area.x_rmax_phimax() <<
"," <<
area.y_rmax_phimax() <<
" " 117 <<
area.x_rmax_phimin() <<
"," <<
area.y_rmax_phimin() <<
" " 118 <<
"z " <<
area.zmin() <<
"," <<
area.zmax();
121 const float x_rmin_phimin =
area.x_rmin_phimin()-orig.x();
122 const float x_rmin_phimax =
area.x_rmin_phimax()-orig.x();
123 const float y_rmin_phimin =
area.y_rmin_phimin()-orig.y();
124 const float y_rmin_phimax =
area.y_rmin_phimax()-orig.y();
126 const std::array<float, 2> p_rmin_phimin = {{x_rmin_phimin, y_rmin_phimin}};
127 const std::array<float, 2> p_rmin_phimax = {{x_rmin_phimax, y_rmin_phimax}};
128 const std::array<float, 2> p_rmax_phimin = {{
area.x_rmax_phimin() - orig.x(),
area.y_rmax_phimin() - orig.y()}};
129 const std::array<float, 2> p_rmax_phimax = {{
area.x_rmax_phimax() - orig.x(),
area.y_rmax_phimax() - orig.y()}};
137 const std::array<float, 2> p_rmin =
perp2(p_rmin_phimin) <
perp2(p_rmin_phimax) ? p_rmin_phimin : p_rmin_phimax;
138 const std::array<float, 2> p_rmax =
perp2(p_rmax_phimin) >
perp2(p_rmax_phimax) ? p_rmax_phimin : p_rmax_phimax;
143 const auto p_min = vecFromOrigPlusRadius(p_rmin);
144 const auto p_max = vecFromOrigPlusRadius(p_rmax);
147 const auto etamin =
std::min(etaFromXYZ(p_min[0], p_min[1],
area.zmin() - (orig.z()+origin.second)),
148 etaFromXYZ(p_max[0], p_max[1],
area.zmin() - (orig.z()+origin.second)));
149 const auto etamax =
std::max(etaFromXYZ(p_min[0], p_min[1],
area.zmax() - (orig.z()-origin.second)),
150 etaFromXYZ(p_max[0], p_max[1],
area.zmax() - (orig.z()-origin.second)));
152 LogTrace(
"AreaSeededTrackingRegionBuilder") <<
" eta min,max " << etamin <<
"," << etamax;
178 const auto phi_ref = std::atan2(y_rmin_phimin + y_rmin_phimax,
179 x_rmin_phimin + x_rmin_phimax);
182 const auto tan_rmin_phimax = tangentVec(p_rmin_phimax, +1);
183 const auto tan_rmax_phimax = tangentVec(p_rmax_phimax, +1);
184 const auto phi_rmin_phimax = std::atan2(tan_rmin_phimax[1], tan_rmin_phimax[0]);
185 const auto phi_rmax_phimax = std::atan2(tan_rmax_phimax[1], tan_rmax_phimax[0]);
188 phi_rmin_phimax : phi_rmax_phimax;
190 LogTrace(
"AreaSeededTrackingRegionBuilder") <<
" rmin_phimax vec " << p_rmin_phimax[0] <<
"," << p_rmin_phimax[1]
191 <<
" tangent " << tan_rmin_phimax[0] <<
"," << tan_rmin_phimax[1]
192 <<
" phi " << phi_rmin_phimax <<
"\n" 193 <<
" rmax_phimax vec " << p_rmax_phimax[0] <<
"," << p_rmax_phimax[1]
194 <<
" tangent " << tan_rmax_phimax[0] <<
"," << tan_rmax_phimax[1]
195 <<
" 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]);
207 phi_rmin_phimin : phi_rmax_phimin;
210 LogTrace(
"AreaSeededTrackingRegionBuilder") <<
" rmin_phimin vec " << p_rmin_phimin[0] <<
"," << p_rmin_phimin[1]
211 <<
" tangent " << tan_rmin_phimin[0] <<
"," << tan_rmin_phimin[1]
212 <<
" phi " << phi_rmin_phimin <<
"\n" 213 <<
" rmax_phimin vec " << p_rmax_phimin[0] <<
"," << p_rmax_phimin[1]
214 <<
" tangent " << tan_rmax_phimin[0] <<
"," << tan_rmax_phimin[1]
215 <<
" phi " << phi_rmax_phimin <<
"\n" 219 if(phimax < phimin) {
220 if(phimax < 0) phimax += 2*
M_PI;
221 else phimin -= 2*
M_PI;
224 LogTrace(
"AreaSeededTrackingRegionBuilder") <<
" phi min,max " << phimin <<
"," <<
phimax;
230 LogTrace(
"AreaSeededTrackingRegionBuilder") <<
" windows after this area eta " << minEta <<
"," <<
maxEta 231 <<
" phi " << minPhi <<
"," <<
maxPhi;
234 const auto meanEta = (minEta+
maxEta)/2.
f;
235 const auto meanPhi = (minPhi+
maxPhi)/2.
f;
239 auto useCandidates =
false;
247 float eta_Cand =
object.eta();
248 float phi_Cand =
object.phi();
249 float dEta_Cand_Point =
std::abs(eta_Cand-meanEta);
252 if(dEta_Cand_Point > (dEta_Cand + dEta) || dPhi_Cand_Point > (dPhi_Cand + dPhi))
continue;
254 float etaMin_RoI =
std::max(eta_Cand-dEta_Cand,meanEta-dEta);
255 float etaMax_RoI =
std::min(eta_Cand+dEta_Cand,meanEta+dEta);
262 float phiMin_RoI =
deltaPhi(phi_Cand_minus,phi_Point_minus)>0. ? phi_Cand_minus : phi_Point_minus ;
263 float phiMax_RoI =
deltaPhi(phi_Cand_plus,phi_Point_plus)<0. ? phi_Cand_plus : phi_Point_plus;
266 const auto meanEtaTemp = (etaMin_RoI+etaMax_RoI)/2.
f;
267 auto meanPhiTemp = (phiMin_RoI+phiMax_RoI)/2.
f;
268 if( phiMax_RoI < phiMin_RoI ) meanPhiTemp-=
M_PI;
271 const auto dPhiTemp =
deltaPhi(phiMax_RoI,meanPhiTemp);
272 const auto dEtaTemp = etaMax_RoI-meanEtaTemp;
278 LogTrace(
"AreaSeededTrackingRegionsBuilder") <<
"Direction x,y,z " <<
x <<
"," <<
y <<
"," <<
z 279 <<
" eta,phi " << meanEtaTemp <<
"," << meanPhiTemp
280 <<
" window eta " << (meanEtaTemp-dEtaTemp) <<
"," << (meanEtaTemp+dEtaTemp)
281 <<
" phi " << (meanPhiTemp-dPhiTemp) <<
"," << (meanPhiTemp+dPhiTemp);
283 return std::make_unique<RectangularEtaPhiTrackingRegion>(
306 LogTrace(
"AreaSeededTrackingRegionsBuilder") <<
"Direction x,y,z " <<
x <<
"," <<
y <<
"," <<
z 307 <<
" eta,phi " << meanEta <<
"," << meanPhi
308 <<
" window eta " << (meanEta-dEta) <<
"," << (meanEta+dEta)
309 <<
" phi " << (meanPhi-dPhi) <<
"," << (meanPhi+dPhi);
311 return std::make_unique<RectangularEtaPhiTrackingRegion>(
const AreaSeededTrackingRegionsBuilder * m_conf
Sin< T >::type sin(const T &t)
TrackingSeedCandidates::Objects candidates
RectangularEtaPhiTrackingRegion::UseMeasurementTracker m_whereToUseMeasurementTracker
Cos< T >::type cos(const T &t)
Tan< T >::type tan(const T &t)
Abs< T >::type abs(const T &t)
double deltaPhi(double phi1, double phi2)
const MeasurementTrackerEvent * m_measurementTracker
T perp2() const
Squared magnitude of transverse component.
std::vector< std::vector< double > > tmp
Global3DVector GlobalVector