CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 = tsPhi - rhPhi;
58  if (phiDiff > pi) phiDiff -= twopi;
59  if (phiDiff < -pi) phiDiff += twopi;
60 
61  if ( phiDiff < thePhiMax && phiDiff > thePhiMin ) {
62 
63  return std::pair<bool,double>(true,1.);
64  } else {
65 
66  return std::pair<bool,double>(false,0.);
67  }
68 }
69 
70 
71 std::pair<bool,double> BarrelMeasurementEstimator::estimate
72  ( const GlobalPoint & vprim,
73  const TrajectoryStateOnSurface & absolute_ts,
74  const GlobalPoint& absolute_gp ) const
75  {
76  GlobalVector ts = absolute_ts.globalParameters().position() - vprim ;
77  GlobalVector gp = absolute_gp - vprim ;
78 
79  float myR = gp.perp();
80  float myZ = gp.z();
81  float zDiff = myZ -ts.z() ;
82  float myZmax = theZMax;
83  float myZmin = theZMin;
84  if(std::abs(myZ)<30. && myR>8.)
85  {
86  myZmax = 0.09;
87  myZmin = -0.09;
88  }
89 
90 
91  if( zDiff >= myZmax || zDiff <= myZmin ) return std::pair<bool,double>(false,0.);
92 
93  float rhPhi = gp.phi() ;
94  float tsPhi = ts.phi();
95  float phiDiff = normalized_phi(rhPhi-tsPhi) ;
96 
97  if ( phiDiff < thePhiMax && phiDiff > thePhiMin )
98  { return std::pair<bool,double>(true,1.) ; }
99  else
100  { return std::pair<bool,double>(false,0.) ; }
101  }
102 
105  const BoundPlane& plane) const
106  {
107  typedef std::pair<float,float> Range;
108 
109 
110  GlobalPoint trajPos(ts.globalParameters().position());
111  GlobalDetRangeZPhi detRange(plane);
112 
113  Range trajZRange(trajPos.z() - std::abs(theZMin), trajPos.z() + std::abs(theZMax));
114  Range trajPhiRange(trajPos.phi() - std::abs(thePhiMin), trajPos.phi() + std::abs(thePhiMax));
115 
116  if(rangesIntersect(trajZRange, detRange.zRange()) &&
117  rangesIntersect(trajPhiRange, detRange.phiRange(), PhiLess()))
118  {
119  return true;
120  }
121  else
122  {
123  // cout <<cout<<" barrel boundpl est returns false!!"<<endl;
124  // cout<<"BarrelMeasurementEstimator(estimate) :thePhiMin,thePhiMax, theZMin,theZMax "<<thePhiMin<<" "<<thePhiMax<<" "<< theZMin<<" "<<theZMax<<endl;
125  // cout<<" trajZRange "<<trajZRange.first<<" "<<trajZRange.second<<endl;
126  // cout<<" trajPhiRange "<<trajPhiRange.first<<" "<<trajPhiRange.second<<endl;
127  // cout<<" detZRange "<<detRange.zRange().first<<" "<<detRange.zRange().second<<endl;
128  // cout<<" detPhiRange "<<detRange.phiRange().first<<" "<<detRange.phiRange().second<<endl;
129  // cout<<" intersect z: "<<rangesIntersect(trajZRange, detRange.zRange())<<endl;
130  // cout<<" intersect phi: "<<rangesIntersect(trajPhiRange, detRange.phiRange(), PhiLess())<<endl;
131  return false ;
132  }
133 
134  }
135 
139  const BoundPlane & plane) const
140  {
141  float nSigmaCut = 3. ;
142  if ( ts.hasError())
143  {
144  LocalError le = ts.localError().positionError() ;
145  return Local2DVector( sqrt(le.xx())*nSigmaCut, sqrt(le.yy())*nSigmaCut) ;
146  }
147  else return Local2DVector(99999,99999) ;
148  }
149 
150 
151 
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
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
Vector2DBase< float, LocalTag > Local2DVector
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:40
LocalError positionError() const
const Double_t pi
float yy() const
Definition: LocalError.h:26
const GeomDet * det() const
RealType normalized_phi(RealType phi)
T sqrt(T t)
Definition: SSEVec.h:18
bool rangesIntersect(const Range &a, const Range &b)
T z() const
Definition: PV3DBase.h:64
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const LocalTrajectoryError & localError() const
const GlobalTrajectoryParameters & globalParameters() const
virtual std::pair< bool, double > estimate(const TrajectoryStateOnSurface &ts, const TrackingRecHit &hit) const
volatile std::atomic< bool > shutdown_flag false
virtual LocalPoint localPosition() const =0
MeasurementEstimator::Local2DVector maximalLocalDisplacement(const TrajectoryStateOnSurface &ts, const BoundPlane &plane) const