CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions
pat::helper::ParametrizationHelper Namespace Reference

Functions

AlgebraicVector4 diffToParameters (pat::CandKinResolution::Parametrization parametrization, const math::XYZTLorentzVector &p4ini, const math::XYZTLorentzVector &p4fin)
 Expresses the difference between two 4-momentum vectors as a shift in coordinates in a given frame. More...
 
AlgebraicVector4 diffToParameters (pat::CandKinResolution::Parametrization parametrization, const math::PtEtaPhiMLorentzVector &p4ini, const math::PtEtaPhiMLorentzVector &p4fin)
 Expresses the difference between two 4-momentum vectors as a shift in coordinates in a given frame. More...
 
uint32_t dimension (pat::CandKinResolution::Parametrization parametrization)
 Returns the number of free parameters in a parametrization (3 or 4) More...
 
pat::CandKinResolution::Parametrization fromString (const std::string &name)
 Convert a name into a parametrization code. More...
 
bool isAlwaysMassive (pat::CandKinResolution::Parametrization parametrization)
 Is this parametrization usable only with massive objects? More...
 
bool isAlwaysMassless (pat::CandKinResolution::Parametrization parametrization)
 Is this parametrization usable only with massless objects? More...
 
bool isMassConstrained (pat::CandKinResolution::Parametrization parametrization)
 If this parametrization has a mass constraint (including the 'isAlwaysMassless' case) More...
 
bool isPhysical (pat::CandKinResolution::Parametrization parametrization, const AlgebraicVector4 &v4, const math::PtEtaPhiMLorentzVector &initialP4)
 
const char * name (pat::CandKinResolution::Parametrization param)
 Convert a number into a string. More...
 
math::XYZTLorentzVector p4fromParameters (pat::CandKinResolution::Parametrization parametrization, const AlgebraicVector4 &parameters, const math::XYZTLorentzVector &initialP4)
 
AlgebraicVector4 parametersFromP4 (pat::CandKinResolution::Parametrization parametrization, const math::XYZTLorentzVector &p4)
 Returns a vector of coordinates values given a coordinate frame and a 4-vector. More...
 
AlgebraicVector4 parametersFromP4 (pat::CandKinResolution::Parametrization parametrization, const math::PtEtaPhiMLorentzVector &p4)
 Returns a vector of coordinates values given a coordinate frame and a 4-vector. More...
 
math::PtEtaPhiMLorentzVector polarP4fromParameters (pat::CandKinResolution::Parametrization parametrization, const AlgebraicVector4 &parameters, const math::PtEtaPhiMLorentzVector &initialP4)
 
template<typename T >
void setParametersFromAnyVector (pat::CandKinResolution::Parametrization parametrization, AlgebraicVector4 &pars, const T &p4)
 For internal use only, so we provide only the interface. Use the 'setParametersFromP4'. More...
 
void setParametersFromP4 (pat::CandKinResolution::Parametrization parametrization, AlgebraicVector4 &pars, const math::XYZTLorentzVector &p4)
 Set the values of the parameters for a given 4-momentum. More...
 
void setParametersFromP4 (pat::CandKinResolution::Parametrization parametrization, AlgebraicVector4 &pars, const math::PtEtaPhiMLorentzVector &p4)
 Set the values of the parameters for a given 4-momentum. More...
 

Function Documentation

AlgebraicVector4 pat::helper::ParametrizationHelper::diffToParameters ( pat::CandKinResolution::Parametrization  parametrization,
const math::XYZTLorentzVector p4ini,
const math::XYZTLorentzVector p4fin 
)

Expresses the difference between two 4-momentum vectors as a shift in coordinates in a given frame.

Basically, if you do: pars = parametersFromP4(param, simp4); diff = diffToParameters(param, simP4, recP4); then up to roundoff errors recP4 == p4fromParameters(param, pars+diff, simP4);

Definition at line 322 of file ParametrizationHelper.cc.

References pat::CandKinResolution::Cart, pat::CandKinResolution::ECart, pat::CandKinResolution::EMomDev, pat::CandKinResolution::EScaledMomDev, pat::CandKinResolution::ESpher, pat::CandKinResolution::EtEtaPhi, pat::CandKinResolution::EtThetaPhi, Exception, pat::CandKinResolution::Invalid, M_PI, pat::CandKinResolution::MCCart, pat::CandKinResolution::MCMomDev, pat::CandKinResolution::MCPInvSpher, pat::CandKinResolution::MCSpher, pat::CandKinResolution::MomDev, p1, p2, parametersFromP4(), runTheMatrix::ret, and pat::CandKinResolution::Spher.

Referenced by diffToParameters().

324 {
326  switch (parametrization) {
331  ret = parametersFromP4(parametrization,p4fin) - parametersFromP4(parametrization,p4ini);
332  break;
338  ret = parametersFromP4(parametrization,p4fin) - parametersFromP4(parametrization,p4ini);
339  while(ret[2] > +M_PI) ret[2] -= (2*M_PI);
340  while(ret[2] < -M_PI) ret[2] += (2*M_PI);
341  break;
346  {
347  typedef ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D<double> > V3Cart;
348  V3Cart p1 = p4ini.Vect(), p2 = p4fin.Vect();
349  V3Cart ur = p1.Unit();
350  V3Cart uz(0,0,1);
351  V3Cart uph = uz.Cross(ur).Unit();
352  V3Cart uth = ur.Cross(uph).Unit();
353  ret[0] = p2.Dot(ur)/p1.R() - 1.0;
354  ret[1] = (p2 - p1).Dot(uth);
355  ret[2] = (p2 - p1).Dot(uph);
356  if (parametrization == pat::CandKinResolution::MomDev) {
357  ret[3] = p4fin.mass()/p4ini.mass() - 1.0;
358  } else if (parametrization == pat::CandKinResolution::EMomDev) {
359  ret[3] = p4fin.energy()/p4ini.energy() - 1.0;
360  }
361  }
362  break;
364  throw cms::Exception("Invalid parametrization") << parametrization;
365  default:
366  throw cms::Exception("Not Implemented") << "diffToParameters not yet implemented for parametrization " << parametrization ;
367  }
368  return ret;
369 }
tuple ret
prodAgent to be discontinued
AlgebraicVector4 parametersFromP4(pat::CandKinResolution::Parametrization parametrization, const math::XYZTLorentzVector &p4)
Returns a vector of coordinates values given a coordinate frame and a 4-vector.
double p2[4]
Definition: TauolaWrapper.h:90
#define M_PI
double p1[4]
Definition: TauolaWrapper.h:89
ROOT::Math::SVector< double, 4 > AlgebraicVector4
AlgebraicVector4 pat::helper::ParametrizationHelper::diffToParameters ( pat::CandKinResolution::Parametrization  parametrization,
const math::PtEtaPhiMLorentzVector p4ini,
const math::PtEtaPhiMLorentzVector p4fin 
)

Expresses the difference between two 4-momentum vectors as a shift in coordinates in a given frame.

Basically, if you do: pars = parametersFromP4(param, simp4); diff = diffToParameters(param, simP4, recP4); then up to roundoff errors recP4 == p4fromParameters(param, pars+diff, simP4);

Definition at line 285 of file ParametrizationHelper.cc.

References pat::CandKinResolution::Cart, diffToParameters(), pat::CandKinResolution::ECart, pat::CandKinResolution::EMomDev, pat::CandKinResolution::EScaledMomDev, pat::CandKinResolution::ESpher, pat::CandKinResolution::EtEtaPhi, pat::CandKinResolution::EtThetaPhi, Exception, pat::CandKinResolution::Invalid, M_PI, pat::CandKinResolution::MCCart, pat::CandKinResolution::MCMomDev, pat::CandKinResolution::MCPInvSpher, pat::CandKinResolution::MCSpher, pat::CandKinResolution::MomDev, parametersFromP4(), runTheMatrix::ret, and pat::CandKinResolution::Spher.

287 {
289  switch (parametrization) {
293  ret = parametersFromP4(parametrization,p4fin) - parametersFromP4(parametrization,p4ini);
294  break;
301  ret = parametersFromP4(parametrization,p4fin) - parametersFromP4(parametrization,p4ini);
302  while(ret[2] > +M_PI) ret[2] -= (2*M_PI);
303  while(ret[2] < -M_PI) ret[2] += (2*M_PI);
304  break;
309  return diffToParameters(parametrization,
311  math::XYZTLorentzVector(p4fin));
313  throw cms::Exception("Invalid parametrization") << parametrization;
314  default:
315  throw cms::Exception("Not Implemented") << "diffToParameters not yet implemented for parametrization " << parametrization ;
316  }
317  return ret;
318 }
tuple ret
prodAgent to be discontinued
AlgebraicVector4 parametersFromP4(pat::CandKinResolution::Parametrization parametrization, const math::XYZTLorentzVector &p4)
Returns a vector of coordinates values given a coordinate frame and a 4-vector.
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
#define M_PI
AlgebraicVector4 diffToParameters(pat::CandKinResolution::Parametrization parametrization, const math::XYZTLorentzVector &p4ini, const math::XYZTLorentzVector &p4fin)
Expresses the difference between two 4-momentum vectors as a shift in coordinates in a given frame...
ROOT::Math::SVector< double, 4 > AlgebraicVector4
uint32_t pat::helper::ParametrizationHelper::dimension ( pat::CandKinResolution::Parametrization  parametrization)
inline

Returns the number of free parameters in a parametrization (3 or 4)

Definition at line 11 of file ParametrizationHelper.h.

Referenced by MillePedeAlignmentAlgorithm::callMille2D(), CosmicMuonSeedGenerator::createSeed(), SETSeedFinder::estimateMomentum(), pat::CandKinResolution::fillMatrixFrom(), pat::CandKinResolution::fillVector(), and SETSeedFinder::pre_prune().

11  {
12  return (static_cast<uint32_t>(parametrization) & 0x0F);
13  }
pat::CandKinResolution::Parametrization pat::helper::ParametrizationHelper::fromString ( const std::string &  name)

Convert a name into a parametrization code.

Definition at line 15 of file ParametrizationHelper.cc.

References pat::CandKinResolution::Cart, pat::CandKinResolution::ECart, pat::CandKinResolution::EMomDev, pat::CandKinResolution::EScaledMomDev, pat::CandKinResolution::ESpher, pat::CandKinResolution::EtEtaPhi, pat::CandKinResolution::EtThetaPhi, Exception, pat::CandKinResolution::MCCart, pat::CandKinResolution::MCMomDev, pat::CandKinResolution::MCPInvSpher, pat::CandKinResolution::MCSpher, pat::CandKinResolution::MomDev, and pat::CandKinResolution::Spher.

Referenced by StringResolutionProvider::StringResolutionProvider(), and ora::Version::thisSchemaVersion().

15  {
16  using namespace std;
17 
18  typedef pat::CandKinResolution::Parametrization Parametrization;
19 
20  static map<string,Parametrization> const parMaps = {
22  {"ECart" , pat::CandKinResolution::ECart},
23  {"MCCart" , pat::CandKinResolution::MCCart},
24  {"Spher" , pat::CandKinResolution::Spher},
25  {"ESpher" , pat::CandKinResolution::ESpher},
26  {"MCSpher" , pat::CandKinResolution::MCSpher},
27  {"MCPInvSpher" , pat::CandKinResolution::MCPInvSpher},
28  {"EtEtaPhi" , pat::CandKinResolution::EtEtaPhi},
29  {"EtThetaPhi" , pat::CandKinResolution::EtThetaPhi},
30  {"MomDev" , pat::CandKinResolution::MomDev},
31  {"EMomDev" , pat::CandKinResolution::EMomDev},
32  {"MCMomDev" , pat::CandKinResolution::MCMomDev},
33  {"EScaledMomDev" , pat::CandKinResolution::EScaledMomDev}
34  };
35  map<string,Parametrization>::const_iterator itP = parMaps.find(name);
36  if (itP == parMaps.end()) {
37  throw cms::Exception("StringResolutionProvider") << "Bad parametrization '" << name.c_str() << "'";
38  }
39  return itP->second;
40 }
bool pat::helper::ParametrizationHelper::isAlwaysMassive ( pat::CandKinResolution::Parametrization  parametrization)

Is this parametrization usable only with massive objects?

Definition at line 398 of file ParametrizationHelper.cc.

References pat::CandKinResolution::Cart, pat::CandKinResolution::ECart, pat::CandKinResolution::EMomDev, pat::CandKinResolution::EScaledMomDev, pat::CandKinResolution::ESpher, pat::CandKinResolution::EtEtaPhi, pat::CandKinResolution::EtThetaPhi, Exception, pat::CandKinResolution::Invalid, pat::CandKinResolution::MCCart, pat::CandKinResolution::MCMomDev, pat::CandKinResolution::MCPInvSpher, pat::CandKinResolution::MCSpher, pat::CandKinResolution::MomDev, and pat::CandKinResolution::Spher.

399 {
400  switch (parametrization) {
413  return false;
415  return true;
417  throw cms::Exception("Invalid parametrization") << parametrization;
418  default:
419  throw cms::Exception("Not Implemented") << "isAlwaysMassless not yet implemented for parametrization " << parametrization ;
420  }
421 }
bool pat::helper::ParametrizationHelper::isAlwaysMassless ( pat::CandKinResolution::Parametrization  parametrization)

Is this parametrization usable only with massless objects?

Definition at line 372 of file ParametrizationHelper.cc.

References pat::CandKinResolution::Cart, pat::CandKinResolution::ECart, pat::CandKinResolution::EMomDev, pat::CandKinResolution::EScaledMomDev, pat::CandKinResolution::ESpher, pat::CandKinResolution::EtEtaPhi, pat::CandKinResolution::EtThetaPhi, Exception, pat::CandKinResolution::Invalid, pat::CandKinResolution::MCCart, pat::CandKinResolution::MCMomDev, pat::CandKinResolution::MCPInvSpher, pat::CandKinResolution::MCSpher, pat::CandKinResolution::MomDev, and pat::CandKinResolution::Spher.

373 {
374  switch (parametrization) {
386  return false;
389  return true;
391  throw cms::Exception("Invalid parametrization") << parametrization;
392  default:
393  throw cms::Exception("Not Implemented") << "isAlwaysMassless not yet implemented for parametrization " << parametrization ;
394  }
395 }
bool pat::helper::ParametrizationHelper::isMassConstrained ( pat::CandKinResolution::Parametrization  parametrization)

If this parametrization has a mass constraint (including the 'isAlwaysMassless' case)

Definition at line 424 of file ParametrizationHelper.cc.

References pat::CandKinResolution::Cart, pat::CandKinResolution::ECart, pat::CandKinResolution::EMomDev, pat::CandKinResolution::EScaledMomDev, pat::CandKinResolution::ESpher, pat::CandKinResolution::EtEtaPhi, pat::CandKinResolution::EtThetaPhi, Exception, pat::CandKinResolution::Invalid, pat::CandKinResolution::MCCart, pat::CandKinResolution::MCMomDev, pat::CandKinResolution::MCPInvSpher, pat::CandKinResolution::MCSpher, pat::CandKinResolution::MomDev, and pat::CandKinResolution::Spher.

425 {
426  switch (parametrization) {
436  return false;
441  return true;
443  throw cms::Exception("Invalid parametrization") << parametrization;
444  default:
445  throw cms::Exception("Not Implemented") << "isAlwaysMassless not yet implemented for parametrization " << parametrization ;
446  }
447 }
bool pat::helper::ParametrizationHelper::isPhysical ( pat::CandKinResolution::Parametrization  parametrization,
const AlgebraicVector4 v4,
const math::PtEtaPhiMLorentzVector initialP4 
)

If this value of the parameters is meaningful in this parametrization. It can be used e.g. when doing random smearing to check you're still within the physical region This DOES check inequalities (e.g. E >= P, M >= 0, theta in [0,PI], ..) This DOES NOT check strict equalities (e.g. M == 0) This DOES NOT check that your parameters comply with your constraints (e.g. fixed mass constraint)

Definition at line 450 of file ParametrizationHelper.cc.

References pat::CandKinResolution::Cart, pat::CandKinResolution::ECart, pat::CandKinResolution::EMomDev, pat::CandKinResolution::EScaledMomDev, pat::CandKinResolution::ESpher, pat::CandKinResolution::EtEtaPhi, pat::CandKinResolution::EtThetaPhi, Exception, pat::CandKinResolution::Invalid, M_PI, pat::CandKinResolution::MCCart, pat::CandKinResolution::MCMomDev, pat::CandKinResolution::MCPInvSpher, pat::CandKinResolution::MCSpher, pat::CandKinResolution::MomDev, AlCaHLTBitMon_ParallelJobs::p, and pat::CandKinResolution::Spher.

452  {
453  switch (parametrization) {
454  // ======= CARTESIAN ==========
456  return parameters[3] >= 0; // M >= 0
458  return true;
460  return (parameters[0]*parameters[0] + parameters[1]*parameters[1] + parameters[2]*parameters[2] <= parameters[3]*parameters[3]); // E >= P
462  return (parameters[0] >= 0 ) && // P >= 0
463  (parameters[3] >= 0 ) && // M >= 0
464  (parameters[1] >= 0 ) && // theta >= 0
465  (parameters[1] <= M_PI); // theta <= pi
467  return (parameters[0] >= 0 ) && // P >= 0
468  (parameters[1] >= 0 ) && // theta >= 0
469  (parameters[1] <= M_PI); // theta <= pi
471  return (parameters[0] >= 0 ) && // P >= 0
472  (parameters[3] >= parameters[0]) && // E >= P
473  (parameters[1] >= 0 ) && // theta >= 0
474  (parameters[1] <= M_PI ) ; // theta <= PI
476  return (parameters[0] > 0 ) && // 1/P > 0
477  (parameters[1] >= 0 ) && // theta >= 0
478  (parameters[1] <= M_PI); // theta <= pi
479  // ======= HEP CYLINDRICAL ==========
481  return (parameters[0] > 0 ) && // Et >= 0
482  (parameters[1] >= 0 ) && // theta >= 0
483  (parameters[1] <= M_PI); // theta <= pi
484  case pat::CandKinResolution::EtEtaPhi: // as simple as that
485  return (parameters[0] > 0); // Et >= 0
486  // ======= MomentumDeviates ==========
488  return (parameters[0] >= 0) && // P >= 0
489  (parameters[3] >= 0); // m/M0 >= 0
491  return (parameters[0] >= 0); // P >= 0
494  {
495  if (parameters[0] <= 0) return false;
496  ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D<double> > p = initialP4.Vect(), uz(0,0,1), uph, uth;
497  uph = uz.Cross(p).Unit();
498  uth = p.Cross(uph).Unit();
499  p *= parameters[0];
500  p += uth * parameters[1] + uph * parameters[2];
501  if (parametrization == pat::CandKinResolution::EMomDev) {
502  if (parameters[3] < 0) return false;
503  double m2 = ROOT::Math::Square(parameters[3] * initialP4.energy()) - p.Mag2();
504  if (m2 < 0) return false;
505  } else if (parametrization == pat::CandKinResolution::EScaledMomDev) {
506  if (parameters[3] < 0) return false;
507  double m2 = ROOT::Math::Square(p.R()*initialP4.E()/initialP4.P()) - p.Mag2();
508  if (m2 < 0) return false;
509  }
510  return true;
511  }
512  // ======= OTHER ==========
514  throw cms::Exception("Invalid parametrization") << parametrization;
515  default:
516  throw cms::Exception("Not Implemented") << "getResolEta not yet implemented for parametrization " << parametrization ;
517  }
518 }
#define M_PI
const char * pat::helper::ParametrizationHelper::name ( pat::CandKinResolution::Parametrization  param)

Convert a number into a string.

Definition at line 43 of file ParametrizationHelper.cc.

References pat::CandKinResolution::Cart, pat::CandKinResolution::ECart, pat::CandKinResolution::EMomDev, pat::CandKinResolution::EScaledMomDev, pat::CandKinResolution::ESpher, pat::CandKinResolution::EtEtaPhi, pat::CandKinResolution::EtThetaPhi, pat::CandKinResolution::Invalid, pat::CandKinResolution::MCCart, pat::CandKinResolution::MCMomDev, pat::CandKinResolution::MCPInvSpher, pat::CandKinResolution::MCSpher, pat::CandKinResolution::MomDev, and pat::CandKinResolution::Spher.

43  {
44  switch (param) {
45  case pat::CandKinResolution::Cart: return "Cart";
46  case pat::CandKinResolution::ECart: return "ECart";
47  case pat::CandKinResolution::MCCart: return "MCCart";
48  case pat::CandKinResolution::Spher: return "Spher";
49  case pat::CandKinResolution::ESpher: return "ESpher";
50  case pat::CandKinResolution::MCSpher: return "MCSpher";
51  case pat::CandKinResolution::MCPInvSpher: return "MCPInvSpher";
52  case pat::CandKinResolution::EtEtaPhi: return "EtEtaPhi";
53  case pat::CandKinResolution::EtThetaPhi: return "EtThetaPhi";
54  case pat::CandKinResolution::MomDev: return "MomDev";
55  case pat::CandKinResolution::EMomDev: return "EMomDev";
56  case pat::CandKinResolution::MCMomDev: return "MCMomDev";
57  case pat::CandKinResolution::EScaledMomDev: return "EScaledMomDev";
58  case pat::CandKinResolution::Invalid: return "Invalid";
59  default: return "UNKNOWN";
60  }
61 }
math::XYZTLorentzVector pat::helper::ParametrizationHelper::p4fromParameters ( pat::CandKinResolution::Parametrization  parametrization,
const AlgebraicVector4 parameters,
const math::XYZTLorentzVector initialP4 
)

Given a choice of coordinate frame, a vector of coordinates and a reference 4-vector, produce a new 4 vector with the specified parameters. The new 4-vector is not guaranteed to satisfy the constraints of these parametrization if the initial 4-vector does not satisfy them. In the future this method will throw an exception if you go in an unphysical point of the coordinate system (e.g. E^2 < P^2)

Definition at line 151 of file ParametrizationHelper.cc.

References pat::CandKinResolution::Cart, pat::CandKinResolution::ECart, pat::CandKinResolution::EMomDev, pat::CandKinResolution::EScaledMomDev, pat::CandKinResolution::MCCart, pat::CandKinResolution::MCMomDev, pat::CandKinResolution::MomDev, AlCaHLTBitMon_ParallelJobs::p, polarP4fromParameters(), runTheMatrix::ret, and mathSSE::sqrt().

153  {
155  switch (parametrization) {
156  // ======= CARTESIAN ==========
158  ret.SetCoordinates(parameters[0], parameters[1], parameters[2],
159  sqrt(parameters[0]*parameters[0] +
160  parameters[1]*parameters[1] +
161  parameters[2]*parameters[2] +
162  parameters[3]*parameters[3]) );
163  break;
164  case pat::CandKinResolution::MCCart: // same as above
165  ret.SetCoordinates(parameters[0], parameters[1], parameters[2],
166  sqrt(parameters[0]*parameters[0] +
167  parameters[1]*parameters[1] +
168  parameters[2]*parameters[2] +
169  initialP4.mass()*initialP4.mass()) );
170  break;
172  ret.SetCoordinates(parameters[0], parameters[1], parameters[2], parameters[3]);
173  break;
174  // ======= MomentumDeviates ==========
179  {
180  ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D<double> > p = initialP4.Vect(), uz(0,0,1), uph, uth;
181  uph = uz.Cross(p).Unit();
182  uth = p.Cross(uph).Unit();
183  p *= parameters[0];
184  p += uth * parameters[1] + uph * parameters[2];
185  if (parametrization == pat::CandKinResolution::MomDev) {
186  ret.SetCoordinates(p.X(), p.Y(), p.Z(), sqrt(p.Mag2() + ROOT::Math::Square(initialP4.mass() * parameters[3])) );
187  } else if (parametrization == pat::CandKinResolution::EMomDev) {
188  ret.SetCoordinates(p.X(), p.Y(), p.Z(), parameters[3] * initialP4.energy());
189  } else if (parametrization == pat::CandKinResolution::EMomDev) {
190  ret.SetCoordinates(p.X(), p.Y(), p.Z(), p.R() * initialP4.E()/initialP4.P());
191  } else {
192  ret.SetCoordinates(p.X(), p.Y(), p.Z(), sqrt(p.Mag2() + initialP4.mass()*initialP4.mass()));
193  }
194  break;
195  }
196  // ======= ALL OTHERS ==========
197  default:
198  ret = polarP4fromParameters(parametrization, parameters, math::PtEtaPhiMLorentzVector(initialP4));
199  }
200  return ret;
201 }
tuple ret
prodAgent to be discontinued
PtEtaPhiMLorentzVectorD PtEtaPhiMLorentzVector
Lorentz vector with cartesian internal representation.
Definition: LorentzVector.h:25
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
T sqrt(T t)
Definition: SSEVec.h:18
math::PtEtaPhiMLorentzVector polarP4fromParameters(pat::CandKinResolution::Parametrization parametrization, const AlgebraicVector4 &parameters, const math::PtEtaPhiMLorentzVector &initialP4)
AlgebraicVector4 pat::helper::ParametrizationHelper::parametersFromP4 ( pat::CandKinResolution::Parametrization  parametrization,
const math::XYZTLorentzVector p4 
)

Returns a vector of coordinates values given a coordinate frame and a 4-vector.

Definition at line 278 of file ParametrizationHelper.cc.

References runTheMatrix::ret, and setParametersFromP4().

Referenced by diffToParameters().

278  {
280  setParametersFromP4(parametrization, ret, p4);
281  return ret;
282 }
tuple ret
prodAgent to be discontinued
double p4[4]
Definition: TauolaWrapper.h:92
void setParametersFromP4(pat::CandKinResolution::Parametrization parametrization, AlgebraicVector4 &pars, const math::XYZTLorentzVector &p4)
Set the values of the parameters for a given 4-momentum.
ROOT::Math::SVector< double, 4 > AlgebraicVector4
AlgebraicVector4 pat::helper::ParametrizationHelper::parametersFromP4 ( pat::CandKinResolution::Parametrization  parametrization,
const math::PtEtaPhiMLorentzVector p4 
)

Returns a vector of coordinates values given a coordinate frame and a 4-vector.

Definition at line 271 of file ParametrizationHelper.cc.

References runTheMatrix::ret, and setParametersFromP4().

271  {
273  setParametersFromP4(parametrization, ret, p4);
274  return ret;
275 }
tuple ret
prodAgent to be discontinued
double p4[4]
Definition: TauolaWrapper.h:92
void setParametersFromP4(pat::CandKinResolution::Parametrization parametrization, AlgebraicVector4 &pars, const math::XYZTLorentzVector &p4)
Set the values of the parameters for a given 4-momentum.
ROOT::Math::SVector< double, 4 > AlgebraicVector4
math::PtEtaPhiMLorentzVector pat::helper::ParametrizationHelper::polarP4fromParameters ( pat::CandKinResolution::Parametrization  parametrization,
const AlgebraicVector4 parameters,
const math::PtEtaPhiMLorentzVector initialP4 
)

Given a choice of coordinate frame, a vector of coordinates and a reference 4-vector, produce a new 4 vector with the specified parameters. The new 4-vector is not guaranteed to satisfy the constraints of these parametrization if the initial 4-vector does not satisfy them. In the future this method will throw an exception if you go in an unphysical point of the coordinate system (e.g. E^2 < P^2)

Definition at line 64 of file ParametrizationHelper.cc.

References pat::CandKinResolution::Cart, pat::CandKinResolution::ECart, pat::CandKinResolution::EMomDev, pat::CandKinResolution::EScaledMomDev, pat::CandKinResolution::ESpher, pat::CandKinResolution::EtEtaPhi, pat::CandKinResolution::EtThetaPhi, Exception, pat::CandKinResolution::Invalid, pat::CandKinResolution::MCCart, pat::CandKinResolution::MCMomDev, pat::CandKinResolution::MCPInvSpher, pat::CandKinResolution::MCSpher, pat::CandKinResolution::MomDev, AlCaHLTBitMon_ParallelJobs::p, runTheMatrix::ret, pat::CandKinResolution::Spher, and mathSSE::sqrt().

Referenced by p4fromParameters().

66  {
68  ROOT::Math::CylindricalEta3D<double> converter;
69  double m2;
70  switch (parametrization) {
71  // ======= CARTESIAN ==========
74  sqrt(parameters[0]*parameters[0] +
75  parameters[1]*parameters[1] +
76  parameters[2]*parameters[2] +
77  parameters[3]*parameters[3]) );
78  ret.SetM(parameters[3]); // to be sure about roundoffs
79  break;
82  sqrt(parameters[0]*parameters[0] +
83  parameters[1]*parameters[1] +
84  parameters[2]*parameters[2] +
85  initialP4.mass()*initialP4.mass()) );
86  ret.SetM(initialP4.mass()); // to be sure about roundoffs
87  break;
90  break;
91  // ======= SPHERICAL ==========
93  converter = ROOT::Math::Polar3D<double>(parameters[0], parameters[1], 0);
94  ret.SetCoordinates(converter.Rho(),converter.Eta(),parameters[2],parameters[3]);
95  break;
96  case pat::CandKinResolution::MCSpher: // same as above
97  converter = ROOT::Math::Polar3D<double>(parameters[0], parameters[1], 0);
98  ret.SetCoordinates(converter.Rho(),converter.Eta(),parameters[2],initialP4.mass());
99  break;
101  converter = ROOT::Math::Polar3D<double>(parameters[0], parameters[1], 0);
102  m2 = - parameters[0]*parameters[0] + parameters[3]*parameters[3];
103  ret.SetCoordinates(converter.Rho(),converter.Eta(),parameters[2],(m2 > 0 ? sqrt(m2) : 0.0));
104  break;
106  converter = ROOT::Math::Polar3D<double>(1.0/parameters[0], parameters[1], 0);
107  ret.SetCoordinates(converter.Rho(),converter.Eta(),parameters[2],initialP4.mass());
108  break;
109  // ======= HEP CYLINDRICAL ==========
111  converter = ROOT::Math::Polar3D<double>(1.0, parameters[1], 0);
112  ret.SetCoordinates(parameters[0],converter.Eta(),parameters[2],0);
113  break;
114  case pat::CandKinResolution::EtEtaPhi: // as simple as that
115  ret.SetCoordinates(parameters[0], parameters[1], parameters[2], 0);
116  break;
117  // ======= MomentumDeviates ==========
122  {
123  ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D<double> > p = initialP4.Vect(), uz(0,0,1), uph, uth;
124  uph = uz.Cross(p).Unit();
125  uth = p.Cross(uph).Unit();
126  p *= parameters[0];
127  p += uth * parameters[1] + uph * parameters[2];
128  if (parametrization == pat::CandKinResolution::MomDev) {
129  ret.SetCoordinates(p.Rho(), p.Eta(), p.Phi(), initialP4.mass() * parameters[3]);
130  } else if (parametrization == pat::CandKinResolution::EMomDev) {
131  double m2 = ROOT::Math::Square(parameters[3] * initialP4.energy()) - p.Mag2();
132  ret.SetCoordinates(p.Rho(), p.Eta(), p.Phi(), (m2 > 0 ? sqrt(m2) : 0.0));
133  } else if (parametrization == pat::CandKinResolution::EScaledMomDev) {
134  double m2 = ROOT::Math::Square(p.R()*initialP4.E()/initialP4.P()) - p.Mag2();
135  ret.SetCoordinates(p.Rho(), p.Eta(), p.Phi(), (m2 > 0 ? sqrt(m2) : 0.0));
136  } else if (parametrization == pat::CandKinResolution::MCMomDev) {
137  ret.SetCoordinates(p.Rho(), p.Eta(), p.Phi(), initialP4.mass());
138  }
139  break;
140  }
141  // ======= OTHER ==========
143  throw cms::Exception("Invalid parametrization") << parametrization;
144  default:
145  throw cms::Exception("Not Implemented") << "getResolEta not yet implemented for parametrization " << parametrization ;
146  }
147  return ret;
148 }
tuple ret
prodAgent to be discontinued
PtEtaPhiMLorentzVectorD PtEtaPhiMLorentzVector
Lorentz vector with cartesian internal representation.
Definition: LorentzVector.h:25
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
T sqrt(T t)
Definition: SSEVec.h:18
template<typename T >
void pat::helper::ParametrizationHelper::setParametersFromAnyVector ( pat::CandKinResolution::Parametrization  parametrization,
AlgebraicVector4 pars,
const T p4 
)

For internal use only, so we provide only the interface. Use the 'setParametersFromP4'.

Definition at line 205 of file ParametrizationHelper.cc.

References pat::CandKinResolution::Cart, pat::CandKinResolution::ECart, pat::CandKinResolution::EMomDev, pat::CandKinResolution::EScaledMomDev, pat::CandKinResolution::ESpher, pat::CandKinResolution::EtEtaPhi, pat::CandKinResolution::EtThetaPhi, Exception, pat::CandKinResolution::Invalid, pat::CandKinResolution::MCCart, pat::CandKinResolution::MCMomDev, pat::CandKinResolution::MCPInvSpher, pat::CandKinResolution::MCSpher, pat::CandKinResolution::MomDev, and pat::CandKinResolution::Spher.

Referenced by setParametersFromP4().

207  {
208  switch (parametrization) {
209  // ======= CARTESIAN ==========
211  ret[0] = p4.px(); ret[1] = p4.py(); ret[2] = p4.pz(); ret[3] = p4.mass();
212  break;
214  ret[0] = p4.px(); ret[1] = p4.py(); ret[2] = p4.pz(); ret[3] = p4.mass();
215  break;
217  ret[0] = p4.px(); ret[1] = p4.py(); ret[2] = p4.pz(); ret[3] = p4.energy();
218  break;
219  // ======= SPHERICAL ==========
221  ret[0] = p4.P(); ret[1] = p4.theta(); ret[2] = p4.phi(); ret[3] = p4.mass();
222  break;
224  ret[0] = p4.P(); ret[1] = p4.theta(); ret[2] = p4.phi(); ret[3] = p4.mass();
225  break;
227  ret[0] = p4.P(); ret[1] = p4.theta(); ret[2] = p4.phi(); ret[3] = p4.energy();
228  break;
230  ret[0] = 1.0/p4.P(); ret[1] = p4.theta(); ret[2] = p4.phi(); ret[3] = p4.mass();
231  break;
232  // ======= HEP CYLINDRICAL ==========
234  ret[0] = p4.pt(); ret[1] = p4.theta(); ret[2] = p4.phi(); ret[3] = 0;
235  break;
237  ret[0] = p4.pt(); ret[1] = p4.eta(); ret[2] = p4.phi(); ret[3] = 0;
238  break;
239  // ======= DEVIATES ==========
242  ret[0] = 1.0; ret[1] = 0.0; ret[2] = 0.0; ret[3] = 1.0;
243  break;
245  ret[0] = 1.0; ret[1] = 0.0; ret[2] = 0.0; ret[3] = p4.mass();
246  break;
248  ret[0] = 1.0; ret[1] = 0.0; ret[2] = 0.0; ret[3] = p4.E()/p4.P();
249  break;
250  // ======= OTHER ==========
252  throw cms::Exception("Invalid parametrization") << parametrization;
253  default:
254  throw cms::Exception("Not Implemented") << "getResolEta not yet implemented for parametrization " << parametrization ;
255  }
256 }
tuple ret
prodAgent to be discontinued
double p4[4]
Definition: TauolaWrapper.h:92
void pat::helper::ParametrizationHelper::setParametersFromP4 ( pat::CandKinResolution::Parametrization  parametrization,
AlgebraicVector4 pars,
const math::XYZTLorentzVector p4 
)

Set the values of the parameters for a given 4-momentum.

Definition at line 265 of file ParametrizationHelper.cc.

References setParametersFromAnyVector().

Referenced by parametersFromP4().

266  {
267  setParametersFromAnyVector(parametrization, v, p4);
268 }
double p4[4]
Definition: TauolaWrapper.h:92
void setParametersFromAnyVector(pat::CandKinResolution::Parametrization parametrization, AlgebraicVector4 &pars, const T &p4)
For internal use only, so we provide only the interface. Use the &#39;setParametersFromP4&#39;.
void pat::helper::ParametrizationHelper::setParametersFromP4 ( pat::CandKinResolution::Parametrization  parametrization,
AlgebraicVector4 pars,
const math::PtEtaPhiMLorentzVector p4 
)

Set the values of the parameters for a given 4-momentum.

Definition at line 259 of file ParametrizationHelper.cc.

References setParametersFromAnyVector().

260  {
261  setParametersFromAnyVector(parametrization, v, p4);
262 }
double p4[4]
Definition: TauolaWrapper.h:92
void setParametersFromAnyVector(pat::CandKinResolution::Parametrization parametrization, AlgebraicVector4 &pars, const T &p4)
For internal use only, so we provide only the interface. Use the &#39;setParametersFromP4&#39;.