CMS 3D CMS Logo

PixelFitterByConformalMappingAndLine.cc
Go to the documentation of this file.
2 
5 
8 
9 
13 
14 
19 
22 
23 #include "ConformalMappingFit.h"
26 
29 
30 using namespace std;
31 
32 template <class T> T sqr( T t) {return t*t;}
33 
34 
36  const TransientTrackingRecHitBuilder *ttrhBuilder,
37  const TrackerGeometry *tracker,
38  const MagneticField *field,
39  double fixImpactParameter,
40  bool useFixImpactParameter):
41  theES(es),
42  theTTRHBuilder(ttrhBuilder),
43  theTracker(tracker),
44  theField(field),
45  theFixImpactParameter(fixImpactParameter),
46  theUseFixImpactParameter(useFixImpactParameter)
47 { }
48 
49 std::unique_ptr<reco::Track> PixelFitterByConformalMappingAndLine::run(
50  const std::vector<const TrackingRecHit * > & hits,
51  const TrackingRegion & region) const
52 {
53 
54  int nhits = hits.size();
55 
56  vector<GlobalPoint> points;
57  vector<GlobalError> errors;
58  vector<bool> isBarrel;
59 
60 
61  for (vector<const TrackingRecHit*>::const_iterator ih=hits.begin(); ih!=hits.end(); ih++) {
63  points.push_back( recHit->globalPosition() );
64  errors.push_back( recHit->globalPositionError() );
65  isBarrel.push_back( recHit->detUnit()->type().isBarrel() );
66  }
67 
68 // if (useMultScatt) {
69 // MultipleScatteringParametrisation ms(hits[i].layer());
70 // float cotTheta = (p.z()-zVtx)/p.perp();
71 // err += sqr( ms( pt, cotTheta, PixelRecoPointRZ(0.,zVtx) ) );
72 // }
73 
74  //
75  // simple fit to get pt, phi0 used for precise calcul.
76  //
77  typedef ConformalMappingFit::PointXY PointXY;
78  vector<PointXY> xy; vector<float> errRPhi2;
79  for (int i=0; i < nhits; ++i) {
80  const GlobalPoint & point = points[i];
81  xy.push_back(PointXY( point.x()-region.origin().x(), point.y()-region.origin().y()));
82  float phiErr2 = errors[i].phierr(point);
83  errRPhi2.push_back( point.perp2()*phiErr2);
84  }
85  ConformalMappingFit parabola(xy, errRPhi2);
88  else if (nhits < 3) parabola.fixImpactParmaeter(0.);
89 
90 
91  Measurement1D curv = parabola.curvature();
92  float invPt = PixelRecoUtilities::inversePt( curv.value(), *theES);
93  float valPt = (invPt > 1.e-4) ? 1./invPt : 1.e4;
94  float errPt =PixelRecoUtilities::inversePt(curv.error(), *theES) * sqr(valPt);
95  Measurement1D pt (valPt,errPt);
96  Measurement1D phi = parabola.directionPhi();
97  Measurement1D tip = parabola.impactParameter();
98 
99  //
100  // precalculate theta to correct errors:
101  //
102  vector<float> r(nhits),z(nhits),errZ(nhits);
103  float simpleCot = ( points.back().z()-points.front().z() )/ (points.back().perp() - points.front().perp() );
104  for (int i=0; i< nhits; ++i) {
105  const GlobalPoint & point = points[i];
106  const GlobalError & error = errors[i];
107  r[i] = sqrt( sqr(point.x()-region.origin().x()) + sqr(point.y()-region.origin().y()) );
109  z[i] = point.z()-region.origin().z();
110  errZ[i] = (isBarrel[i]) ? sqrt(error.czz()) : sqrt( error.rerr(point) )*simpleCot;
111  }
112 
113  //
114  // line fit (R-Z plane)
115  //
116  RZLine rzLine(r,z,errZ);
117 
118 //
119 // parameters for track builder
120 //
121  Measurement1D zip(rzLine.intercept(), sqrt(rzLine.covii()));
122  Measurement1D cotTheta(rzLine.cotTheta(), sqrt(rzLine.covss()));
123  float chi2 = parabola.chi2() + rzLine.chi2();
124  int charge = parabola.charge();
125 
126 
127  PixelTrackBuilder builder;
128  return std::unique_ptr<reco::Track>(builder.build(pt, phi, cotTheta, tip, zip, chi2, charge, hits, theField, region.origin()));
129 }
130 
131 
PixelFitterByConformalMappingAndLine(const edm::EventSetup *es, const TransientTrackingRecHitBuilder *ttrhBuilder, const TrackerGeometry *tracker, const MagneticField *field, double fixImpactParameter, bool useFixImpactParameter)
Measurement1D curvature() const
GlobalPoint const & origin() const
float cotTheta() const
Definition: RZLine.h:91
T y() const
Definition: PV3DBase.h:63
double error() const
Definition: Measurement1D.h:30
float intercept() const
Definition: RZLine.h:92
Measurement1D directionPhi() const
T perp2() const
Definition: PV3DBase.h:71
T inversePt(T curvature, const edm::EventSetup &iSetup)
Measurement1D impactParameter() const
OutputIterator zip(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp)
T sqrt(T t)
Definition: SSEVec.h:18
T z() const
Definition: PV3DBase.h:64
reco::Track * build(const Measurement1D &pt, const Measurement1D &phi, const Measurement1D &cotTheta, const Measurement1D &tip, const Measurement1D &zip, float chi2, int charge, const std::vector< const TrackingRecHit * > &hits, const MagneticField *mf, const GlobalPoint &reference=GlobalPoint(0, 0, 0)) const
std::unique_ptr< reco::Track > run(const std::vector< const TrackingRecHit * > &hits, const TrackingRegion &region) const override
std::shared_ptr< TrackingRecHit const > RecHitPointer
virtual RecHitPointer build(const TrackingRecHit *p) const =0
build a tracking rechit from an existing rechit
void fixImpactParmaeter(double ip)
Definition: RZLine.h:12
T rerr(const GlobalPoint &aPoint) const
double value() const
Definition: Measurement1D.h:28
long double T
T x() const
Definition: PV3DBase.h:62
float chi2() const
Definition: RZLine.h:97
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5
float covii() const
Definition: RZLine.h:94
const TransientTrackingRecHitBuilder * theTTRHBuilder
float covss() const
Definition: RZLine.h:93