CMS 3D CMS Logo

TkDetUtil.cc
Go to the documentation of this file.
1 #include "TkDetUtil.h"
2 
7 
8 namespace tkDetUtil {
9 
10  float computeWindowSize(const GeomDet* det, const TrajectoryStateOnSurface& tsos, const MeasurementEstimator& est) {
11  const Plane& startPlane = det->surface();
12  auto maxDistance = est.maximalLocalDisplacement(tsos, startPlane);
13  return std::copysign(calculatePhiWindow(maxDistance, tsos, startPlane), maxDistance.x());
14  }
15 
17  const TrajectoryStateOnSurface& ts,
18  const Plane& plane) {
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
26  LIKELY(std::abs(1.f - std::abs(plane.normalVector().z())) < tolerance) {
27  auto ori = plane.toLocal(GlobalPoint(0., 0., 0.));
28  auto xc = std::abs(start.x() - ori.x());
29  auto yc = std::abs(start.y() - ori.y());
30 
31  if (yc < maxDistance.y() && xc < maxDistance.x())
32  return M_PI;
33 
34  auto hori = yc > maxDistance.y(); // quadrant 1 (&2), otherwiase quadrant 1&4
35  auto y0 = hori ? yc + std::copysign(maxDistance.y(), xc - maxDistance.x()) : xc - maxDistance.x();
36  auto x0 = hori ? xc - maxDistance.x() : -yc - maxDistance.y();
37  auto y1 = hori ? yc - maxDistance.y() : xc - maxDistance.x();
38  auto x1 = hori ? xc + maxDistance.x() : -yc + maxDistance.y();
39 
40  auto sp = (x0 * x1 + y0 * y1) / std::sqrt((x0 * x0 + y0 * y0) * (x1 * x1 + y1 * y1));
41  sp = std::min(std::max(sp, -1.f), 1.f);
42  dphi = std::acos(sp);
43 
44  return dphi;
45  }
46 
47  // generic algo
48  float corners[] = {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  plane.toGlobal(LocalPoint(start.x() + maxDistance.x(), start.y() - maxDistance.y())).barePhi()};
52 
53  float phimin = corners[0];
54  float phimax = phimin;
55  for (int i = 1; i < 4; i++) {
56  float cPhi = corners[i];
57  if (Geom::phiLess(cPhi, phimin)) {
58  phimin = cPhi;
59  }
60  if (Geom::phiLess(phimax, cPhi)) {
61  phimax = cPhi;
62  }
63  }
64  float phiWindow = phimax - phimin;
65  if (phiWindow < 0.) {
66  phiWindow += 2. * Geom::pi();
67  }
68  // std::cout << "phiWindow " << phiWindow << ' ' << dphi << ' ' << dphi-phiWindow << std::endl;
69  return phiWindow;
70  }
71 
72 } // namespace tkDetUtil
MeasurementEstimator
Definition: MeasurementEstimator.h:19
tkDetUtil::computeWindowSize
float computeWindowSize(const GeomDet *det, const TrajectoryStateOnSurface &tsos, const MeasurementEstimator &est)
Definition: TkDetUtil.cc:10
TrajectoryStateOnSurface.h
mps_fire.i
i
Definition: mps_fire.py:355
start
Definition: start.py:1
particleFlowClusterHGCal_cfi.maxDistance
maxDistance
Definition: particleFlowClusterHGCal_cfi.py:22
GeomDet
Definition: GeomDet.h:27
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
min
T min(T a, T b)
Definition: MathUtil.h:58
phimin
float phimin
Definition: ReggeGribovPartonMCHadronizer.h:107
VectorUtil.h
tkDetUtil::calculatePhiWindow
float calculatePhiWindow(const MeasurementEstimator::Local2DVector &imaxDistance, const TrajectoryStateOnSurface &ts, const Plane &plane)
Definition: TkDetUtil.cc:16
align::LocalPoint
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:30
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
Plane.h
GeomDet::surface
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
testProducerWithPsetDescEmpty_cfi.x1
x1
Definition: testProducerWithPsetDescEmpty_cfi.py:33
testProducerWithPsetDescEmpty_cfi.y1
y1
Definition: testProducerWithPsetDescEmpty_cfi.py:29
MeasurementEstimator.h
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
Surface::toGlobal
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:79
Geom::pi
constexpr double pi()
Definition: Pi.h:31
Vector2DBase
Definition: Vector2DBase.h:8
GlobalPoint
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
tkDetUtil
Definition: TkDetUtil.cc:8
Point3DBase< float, LocalTag >
trackingPOGFilters_cfi.phiWindow
phiWindow
Definition: trackingPOGFilters_cfi.py:109
TkDetUtil.h
TrajectoryStateOnSurface::localPosition
LocalPoint localPosition() const
Definition: TrajectoryStateOnSurface.h:74
Geom::phiLess
bool phiLess(float phi1, float phi2)
Definition: VectorUtil.h:18
PV3DBase::barePhi
T barePhi() const
Definition: PV3DBase.h:65
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
PV2DBase::y
T y() const
Definition: PV2DBase.h:44
PV2DBase::x
T x() const
Definition: PV2DBase.h:43
tolerance
const double tolerance
Definition: HGCalGeomParameters.cc:27
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:50
phimax
float phimax
Definition: ReggeGribovPartonMCHadronizer.h:106
LIKELY
#define LIKELY(x)
Definition: Likely.h:20
GloballyPositioned::toLocal
LocalPoint toLocal(const GlobalPoint &gp) const
Definition: GloballyPositioned.h:98
Plane
Definition: Plane.h:16
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
MeasurementEstimator::maximalLocalDisplacement
virtual Local2DVector maximalLocalDisplacement(const TrajectoryStateOnSurface &ts, const Plane &plane) const =0
Plane::normalVector
GlobalVector normalVector() const
Definition: Plane.h:41