CMS 3D CMS Logo

BarrelMeasurementEstimator.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: EgammaElectronAlgos
4 // Class: BarrelMeasurementEstimator
5 //
13 //
14 // Original Author: Ursula Berthon, Claude Charlot
15 // Created: Mon Mar 27 13:22:06 CEST 2006
16 //
17 //
18 
25 
26 
27 // zero value indicates incompatible ts - hit pair
29  const TrackingRecHit& hit) const {
30  LocalPoint lp = hit.localPosition();
31  GlobalPoint gp = hit.det()->surface().toGlobal( lp);
32  return this->estimate(ts,gp);
33 }
34 
35 //usable in case we have no TransientTrackingRecHit
37  const GlobalPoint &gp) const {
38 
39  float myZ = gp.z();
40  float myR = gp.perp();
41  float zDiff = ts.globalParameters().position().z() - myZ;
42 
43  float myZmax = theZMax;
44  float myZmin = theZMin;
45 
46  if(std::abs(myZ)<30. && myR>8.) {
47  myZmax = 0.09;
48  myZmin = -0.09;
49  }
50 
51  if( zDiff >= myZmax || zDiff <= myZmin ) return std::pair<bool,double>(false,0.);
52 
53  float tsPhi = ts.globalParameters().position().phi();
54 
55  float rhPhi = gp.phi();
56 
57  float phiDiff = normalizedPhi(tsPhi - rhPhi);
58 
59  if ( phiDiff < thePhiMax && phiDiff > thePhiMin ) {
60 
61  return std::pair<bool,double>(true,1.);
62  } else {
63 
64  return std::pair<bool,double>(false,0.);
65  }
66 }
67 
68 
69 std::pair<bool,double> BarrelMeasurementEstimator::estimate
70  ( const GlobalPoint & vprim,
71  const TrajectoryStateOnSurface & absolute_ts,
72  const GlobalPoint& absolute_gp ) const
73  {
74  GlobalVector ts = absolute_ts.globalParameters().position() - vprim ;
75  GlobalVector gp = absolute_gp - vprim ;
76 
77  float myR = gp.perp();
78  float myZ = gp.z();
79  float zDiff = myZ -ts.z() ;
80  float myZmax = theZMax;
81  float myZmin = theZMin;
82  if( (std::abs(myZ)<30.f) & (myR>8.f) )
83  {
84  myZmax = 0.09f;
85  myZmin = -0.09f;
86  }
87 
88 
89  if( zDiff >= myZmax || zDiff <= myZmin ) return std::pair<bool,double>(false,0.);
90 
91  float rhPhi = gp.barePhi() ;
92  float tsPhi = ts.barePhi();
93  float phiDiff = normalizedPhi(rhPhi-tsPhi) ;
94 
95  if ( (phiDiff < thePhiMax) & (phiDiff > thePhiMin) )
96  { return std::pair<bool,double>(true,1.) ; }
97  else
98  { return std::pair<bool,double>(false,0.) ; }
99  }
100 
103  const BoundPlane& plane) const
104  {
105  typedef std::pair<float,float> Range;
106 
107 
108  GlobalPoint trajPos(ts.globalParameters().position());
109 
110  Range trajZRange(trajPos.z() - std::abs(theZMin), trajPos.z() + std::abs(theZMax));
111  Range trajPhiRange(trajPos.phi() - std::abs(thePhiMin), trajPos.phi() + std::abs(thePhiMax));
112 
113  if(rangesIntersect(trajZRange, plane.zSpan()) &&
114  rangesIntersect(trajPhiRange, plane.phiSpan(), [](auto x,auto y){ return Geom::phiLess(x, y);}))
115  {
116  return true;
117  }
118  else
119  {
120  // cout <<cout<<" barrel boundpl est returns false!!"<<endl;
121  // cout<<"BarrelMeasurementEstimator(estimate) :thePhiMin,thePhiMax, theZMin,theZMax "<<thePhiMin<<" "<<thePhiMax<<" "<< theZMin<<" "<<theZMax<<endl;
122  // cout<<" trajZRange "<<trajZRange.first<<" "<<trajZRange.second<<endl;
123  // cout<<" trajPhiRange "<<trajPhiRange.first<<" "<<trajPhiRange.second<<endl;
124  // cout<<" detZRange "<<detRange.zRange().first<<" "<<detRange.zRange().second<<endl;
125  // cout<<" detPhiRange "<<detRange.phiRange().first<<" "<<detRange.phiRange().second<<endl;
126  // cout<<" intersect z: "<<rangesIntersect(trajZRange, detRange.zRange())<<endl;
127  // cout<<" intersect phi: "<<rangesIntersect(trajPhiRange, detRange.phiRange(), PhiLess())<<endl;
128  return false ;
129  }
130 
131  }
132 
136  const BoundPlane & plane) const
137  {
138  float nSigmaCut = 3. ;
139  if ( ts.hasError())
140  {
141  LocalError le = ts.localError().positionError() ;
142  return Local2DVector( std::sqrt(le.xx())*nSigmaCut, std::sqrt(le.yy())*nSigmaCut) ;
143  }
144  else return Local2DVector(99999,99999) ;
145  }
146 
147 
148 
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:106
float xx() const
Definition: LocalError.h:24
T perp() const
Definition: PV3DBase.h:72
PixelRecoRange< float > Range
constexpr T normalizedPhi(T phi)
Definition: normalizedPhi.h:9
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:42
LocalError positionError() const
T barePhi() const
Definition: PV3DBase.h:68
float yy() const
Definition: LocalError.h:26
Vector2DBase< float, LocalTag > Local2DVector
const GeomDet * det() const
T sqrt(T t)
Definition: SSEVec.h:18
bool rangesIntersect(const Range &a, const Range &b)
MeasurementEstimator::Local2DVector maximalLocalDisplacement(const TrajectoryStateOnSurface &ts, const BoundPlane &plane) const override
T z() const
Definition: PV3DBase.h:64
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double f[11][100]
const LocalTrajectoryError & localError() const
virtual LocalPoint localPosition() const =0
bool phiLess(float phi1, float phi2)
Definition: VectorUtil.h:23
const GlobalTrajectoryParameters & globalParameters() const
std::pair< bool, double > estimate(const TrajectoryStateOnSurface &ts, const TrackingRecHit &hit) const override