14 float perp2(
const std::array<float, 2>&
a) {
return a[0] *
a[0] +
a[1] *
a[1]; }
19 : candidates_(regPSet, iC), token_field(iC.
esConsumes()) {
40 desc.add<
double>(
"extraPhi", 0.);
41 desc.add<
double>(
"extraEta", 0.);
43 desc.add<
double>(
"ptMin", 0.9);
44 desc.add<
double>(
"originRadius", 0.2);
45 desc.add<
bool>(
"precise",
true);
50 desc.add<
bool>(
"searchOpt",
false);
60 auto builder =
Builder(
this, &field, msmaker);
65 builder.setMeasurementTracker(hmte.
product());
72 const Origins& origins,
const std::vector<Area>& areas)
const {
73 std::vector<std::unique_ptr<TrackingRegion> >
result;
77 for (
const auto& origin : origins) {
78 auto reg =
region(origin, areas);
84 LogDebug(
"AreaSeededTrackingRegionsBuilder") <<
"produced " << n_regions <<
" regions";
90 const Origin& origin,
const std::vector<Area>& areas)
const {
91 return regionImpl(origin, areas);
95 return regionImpl(origin, areas);
100 const T& areas)
const {
104 const auto& orig = origin.first;
106 LogDebug(
"AreaSeededTrackingRegionsProducer") <<
"Origin x,y,z " << orig.x() <<
"," << orig.y() <<
"," << orig.z();
108 auto vecFromOrigPlusRadius = [&](
const std::array<float, 2>& vec) {
110 const auto tmp = (1.f - m_conf->m_originRadius * invlen);
111 return std::array<float, 2>{{vec[0] *
tmp, vec[1] *
tmp}};
113 auto tangentVec = [&](
const std::array<float, 2>& vec,
int sign) {
115 const auto r = m_conf->m_originRadius;
118 const auto orthvec =
sign > 0 ? std::array<float, 2>{{-vec[1] *
tmp, vec[0] *
tmp}}
119 : std::array<float, 2>{{vec[1] *
tmp, -vec[0] *
tmp}};
120 return std::array<float, 2>{{vec[0] - orthvec[0], vec[1] - orthvec[1]}};
123 for (
const auto&
area : areas) {
126 LogTrace(
"AreaSeededTrackingRegionsBuilder")
127 <<
" area x,y points " <<
area.x_rmin_phimin() <<
"," <<
area.y_rmin_phimin() <<
" " 128 <<
area.x_rmin_phimax() <<
"," <<
area.y_rmin_phimax() <<
" " <<
area.x_rmax_phimax() <<
"," 129 <<
area.y_rmax_phimax() <<
" " <<
area.x_rmax_phimin() <<
"," <<
area.y_rmax_phimin() <<
" " 130 <<
"z " <<
area.zmin() <<
"," <<
area.zmax();
133 const float x_rmin_phimin =
area.x_rmin_phimin() - orig.x();
134 const float x_rmin_phimax =
area.x_rmin_phimax() - orig.x();
135 const float y_rmin_phimin =
area.y_rmin_phimin() - orig.y();
136 const float y_rmin_phimax =
area.y_rmin_phimax() - orig.y();
138 const std::array<float, 2> p_rmin_phimin = {{x_rmin_phimin, y_rmin_phimin}};
139 const std::array<float, 2> p_rmin_phimax = {{x_rmin_phimax, y_rmin_phimax}};
140 const std::array<float, 2> p_rmax_phimin = {{
area.x_rmax_phimin() - orig.x(),
area.y_rmax_phimin() - orig.y()}};
141 const std::array<float, 2> p_rmax_phimax = {{
area.x_rmax_phimax() - orig.x(),
area.y_rmax_phimax() - orig.y()}};
148 const std::array<float, 2> p_rmin =
perp2(p_rmin_phimin) <
perp2(p_rmin_phimax) ? p_rmin_phimin : p_rmin_phimax;
149 const std::array<float, 2> p_rmax =
perp2(p_rmax_phimin) >
perp2(p_rmax_phimax) ? p_rmax_phimin : p_rmax_phimax;
154 const auto p_min = vecFromOrigPlusRadius(p_rmin);
155 const auto p_max = vecFromOrigPlusRadius(p_rmax);
158 const auto etamin =
std::min(etaFromXYZ(p_min[0], p_min[1],
area.zmin() - (orig.z() + origin.second)),
159 etaFromXYZ(p_max[0], p_max[1],
area.zmin() - (orig.z() + origin.second)));
160 const auto etamax =
std::max(etaFromXYZ(p_min[0], p_min[1],
area.zmax() - (orig.z() - origin.second)),
161 etaFromXYZ(p_max[0], p_max[1],
area.zmax() - (orig.z() - origin.second)));
189 const auto phi_ref =
std::atan2(y_rmin_phimin + y_rmin_phimax, x_rmin_phimin + x_rmin_phimax);
192 const auto tan_rmin_phimax = tangentVec(p_rmin_phimax, +1);
193 const auto tan_rmax_phimax = tangentVec(p_rmax_phimax, +1);
194 const auto phi_rmin_phimax =
std::atan2(tan_rmin_phimax[1], tan_rmin_phimax[0]);
195 const auto phi_rmax_phimax =
std::atan2(tan_rmax_phimax[1], tan_rmax_phimax[0]);
202 LogTrace(
"AreaSeededTrackingRegionBuilder")
203 <<
" rmin_phimax vec " << p_rmin_phimax[0] <<
"," << p_rmin_phimax[1] <<
" tangent " << tan_rmin_phimax[0]
204 <<
"," << tan_rmin_phimax[1] <<
" phi " << phi_rmin_phimax <<
"\n" 205 <<
" rmax_phimax vec " << p_rmax_phimax[0] <<
"," << p_rmax_phimax[1] <<
" tangent " << tan_rmax_phimax[0]
206 <<
"," << tan_rmax_phimax[1] <<
" phi " << phi_rmax_phimax <<
"\n" 210 const auto tan_rmin_phimin = tangentVec(p_rmin_phimin, -1);
211 const auto tan_rmax_phimin = tangentVec(p_rmax_phimin, -1);
212 const auto phi_rmin_phimin =
std::atan2(tan_rmin_phimin[1], tan_rmin_phimin[0]);
213 const auto phi_rmax_phimin =
std::atan2(tan_rmax_phimin[1], tan_rmax_phimin[0]);
220 LogTrace(
"AreaSeededTrackingRegionBuilder")
221 <<
" rmin_phimin vec " << p_rmin_phimin[0] <<
"," << p_rmin_phimin[1] <<
" tangent " << tan_rmin_phimin[0]
222 <<
"," << tan_rmin_phimin[1] <<
" phi " << phi_rmin_phimin <<
"\n" 223 <<
" rmax_phimin vec " << p_rmax_phimin[0] <<
"," << p_rmax_phimin[1] <<
" tangent " << tan_rmax_phimin[0]
224 <<
"," << tan_rmax_phimin[1] <<
" phi " << phi_rmax_phimin <<
"\n" 241 LogTrace(
"AreaSeededTrackingRegionBuilder")
247 const auto dEta =
maxEta - meanEta + m_conf->m_extraEta;
248 const auto dPhi =
maxPhi - meanPhi + m_conf->m_extraPhi;
250 auto useCandidates =
false;
252 useCandidates =
true;
256 for (
const auto&
object : *
candidates.first) {
259 float eta_Cand =
object.eta();
260 float phi_Cand =
object.phi();
261 float dEta_Cand_Point =
std::abs(eta_Cand - meanEta);
264 if (dEta_Cand_Point > (dEta_Cand +
dEta) || dPhi_Cand_Point > (dPhi_Cand +
dPhi))
267 float etaMin_RoI =
std::max(eta_Cand - dEta_Cand, meanEta -
dEta);
268 float etaMax_RoI =
std::min(eta_Cand + dEta_Cand, meanEta +
dEta);
275 float phiMin_RoI =
deltaPhi(phi_Cand_minus, phi_Point_minus) > 0. ? phi_Cand_minus : phi_Point_minus;
276 float phiMax_RoI =
deltaPhi(phi_Cand_plus, phi_Point_plus) < 0. ? phi_Cand_plus : phi_Point_plus;
278 const auto meanEtaTemp = (etaMin_RoI + etaMax_RoI) / 2.
f;
279 auto meanPhiTemp = (phiMin_RoI + phiMax_RoI) / 2.
f;
280 if (phiMax_RoI < phiMin_RoI)
284 const auto dPhiTemp =
deltaPhi(phiMax_RoI, meanPhiTemp);
285 const auto dEtaTemp = etaMax_RoI - meanEtaTemp;
291 LogTrace(
"AreaSeededTrackingRegionsBuilder")
292 <<
"Direction x,y,z " <<
x <<
"," <<
y <<
"," <<
z <<
" eta,phi " << meanEtaTemp <<
"," << meanPhiTemp
293 <<
" window eta " << (meanEtaTemp - dEtaTemp) <<
"," << (meanEtaTemp + dEtaTemp) <<
" phi " 294 << (meanPhiTemp - dPhiTemp) <<
"," << (meanPhiTemp + dPhiTemp);
296 return std::make_unique<RectangularEtaPhiTrackingRegion>(
GlobalVector(
x,
y,
z),
299 m_conf->m_originRadius,
306 m_conf->m_whereToUseMeasurementTracker,
307 m_measurementTracker,
308 m_conf->m_searchOpt);
318 LogTrace(
"AreaSeededTrackingRegionsBuilder")
319 <<
"Direction x,y,z " <<
x <<
"," <<
y <<
"," <<
z <<
" eta,phi " << meanEta <<
"," << meanPhi <<
" window eta " 320 << (meanEta -
dEta) <<
"," << (meanEta +
dEta) <<
" phi " << (meanPhi -
dPhi) <<
"," << (meanPhi +
dPhi);
322 return std::make_unique<RectangularEtaPhiTrackingRegion>(
GlobalVector(
x,
y,
z),
325 m_conf->m_originRadius,
332 m_conf->m_whereToUseMeasurementTracker,
333 m_measurementTracker,
334 m_conf->m_searchOpt);
constexpr double deltaPhi(double phi1, double phi2)
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
static void fillDescriptions(edm::ParameterSetDescription &desc)
T getParameter(std::string const &) const
std::vector< std::unique_ptr< TrackingRegion > > regions(const Origins &origins, const std::vector< Area > &areas) const
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Builder beginEvent(const edm::Event &e, const edm::EventSetup &es) const
std::vector< Origin > Origins
constexpr T normalizedPhi(T phi)
Sin< T >::type sin(const T &t)
T const * product() const
constexpr bool isUninitialized() const noexcept
static UseMeasurementTracker stringToUseMeasurementTracker(const std::string &name)
RectangularEtaPhiTrackingRegion::UseMeasurementTracker m_whereToUseMeasurementTracker
T perp2() const
Squared magnitude of transverse component.
TrackingSeedCandidates candidates_
Cos< T >::type cos(const T &t)
Tan< T >::type tan(const T &t)
Abs< T >::type abs(const T &t)
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > token_field
edm::ESGetToken< MultipleScatteringParametrisationMaker, TrackerMultipleScatteringRecord > token_msmaker
std::unique_ptr< TrackingRegion > regionImpl(const Origin &origin, const T &areas) const
std::unique_ptr< TrackingRegion > region(const Origin &origin, const std::vector< Area > &areas) const
static void fillDescriptions(edm::ParameterSetDescription &desc)
std::pair< GlobalPoint, float > Origin
edm::EDGetTokenT< MeasurementTrackerEvent > token_measurementTracker
Objects objects(const edm::Event &iEvent) const
AreaSeededTrackingRegionsBuilder(const edm::ParameterSet ®PSet, edm::ConsumesCollector &&iC)
Global3DVector GlobalVector
MPlex< T, D1, D2, N > atan2(const MPlex< T, D1, D2, N > &y, const MPlex< T, D1, D2, N > &x)