CMS 3D CMS Logo

PixelFitterByHelixProjections.cc
Go to the documentation of this file.
3 
5 
9 
13 //#include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h"
15 
18 
21 
23 
25 
31 
34 
36 
37 using namespace std;
38 
39 namespace {
40 
41  int charge(DynArray<GlobalPoint> const& points) {
42  // the cross product will tell me...
43  float dir = (points[1].x() - points[0].x()) * (points[2].y() - points[1].y()) -
44  (points[1].y() - points[0].y()) * (points[2].x() - points[1].x());
45 
46  /*
47  GlobalVector v21 = points[1]-points[0];
48  GlobalVector v32 = points[2]-points[1];
49  float dphi = v32.phi() - v21.phi();
50  while (dphi > Geom::fpi()) dphi -= Geom::ftwoPi();
51  while (dphi < -Geom::fpi()) dphi += Geom::ftwoPi();
52  return (dphi > 0) ? -1 : 1;
53  */
54  return (dir > 0) ? -1 : 1;
55  }
56 
57  float cotTheta(const GlobalPoint& inner, const GlobalPoint& outer) {
58  float dr = outer.perp() - inner.perp();
59  float dz = outer.z() - inner.z();
60  return (std::abs(dr) > 1.e-3f) ? dz / dr : 0;
61  }
62 
63  inline float phi(float xC, float yC, int charge) { return (charge > 0) ? std::atan2(xC, -yC) : std::atan2(-xC, yC); }
64 
65  float zip(float d0, float phi_p, float curv, const GlobalPoint& pinner, const GlobalPoint& pouter) {
66  //
67  //phi = asin(r*rho/2) with asin(x) ~= x+x**3/(2*3) = x(1+x*x/6);
68  //
69 
70  float phi0 = phi_p - Geom::fhalfPi();
71  GlobalPoint pca(d0 * std::cos(phi0), d0 * std::sin(phi0), 0.);
72 
73  constexpr float o24 = 1.f / 24.f;
74  float rho2 = curv * curv;
75  float r1s = (pinner - pca).perp2();
76  double phi1 = std::sqrt(r1s) * (curv * 0.5f) * (1.f + r1s * (rho2 * o24));
77  float r2s = (pouter - pca).perp2();
78  double phi2 = std::sqrt(r2s) * (curv * 0.5f) * (1.f + r2s * (rho2 * o24));
79  double z1 = pinner.z();
80  double z2 = pouter.z();
81 
82  if (fabs(curv) > 1.e-5)
83  return z1 - phi1 / (phi1 - phi2) * (z1 - z2);
84  else {
85  double dr = std::max(std::sqrt(r2s) - std::sqrt(r1s), 1.e-5f);
86  return z1 - std::sqrt(r1s) * (z2 - z1) / dr;
87  }
88  }
89 } // namespace
90 
92  const MagneticField* field,
94  float scaleFactor)
95  : theField(field), thescaleErrorsForBPix1(scaleErrorsForBPix1), thescaleFactor(scaleFactor) {
96  //Retrieve tracker topology from geometry
98  es->get<TrackerTopologyRcd>().get(tTopo);
99  theTopo = tTopo.product();
100 }
101 
102 std::unique_ptr<reco::Track> PixelFitterByHelixProjections::run(const std::vector<const TrackingRecHit*>& hits,
103  const TrackingRegion& region,
104  const edm::EventSetup& setup) const {
105  std::unique_ptr<reco::Track> ret;
106 
107  int nhits = hits.size();
108  if (nhits < 2)
109  return ret;
110 
114 
115  for (int i = 0; i != nhits; ++i) {
116  auto const& recHit = hits[i];
117  points[i] = GlobalPoint(recHit->globalPosition().basicVector() - region.origin().basicVector());
118  errors[i] = recHit->globalPositionError();
119  isBarrel[i] = recHit->detUnit()->type().isBarrel();
120  }
121 
122  CircleFromThreePoints circle = (nhits == 2) ? CircleFromThreePoints(GlobalPoint(0., 0., 0.), points[0], points[1])
124 
125  float valPhi, valTip, valPt;
126 
127  int iCharge = charge(points);
128  float curvature = circle.curvature();
129 
130  if ((curvature > 1.e-4) && (LIKELY(PixelRecoUtilities::fieldInInvGev(setup) > 0.01))) {
131  float invPt = PixelRecoUtilities::inversePt(circle.curvature(), setup);
132  valPt = (invPt > 1.e-4f) ? 1.f / invPt : 1.e4f;
133  CircleFromThreePoints::Vector2D center = circle.center();
134  valTip = iCharge * (center.mag() - 1.f / curvature);
135  valPhi = phi(center.x(), center.y(), iCharge);
136  } else {
137  valPt = 1.e4f;
138  GlobalVector direction(points[1] - points[0]);
139  valPhi = direction.barePhi();
140  valTip = -points[0].x() * sin(valPhi) + points[0].y() * cos(valPhi);
141  }
142 
143  float valCotTheta = cotTheta(points[0], points[1]);
144  float valEta = std::asinh(valCotTheta);
145  float valZip = zip(valTip, valPhi, curvature, points[0], points[1]);
146 
147  // Rescale down the error to take into accont the fact that the
148  // inner pixel barrel layer for PhaseI is closer to the interaction
149  // point. The effective scale factor has been derived by checking
150  // that the pulls of the pixelVertices derived from the pixelTracks
151  // have the correct mean and sigma.
152  float errFactor = 1.;
153  if (thescaleErrorsForBPix1 && (hits[0]->geographicalId().subdetId() == PixelSubdetector::PixelBarrel) &&
154  (theTopo->pxbLayer(hits[0]->geographicalId()) == 1))
155  errFactor = thescaleFactor;
156 
157  PixelTrackErrorParam param(valEta, valPt);
158  float errValPt = errFactor * param.errPt();
159  float errValCot = errFactor * param.errCot();
160  float errValTip = errFactor * param.errTip();
161  float errValPhi = errFactor * param.errPhi();
162  float errValZip = errFactor * param.errZip();
163 
164  float chi2 = 0;
165  if (nhits > 2) {
166  RZLine rzLine(points, errors, isBarrel);
167  chi2 = rzLine.chi2();
168  }
169 
170  PixelTrackBuilder builder;
171  Measurement1D pt(valPt, errValPt);
172  Measurement1D phi(valPhi, errValPhi);
173  Measurement1D cotTheta(valCotTheta, errValCot);
174  Measurement1D tip(valTip, errValTip);
175  Measurement1D zip(valZip, errValZip);
176 
177  ret.reset(builder.build(pt, phi, cotTheta, tip, zip, chi2, iCharge, hits, theField, region.origin()));
178  return ret;
179 }
Vector3DBase
Definition: Vector3DBase.h:8
runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:373
PixelFitterByHelixProjections::PixelFitterByHelixProjections
PixelFitterByHelixProjections(const edm::EventSetup *es, const MagneticField *field, bool scaleErrorsForBPix1, float scaleFactor)
Definition: PixelFitterByHelixProjections.cc:91
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
CircleFromThreePoints
Definition: CircleFromThreePoints.h:18
Measurement1D
Definition: Measurement1D.h:11
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
PixelSubdetector::PixelBarrel
Definition: PixelSubdetector.h:11
PixelRecoUtilities::fieldInInvGev
float fieldInInvGev(const edm::EventSetup &iSetup)
Definition: PixelRecoUtilities.h:25
hfClusterShapes_cfi.hits
hits
Definition: hfClusterShapes_cfi.py:5
Geom::fhalfPi
constexpr float fhalfPi()
Definition: Pi.h:37
HLT_FULL_cff.points
points
Definition: HLT_FULL_cff.py:21455
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
CircleFromThreePoints::curvature
float curvature() const
Definition: CircleFromThreePoints.h:42
HLT_FULL_cff.scaleErrorsForBPix1
scaleErrorsForBPix1
Definition: HLT_FULL_cff.py:9784
Measurement1D.h
PixelFitterByHelixProjections::theField
const MagneticField * theField
Definition: PixelFitterByHelixProjections.h:27
GeomDetType.h
PixelRecoUtilities::inversePt
T inversePt(T curvature, const edm::EventSetup &iSetup)
Definition: PixelRecoUtilities.h:48
LinearFit.h
hltPixelTracks_cff.chi2
chi2
Definition: hltPixelTracks_cff.py:25
Basic2DVector::mag
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
Definition: extBasic2DVector.h:73
PixelRecoUtilities::curvature
T curvature(T InversePt, const edm::EventSetup &iSetup)
Definition: PixelRecoUtilities.h:42
rpcPointValidation_cfi.recHit
recHit
Definition: rpcPointValidation_cfi.py:7
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
RZLine::chi2
float chi2() const
Definition: RZLine.h:94
TrackerTopology::pxbLayer
unsigned int pxbLayer(const DetId &id) const
Definition: TrackerTopology.h:144
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
testProducerWithPsetDescEmpty_cfi.z2
z2
Definition: testProducerWithPsetDescEmpty_cfi.py:41
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
PixelTrackErrorParam::errCot
double errCot() const
Definition: PixelTrackErrorParam.h:10
TrackerTopology.h
TrackingRecHit.h
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
TrackerTopologyRcd.h
PixelTrackErrorParam::errPhi
double errPhi() const
Definition: PixelTrackErrorParam.h:13
Basic2DVector::y
T y() const
Cartesian y coordinate.
Definition: extBasic2DVector.h:67
edm::EventSetup::get
T get() const
Definition: EventSetup.h:80
errors
Definition: errors.py:1
SurfaceOrientation::inner
Definition: Surface.h:19
DynArray
Definition: DynArray.h:5
PixelTrackErrorParam
Definition: PixelTrackErrorParam.h:5
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
edm::ESHandle< TrackerTopology >
declareDynArray
#define declareDynArray(T, n, x)
Definition: DynArray.h:91
PixelTrackBuilder
Definition: PixelTrackBuilder.h:13
Basic2DVector::x
T x() const
Cartesian x coordinate.
Definition: extBasic2DVector.h:64
CircleFromThreePoints.h
GlobalPoint
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
PixelRecoUtilities.h
Point3DBase< float, GlobalTag >
nhits
Definition: HIMultiTrackSelector.h:42
PixelTrackErrorParam::errZip
double errZip() const
Definition: PixelTrackErrorParam.h:12
CircleFromThreePoints::center
Vector2D center() const
Definition: CircleFromThreePoints.h:50
PixelTrackErrorParam::errTip
double errTip() const
Definition: PixelTrackErrorParam.h:11
qcdUeDQM_cfi.tip
tip
Definition: qcdUeDQM_cfi.py:23
Basic2DVector< float >
ALCARECOTkAlJpsiMuMu_cff.charge
charge
Definition: ALCARECOTkAlJpsiMuMu_cff.py:47
PixelPluginsPhase0_cfi.isBarrel
isBarrel
Definition: PixelPluginsPhase0_cfi.py:17
PV3DBase::barePhi
T barePhi() const
Definition: PV3DBase.h:65
PVValHelper::phi
Definition: PVValidationHelpers.h:68
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
Pi.h
RZLine.h
HLT_FULL_cff.region
region
Definition: HLT_FULL_cff.py:88272
GlobalError.h
GlobalErrorBase< double, ErrorMatrixTag >
MagneticField.h
edm::EventSetup
Definition: EventSetup.h:57
perp2
T perp2() const
Squared magnitude of transverse component.
Definition: Basic3DVectorLD.h:130
get
#define get
DynArray.h
PixelFitterByHelixProjections::theTopo
const TrackerTopology * theTopo
Definition: PixelFitterByHelixProjections.h:30
ComparisonHelper::zip
OutputIterator zip(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp)
Definition: L1TStage2CaloLayer1.h:41
PixelTrackBuilder::build
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
Definition: PixelTrackBuilder.cc:123
PixelTrackBuilder.h
PixelTrackErrorParam.h
DDAxes::phi
RZLine
Definition: RZLine.h:12
GeomDet.h
std
Definition: JetResolutionObject.h:76
PixelFitterByHelixProjections.h
PVValHelper::dz
Definition: PVValidationHelpers.h:50
LocalPoint.h
LIKELY
#define LIKELY(x)
Definition: Likely.h:20
flavorHistoryFilter_cfi.dr
dr
Definition: flavorHistoryFilter_cfi.py:37
genVertex_cff.x
x
Definition: genVertex_cff.py:12
multiplicitycorr_cfi.scaleFactor
scaleFactor
Definition: multiplicitycorr_cfi.py:7
detailsBasic3DVector::y
float float y
Definition: extBasic3DVector.h:14
DetLayer.h
EventSetup.h
PixelTrackErrorParam::errPt
double errPt() const
Definition: PixelTrackErrorParam.cc:59
PixelFitterByHelixProjections::run
std::unique_ptr< reco::Track > run(const std::vector< const TrackingRecHit * > &hits, const TrackingRegion &region, const edm::EventSetup &setup) const override
Definition: PixelFitterByHelixProjections.cc:102
TrackingRegion
Definition: TrackingRegion.h:41
PixelFitterByHelixProjections::thescaleErrorsForBPix1
const bool thescaleErrorsForBPix1
Definition: PixelFitterByHelixProjections.h:28
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
TrackerTopologyRcd
Definition: TrackerTopologyRcd.h:10
ParameterSet.h
SurfaceOrientation::outer
Definition: Surface.h:19
PixelFitterByHelixProjections::thescaleFactor
const float thescaleFactor
Definition: PixelFitterByHelixProjections.h:29
MagneticField
Definition: MagneticField.h:19
d0
static constexpr float d0
Definition: L1EGammaCrystalsEmulatorProducer.cc:84
GlobalPoint.h
DeadROC_duringRun.dir
dir
Definition: DeadROC_duringRun.py:23
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37