CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
AreaSeededTrackingRegionsBuilder::Builder Class Reference

#include <AreaSeededTrackingRegionsBuilder.h>

Public Member Functions

 Builder (const AreaSeededTrackingRegionsBuilder *conf)
 
std::unique_ptr< TrackingRegionregion (const Origin &origin, const edm::VecArray< Area, 2 > &areas) const
 
std::unique_ptr< TrackingRegionregion (const Origin &origin, const std::vector< Area > &areas) const
 
std::vector< std::unique_ptr< TrackingRegion > > regions (const Origins &origins, const std::vector< Area > &areas) const
 
void setCandidates (const TrackingSeedCandidates::Objects cands)
 
void setMeasurementTracker (const MeasurementTrackerEvent *mte)
 
 ~Builder ()=default
 

Private Member Functions

template<typename T >
std::unique_ptr< TrackingRegionregionImpl (const Origin &origin, const T &areas) const
 

Private Attributes

TrackingSeedCandidates::Objects candidates
 
const AreaSeededTrackingRegionsBuilderm_conf = nullptr
 
const MeasurementTrackerEventm_measurementTracker = nullptr
 

Detailed Description

Definition at line 73 of file AreaSeededTrackingRegionsBuilder.h.

Constructor & Destructor Documentation

◆ Builder()

AreaSeededTrackingRegionsBuilder::Builder::Builder ( const AreaSeededTrackingRegionsBuilder conf)
inlineexplicit

Definition at line 75 of file AreaSeededTrackingRegionsBuilder.h.

75 : m_conf(conf) {}

◆ ~Builder()

AreaSeededTrackingRegionsBuilder::Builder::~Builder ( )
default

Member Function Documentation

◆ region() [1/2]

std::unique_ptr< TrackingRegion > AreaSeededTrackingRegionsBuilder::Builder::region ( const Origin origin,
const edm::VecArray< Area, 2 > &  areas 
) const

Definition at line 84 of file AreaSeededTrackingRegionsBuilder.cc.

85  {
86  return regionImpl(origin, areas);
87 }

◆ region() [2/2]

std::unique_ptr< TrackingRegion > AreaSeededTrackingRegionsBuilder::Builder::region ( const Origin origin,
const std::vector< Area > &  areas 
) const

Definition at line 80 of file AreaSeededTrackingRegionsBuilder.cc.

81  {
82  return regionImpl(origin, areas);
83 }

Referenced by regions().

◆ regionImpl()

template<typename T >
std::unique_ptr< TrackingRegion > AreaSeededTrackingRegionsBuilder::Builder::regionImpl ( const Origin origin,
const T areas 
) const
private

Definition at line 90 of file AreaSeededTrackingRegionsBuilder.cc.

91  {
92  float minEta = std::numeric_limits<float>::max(), maxEta = std::numeric_limits<float>::lowest();
93  float minPhi = std::numeric_limits<float>::max(), maxPhi = std::numeric_limits<float>::lowest();
94 
95  const auto& orig = origin.first;
96 
97  LogDebug("AreaSeededTrackingRegionsProducer") << "Origin x,y,z " << orig.x() << "," << orig.y() << "," << orig.z();
98 
99  auto vecFromOrigPlusRadius = [&](const std::array<float, 2>& vec) {
100  const auto invlen = 1.f / std::sqrt(perp2(vec));
101  const auto tmp = (1.f - m_conf->m_originRadius * invlen);
102  return std::array<float, 2>{{vec[0] * tmp, vec[1] * tmp}};
103  };
104  auto tangentVec = [&](const std::array<float, 2>& vec, int sign) {
105  const auto d = std::sqrt(perp2(vec));
106  const auto r = m_conf->m_originRadius;
107  const auto tmp = r / std::sqrt(d * d - r * r);
108  // sign+ for counterclockwise, sign- for clockwise
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]}};
112  };
113 
114  for (const auto& area : areas) {
115  // straight line assumption is conservative, accounding for
116  // low-pT bending would only tighten the eta-phi window
117  LogTrace("AreaSeededTrackingRegionsBuilder")
118  << " area x,y points " << area.x_rmin_phimin() << "," << area.y_rmin_phimin() << " " // go around
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();
122 
123  // some common variables
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();
128 
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()}};
133 
134  // eta
135  {
136  // find which of the two rmin points is closer to the origin
137  //
138  // closest point for p_rmin, farthest point for p_rmax
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;
141 
142  // then calculate the xy vector from the point closest to p_rmin on
143  // the (origin,originRadius) circle to the p_rmin
144  // this will maximize the eta window
145  const auto p_min = vecFromOrigPlusRadius(p_rmin);
146  const auto p_max = vecFromOrigPlusRadius(p_rmax);
147 
148  // then we calculate the maximal eta window
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)));
153 
154  LogTrace("AreaSeededTrackingRegionBuilder") << " eta min,max " << etamin << "," << etamax;
155 
158  }
159 
160  // phi
161  {
162  // For phi we construct the tangent lines of (origin,
163  // originRadius) that go though each of the 4 points (in xy
164  // plane) of the area. Easiest is to make a vector orthogonal to
165  // origin->point vector which has a length of
166  //
167  // length = r*d/std::sqrt(d*d-r*r)
168  //
169  // where r is the originRadius and d is the distance from origin
170  // to the point (to derive draw the situation and start with
171  // definitions of sin/cos of one of the angles of the
172  // right-angled triangle.
173 
174  // But we start with a "reference phi" so that we can easily
175  // decide which phi is the largest/smallest without having too
176  // much of headache with the wrapping. The reference is in
177  // principle defined by the averages of y&x phimin/phimax at
178  // rmin, but the '0.5f*' factor is omitted here to reduce
179  // computations.
180  const auto phi_ref = std::atan2(y_rmin_phimin + y_rmin_phimax, x_rmin_phimin + x_rmin_phimax);
181 
182  // for maximum phi we need the orthogonal vector to the left
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]);
187 
188  auto phimax =
189  std::abs(reco::deltaPhi(phi_rmin_phimax, phi_ref)) > std::abs(reco::deltaPhi(phi_rmax_phimax, phi_ref))
190  ? phi_rmin_phimax
191  : phi_rmax_phimax;
192 
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"
198  << " phimax " << phimax;
199 
200  // for minimum phi we need the orthogonal vector to the right
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]);
205 
206  auto phimin =
207  std::abs(reco::deltaPhi(phi_rmin_phimin, phi_ref)) > std::abs(reco::deltaPhi(phi_rmax_phimin, phi_ref))
208  ? phi_rmin_phimin
209  : phi_rmax_phimin;
210 
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"
216  << " phimin " << phimin;
217 
218  // wrapped around, need to decide which one to wrap
219  if (phimax < phimin) {
220  if (phimax < 0)
221  phimax += 2 * M_PI;
222  else
223  phimin -= 2 * M_PI;
224  }
225 
226  LogTrace("AreaSeededTrackingRegionBuilder") << " phi min,max " << phimin << "," << phimax;
227 
230  }
231 
232  LogTrace("AreaSeededTrackingRegionBuilder")
233  << " windows after this area eta " << minEta << "," << maxEta << " phi " << minPhi << "," << maxPhi;
234  }
235 
236  const auto meanEta = (minEta + maxEta) / 2.f;
237  const auto meanPhi = (minPhi + maxPhi) / 2.f;
238  const auto dEta = maxEta - meanEta + m_conf->m_extraEta;
239  const auto dPhi = maxPhi - meanPhi + m_conf->m_extraPhi;
240 
241  auto useCandidates = false;
242  if (candidates.first)
243  useCandidates = true;
244 
245  if (useCandidates) {
246  // If we have objects used for seeding, loop over objects and find overlap with the found region. Return overlaps as tracking regions to use
247  for (const auto& object : *candidates.first) {
248  float dEta_Cand = candidates.second.first;
249  float dPhi_Cand = candidates.second.second;
250  float eta_Cand = object.eta();
251  float phi_Cand = object.phi();
252  float dEta_Cand_Point = std::abs(eta_Cand - meanEta);
253  float dPhi_Cand_Point = std::abs(deltaPhi(phi_Cand, meanPhi));
254 
255  if (dEta_Cand_Point > (dEta_Cand + dEta) || dPhi_Cand_Point > (dPhi_Cand + dPhi))
256  continue;
257 
258  float etaMin_RoI = std::max(eta_Cand - dEta_Cand, meanEta - dEta);
259  float etaMax_RoI = std::min(eta_Cand + dEta_Cand, meanEta + dEta);
260 
261  float phi_Cand_minus = normalizedPhi(phi_Cand - dPhi_Cand);
262  float phi_Point_minus = normalizedPhi(meanPhi - dPhi);
263  float phi_Cand_plus = normalizedPhi(phi_Cand + dPhi_Cand);
264  float phi_Point_plus = normalizedPhi(meanPhi + dPhi);
265 
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;
268 
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)
272  meanPhiTemp -= M_PI;
273  meanPhiTemp = normalizedPhi(meanPhiTemp);
274 
275  const auto dPhiTemp = deltaPhi(phiMax_RoI, meanPhiTemp);
276  const auto dEtaTemp = etaMax_RoI - meanEtaTemp;
277 
278  const auto x = std::cos(meanPhiTemp);
279  const auto y = std::sin(meanPhiTemp);
280  const auto z = 1. / std::tan(2.f * std::atan(std::exp(-meanEtaTemp)));
281 
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);
286 
287  return std::make_unique<RectangularEtaPhiTrackingRegion>(GlobalVector(x, y, z),
288  origin.first, // GlobalPoint
289  m_conf->m_ptMin,
291  origin.second,
292  dEtaTemp,
293  dPhiTemp,
295  m_conf->m_precise,
298  }
299  // Have to retun nullptr here to ensure that we always return something
300  return nullptr;
301 
302  } else {
303  const auto x = std::cos(meanPhi);
304  const auto y = std::sin(meanPhi);
305  const auto z = 1. / std::tan(2.f * std::atan(std::exp(-meanEta)));
306 
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);
310 
311  return std::make_unique<RectangularEtaPhiTrackingRegion>(GlobalVector(x, y, z),
312  origin.first, // GlobalPoint
313  m_conf->m_ptMin,
315  origin.second,
316  dEta,
317  dPhi,
319  m_conf->m_precise,
322  }
323 }

References funct::abs(), custom_jme_cff::area, HLT_FULL_cff::candidates, funct::cos(), ztail::d, SiPixelRawToDigiRegional_cfi::deltaPhi, reco::deltaPhi(), HLT_FULL_cff::dEta, HLT_FULL_cff::dPhi, muonTiming_cfi::etamax, muonTiming_cfi::etamin, JetChargeProducer_cfi::exp, f, LogDebug, LogTrace, M_PI, SiStripPI::max, maxEta, HLT_FULL_cff::maxPhi, min(), EgHLTOffEleSelection_cfi::minEta, HLT_FULL_cff::minPhi, normalizedPhi(), perp2(), phimax, phimin, alignCSCRings::r, Validation_hcalonly_cfi::sign, funct::sin(), mathSSE::sqrt(), funct::tan(), createJobs::tmp, x, y, and z.

◆ regions()

std::vector< std::unique_ptr< TrackingRegion > > AreaSeededTrackingRegionsBuilder::Builder::regions ( const Origins origins,
const std::vector< Area > &  areas 
) const

Definition at line 62 of file AreaSeededTrackingRegionsBuilder.cc.

63  {
64  std::vector<std::unique_ptr<TrackingRegion> > result;
65 
66  // create tracking regions in directions of the points of interest
67  int n_regions = 0;
68  for (const auto& origin : origins) {
69  auto reg = region(origin, areas);
70  if (!reg)
71  continue;
72  result.push_back(std::move(reg));
73  ++n_regions;
74  }
75  LogDebug("AreaSeededTrackingRegionsBuilder") << "produced " << n_regions << " regions";
76 
77  return result;
78 }

References LogDebug, eostools::move(), region(), and mps_fire::result.

Referenced by AreaSeededTrackingRegionsProducer::regions().

◆ setCandidates()

void AreaSeededTrackingRegionsBuilder::Builder::setCandidates ( const TrackingSeedCandidates::Objects  cands)
inline

Definition at line 79 of file AreaSeededTrackingRegionsBuilder.h.

79 { candidates = cands; }

References candidates, and HLT_FULL_cff::cands.

◆ setMeasurementTracker()

void AreaSeededTrackingRegionsBuilder::Builder::setMeasurementTracker ( const MeasurementTrackerEvent mte)
inline

Definition at line 78 of file AreaSeededTrackingRegionsBuilder.h.

78 { m_measurementTracker = mte; }

References m_measurementTracker.

Member Data Documentation

◆ candidates

TrackingSeedCandidates::Objects AreaSeededTrackingRegionsBuilder::Builder::candidates
private

Definition at line 91 of file AreaSeededTrackingRegionsBuilder.h.

Referenced by setCandidates().

◆ m_conf

const AreaSeededTrackingRegionsBuilder* AreaSeededTrackingRegionsBuilder::Builder::m_conf = nullptr
private

Definition at line 89 of file AreaSeededTrackingRegionsBuilder.h.

◆ m_measurementTracker

const MeasurementTrackerEvent* AreaSeededTrackingRegionsBuilder::Builder::m_measurementTracker = nullptr
private

Definition at line 90 of file AreaSeededTrackingRegionsBuilder.h.

Referenced by setMeasurementTracker().

DDAxes::y
AreaSeededTrackingRegionsBuilder::m_ptMin
float m_ptMin
Definition: AreaSeededTrackingRegionsBuilder.h:108
AreaSeededTrackingRegionsBuilder::Builder::m_conf
const AreaSeededTrackingRegionsBuilder * m_conf
Definition: AreaSeededTrackingRegionsBuilder.h:89
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
min
T min(T a, T b)
Definition: MathUtil.h:58
reco::deltaPhi
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:26
phimin
float phimin
Definition: ReggeGribovPartonMCHadronizer.h:107
Validation_hcalonly_cfi.sign
sign
Definition: Validation_hcalonly_cfi.py:32
AreaSeededTrackingRegionsBuilder::m_extraEta
float m_extraEta
Definition: AreaSeededTrackingRegionsBuilder.h:107
DDAxes::x
AreaSeededTrackingRegionsBuilder::Builder::regionImpl
std::unique_ptr< TrackingRegion > regionImpl(const Origin &origin, const T &areas) const
Definition: AreaSeededTrackingRegionsBuilder.cc:90
GlobalVector
Global3DVector GlobalVector
Definition: GlobalVector.h:10
HLT_FULL_cff.dPhi
dPhi
Definition: HLT_FULL_cff.py:13703
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
AreaSeededTrackingRegionsBuilder::Builder::region
std::unique_ptr< TrackingRegion > region(const Origin &origin, const std::vector< Area > &areas) const
Definition: AreaSeededTrackingRegionsBuilder.cc:80
muonTiming_cfi.etamin
etamin
Definition: muonTiming_cfi.py:30
AreaSeededTrackingRegionsBuilder::m_originRadius
float m_originRadius
Definition: AreaSeededTrackingRegionsBuilder.h:109
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
HLT_FULL_cff.maxPhi
maxPhi
Definition: HLT_FULL_cff.py:52987
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
SiPixelRawToDigiRegional_cfi.deltaPhi
deltaPhi
Definition: SiPixelRawToDigiRegional_cfi.py:9
AreaSeededTrackingRegionsBuilder::Builder::candidates
TrackingSeedCandidates::Objects candidates
Definition: AreaSeededTrackingRegionsBuilder.h:91
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
DDAxes::z
maxEta
double maxEta
Definition: PFJetBenchmarkAnalyzer.cc:76
normalizedPhi
constexpr T normalizedPhi(T phi)
Definition: normalizedPhi.h:8
AreaSeededTrackingRegionsBuilder::m_whereToUseMeasurementTracker
RectangularEtaPhiTrackingRegion::UseMeasurementTracker m_whereToUseMeasurementTracker
Definition: AreaSeededTrackingRegionsBuilder.h:112
HLT_FULL_cff.cands
cands
Definition: HLT_FULL_cff.py:15146
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
AreaSeededTrackingRegionsBuilder::m_searchOpt
bool m_searchOpt
Definition: AreaSeededTrackingRegionsBuilder.h:113
funct::tan
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:49
perp2
T perp2() const
Squared magnitude of transverse component.
Definition: Basic3DVectorLD.h:130
alignCSCRings.r
r
Definition: alignCSCRings.py:93
phimax
float phimax
Definition: ReggeGribovPartonMCHadronizer.h:106
HLT_FULL_cff.minPhi
minPhi
Definition: HLT_FULL_cff.py:52975
eostools.move
def move(src, dest)
Definition: eostools.py:511
AreaSeededTrackingRegionsBuilder::m_extraPhi
float m_extraPhi
Definition: AreaSeededTrackingRegionsBuilder.h:106
HLT_FULL_cff.dEta
dEta
Definition: HLT_FULL_cff.py:13702
muonTiming_cfi.etamax
etamax
Definition: muonTiming_cfi.py:23
ztail.d
d
Definition: ztail.py:151
AreaSeededTrackingRegionsBuilder::Builder::m_measurementTracker
const MeasurementTrackerEvent * m_measurementTracker
Definition: AreaSeededTrackingRegionsBuilder.h:90
mps_fire.result
result
Definition: mps_fire.py:311
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:234
JetChargeProducer_cfi.exp
exp
Definition: JetChargeProducer_cfi.py:6
EgHLTOffEleSelection_cfi.minEta
minEta
Definition: EgHLTOffEleSelection_cfi.py:11
AreaSeededTrackingRegionsBuilder::m_precise
bool m_precise
Definition: AreaSeededTrackingRegionsBuilder.h:110
custom_jme_cff.area
area
Definition: custom_jme_cff.py:140