CMS 3D CMS Logo

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