test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TkDetUtil.cc
Go to the documentation of this file.
1 #include "TkDetUtil.h"
2 
6 
7 namespace tkDetUtil {
8 
9  float computeWindowSize( const GeomDet* det,
10  const TrajectoryStateOnSurface& tsos,
11  const MeasurementEstimator& est)
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  }
17 
18 
19  float
21  const TrajectoryStateOnSurface& ts,
22  const Plane& plane)
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  }
70 
71 
72 
73 
74 }
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:106
int i
Definition: DBlmapReader.cc:9
tuple start
Check for commandline option errors.
Definition: dqm_diff.py:58
T y() const
Definition: PV2DBase.h:46
GlobalVector normalVector() const
Definition: Plane.h:41
virtual Local2DVector maximalLocalDisplacement(const TrajectoryStateOnSurface &ts, const Plane &plane) const =0
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
T y() const
Definition: PV3DBase.h:63
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:40
Definition: Plane.h:17
#define constexpr
float computeWindowSize(const GeomDet *det, const TrajectoryStateOnSurface &tsos, const MeasurementEstimator &est)
Definition: TkDetUtil.cc:9
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
double pi()
Definition: Pi.h:31
Local3DPoint LocalPoint
Definition: LocalPoint.h:11
Definition: sp.h:21
T x() const
Definition: PV2DBase.h:45
T x() const
Definition: PV3DBase.h:62
float calculatePhiWindow(const MeasurementEstimator::Local2DVector &imaxDistance, const TrajectoryStateOnSurface &ts, const Plane &plane)
Definition: TkDetUtil.cc:20