CMS 3D CMS Logo

ConversionBarrelEstimator.cc
Go to the documentation of this file.
1 #include "CLHEP/Units/GlobalPhysicalConstants.h"
8 
9 // zero value indicates incompatible ts - hit pair
11  const TrackingRecHit& hit) const {
12  std::pair<bool, double> result;
13 
14  //std::cout << " ConversionBarrelEstimator::estimate( const TrajectoryStateOnSurface& ts, const TransientTrackingRecHit& hit) " << std::endl;
15 
16  float tsPhi = ts.globalParameters().position().phi();
17  GlobalPoint gp = hit.globalPosition();
18  float rhPhi = gp.phi();
19 
20  // allow a z fudge of 2 sigma
21  float dz = 2. * sqrt(hit.localPositionError().yy());
22  float zDiff = ts.globalParameters().position().z() - gp.z();
23  float phiDiff = tsPhi - rhPhi;
24  if (phiDiff > pi)
25  phiDiff -= twopi;
26  if (phiDiff < -pi)
27  phiDiff += twopi;
28 
29  // add the errors on the window and the point in quadrature
30  float zrange = sqrt(theZRangeMax * theZRangeMax + dz * dz);
31 
32  /*
33  std::cout << " BarrelEstimator ts local error " <<ts.localError().positionError() << " hit local error " << hit.localPositionError() << std::endl;
34  std::cout << " BarrelEstimator: RecHit at " << gp << " phi " << rhPhi << " eta " << gp.eta() << std::endl;
35  std::cout << " BarrelEstimator: ts at " << ts.globalParameters().position() << " phi " <<ts.globalParameters().position().phi() << " eta " << ts.globalParameters().position().eta()<< std::endl;
36  std::cout << " zrange = +/-" << zrange << ", zDiff = " << zDiff << std::endl;
37  std::cout << " thePhiRangeMin = " << thePhiRangeMin << ", thePhiRangeMax = " << thePhiRangeMax << ", phiDiff = " << phiDiff << std::endl;
38  */
39 
40  if (phiDiff < thePhiRangeMax && phiDiff > thePhiRangeMin && zDiff < zrange && zDiff > -zrange) {
41  // std::cout << " estimator returns 1 with phiDiff " << thePhiRangeMin << " < " << phiDiff << " < "
42  // << thePhiRangeMax << " and zDiff " << zDiff << " < " << zrange << std::endl;
43  // std::cout << " YES " << phiDiff << " " << zDiff << std::endl;
44  // std::cout << " => RECHIT ACCEPTED " << std::endl;
45 
46  result.first = true;
47  result.second = phiDiff;
48  } else {
49  // std::cout << " estimator returns NOT ACCEPTED with phiDiff " << thePhiRangeMin << " < " << phiDiff << " < "
50  //<< thePhiRangeMax << " and zDiff " << zDiff << " < " << theZRangeMax+dz << std::endl;
51 
52  result.first = false;
53  result.second = 0;
54  }
55 
56  return result;
57 }
58 
60  typedef std::pair<float, float> Range;
61  // std::cout << " ConversionBarrelEstimator::estimate( const TrajectoryStateOnSurface& ts, const BoundPlane& plane) " << std::endl;
62 
63  GlobalPoint trajPos(ts.globalParameters().position());
64  Range trajZRange(trajPos.z() - 2. * theZRangeMax, trajPos.z() + 2. * theZRangeMax);
65  Range trajPhiRange(trajPos.phi() + thePhiRangeMin, trajPos.phi() + thePhiRangeMax);
66 
67  if (rangesIntersect(trajZRange, plane.zSpan()) &&
68  rangesIntersect(trajPhiRange, plane.phiSpan(), [](auto x, auto y) { return Geom::phiLess(x, y); })) {
69  // std::cout << " ConversionBarrelEstimator::estimate( const TrajectoryStateOnSurface& ts, const BoundPlane& plane) IN RANGE " << std::endl;
70  return true;
71 
72  } else {
73  // std::cout << " ConversionBarrelEstimator::estimate( const TrajectoryStateOnSurface& ts, const BoundPlane& plane) NOT IN RANGE " << std::endl;
74  return false;
75  }
76 }
77 
79  const TrajectoryStateOnSurface& ts, const BoundPlane& plane) const {
80  /*
81  if ( ts.hasError() ) {
82  LocalError le = ts.localError().positionError();
83  std::cout << " ConversionBarrelEstimator::maximalLocalDisplacent local error " << sqrt(le.xx()) << " " << sqrt(le.yy()) << " nSigma " << nSigmaCut() << " sqrt(le.xx())*nSigmaCut() " << sqrt(le.xx())*nSigmaCut() << " sqrt(le.yy())*nSigmaCut() " << sqrt(le.yy())*nSigmaCut() << std::endl;
84  return Local2DVector( sqrt(le.xx())*nSigmaCut(), sqrt(le.yy())*nSigmaCut());
85  }
86 
87  else return Local2DVector(9999,9999);
88  */
89  return Local2DVector(9999, 9999);
90 }
PixelRecoRange< float > Range
T z() const
Definition: PV3DBase.h:61
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
const GlobalTrajectoryParameters & globalParameters() const
const Double_t pi
T sqrt(T t)
Definition: SSEVec.h:23
Vector2DBase< float, LocalTag > Local2DVector
Local2DVector maximalLocalDisplacement(const TrajectoryStateOnSurface &ts, const Plane &plane) const override
bool phiLess(float phi1, float phi2)
Definition: VectorUtil.h:18
bool rangesIntersect(const Range &a, const Range &b)
std::pair< bool, double > estimate(const TrajectoryStateOnSurface &ts, const TrackingRecHit &hit) const override