CMS 3D CMS Logo

OuterDetCompatibility.cc
Go to the documentation of this file.
4 
5 using namespace std;
6 
7 bool OuterDetCompatibility::operator()(const BoundPlane& plane) const {
8  if (barrel) {
9  if (!checkPhi(plane.phiSpan()))
10  return false;
11  if (!checkZ(plane.zSpan()))
12  return false;
13  } else {
14  if (!checkPhi(plane.phiSpan()))
15  return false;
16  if (!checkR(plane.rSpan()))
17  return false;
18  }
19  return true;
20 }
21 
23  return rangesIntersect(detPhiRange, hitDetPhiRange, [](auto x, auto y) { return Geom::phiLess(x, y); });
24 }
25 
26 bool OuterDetCompatibility::checkR(const Range& detRRange) const { return rangesIntersect(detRRange, hitDetRRange); }
27 
28 bool OuterDetCompatibility::checkZ(const Range& detZRange) const { return rangesIntersect(detZRange, hitDetZRange); }
29 
31  float phi = hitDetPhiRange.mean();
32  float r = hitDetRRange.mean();
33  return GlobalPoint(r * cos(phi), r * sin(phi), hitDetZRange.mean());
34 }
35 
37  const BoundPlane& plane) const {
38  float x_loc = 0.;
39  float y_loc = 0.;
40  if (barrel) {
41  double radius = ts.perp();
42  GlobalVector planeNorm = plane.normalVector();
43  GlobalVector tsDir = GlobalVector(ts.x(), ts.y(), 0.).unit();
44  double ts_phi = tsDir.phi();
45  if (!hitDetPhiRange.inside(ts_phi)) {
46  while (ts_phi >= hitDetPhiRange.max())
47  ts_phi -= 2 * M_PI;
48  while (ts_phi < hitDetPhiRange.min())
49  ts_phi += 2 * M_PI;
50  if (!hitDetPhiRange.inside(ts_phi))
52  }
53  double cosGamma = tsDir.dot(planeNorm);
54 
55  double dx1 = loc_dist(radius, ts_phi, hitDetPhiRange.min(), cosGamma);
56  double dx2 = loc_dist(radius, ts_phi, hitDetPhiRange.max(), cosGamma);
57 
58  double ts_z = ts.z();
59  double dy1 = ts_z - hitDetZRange.min();
60  double dy2 = hitDetZRange.max() - ts_z;
61 
62  x_loc = max(dx1, dx2);
63  y_loc = max(dy1, dy2);
64 
65  // debug only
66  /*
67  double r1 = dx1 * fabs(cosGamma) / sin(ts_phi-hitDetPhiRange.min());
68  double r2 = dx2 * fabs(cosGamma) / sin(hitDetPhiRange.max()-ts_phi);
69  GlobalPoint p1( r1* cos(hitDetPhiRange.min()), r1 * sin(hitDetPhiRange.min()), hitDetZRange.min());
70  GlobalPoint p2( r2* cos(hitDetPhiRange.max()), r2 * sin(hitDetPhiRange.max()), hitDetZRange.min());
71  GlobalPoint p3( r1* cos(hitDetPhiRange.min()), r1 * sin(hitDetPhiRange.min()), hitDetZRange.max());
72  GlobalPoint p4( r2* cos(hitDetPhiRange.max()), r2 * sin(hitDetPhiRange.max()), hitDetZRange.max());
73  cout << " Local1: " << plane.toLocal(ts-p1) << endl;
74  cout << " Local2: " << plane.toLocal(ts-p2) << endl;
75  cout << " Local3: " << plane.toLocal(ts-p3) << endl;
76  cout << " Local4: " << plane.toLocal(ts-p4) << endl;
77 */
78  } else {
79  LocalPoint ts_loc = plane.toLocal(ts);
80  GlobalVector planeNorm = plane.normalVector();
81 
82  double x_glob[4], y_glob[4], z_glob[4];
83  x_glob[0] = hitDetRRange.min() * cos(hitDetPhiRange.min());
84  y_glob[0] = hitDetRRange.min() * sin(hitDetPhiRange.min());
85  x_glob[1] = hitDetRRange.max() * cos(hitDetPhiRange.min());
86  y_glob[1] = hitDetRRange.max() * sin(hitDetPhiRange.min());
87  x_glob[2] = hitDetRRange.min() * cos(hitDetPhiRange.max());
88  y_glob[2] = hitDetRRange.min() * sin(hitDetPhiRange.max());
89  x_glob[3] = hitDetRRange.max() * cos(hitDetPhiRange.max());
90  y_glob[3] = hitDetRRange.max() * sin(hitDetPhiRange.max());
91 
92  for (int idx = 0; idx < 4; idx++) {
93  double dx_glob = x_glob[idx] - ts.x();
94  double dy_glob = y_glob[idx] - ts.y();
95  double dz_glob = -(dx_glob * planeNorm.x() + dy_glob * planeNorm.y()) / planeNorm.z();
96  z_glob[idx] = dz_glob + ts.z();
97  }
98 
99  for (int idx = 0; idx < 4; idx++) {
100  LocalPoint lp = plane.toLocal(GlobalPoint(x_glob[idx], y_glob[idx], z_glob[idx]));
101  x_loc = max(x_loc, fabs(lp.x() - ts_loc.x()));
102  y_loc = max(y_loc, fabs(lp.y() - ts_loc.y()));
103  }
104  }
106  return distance;
107 }
108 
109 double OuterDetCompatibility::loc_dist(double radius, double ts_phi, double range_phi, double cosGamma) const {
110  double sinDphi = sin(ts_phi - range_phi);
111  double cosDphi = sqrt(1 - sinDphi * sinDphi);
112  double sinGamma = sqrt(1 - cosGamma * cosGamma);
113  double sinBeta = fabs(cosDphi * cosGamma - sinDphi * sinGamma);
114  return radius * fabs(sinDphi) / sinBeta;
115 }
Vector3DBase
Definition: Vector3DBase.h:8
Reference_intrackfit_cff.barrel
list barrel
Definition: Reference_intrackfit_cff.py:37
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
VectorUtil.h
OuterDetCompatibility::checkZ
bool checkZ(const Range &detZRange) const
Definition: OuterDetCompatibility.cc:28
GlobalVector
Global3DVector GlobalVector
Definition: GlobalVector.h:10
OuterDetCompatibility::loc_dist
double loc_dist(double radius, double ts_phi, double range_phi, double cosGamma) const
Definition: OuterDetCompatibility.cc:109
OuterDetCompatibility.h
heavyIonCSV_trainingSettings.idx
idx
Definition: heavyIonCSV_trainingSettings.py:5
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
Vector3DBase::unit
Vector3DBase unit() const
Definition: Vector3DBase.h:54
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
Vector2DBase
Definition: Vector2DBase.h:8
GlobalPoint
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
OuterDetCompatibility::checkR
bool checkR(const Range &detRRange) const
Definition: OuterDetCompatibility.cc:26
Point3DBase< float, GlobalTag >
PixelRecoRange< float >
Geom::phiLess
bool phiLess(float phi1, float phi2)
Definition: VectorUtil.h:18
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
OuterDetCompatibility::maximalLocalDisplacement
MeasurementEstimator::Local2DVector maximalLocalDisplacement(const TrajectoryStateOnSurface &ts, const BoundPlane &plane) const
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:49
Vector3DBase::dot
PreciseFloatType< T, U >::Type dot(const Vector3DBase< U, FrameTag > &v) const
Definition: Vector3DBase.h:99
alignCSCRings.r
r
Definition: alignCSCRings.py:93
std
Definition: JetResolutionObject.h:76
BoundPlane
CosmicsPD_Skims.radius
radius
Definition: CosmicsPD_Skims.py:135
rangesIntersect
bool rangesIntersect(const Range &a, const Range &b)
Definition: rangesIntersect.h:14
OuterDetCompatibility::center
GlobalPoint center() const
Definition: OuterDetCompatibility.cc:30
OuterDetCompatibility::checkPhi
bool checkPhi(const OuterHitPhiPrediction::Range &detPhiRange) const
Definition: OuterDetCompatibility.cc:22
HLT_FULL_cff.distance
distance
Definition: HLT_FULL_cff.py:7746
rangesIntersect.h
PV3DBase::perp
T perp() const
Definition: PV3DBase.h:69
PV3DBase::phi
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
OuterDetCompatibility::operator()
bool operator()(const BoundPlane &plane) const
Definition: OuterDetCompatibility.cc:7