CMS 3D CMS Logo

Functions
tkDetUtil Namespace Reference

Functions

float calculatePhiWindow (const MeasurementEstimator::Local2DVector &imaxDistance, const TrajectoryStateOnSurface &ts, const Plane &plane)
 
float computeWindowSize (const GeomDet *det, const TrajectoryStateOnSurface &tsos, const MeasurementEstimator &est)
 
bool overlapInPhi (float phi, const GeomDet &det, float phiWindow)
 
bool overlapInPhi (GlobalPoint crossPoint, const GeomDet &det, float phiWindow)
 

Function Documentation

float tkDetUtil::calculatePhiWindow ( const MeasurementEstimator::Local2DVector imaxDistance,
const TrajectoryStateOnSurface ts,
const Plane plane 
)

Definition at line 20 of file TkDetUtil.cc.

References funct::abs(), PV3DBase< T, PVType, FrameType >::barePhi(), constexpr, f, mps_fire::i, likely, TrajectoryStateOnSurface::localPosition(), M_PI, hpstanc_transforms::max, particleFlowClusterHGC_cfi::maxDistance, min(), Plane::normalVector(), Geom::phiLess(), phimax, phimin, trackingPOGFilters_cfi::phiWindow, Geom::pi(), mathSSE::sqrt(), Surface::toGlobal(), RecoTauCleanerPlugins::tolerance, GloballyPositioned< T >::toLocal(), PV2DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::x(), PV2DBase< T, PVType, FrameType >::y(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by computeWindowSize(), and overlapInPhi().

23  {
24  MeasurementEstimator::Local2DVector maxDistance(std::abs(imaxDistance.x()),std::abs(imaxDistance.y()));
25 
26  constexpr float tolerance=1.e-6;
28  // std::cout << "plane z " << plane.normalVector() << std::endl;
29  float dphi=0;
30  if likely(std::abs(1.f-std::abs(plane.normalVector().z()))<tolerance) {
31  auto ori = plane.toLocal(GlobalPoint(0.,0.,0.));
32  auto xc = std::abs(start.x() - ori.x());
33  auto yc = std::abs(start.y() - ori.y());
34 
35  if (yc<maxDistance.y() && xc<maxDistance.x()) return M_PI;
36 
37  auto hori = yc>maxDistance.y(); // quadrant 1 (&2), otherwiase quadrant 1&4
38  auto y0 = hori ? yc + std::copysign(maxDistance.y(), xc - maxDistance.x()) : xc - maxDistance.x();
39  auto x0 = hori ? xc - maxDistance.x() : -yc - maxDistance.y();
40  auto y1 = hori ? yc - maxDistance.y() : xc - maxDistance.x();
41  auto x1 = hori ? xc + maxDistance.x() : -yc + maxDistance.y();
42 
43  auto sp = (x0*x1+y0*y1)/std::sqrt((x0*x0+y0*y0)*(x1*x1+y1*y1));
44  sp = std::min(std::max(sp,-1.f),1.f);
45  dphi = std::acos(sp);
46 
47  return dphi;
48  }
49 
50 
51  // generic algo
52  float corners[] = { plane.toGlobal(LocalPoint( start.x()+maxDistance.x(), start.y()+maxDistance.y() )).barePhi(),
53  plane.toGlobal(LocalPoint( start.x()-maxDistance.x(), start.y()+maxDistance.y() )).barePhi(),
54  plane.toGlobal(LocalPoint( start.x()-maxDistance.x(), start.y()-maxDistance.y() )).barePhi(),
55  plane.toGlobal(LocalPoint( start.x()+maxDistance.x(), start.y()-maxDistance.y() )).barePhi()
56  };
57 
58  float phimin = corners[0];
59  float phimax = phimin;
60  for ( int i = 1; i<4; i++) {
61  float cPhi = corners[i];
62  if ( Geom::phiLess(cPhi, phimin) ) { phimin = cPhi; }
63  if ( Geom::phiLess( phimax, cPhi) ) { phimax = cPhi; }
64  }
65  float phiWindow = phimax - phimin;
66  if ( phiWindow < 0.) { phiWindow += 2.*Geom::pi();}
67  // std::cout << "phiWindow " << phiWindow << ' ' << dphi << ' ' << dphi-phiWindow << std::endl;
68  return phiWindow;
69  }
Definition: start.py:1
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:106
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:32
T y() const
Definition: PV2DBase.h:46
GlobalVector normalVector() const
Definition: Plane.h:41
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
T y() const
Definition: PV3DBase.h:63
#define constexpr
T barePhi() const
Definition: PV3DBase.h:68
#define likely(x)
T sqrt(T t)
Definition: SSEVec.h:18
LocalPoint toLocal(const GlobalPoint &gp) const
T z() const
Definition: PV3DBase.h:64
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double f[11][100]
T min(T a, T b)
Definition: MathUtil.h:58
#define M_PI
bool phiLess(float phi1, float phi2)
Definition: VectorUtil.h:23
constexpr double pi()
Definition: Pi.h:31
T x() const
Definition: PV2DBase.h:45
T x() const
Definition: PV3DBase.h:62
float tkDetUtil::computeWindowSize ( const GeomDet det,
const TrajectoryStateOnSurface tsos,
const MeasurementEstimator est 
)

Definition at line 9 of file TkDetUtil.cc.

References calculatePhiWindow(), particleFlowClusterHGC_cfi::maxDistance, MeasurementEstimator::maximalLocalDisplacement(), and GeomDet::surface().

Referenced by TECLayer::groupedCompatibleDetsV(), TIDRing::groupedCompatibleDetsV(), CompositeTECWedge::groupedCompatibleDetsV(), Phase2EndcapRing::groupedCompatibleDetsV(), and overlapInPhi().

12  {
13  const Plane& startPlane = det->surface();
14  auto maxDistance = est.maximalLocalDisplacement( tsos, startPlane);
15  return std::copysign(calculatePhiWindow(maxDistance, tsos, startPlane),maxDistance.x());
16  }
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:42
Definition: Plane.h:17
virtual Local2DVector maximalLocalDisplacement(const TrajectoryStateOnSurface &ts, const Plane &plane) const =0
float calculatePhiWindow(const MeasurementEstimator::Local2DVector &imaxDistance, const TrajectoryStateOnSurface &ts, const Plane &plane)
Definition: TkDetUtil.cc:20
bool tkDetUtil::overlapInPhi ( float  phi,
const GeomDet det,
float  phiWindow 
)
inline

Definition at line 19 of file TkDetUtil.h.

References Surface::phiSpan(), rangesIntersect(), and GeomDet::surface().

Referenced by overlapInPhi(), CompositeTECWedge::searchNeighbors(), TIDRing::searchNeighbors(), and Phase2EndcapRing::searchNeighbors().

19  {
20  std::pair<float,float> phiRange(phi-phiWindow, phi+phiWindow);
21  return rangesIntersect( phiRange, det.surface().phiSpan(), PhiLess());
22  }
std::pair< float, float > const & phiSpan() const
Definition: Surface.h:123
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:42
bool rangesIntersect(const Range &a, const Range &b)
bool tkDetUtil::overlapInPhi ( GlobalPoint  crossPoint,
const GeomDet det,
float  phiWindow 
)
inline

Definition at line 26 of file TkDetUtil.h.

References PV3DBase< T, PVType, FrameType >::barePhi(), calculatePhiWindow(), computeWindowSize(), particleFlowClusterHGC_cfi::maxDistance, overlapInPhi(), and trackingPOGFilters_cfi::phiWindow.

26  {
27  return overlapInPhi(crossPoint.barePhi(), det,phiWindow);
28  }
T barePhi() const
Definition: PV3DBase.h:68
bool overlapInPhi(GlobalPoint crossPoint, const GeomDet &det, float phiWindow)
Definition: TkDetUtil.h:26