CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 16 of file TkDetUtil.cc.

References funct::abs(), PV3DBase< T, PVType, FrameType >::barePhi(), validate-o2o-wbm::f, mps_fire::i, LIKELY, TrajectoryStateOnSurface::localPosition(), M_PI, SiStripPI::max, min(), Plane::normalVector(), Geom::phiLess(), phimax, phimin, Geom::pi(), mathSSE::sqrt(), command_line::start, Surface::toGlobal(), 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().

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

Definition at line 10 of file TkDetUtil.cc.

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

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

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

Definition at line 18 of file TkDetUtil.h.

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

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

18  {
19  std::pair<float, float> phiRange(phi - phiWindow, phi + phiWindow);
20  return rangesIntersect(phiRange, det.surface().phiSpan(), [](auto x, auto y) { return Geom::phiLess(x, y); });
21  }
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
uint16_t const *__restrict__ x
Definition: gpuClustering.h:39
std::pair< float, float > const & phiSpan() const
Definition: Surface.h:90
bool phiLess(float phi1, float phi2)
Definition: VectorUtil.h:18
bool rangesIntersect(const Range &a, const Range &b)
bool tkDetUtil::overlapInPhi ( GlobalPoint  crossPoint,
const GeomDet det,
float  phiWindow 
)
inline

Definition at line 23 of file TkDetUtil.h.

References PV3DBase< T, PVType, FrameType >::barePhi(), and overlapInPhi().

23  {
24  return overlapInPhi(crossPoint.barePhi(), det, phiWindow);
25  }
bool overlapInPhi(float phi, const GeomDet &det, float phiWindow)
Definition: TkDetUtil.h:18
T barePhi() const
Definition: PV3DBase.h:65