test
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 
14 
15 
24 
27 
28 #include "ConformalMappingFit.h"
30 #include "RZLine.h"
31 
34 
35 using namespace std;
36 
37 template <class T> T sqr( T t) {return t*t;}
38 
39 
41  const edm::ParameterSet& cfg) : theConfig(cfg)
42 { }
43 
45 { }
46 
48  const edm::EventSetup& es,
49  const std::vector<const TrackingRecHit * > & hits,
50  const TrackingRegion & region) const
51 {
52 
53  int nhits = hits.size();
54 
55  vector<GlobalPoint> points;
56  vector<GlobalError> errors;
57  vector<bool> isBarrel;
58 
59 
61  es.get<TrackerDigiGeometryRecord>().get(tracker);
62 
64  es.get<IdealMagneticFieldRecord>().get(field);
65 
67  string ttrhBuilderName = theConfig.getParameter<std::string>("TTRHBuilder");
68  es.get<TransientRecHitRecord>().get( ttrhBuilderName, ttrhBuilder);
69 
70  for (vector<const TrackingRecHit*>::const_iterator ih=hits.begin(); ih!=hits.end(); ih++) {
71  TransientTrackingRecHit::RecHitPointer recHit = ttrhBuilder->build(*ih);
72  points.push_back( recHit->globalPosition() );
73  errors.push_back( recHit->globalPositionError() );
74  isBarrel.push_back( recHit->detUnit()->type().isBarrel() );
75  }
76 
77 // if (useMultScatt) {
78 // MultipleScatteringParametrisation ms(hits[i].layer());
79 // float cotTheta = (p.z()-zVtx)/p.perp();
80 // err += sqr( ms( pt, cotTheta, PixelRecoPointRZ(0.,zVtx) ) );
81 // }
82 
83  //
84  // simple fit to get pt, phi0 used for precise calcul.
85  //
86  typedef ConformalMappingFit::PointXY PointXY;
87  vector<PointXY> xy; vector<float> errRPhi2;
88  for (int i=0; i < nhits; ++i) {
89  const GlobalPoint & point = points[i];
90  xy.push_back(PointXY( point.x()-region.origin().x(), point.y()-region.origin().y()));
91  float phiErr2 = errors[i].phierr(point);
92  errRPhi2.push_back( point.perp2()*phiErr2);
93  }
94  ConformalMappingFit parabola(xy, errRPhi2);
95  if (theConfig.exists("fixImpactParameter"))
96  parabola.fixImpactParmaeter(theConfig.getParameter<double>("fixImpactParameter"));
97  else if (nhits < 3) parabola.fixImpactParmaeter(0.);
98 
99 
100  Measurement1D curv = parabola.curvature();
101  float invPt = PixelRecoUtilities::inversePt( curv.value(), es);
102  float valPt = (invPt > 1.e-4) ? 1./invPt : 1.e4;
103  float errPt =PixelRecoUtilities::inversePt(curv.error(), es) * sqr(valPt);
104  Measurement1D pt (valPt,errPt);
105  Measurement1D phi = parabola.directionPhi();
106  Measurement1D tip = parabola.impactParameter();
107 
108  //
109  // precalculate theta to correct errors:
110  //
111  vector<float> r(nhits),z(nhits),errZ(nhits);
112  float simpleCot = ( points.back().z()-points.front().z() )/ (points.back().perp() - points.front().perp() );
113  for (int i=0; i< nhits; ++i) {
114  const GlobalPoint & point = points[i];
115  const GlobalError & error = errors[i];
116  r[i] = sqrt( sqr(point.x()-region.origin().x()) + sqr(point.y()-region.origin().y()) );
118  z[i] = point.z()-region.origin().z();
119  errZ[i] = (isBarrel[i]) ? sqrt(error.czz()) : sqrt( error.rerr(point) )*simpleCot;
120  }
121 
122  //
123  // line fit (R-Z plane)
124  //
125  RZLine rzLine(r,z,errZ);
126  float cottheta, intercept, covss, covii, covsi;
127  rzLine.fit(cottheta, intercept, covss, covii, covsi);
128 
129 //
130 // parameters for track builder
131 //
132  Measurement1D zip(intercept, sqrt(covii));
133  Measurement1D cotTheta(cottheta, sqrt(covss));
134  float chi2 = parabola.chi2() + rzLine.chi2(cottheta, intercept);
135  int charge = parabola.charge();
136 
137 
138  PixelTrackBuilder builder;
139  return builder.build(pt, phi, cotTheta, tip, zip, chi2, charge, hits, field.product(), region.origin());
140 }
141 
142 
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
Measurement1D curvature() const
tuple cfg
Definition: looper.py:293
GlobalPoint const & origin() const
bool isBarrel(GeomDetEnumerators::SubDetector m)
T y() const
Definition: PV3DBase.h:63
bool exists(std::string const &parameterName) const
checks if a parameter exists
double error() const
Definition: Measurement1D.h:30
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::shared_ptr< TrackingRecHit const > RecHitPointer
void fixImpactParmaeter(double ip)
Definition: RZLine.h:8
T rerr(const GlobalPoint &aPoint) const
const T & get() const
Definition: EventSetup.h:56
T const * product() const
Definition: ESHandle.h:86
double value() const
Definition: Measurement1D.h:28
Square< F >::type sqr(const F &f)
Definition: Square.h:13
void fit(float &cotTheta, float &intercept, float &covss, float &covii, float &covsi) const
Definition: RZLine.cc:44
float chi2(float cotTheta, float intercept) const
Definition: RZLine.cc:50
virtual reco::Track * run(const edm::EventSetup &es, const std::vector< const TrackingRecHit * > &hits, const TrackingRegion &region) const
long double T
T x() const
Definition: PV3DBase.h:62
*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