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 TrackerGeometry *tracker,
37  const MagneticField *field,
38  double fixImpactParameter,
39  bool useFixImpactParameter):
40  theTTRHBuilder(ttrhBuilder),
41  theTracker(tracker),
42  theField(field),
43  theFixImpactParameter(fixImpactParameter),
44  theUseFixImpactParameter(useFixImpactParameter)
45 { }
46 
47 std::unique_ptr<reco::Track> PixelFitterByConformalMappingAndLine::run(
48  const std::vector<const TrackingRecHit * > & hits,
49  const TrackingRegion & region,
50  const edm::EventSetup& setup) const
51 {
52 
53  int nhits = hits.size();
54 
55  vector<GlobalPoint> points;
56  vector<GlobalError> errors;
57  vector<bool> isBarrel;
58 
59 
60  for (vector<const TrackingRecHit*>::const_iterator ih=hits.begin(); ih!=hits.end(); ih++) {
62  points.push_back( recHit->globalPosition() );
63  errors.push_back( recHit->globalPositionError() );
64  isBarrel.push_back( recHit->detUnit()->type().isBarrel() );
65  }
66 
67 // if (useMultScatt) {
68 // MultipleScatteringParametrisation ms(hits[i].layer());
69 // float cotTheta = (p.z()-zVtx)/p.perp();
70 // err += sqr( ms( pt, cotTheta, PixelRecoPointRZ(0.,zVtx) ) );
71 // }
72 
73  //
74  // simple fit to get pt, phi0 used for precise calcul.
75  //
76  typedef ConformalMappingFit::PointXY PointXY;
77  vector<PointXY> xy; vector<float> errRPhi2;
78  for (int i=0; i < nhits; ++i) {
79  const GlobalPoint & point = points[i];
80  xy.push_back(PointXY( point.x()-region.origin().x(), point.y()-region.origin().y()));
81  float phiErr2 = errors[i].phierr(point);
82  errRPhi2.push_back( point.perp2()*phiErr2);
83  }
84  ConformalMappingFit parabola(xy, errRPhi2);
87  else if (nhits < 3) parabola.fixImpactParmaeter(0.);
88 
89 
90  Measurement1D curv = parabola.curvature();
91  float invPt = PixelRecoUtilities::inversePt( curv.value(), setup);
92  float valPt = (invPt > 1.e-4) ? 1./invPt : 1.e4;
93  float errPt =PixelRecoUtilities::inversePt(curv.error(), setup) * sqr(valPt);
94  Measurement1D pt (valPt,errPt);
95  Measurement1D phi = parabola.directionPhi();
96  Measurement1D tip = parabola.impactParameter();
97 
98  //
99  // precalculate theta to correct errors:
100  //
101  vector<float> r(nhits),z(nhits),errZ(nhits);
102  float simpleCot = ( points.back().z()-points.front().z() )/ (points.back().perp() - points.front().perp() );
103  for (int i=0; i< nhits; ++i) {
104  const GlobalPoint & point = points[i];
105  const GlobalError & error = errors[i];
106  r[i] = sqrt( sqr(point.x()-region.origin().x()) + sqr(point.y()-region.origin().y()) );
108  z[i] = point.z()-region.origin().z();
109  errZ[i] = (isBarrel[i]) ? sqrt(error.czz()) : sqrt( error.rerr(point) )*simpleCot;
110  }
111 
112  //
113  // line fit (R-Z plane)
114  //
115  RZLine rzLine(r,z,errZ);
116 
117 //
118 // parameters for track builder
119 //
120  Measurement1D zip(rzLine.intercept(), sqrt(rzLine.covii()));
121  Measurement1D cotTheta(rzLine.cotTheta(), sqrt(rzLine.covss()));
122  float chi2 = parabola.chi2() + rzLine.chi2();
123  int charge = parabola.charge();
124 
125 
126  PixelTrackBuilder builder;
127  return std::unique_ptr<reco::Track>(builder.build(pt, phi, cotTheta, tip, zip, chi2, charge, hits, theField, region.origin()));
128 }
129 
130 
Measurement1D curvature() const
GlobalPoint const & origin() const
float cotTheta() const
Definition: RZLine.h:91
bool isBarrel(GeomDetEnumerators::SubDetector m)
T y() const
Definition: PV3DBase.h:63
double error() const
Definition: Measurement1D.h:27
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:2
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)
PixelFitterByConformalMappingAndLine(const TransientTrackingRecHitBuilder *ttrhBuilder, const TrackerGeometry *tracker, const MagneticField *field, double fixImpactParameter, bool useFixImpactParameter)
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 edm::EventSetup &setup) 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:25
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