12 switch (parametrization) {
16 inv = 1.0 / initialP4.mass();
17 for (
int i = 0;
i < 4;
i++) {
18 covariance(3,
i) *= inv;
20 covariance(3, 3) *= inv;
24 inv = 1.0 / initialP4.energy();
25 for (
int i = 0;
i < 4;
i++) {
26 covariance(3,
i) *= inv;
28 covariance(3, 3) *= inv;
37 switch (parametrization) {
52 return sqrt(covariance(0, 0));
55 return sqrt(covariance(0, 0)) * (p4.P2());
59 return getResolE(parametrization, covariance, p4);
62 throw cms::Exception(
"Invalid parametrization") << parametrization;
65 <<
"getResolP not yet implemented for parametrization " << parametrization;
71 switch (parametrization) {
76 double pti2 = 1.0 / (p4.Perp2());
77 return sqrt((covariance(0, 0) * p4.Px() * p4.Px() + covariance(1, 1) * p4.Py() * p4.Py() +
78 2 * covariance(0, 1) * p4.Px() * p4.Py()) *
86 double a =
sin(p4.Theta());
87 double b = p4.P() *
cos(p4.Theta());
88 return sqrt(a * a * covariance(0, 0) + b * b * covariance(1, 1) + 2 * a * b * covariance(0, 1));
94 double a = -(p *
p) *
sin(p4.Theta());
95 double b = p *
cos(p4.Theta());
96 return sqrt(a * a * covariance(0, 0) + b * b * covariance(1, 1) + 2 * a * b * covariance(0, 1));
101 return sqrt(covariance(0, 0));
103 throw cms::Exception(
"Invalid parametrization") << parametrization;
106 <<
"getResolPt not yet implemented for parametrization " << parametrization;
113 switch (parametrization) {
118 return 1.0 / p4.P2() *
sqrt(covariance(0, 0));
121 return sqrt(covariance(0, 0));
128 return 1.0 / p4.P2() *
getResolP(parametrization, covariance, p4);
130 throw cms::Exception(
"Invalid parametrization") << parametrization;
133 <<
"getResolPInv not yet implemented for parametrization " << parametrization;
140 switch (parametrization) {
145 return sqrt(covariance(0, 0));
154 derivs[0] =
sin(p4.Theta()) *
cos(p4.Phi());
156 derivs[0] *= -(p *
p);
158 derivs[1] = p *
cos(p4.Theta()) *
cos(p4.Phi());
159 derivs[2] = p *
sin(p4.Theta()) * -
sin(p4.Phi());
166 double a =
cos(p4.Phi());
167 double b = -p4.Pt() *
sin(p4.Phi());
168 return sqrt(a * a * covariance(0, 0) + 2 * a * b * covariance(2, 0) + b * b * covariance(2, 2));
172 throw cms::Exception(
"Invalid parametrization") << parametrization;
175 <<
"getResolPx not yet implemented for parametrization " << parametrization;
181 switch (parametrization) {
186 return sqrt(covariance(1, 1));
195 derivs[0] =
sin(p4.Theta()) *
sin(p4.Phi());
197 derivs[0] *= -(p *
p);
199 derivs[1] = p *
cos(p4.Theta()) *
sin(p4.Phi());
200 derivs[2] = p *
sin(p4.Theta()) *
cos(p4.Phi());
207 double a =
sin(p4.Phi());
208 double b = p4.Pt() *
cos(p4.Phi());
209 return sqrt(a * a * covariance(0, 0) + 2 * a * b * covariance(2, 0) + b * b * covariance(2, 2));
213 throw cms::Exception(
"Invalid parametrization") << parametrization;
216 <<
"getResolPy not yet implemented for parametrization " << parametrization;
222 switch (parametrization) {
227 return sqrt(covariance(2, 2));
233 double a =
cos(p4.Theta());
234 double b = -p4.P() *
sin(p4.Theta());
235 return sqrt(a * a * covariance(0, 0) + 2 * a * b * covariance(1, 0) + b * b * covariance(1, 1));
240 double a = -p * p *
cos(p4.Theta());
241 double b = -p *
sin(p4.Theta());
242 return sqrt(a * a * covariance(0, 0) + 2 * a * b * covariance(1, 0) + b * b * covariance(1, 1));
247 double s =
sin(p4.Theta()),
c =
cos(p4.Theta());
249 double b = -p4.Pt() / (s *
s);
250 return sqrt(a * a * covariance(0, 0) + 2 * a * b * covariance(1, 0) + b * b * covariance(1, 1));
254 double a = sinh(p4.Eta());
255 double b = p4.Et() * cosh(p4.Eta());
256 return sqrt(a * a * covariance(0, 0) + 2 * a * b * covariance(1, 0) + b * b * covariance(1, 1));
260 throw cms::Exception(
"Invalid parametrization") << parametrization;
263 <<
"getResolPz not yet implemented for parametrization " << parametrization;
270 switch (parametrization) {
274 return sqrt(covariance(3, 3));
278 double a = 1.0 /
sin(p4.Theta());
279 double b = -a * a * p4.Et() *
cos(p4.Theta());
280 return sqrt(a * a * covariance(0, 0) + b * b * covariance(1, 1) + 2 * a * b * covariance(0, 1));
284 double th = p4.Theta();
285 double a = 1.0 /
sin(th);
286 double b = a * p4.Et() *
cos(th);
287 return sqrt(a * a * covariance(0, 0) + b * b * covariance(1, 1) + 2 * a * b * covariance(0, 1));
293 return sqrt(ROOT::Math::Similarity(xoE, covariance));
298 return sqrt(ROOT::Math::Similarity(xoE, covariance));
302 double einv = 1.0 / p4.E();
303 double a = p4.P() * einv;
304 double b = p4.M() * einv;
305 return sqrt(a * a * covariance(0, 0) + b * b * covariance(3, 3) + 2 * a * b * covariance(0, 3));
309 return p4.P() / p4.E() *
sqrt(covariance(0, 0));
315 return p * p * p / p4.E() *
sqrt(covariance(0, 0));
319 throw cms::Exception(
"Invalid parametrization") << parametrization;
322 <<
"getResolE not yet implemented for parametrization " << parametrization;
329 switch (parametrization) {
333 double pt2 = p4.Perp2();
337 derivs *= (1.0 / p4.Et());
338 derivs[0] *= pz2 * e2OverP4;
339 derivs[1] *= pz2 * e2OverP4;
340 derivs[2] *= -pt2 * e2OverP4;
341 derivs[3] *= pt2 /
p2;
342 return sqrt(ROOT::Math::Similarity(derivs, covariance));
346 double st =
sin(p4.Theta()), ct =
cos(p4.Theta());
348 2 * st * ct * p4.E() * covariance(1, 3));
353 return sqrt(covariance(0, 0));
358 double pt2 = p4.Perp2();
360 double e2 = p2 + p4.M2();
361 double s2 = pt2 /
p2,
pi2 = 1.0 /
p2;
362 double et =
sqrt(e2 * s2);
365 derivs[0] *= (s2 + e2 * pi2 * (1.0 - pt2 *
pi2));
366 derivs[1] *= (s2 + e2 * pi2 * (1.0 - pt2 *
pi2));
367 derivs[2] *= (s2 - e2 * pt2 * pi2 *
pi2);
370 return sqrt(ROOT::Math::Similarity(derivs, covariance));
373 return sqrt(ROOT::Math::Similarity(derivs, covariance));
378 double s =
sin(p4.Theta()),
c =
cos(p4.Theta());
381 return sqrt(ROOT::Math::Similarity(derivs, covariance));
385 double s =
sin(p4.Theta()),
c =
cos(p4.Theta());
387 double a = p4.P() * s /
e;
389 return sqrt(a * a * covariance(0, 0) + b * b * covariance(1, 1) + 2 * a * b * covariance(0, 1));
393 double s =
sin(p4.Theta()),
c =
cos(p4.Theta());
394 double p = p4.P(),
e = p4.E();
395 double a = (-p * p * p /
e) * s;
397 return sqrt(a * a * covariance(0, 0) + b * b * covariance(1, 1) + 2 * a * b * covariance(0, 1));
401 throw cms::Exception(
"Invalid parametrization") << parametrization;
404 <<
"getResolEt not yet implemented for parametrization " << parametrization;
411 switch (parametrization) {
422 return sqrt(covariance(3, 3));
425 double dMdE = p4.E() / p4.M(), dMdP = -p4.P() / p4.M();
426 return sqrt(dMdP * dMdP * covariance(0, 0) + 2 * dMdP * dMdE * covariance(0, 3) + dMdE * dMdE * covariance(3, 3));
430 derivs *= 1.0 / p4.M();
431 return sqrt(ROOT::Math::Similarity(derivs, covariance));
434 <<
"getResolM not yet implemented for parametrization " << parametrization;
436 throw cms::Exception(
"Invalid parametrization") << parametrization;
439 <<
"getResolM not yet implemented for parametrization " << parametrization;
446 return -1.0 /
sin(theta);
451 double e =
exp(-eta);
452 return -2.0 / (e + 1.0 /
e);
458 switch (parametrization) {
471 return sqrt(covariance(1, 1));
473 throw cms::Exception(
"Invalid parametrization") << parametrization;
476 <<
"getResolEta not yet implemented for parametrization " << parametrization;
482 switch (parametrization) {
487 double pt2 = p4.Perp2();
488 double p = p4.P(),
pi = 1.0 /
p, pi3 =
pi *
pi *
pi;
489 double dacos = -p /
sqrt(pt2);
491 derivs[0] = -p4.Px() * p4.Pz() * dacos * pi3;
492 derivs[1] = -p4.Py() * p4.Pz() * dacos * pi3;
493 derivs[2] = pt2 * dacos * pi3;
501 return sqrt(covariance(1, 1));
505 throw cms::Exception(
"Invalid parametrization") << parametrization;
508 <<
"getResolTheta not yet implemented for parametrization " << parametrization;
514 double pt2 = p4.Perp2();
515 switch (parametrization) {
520 -2 * p4.Px() * p4.Py() * covariance(0, 1)) /
528 return sqrt(covariance(2, 2));
530 throw cms::Exception(
"Invalid parametrization") << parametrization;
533 <<
"getResolPhi not yet implemented for parametrization " << parametrization;
double getResolEt(pat::CandKinResolution::Parametrization parametrization, const AlgebraicSymMatrix44 &covariance, const pat::CandKinResolution::LorentzVector &p4)
double DetaDtheta(double theta)
const edm::EventSetup & c
double getResolPz(pat::CandKinResolution::Parametrization parametrization, const AlgebraicSymMatrix44 &covariance, const pat::CandKinResolution::LorentzVector &p4)
double getResolPy(pat::CandKinResolution::Parametrization parametrization, const AlgebraicSymMatrix44 &covariance, const pat::CandKinResolution::LorentzVector &p4)
double getResolP(pat::CandKinResolution::Parametrization parametrization, const AlgebraicSymMatrix44 &covariance, const pat::CandKinResolution::LorentzVector &p4)
double getResolPx(pat::CandKinResolution::Parametrization parametrization, const AlgebraicSymMatrix44 &covariance, const pat::CandKinResolution::LorentzVector &p4)
double getResolPt(pat::CandKinResolution::Parametrization parametrization, const AlgebraicSymMatrix44 &covariance, const pat::CandKinResolution::LorentzVector &p4)
double getResolPhi(pat::CandKinResolution::Parametrization parametrization, const AlgebraicSymMatrix44 &covariance, const pat::CandKinResolution::LorentzVector &p4)
Sin< T >::type sin(const T &t)
double getResolM(pat::CandKinResolution::Parametrization parametrization, const AlgebraicSymMatrix44 &covariance, const pat::CandKinResolution::LorentzVector &p4)
void rescaleForKinFitter(const pat::CandKinResolution::Parametrization parametrization, AlgebraicSymMatrix44 &covariance, const math::XYZTLorentzVector &initialP4)
Geom::Theta< T > theta() const
double getResolPInv(pat::CandKinResolution::Parametrization parametrization, const AlgebraicSymMatrix44 &covariance, const pat::CandKinResolution::LorentzVector &p4)
Exp< T >::type exp(const T &t)
double getResolE(pat::CandKinResolution::Parametrization parametrization, const AlgebraicSymMatrix44 &covariance, const pat::CandKinResolution::LorentzVector &p4)
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Cos< T >::type cos(const T &t)
Abs< T >::type abs(const T &t)
double DthetaDeta(double eta)
ROOT::Math::SMatrix< double, 4, 4, ROOT::Math::MatRepSym< double, 4 > > AlgebraicSymMatrix44
ROOT::Math::SVector< double, 4 > AlgebraicVector4
math::XYZTLorentzVector LorentzVector
ROOT::Math::SVector< double, 3 > AlgebraicVector3
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepSym< double, 3 > > AlgebraicSymMatrix33
double getResolEta(pat::CandKinResolution::Parametrization parametrization, const AlgebraicSymMatrix44 &covariance, const pat::CandKinResolution::LorentzVector &p4)
double getResolTheta(pat::CandKinResolution::Parametrization parametrization, const AlgebraicSymMatrix44 &covariance, const pat::CandKinResolution::LorentzVector &p4)