CMS 3D CMS Logo

ParticleBuilder.cc
Go to the documentation of this file.
1 /* From SimpleFits Package
2  * Designed an written by
3  * author: Ian M. Nugent
4  * Humboldt Foundations
5  */
14 #include <TVector3.h>
16 
17 using namespace tauImpactParameter;
18 
20  const reco::Vertex& V,
21  bool fromPerigee,
22  bool useTrackHelixPropagation) {
23  GlobalPoint p(V.position().x(), V.position().y(), V.position().z());
24  TrackParticle tp = createTrackParticle(transTrk, p, fromPerigee, useTrackHelixPropagation);
25 
26  int N =
28  TVectorT<double> par(N);
29  par(TrackHelixVertexFitter::x0) = V.position().x();
30  par(TrackHelixVertexFitter::y0) = V.position().y();
31  par(TrackHelixVertexFitter::z0) = V.position().z();
35  par(TrackHelixVertexFitter::NFreeTrackPar + TrackHelixVertexFitter::MassOffSet) = tp.mass();
37 
38  TMatrixTSym<double> parcov(N);
39  for (int i = 0; i < TrackHelixVertexFitter::NFreeVertexPar; i++) {
40  for (int j = 0; j < TrackHelixVertexFitter::NFreeVertexPar; j++) {
41  parcov(i, j) = V.covariance(i, j);
42  }
43  }
49  tp.covariance(TrackParticle::phi, TrackParticle::phi);
50 
51  TVectorT<double> LVPar = TrackHelixVertexFitter::computeLorentzVectorPar(par);
52  TMatrixTSym<double> LVCov =
54  return LorentzVectorParticle(LVPar, LVCov, tp.pdgId(), tp.charge(), tp.bField());
55 }
56 
58  const GlobalPoint& p,
59  bool fromPerigee,
60  bool useTrackHelixPropagation) {
61  // Configured for CMSSW Tracks only
62  TVectorT<double> par(TrackParticle::NHelixPar + 1);
63  TMatrixTSym<double> cov(TrackParticle::NHelixPar + 1);
64  TVectorT<double> SFpar(TrackParticle::NHelixPar);
65  TMatrixTSym<double> SFcov(TrackParticle::NHelixPar);
66  if (!fromPerigee) {
67  for (int i = 0; i < TrackParticle::NHelixPar; i++) {
68  par(i) = transTrk.track().parameter(i);
69  for (int j = 0; j < TrackParticle::NHelixPar; j++) {
70  cov(i, j) = transTrk.track().covariance(i, j);
71  }
72  }
73  par(TrackParticle::NHelixPar) = transTrk.field()->inInverseGeV(p).z();
76  } else {
77  GlobalPoint TrackIPPos = transTrk.impactPointTSCP().position();
78  //GlobalPoint TrackIPOrigin=transTrk.impactPointTSCP().referencePoint();
79  GlobalPoint origin(0.0, 0.0, 0.0);
80  for (int i = 0; i < TrackParticle::NHelixPar; i++) {
81  par(i) = transTrk.trajectoryStateClosestToPoint(origin).perigeeParameters().vector()(i);
82  for (int j = 0; j < TrackParticle::NHelixPar; j++) {
83  cov(i, j) = transTrk.trajectoryStateClosestToPoint(origin).perigeeError().covarianceMatrix()(i, j);
84  }
85  }
86  par(TrackParticle::NHelixPar) = transTrk.field()->inInverseGeV(p).z();
89  if (useTrackHelixPropagation) {
91  // correct dxy dz neglecting material and radiative corrections
92 
93  LogDebug("RecoTauImpactParameterParticleBuilder")
94  << "Offical CMS dxy - " << par(TrackParticle::dxy) << " dz " << par(TrackParticle::dz) << " kappa "
96  LogDebug("RecoTauImpactParameterParticleBuilder")
97  << "Offical CMS dxy - SimpleFits Format" << SFpar(TrackParticle::dxy) << " dz " << SFpar(TrackParticle::dz)
98  << " kappa " << SFpar(reco::TrackBase::i_qoverp);
99 
100  double x, y, z, dxy, dz, s, kappa, lambda, phi;
101  TVectorT<double> freehelix(TrackHelixVertexFitter::NFreeTrackPar);
102  freehelix(TrackHelixVertexFitter::x0) = TrackIPPos.x();
103  freehelix(TrackHelixVertexFitter::y0) = TrackIPPos.y();
104  freehelix(TrackHelixVertexFitter::z0) = TrackIPPos.z();
108  TrackHelixVertexFitter::computedxydz(freehelix, 0, kappa, lambda, phi, x, y, z, s, dxy, dz);
109  SFpar(TrackParticle::dxy) = dxy;
110  SFpar(TrackParticle::dz) = dz;
111  LogDebug("RecoTauImpactParameterParticleBuilder") << "Found values dxy " << dxy << " dz " << dz;
112  //exit(0);
114  }
115  }
116 
117  PDGInfo pdgInfo;
118  double c = transTrk.charge();
119  return TrackParticle(
120  SFpar, SFcov, abs(PdtPdgMini::pi_plus) * c, pdgInfo.pi_mass(), c, transTrk.field()->inInverseGeV(p).z());
121 }
122 
124  TVector3 v = p.vertex();
125  TMatrixTSym<double> vcov = p.vertexCov();
126  reco::Vertex::Point vp(v.X(), v.Y(), v.Z());
128  for (int i = 0; i < vcov.GetNrows(); i++) {
129  for (int j = 0; j < vcov.GetNrows(); j++) {
130  ve(i, j) = vcov(i, j);
131  }
132  }
133  return reco::Vertex(vp, ve);
134 }
135 
136 TVectorT<double> ParticleBuilder::convertCMSSWTrackParToSFTrackPar(const TVectorT<double>& inpar) {
137  TVectorT<double> par(TrackParticle::NHelixPar);
139  fabs(cos(inpar(reco::TrackBase::i_lambda)));
144  return par;
145 }
146 
147 TVectorT<double> ParticleBuilder::convertCMSSWTrackPerigeeToSFTrackPar(const TVectorT<double>& inpar) {
148  TVectorT<double> par(TrackParticle::NHelixPar);
149  par(TrackParticle::kappa) = inpar(aCurv);
150  par(TrackParticle::lambda) = TMath::Pi() / 2 - inpar(aTheta);
151  par(TrackParticle::phi) = inpar(aPhi);
152  par(TrackParticle::dxy) = -inpar(aTip);
153  par(TrackParticle::dz) = inpar(aLip);
154  return par;
155 }
#define LogDebug(id)
TMatrixTSym< double > vertexCov() const
const double Pi
const AlgebraicVector5 & vector() const
const PerigeeTrajectoryError & perigeeError() const
TrajectoryStateClosestToPoint impactPointTSCP() const
static LorentzVectorParticle createLorentzVectorParticle(const reco::TransientTrack &transTrk, const reco::Vertex &V, bool fromPerigee, bool useTrackHelixPropagation)
T y() const
Definition: PV3DBase.h:60
math::Error< dimension >::type Error
covariance error matrix (3x3)
Definition: Vertex.h:43
const MagneticField * field() const
static TVectorT< double > convertCMSSWTrackPerigeeToSFTrackPar(const TVectorT< double > &inpar)
double covariance(int i, int j) const
(i, j)-th element of error matrix, i, j = 0, ... 2
Definition: Vertex.h:134
const Point & position() const
position
Definition: Vertex.h:113
GlobalVector inInverseGeV(const GlobalPoint &gp) const
Field value ad specified global point, in 1/Gev.
Definition: MagneticField.h:36
TrackCharge charge() const
const PerigeeTrajectoryParameters & perigeeParameters() const
CovarianceMatrix covariance() const
return track covariance matrix
Definition: TrackBase.h:677
static TVectorT< double > computeLorentzVectorPar(const TVectorT< double > &inpar)
T z() const
Definition: PV3DBase.h:61
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
math::XYZPoint Point
point in the space
Definition: Vertex.h:39
static double pi_mass()
Definition: PDGInfo.h:13
const AlgebraicSymMatrix55 & covarianceMatrix() const
double parameter(int i) const
i-th parameter ( i = 0, ... 4 )
Definition: TrackBase.h:684
#define N
Definition: blowfish.cc:9
const Track & track() const
TrajectoryStateClosestToPoint trajectoryStateClosestToPoint(const GlobalPoint &point) const
static TVectorT< double > convertCMSSWTrackParToSFTrackPar(const TVectorT< double > &inpar)
static void computedxydz(const TVectorT< double > &inpar, int particle, double &kappa, double &lam, double &phi, double &x, double &y, double &z, double &s, double &dxy, double &dz)
static reco::Vertex getVertex(const LorentzVectorParticle &p)
static TrackParticle createTrackParticle(const reco::TransientTrack &transTrk, const GlobalPoint &p, bool fromPerigee=true, bool useTrackHelixPropogation=true)
static const G4double kappa
T x() const
Definition: PV3DBase.h:59
static TMatrixTSym< double > propagateError(std::function< TVectorT< double >(const TVectorT< double > &)> f, const TVectorT< double > &inPar, TMatrixTSym< double > &inCov, double epsilon=0.001, double errorEpsilonRatio=1000)