13 float perp2(
const std::array<float, 2>&
a) {
14 return a[0]*a[0] + a[1]*a[1];
34 desc.
add<
double>(
"extraPhi", 0.);
35 desc.
add<
double>(
"extraEta", 0.);
37 desc.
add<
double>(
"ptMin", 0.9);
38 desc.
add<
double>(
"originRadius", 0.2);
39 desc.
add<
bool>(
"precise",
true);
44 desc.
add<
bool>(
"searchOpt",
false);
53 builder.setMeasurementTracker(hmte.
product());
61 std::vector<std::unique_ptr<TrackingRegion> >
result;
65 for(
const auto& origin: origins) {
66 result.push_back(region(origin, areas));
69 LogDebug(
"AreaSeededTrackingRegionsBuilder") <<
"produced "<<n_regions<<
" regions";
75 return regionImpl(origin, areas);
78 return regionImpl(origin, areas);
86 const auto& orig = origin.first;
88 LogDebug(
"AreaSeededTrackingRegionsProducer") <<
"Origin x,y,z " << orig.x() <<
"," << orig.y() <<
"," << orig.z();
90 auto vecFromOrigPlusRadius = [&](
const std::array<float, 2>& vec) {
92 const auto tmp = (1.f - m_conf->m_originRadius*invlen);
93 return std::array<float, 2>{{vec[0]*
tmp, vec[1]*tmp}};
95 auto tangentVec = [&](
const std::array<float, 2>& vec,
int sign) {
97 const auto r = m_conf->m_originRadius;
100 const auto orthvec =
sign > 0 ? std::array<float, 2>{{-vec[1]*
tmp, vec[0]*tmp}}
101 : std::array<float, 2>{{ vec[1]*
tmp, -vec[0]*tmp}};
102 return std::array<float, 2>{{vec[0]-orthvec[0], vec[1]-orthvec[1]}};
105 for(
const auto&
area: areas) {
108 LogTrace(
"AreaSeededTrackingRegionsBuilder") <<
" area x,y points " 109 <<
area.x_rmin_phimin() <<
"," <<
area.y_rmin_phimin() <<
" " 110 <<
area.x_rmin_phimax() <<
"," <<
area.y_rmin_phimax() <<
" " 111 <<
area.x_rmax_phimax() <<
"," <<
area.y_rmax_phimax() <<
" " 112 <<
area.x_rmax_phimin() <<
"," <<
area.y_rmax_phimin() <<
" " 113 <<
"z " <<
area.zmin() <<
"," <<
area.zmax();
116 const float x_rmin_phimin =
area.x_rmin_phimin()-orig.x();
117 const float x_rmin_phimax =
area.x_rmin_phimax()-orig.x();
118 const float y_rmin_phimin =
area.y_rmin_phimin()-orig.y();
119 const float y_rmin_phimax =
area.y_rmin_phimax()-orig.y();
121 const std::array<float, 2> p_rmin_phimin = {{x_rmin_phimin, y_rmin_phimin}};
122 const std::array<float, 2> p_rmin_phimax = {{x_rmin_phimax, y_rmin_phimax}};
123 const std::array<float, 2> p_rmax_phimin = {{
area.x_rmax_phimin() - orig.x(),
area.y_rmax_phimin() - orig.y()}};
124 const std::array<float, 2> p_rmax_phimax = {{
area.x_rmax_phimax() - orig.x(),
area.y_rmax_phimax() - orig.y()}};
132 const std::array<float, 2> p_rmin =
perp2(p_rmin_phimin) <
perp2(p_rmin_phimax) ? p_rmin_phimin : p_rmin_phimax;
133 const std::array<float, 2> p_rmax =
perp2(p_rmax_phimin) >
perp2(p_rmax_phimax) ? p_rmax_phimin : p_rmax_phimax;
138 const auto p_min = vecFromOrigPlusRadius(p_rmin);
139 const auto p_max = vecFromOrigPlusRadius(p_rmax);
142 const auto etamin =
std::min(etaFromXYZ(p_min[0], p_min[1],
area.zmin() - (orig.z()+origin.second)),
143 etaFromXYZ(p_max[0], p_max[1],
area.zmin() - (orig.z()+origin.second)));
144 const auto etamax =
std::max(etaFromXYZ(p_min[0], p_min[1],
area.zmax() - (orig.z()-origin.second)),
145 etaFromXYZ(p_max[0], p_max[1],
area.zmax() - (orig.z()-origin.second)));
147 LogTrace(
"AreaSeededTrackingRegionBuilder") <<
" eta min,max " << etamin <<
"," << etamax;
173 const auto phi_ref = std::atan2(y_rmin_phimin + y_rmin_phimax,
174 x_rmin_phimin + x_rmin_phimax);
177 const auto tan_rmin_phimax = tangentVec(p_rmin_phimax, +1);
178 const auto tan_rmax_phimax = tangentVec(p_rmax_phimax, +1);
179 const auto phi_rmin_phimax = std::atan2(tan_rmin_phimax[1], tan_rmin_phimax[0]);
180 const auto phi_rmax_phimax = std::atan2(tan_rmax_phimax[1], tan_rmax_phimax[0]);
183 phi_rmin_phimax : phi_rmax_phimax;
185 LogTrace(
"AreaSeededTrackingRegionBuilder") <<
" rmin_phimax vec " << p_rmin_phimax[0] <<
"," << p_rmin_phimax[1]
186 <<
" tangent " << tan_rmin_phimax[0] <<
"," << tan_rmin_phimax[1]
187 <<
" phi " << phi_rmin_phimax <<
"\n" 188 <<
" rmax_phimax vec " << p_rmax_phimax[0] <<
"," << p_rmax_phimax[1]
189 <<
" tangent " << tan_rmax_phimax[0] <<
"," << tan_rmax_phimax[1]
190 <<
" phi " << phi_rmax_phimax <<
"\n" 196 const auto tan_rmin_phimin = tangentVec(p_rmin_phimin, -1);
197 const auto tan_rmax_phimin = tangentVec(p_rmax_phimin, -1);
198 const auto phi_rmin_phimin = std::atan2(tan_rmin_phimin[1], tan_rmin_phimin[0]);
199 const auto phi_rmax_phimin = std::atan2(tan_rmax_phimin[1], tan_rmax_phimin[0]);
202 phi_rmin_phimin : phi_rmax_phimin;
205 LogTrace(
"AreaSeededTrackingRegionBuilder") <<
" rmin_phimin vec " << p_rmin_phimin[0] <<
"," << p_rmin_phimin[1]
206 <<
" tangent " << tan_rmin_phimin[0] <<
"," << tan_rmin_phimin[1]
207 <<
" phi " << phi_rmin_phimin <<
"\n" 208 <<
" rmax_phimin vec " << p_rmax_phimin[0] <<
"," << p_rmax_phimin[1]
209 <<
" tangent " << tan_rmax_phimin[0] <<
"," << tan_rmax_phimin[1]
210 <<
" phi " << phi_rmax_phimin <<
"\n" 214 if(phimax < phimin) {
215 if(phimax < 0) phimax += 2*
M_PI;
216 else phimin -= 2*
M_PI;
219 LogTrace(
"AreaSeededTrackingRegionBuilder") <<
" phi min,max " << phimin <<
"," <<
phimax;
225 LogTrace(
"AreaSeededTrackingRegionBuilder") <<
" windows after this area eta " << minEta <<
"," <<
maxEta 226 <<
" phi " << minPhi <<
"," <<
maxPhi;
229 const auto meanEta = (minEta+
maxEta)/2.
f;
230 const auto meanPhi = (minPhi+
maxPhi)/2.
f;
238 LogTrace(
"AreaSeededTrackingRegionsBuilder") <<
"Direction x,y,z " <<
x <<
"," <<
y <<
"," <<
z 239 <<
" eta,phi " << meanEta <<
"," << meanPhi
243 return std::make_unique<RectangularEtaPhiTrackingRegion>(
247 m_conf->m_originRadius,
251 m_conf->m_whereToUseMeasurementTracker,
253 m_measurementTracker,
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
static void fillDescriptions(edm::ParameterSetDescription &desc)
T getParameter(std::string const &) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
std::vector< Origin > Origins
Sin< T >::type sin(const T &t)
static UseMeasurementTracker stringToUseMeasurementTracker(const std::string &name)
static const double deltaEta
RectangularEtaPhiTrackingRegion::UseMeasurementTracker m_whereToUseMeasurementTracker
std::unique_ptr< TrackingRegion > region(const Origin &origin, const std::vector< Area > &areas) const
Cos< T >::type cos(const T &t)
Tan< T >::type tan(const T &t)
Abs< T >::type abs(const T &t)
std::vector< std::unique_ptr< TrackingRegion > > regions(const Origins &origins, const std::vector< Area > &areas) const
ParameterDescriptionBase * add(U const &iLabel, T const &value)
double deltaPhi(double phi1, double phi2)
T const * product() const
T perp2() const
Squared magnitude of transverse component.
std::unique_ptr< TrackingRegion > regionImpl(const Origin &origin, const T &areas) const
std::pair< GlobalPoint, float > Origin
std::vector< std::vector< double > > tmp
bool isUninitialized() const
Builder beginEvent(const edm::Event &e) const
edm::EDGetTokenT< MeasurementTrackerEvent > token_measurementTracker
AreaSeededTrackingRegionsBuilder(const edm::ParameterSet ®PSet, edm::ConsumesCollector &&iC)
Global3DVector GlobalVector