1 #ifndef RIVET_MATH_VECTOR4 2 #define RIVET_MATH_VECTOR4 4 #include "Rivet/Tools/TypeTraits.hh" 5 #include "Rivet/Math/MathConstants.hh" 6 #include "Rivet/Math/MathUtils.hh" 7 #include "Rivet/Math/VectorN.hh" 8 #include "Rivet/Math/Vector3.hh" 14 typedef FourVector Vector4;
15 typedef FourVector V4;
18 typedef FourMomentum P4;
20 class LorentzTransform;
21 FourVector
transform(
const LorentzTransform& lt,
const FourVector& v4);
37 template<typename V4TYPE, typename std::enable_if<HasXYZT<V4TYPE>::value,
int>::type DUMMY=0>
39 this->setT(other.t());
40 this->setX(other.x());
41 this->setY(other.y());
42 this->setZ(other.z());
48 FourVector(
const double t,
const double x,
const double y,
const double z) {
55 virtual ~FourVector() { }
59 double t()
const {
return get(0); }
60 double t2()
const {
return sqr(t()); }
61 FourVector& setT(
const double t) {
set(0, t);
return *
this; }
63 double x()
const {
return get(1); }
64 double x2()
const {
return sqr(x()); }
65 FourVector& setX(
const double x) {
set(1, x);
return *
this; }
67 double y()
const {
return get(2); }
68 double y2()
const {
return sqr(y()); }
69 FourVector& setY(
const double y) {
set(2, y);
return *
this; }
71 double z()
const {
return get(3); }
72 double z2()
const {
return sqr(z()); }
73 FourVector& setZ(
const double z) {
set(3, z);
return *
this; }
75 double invariant()
const {
77 return (t() + z())*(t() - z()) - x()*x() - y()*y();
85 double angle(
const FourVector& v)
const {
168 return Vector3(
get(1),
get(2),
get(3));
179 const double result = t()*v.t() - x()*v.x() - y()*v.y() - z()*v.z();
184 double dot(
const FourVector& v)
const {
195 _vec = multiply(a, *
this)._vec;
201 _vec = multiply(1.0/a, *
this)._vec;
207 _vec = add(*
this, v)._vec;
213 _vec = add(*
this, -v)._vec;
226 FourVector result = -*
this;
227 result.setT(-result.t());
246 result._vec = a * v._vec;
251 return multiply(a, v);
255 return multiply(a, v);
259 return multiply(a, v);
263 return multiply(1.0/a, v);
268 result._vec = a._vec + b._vec;
283 return lv.invariant();
315 template<typename V4TYPE, typename std::enable_if<HasXYZT<V4TYPE>::value,
int>::type DUMMY=0>
317 this->setE(other.t());
318 this->setPx(other.x());
319 this->setPy(other.y());
320 this->setPz(other.z());
326 FourMomentum(
const double E,
const double px,
const double py,
const double pz) {
367 FourMomentum&
setPE(
double px,
double py,
double pz,
double E) {
369 throw std::invalid_argument(
"Negative energy given as argument: " +
to_str(E));
370 setPx(px); setPy(py); setPz(pz); setE(E);
374 FourMomentum&
setXYZE(
double px,
double py,
double pz,
double E) {
375 return setPE(px, py, pz, E);
388 FourMomentum&
setPM(
double px,
double py,
double pz,
double mass) {
390 throw std::invalid_argument(
"Negative mass given as argument: " +
to_str(mass));
391 const double E = sqrt(
sqr(mass) +
sqr(px) +
sqr(py) +
sqr(pz) );
393 return setPE(px, py, pz, E);
396 FourMomentum&
setXYZM(
double px,
double py,
double pz,
double mass) {
397 return setPM(px, py, pz, mass);
407 throw std::invalid_argument(
"Negative mass given as argument");
409 throw std::invalid_argument(
"Negative energy given as argument");
410 const double theta = 2 * atan(exp(-eta));
411 if (theta < 0 || theta > M_PI)
412 throw std::domain_error(
"Polar angle outside 0..pi in calculation");
413 setThetaPhiME(theta, phi, mass, E);
423 throw std::invalid_argument(
"Negative mass given as argument");
425 throw std::invalid_argument(
"Negative transverse momentum given as argument");
426 const double theta = 2 * atan(exp(-eta));
427 if (theta < 0 || theta > M_PI)
428 throw std::domain_error(
"Polar angle outside 0..pi in calculation");
429 const double p = pt / sin(theta);
430 const double E = sqrt(
sqr(p) +
sqr(mass) );
431 setThetaPhiME(theta, phi, mass, E);
445 throw std::invalid_argument(
"Negative mass given as argument");
447 throw std::invalid_argument(
"Negative energy given as argument");
448 const double sqrt_pt2_m2 = E / cosh(y);
449 const double pt = sqrt(
sqr(sqrt_pt2_m2) -
sqr(mass) );
451 throw std::domain_error(
"Negative transverse momentum in calculation");
452 const double pz = sqrt_pt2_m2 * sinh(y);
453 const double px = pt * cos(phi);
454 const double py = pt * sin(phi);
455 setPE(px, py, pz, E);
465 throw std::invalid_argument(
"Negative mass given as argument");
467 throw std::invalid_argument(
"Negative transverse mass given as argument");
468 const double E = sqrt(
sqr(pt) +
sqr(mass) ) * cosh(y);
470 throw std::domain_error(
"Negative energy in calculation");
471 setRapPhiME(y, phi, mass, E);
481 if (theta < 0 || theta > M_PI)
482 throw std::invalid_argument(
"Polar angle outside 0..pi given as argument");
484 throw std::invalid_argument(
"Negative mass given as argument");
486 throw std::invalid_argument(
"Negative energy given as argument");
487 const double p = sqrt(
sqr(E) -
sqr(mass) );
488 const double pz = p * cos(theta);
489 const double pt = p * sin(theta);
491 throw std::invalid_argument(
"Negative transverse momentum in calculation");
492 const double px = pt * cos(phi);
493 const double py = pt * sin(phi);
494 setPE(px, py, pz, E);
504 if (theta < 0 || theta > M_PI)
505 throw std::invalid_argument(
"Polar angle outside 0..pi given as argument");
507 throw std::invalid_argument(
"Negative mass given as argument");
509 throw std::invalid_argument(
"Negative transverse momentum given as argument");
510 const double p = pt / sin(theta);
511 const double px = pt * cos(phi);
512 const double py = pt * sin(phi);
513 const double pz = p * cos(theta);
514 const double E = sqrt(
sqr(p) +
sqr(mass) );
515 setPE(px, py, pz, E);
524 throw std::invalid_argument(
"Negative transverse momentum given as argument");
526 throw std::invalid_argument(
"Negative mass given as argument");
528 throw std::invalid_argument(
"Negative energy given as argument");
529 const double px = pt * cos(phi);
530 const double py = pt * sin(phi);
531 const double pz = sqrt(
sqr(E) -
sqr(mass) -
sqr(pt));
532 setPE(px, py, pz, E);
543 double E()
const {
return t(); }
545 double E2()
const {
return t2(); }
548 double px()
const {
return x(); }
550 double px2()
const {
return x2(); }
553 double py()
const {
return y(); }
555 double py2()
const {
return y2(); }
558 double pz()
const {
return z(); }
560 double pz2()
const {
return z2(); }
573 return sign(mass2()) * sqrt(fabs(mass2()));
598 return 0.5 * std::log( (E() + pz()) / (E() - pz()) );
659 return sqrt(E2()/mass2());
665 return gamma() * p3().
unit();
691 struct byEAscending {
692 bool operator()(
const FourMomentum& left,
const FourMomentum& right)
const{
693 const double pt2left = left.
E();
694 const double pt2right = right.
E();
695 return pt2left < pt2right;
698 bool operator()(
const FourMomentum* left,
const FourMomentum* right)
const{
699 return (*
this)(*left, *right);
706 struct byEDescending {
707 bool operator()(
const FourMomentum& left,
const FourMomentum& right)
const{
708 return byEAscending()(right, left);
711 bool operator()(
const FourMomentum* left,
const FourVector* right)
const{
712 return (*
this)(*left, *right);
727 _vec = multiply(a, *
this)._vec;
733 _vec = multiply(1.0/a, *
this)._vec;
739 _vec = add(*
this, v)._vec;
745 _vec = add(*
this, -v)._vec;
758 FourMomentum result = -*
this;
759 result.
setE(-result.
E());
773 static FourMomentum
mkXYZE(
double px,
double py,
double pz,
double E) {
774 return FourMomentum().
setPE(px, py, pz, E);
778 static FourMomentum
mkXYZM(
double px,
double py,
double pz,
double mass) {
779 return FourMomentum().
setPM(px, py, pz, mass);
784 return FourMomentum().
setEtaPhiME(eta, phi, mass, E);
793 static FourMomentum
mkRapPhiME(
double y,
double phi,
double mass,
double E) {
794 return FourMomentum().
setRapPhiME(y, phi, mass, E);
813 static FourMomentum
mkPtPhiME(
double pt,
double phi,
double mass,
double E) {
814 return FourMomentum().
setPtPhiME(pt, phi, mass, E);
825 result._vec = a * v._vec;
830 return multiply(a, v);
834 return multiply(a, v);
838 return multiply(a, v);
842 return multiply(1.0/a, v);
847 result._vec = a._vec + b._vec;
877 case PSEUDORAPIDITY :
884 string err =
"deltaR with scheme RAPIDITY can only be called with FourMomentum objects, not FourVectors";
885 throw std::runtime_error(err);
887 return deltaR2(*ma, *mb, scheme);
890 throw std::runtime_error(
"The specified deltaR scheme is not yet implemented");
904 return sqrt(
deltaR2(a, b, scheme));
916 double eta2,
double phi2,
919 case PSEUDORAPIDITY :
925 string err =
"deltaR with scheme RAPIDITY can only be called with FourMomentum objects, not FourVectors";
926 throw std::runtime_error(err);
928 return deltaR2(*mv, eta2, phi2, scheme);
931 throw std::runtime_error(
"The specified deltaR scheme is not yet implemented");
942 double eta2,
double phi2,
944 return sqrt(
deltaR2(v, eta2, phi2, scheme));
954 inline double deltaR2(
double eta1,
double phi1,
958 case PSEUDORAPIDITY :
964 string err =
"deltaR with scheme RAPIDITY can only be called with FourMomentum objects, not FourVectors";
965 throw std::runtime_error(err);
967 return deltaR2(eta1, phi1, *mv, scheme);
970 throw std::runtime_error(
"The specified deltaR scheme is not yet implemented");
980 inline double deltaR(
double eta1,
double phi1,
983 return sqrt(
deltaR2(eta1, phi1, v, scheme));
1001 throw std::runtime_error(
"The specified deltaR scheme is not yet implemented");
1013 return sqrt(
deltaR2(a, b, scheme));
1023 double eta2,
double phi2,
1026 case PSEUDORAPIDITY:
1031 throw std::runtime_error(
"The specified deltaR scheme is not yet implemented");
1041 double eta2,
double phi2,
1043 return sqrt(
deltaR2(v, eta2, phi2, scheme));
1056 case PSEUDORAPIDITY:
1061 throw std::runtime_error(
"The specified deltaR scheme is not yet implemented");
1070 inline double deltaR(
double eta1,
double phi1,
1073 return sqrt(
deltaR2(eta1, phi1, v, scheme));
1085 case PSEUDORAPIDITY:
1090 throw std::runtime_error(
"The specified deltaR scheme is not yet implemented");
1101 return sqrt(
deltaR2(a, b, scheme));
1122 return deltaR(b, a, scheme);
1347 return a.
pt() > b.
pt();
1351 return a.
pt() < b.
pt();
1365 return a.
Et() > b.
Et();
1369 return a.
Et() < b.
Et();
1374 return a.
E() > b.
E();
1378 return a.
E() < b.
E();
1392 return a.
eta() < b.
eta();
1402 return fabs(a.
eta()) < fabs(b.
eta());
1407 return fabs(a.
eta()) > fabs(b.
eta());
1434 template<
typename MOMS,
typename CMP>
1436 std::sort(pbs.begin(), pbs.end(),
cmp);
1440 template<
typename MOMS,
typename CMP>
1443 std::sort(rtn.begin(), rtn.end(),
cmp);
1448 template<
typename MOMS>
1453 template<
typename MOMS>
1459 template<
typename MOMS>
1464 template<
typename MOMS>
1470 template<
typename MOMS>
1475 template<
typename MOMS>
1488 return mT(vis.
p3(), invis.
p3());
1493 return mT(vis.
p3(), invis);
1498 return mT(vis, invis.
p3());
1512 std::ostringstream out;
1513 out <<
"(" << (fabs(lv.t()) < 1E-30 ? 0.0 : lv.t())
1514 <<
"; " << (fabs(lv.x()) < 1E-30 ? 0.0 : lv.x())
1515 <<
", " << (fabs(lv.y()) < 1E-30 ? 0.0 : lv.y())
1516 <<
", " << (fabs(lv.z()) < 1E-30 ? 0.0 : lv.z())
1532 typedef std::vector<FourMomentum> FourMomenta;
FourMomentum & setPy(double py)
Set y-component of momentum .
Definition: Vector4.hh:354
FourVector operator-() const
Multiply all components (space and time) by -1.
Definition: Vector4.hh:218
bool cmpMomByAscE(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by increasing energy.
Definition: Vector4.hh:1377
Definition: MC_Cent_pPb.hh:10
double abseta() const
Get the directly (alias).
Definition: Vector4.hh:164
double py2() const
Get y-squared .
Definition: Vector4.hh:555
FourMomentum & setXYZM(double px, double py, double pz, double mass)
Alias for setPM.
Definition: Vector4.hh:396
Vector3 rhoVec() const
Synonym for polarVec.
Definition: Vector3.hh:123
double pT() const
Calculate the transverse momentum .
Definition: Vector4.hh:633
FourMomentum & operator+=(const FourMomentum &v)
Add to this 4-vector. NB time as well as space components are added.
Definition: Vector4.hh:738
Vector3 betaVec() const
Definition: Vector4.hh:676
double perp() const
Synonym for polarRadius.
Definition: Vector4.hh:113
double rapidity(double E, double pz)
Calculate a rapidity value from the supplied energy E and longitudinal momentum pz.
Definition: MathUtils.hh:664
double px() const
Get x-component of momentum .
Definition: Vector4.hh:548
double mod2() const
Calculate the modulus-squared of a vector. .
Definition: VectorN.hh:84
double eta() const
Synonym for pseudorapidity.
Definition: Vector4.hh:157
static FourMomentum mkRapPhiMPt(double y, double phi, double mass, double pt)
Make a vector from (y,phi,pT) coordinates and the mass.
Definition: Vector4.hh:798
FourMomentum & setPz(double pz)
Set z-component of momentum .
Definition: Vector4.hh:360
FourVector & operator*=(double a)
Multiply by a scalar.
Definition: Vector4.hh:194
double polarRadius() const
Polar radius.
Definition: Vector3.hh:141
double absrap() const
Absolute rapidity.
Definition: Vector4.hh:610
bool cmpMomByMass(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by decreasing mass.
Definition: Vector4.hh:1382
double pt2() const
Calculate the squared transverse momentum .
Definition: Vector4.hh:628
bool cmpMomByDescAbsRap(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by decreasing absolute rapidity.
Definition: Vector4.hh:1426
Vector3 polarVec() const
Projection of 3-vector on to the plane.
Definition: Vector4.hh:122
double azimuthalAngle(const PhiMapping mapping=ZERO_2PI) const
Angle subtended by the 3-vector's projection in x-y and the x-axis.
Definition: Vector4.hh:135
double Et() const
Calculate the transverse energy .
Definition: Vector4.hh:646
bool cmpMomByEt(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by decreasing transverse energy.
Definition: Vector4.hh:1364
Vector3 ptvec() const
Synonym for pTvec.
Definition: Vector4.hh:619
double rho() const
Synonym for polarRadius.
Definition: Vector3.hh:149
Vector3 gammaVec() const
Definition: Vector4.hh:664
double absrapidity() const
Absolute rapidity.
Definition: Vector4.hh:606
double p2() const
Get the modulus-squared of the 3-momentum.
Definition: Vector4.hh:591
FourMomentum & operator*=(double a)
Multiply by a scalar.
Definition: Vector4.hh:726
double perp() const
Synonym for polarRadius.
Definition: Vector3.hh:145
bool cmpMomByEta(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by increasing eta (pseudorapidity)
Definition: Vector4.hh:1391
static FourMomentum mkThetaPhiME(double theta, double phi, double mass, double E)
Make a vector from (theta,phi,energy) coordinates and the mass.
Definition: Vector4.hh:803
MOMS & isortBy(MOMS &pbs, const CMP &cmp)
Sort a container of momenta by cmp and return by reference for non-const inputs.
Definition: Vector4.hh:1435
FourMomentum & setE(double E)
Set energy (time component of momentum).
Definition: Vector4.hh:342
double contract(const FourVector &v) const
Contract two 4-vectors, with metric signature (+ - - -).
Definition: Vector4.hh:178
bool cmpMomByPt(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by decreasing pT.
Definition: Vector4.hh:1346
static FourMomentum mkEtaPhiMPt(double eta, double phi, double mass, double pt)
Make a vector from (eta,phi,pT) coordinates and the mass.
Definition: Vector4.hh:788
static FourMomentum mkEtaPhiME(double eta, double phi, double mass, double E)
Make a vector from (eta,phi,energy) coordinates and the mass.
Definition: Vector4.hh:783
double mass2() const
Get the squared mass (the Lorentz self-invariant).
Definition: Vector4.hh:577
double abspseudorapidity() const
Get the directly.
Definition: Vector4.hh:162
MOMS sortByE(const MOMS &pbs)
Sort a container of momenta by E (decreasing) and return by value for const inputs.
Definition: Vector4.hh:1465
bool cmpMomByDescEta(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by decreasing eta (pseudorapidity)
Definition: Vector4.hh:1396
double rapidity() const
Calculate the rapidity.
Definition: Vector4.hh:597
MOMS sortByPt(const MOMS &pbs)
Sort a container of momenta by pT (decreasing) and return by value for const inputs.
Definition: Vector4.hh:1454
double pz2() const
Get z-squared .
Definition: Vector4.hh:560
FourMomentum & operator-=(const FourMomentum &v)
Subtract from this 4-vector. NB time as well as space components are subtracted.
Definition: Vector4.hh:744
Vector3 p3() const
Get 3-momentum part, .
Definition: Vector4.hh:583
double pseudorapidity() const
Pseudorapidity (defined purely by the 3-vector components)
Definition: Vector4.hh:153
bool cmpMomByE(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by decreasing energy.
Definition: Vector4.hh:1373
double polarRadius() const
Magnitude of projection of 3-vector on to the plane.
Definition: Vector4.hh:109
double E2() const
Get energy-squared .
Definition: Vector4.hh:545
double deltaEta(double eta1, double eta2, bool sign=false)
Definition: MathUtils.hh:637
FourMomentum & setThetaPhiME(double theta, double phi, double mass, double E)
Definition: Vector4.hh:480
bool cmpMomByAscPt(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by increasing pT.
Definition: Vector4.hh:1350
double angle(const Vector3 &v) const
Angle in radians to another vector.
Definition: Vector3.hh:91
FourMomentum & setEtaPhiMPt(double eta, double phi, double mass, double pt)
Definition: Vector4.hh:421
bool cmpMomByP(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by decreasing 3-momentum magnitude |p|.
Definition: Vector4.hh:1355
Vector3 polarVec() const
Polar projection of this vector into the x-y plane.
Definition: Vector3.hh:113
FourMomentum & setPtPhiME(double pt, double phi, double mass, double E)
Definition: Vector4.hh:522
FourMomentum & setThetaPhiMPt(double theta, double phi, double mass, double pt)
Definition: Vector4.hh:503
static FourMomentum mkPtPhiME(double pt, double phi, double mass, double E)
Make a vector from (pT,phi,energy) coordinates and the mass.
Definition: Vector4.hh:813
string to_str(const T &x)
Convert any object to a string.
Definition: Utils.hh:75
FourMomentum & setPx(double px)
Set x-component of momentum .
Definition: Vector4.hh:348
double polarAngle() const
Angle subtended by the vector and the z-axis.
Definition: Vector3.hh:176
PhiMapping
Enum for range of to be mapped into.
Definition: MathConstants.hh:49
double gamma() const
Definition: Vector4.hh:658
double dot(const FourVector &v) const
Contract two 4-vectors, with metric signature (+ - - -).
Definition: Vector4.hh:184
double pseudorapidity() const
Purely geometric approximation to rapidity.
Definition: Vector3.hh:195
double deltaPhi(double phi1, double phi2, bool sign=false)
Calculate the difference between two angles in radians.
Definition: MathUtils.hh:629
MOMS sortBy(const MOMS &pbs, const CMP &cmp)
Sort a container of momenta by cmp and return by value for const inputs.
Definition: Vector4.hh:1441
double angle(const Vector3 &v3) const
Angle between this vector and another (3-vector)
Definition: Vector4.hh:89
double rho2() const
Synonym for polarRadius2.
Definition: Vector3.hh:136
double mass() const
Get the mass (the Lorentz self-invariant).
Definition: Vector4.hh:566
double beta() const
Definition: Vector4.hh:670
double rho2() const
Synonym for polarRadius2.
Definition: Vector4.hh:104
FourMomentum operator-() const
Multiply all components (time and space) by -1.
Definition: Vector4.hh:750
MOMS sortByEt(const MOMS &pbs)
Sort a container of momenta by Et (decreasing) and return by value for const inputs.
Definition: Vector4.hh:1476
bool cmpMomByDescAbsEta(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by increasing absolute eta (pseudorapidity)
Definition: Vector4.hh:1406
MOMS & isortByEt(MOMS &pbs)
Sort a container of momenta by Et (decreasing) and return by reference for non-const inputs...
Definition: Vector4.hh:1471
bool cmpMomByAscMass(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by increasing mass.
Definition: Vector4.hh:1386
Specialisation of VectorN to a general (non-momentum) Lorentz 4-vector.
Definition: Vector4.hh:27
double mT(double pT1, double pT2, double dphi)
Definition: MathUtils.hh:681
double p() const
Get the modulus of the 3-momentum.
Definition: Vector4.hh:586
double invariant(const FourVector &lv)
Definition: Vector4.hh:282
static FourMomentum mkXYZE(double px, double py, double pz, double E)
Make a vector from (px,py,pz,E) coordinates.
Definition: Vector4.hh:773
std::vector< FourVector > FourVectors
Definition: Vector4.hh:1531
double deltaRap(double y1, double y2, bool sign=false)
Definition: MathUtils.hh:645
A minimal base class for -dimensional vectors.
Definition: VectorN.hh:13
double deltaR2(double rap1, double phi1, double rap2, double phi2)
Definition: MathUtils.hh:652
double polarRadius2() const
Mod-square of the projection of the 3-vector on to the plane This is a more efficient function than ...
Definition: Vector4.hh:96
double deltaR(double rap1, double phi1, double rap2, double phi2)
Definition: MathUtils.hh:659
double E() const
Get energy (time component of momentum).
Definition: Vector4.hh:543
const CONTAINER2 & transform(const CONTAINER1 &in, CONTAINER2 &out, const FN &f)
A single-container-arg version of std::transform, aka map.
Definition: Utils.hh:397
MOMS & isortByE(MOMS &pbs)
Sort a container of momenta by E (decreasing) and return by reference for non-const inputs...
Definition: Vector4.hh:1460
Vector3 perpVec() const
Synonym for polarVec.
Definition: Vector4.hh:126
bool cmpMomByAscP(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by increasing 3-momentum magnitude |p|.
Definition: Vector4.hh:1359
RapScheme
Enum for rapidity variable to be used in calculating , applying rapidity cuts, etc.
Definition: MathConstants.hh:46
FourMomentum & operator/=(double a)
Divide by a scalar.
Definition: Vector4.hh:732
Vector3 perpVec() const
Synonym for polarVec.
Definition: Vector3.hh:119
double operator*(const FourVector &v) const
Contract two 4-vectors, with metric signature (+ - - -).
Definition: Vector4.hh:189
FourMomentum & setRapPhiMPt(double y, double phi, double mass, double pt)
Definition: Vector4.hh:463
double perp2() const
Synonym for polarRadius2.
Definition: Vector4.hh:100
double pt() const
Calculate the transverse momentum .
Definition: Vector4.hh:637
Vector3 vector3() const
Get the spatial part of the 4-vector as a 3-vector.
Definition: Vector4.hh:167
Vector3 unit() const
Synonym for unitVec.
Definition: Vector3.hh:107
FourMomentum & setXYZE(double px, double py, double pz, double E)
Alias for setPE.
Definition: Vector4.hh:374
MOMS & isortByPt(MOMS &pbs)
Sort a container of momenta by pT (decreasing) and return by reference for non-const inputs...
Definition: Vector4.hh:1449
std::string toString(const AnalysisInfo &ai)
String representation.
static FourMomentum mkThetaPhiMPt(double theta, double phi, double mass, double pt)
Make a vector from (theta,phi,pT) coordinates and the mass.
Definition: Vector4.hh:808
FourMomentum & setRapPhiME(double y, double phi, double mass, double E)
Definition: Vector4.hh:443
double angle(const FourVector &v) const
Angle between this vector and another.
Definition: Vector4.hh:85
double theta() const
Synonym for polarAngle.
Definition: Vector4.hh:148
std::enable_if< std::is_floating_point< NUM >::value, bool >::type isZero(NUM val, double tolerance=1e-8)
Compare a number to zero.
Definition: MathUtils.hh:24
double polarAngle() const
Angle subtended by the 3-vector and the z-axis.
Definition: Vector4.hh:144
Vector3 pTvec() const
Calculate the transverse momentum vector .
Definition: Vector4.hh:615
FourMomentum & setEtaPhiME(double eta, double phi, double mass, double E)
Definition: Vector4.hh:405
double pz() const
Get z-component of momentum .
Definition: Vector4.hh:558
double phi(const PhiMapping mapping=ZERO_2PI) const
Synonym for azimuthalAngle.
Definition: Vector4.hh:139
double py() const
Get y-component of momentum .
Definition: Vector4.hh:553
double azimuthalAngle(const PhiMapping mapping=ZERO_2PI) const
Angle subtended by the vector's projection in x-y and the x-axis.
Definition: Vector3.hh:157
FourVector & operator-=(const FourVector &v)
Subtract from this 4-vector. NB time as well as space components are subtracted.
Definition: Vector4.hh:212
double px2() const
Get x-squared .
Definition: Vector4.hh:550
FourMomentum & setPE(double px, double py, double pz, double E)
Set the p coordinates and energy simultaneously.
Definition: Vector4.hh:367
double theta() const
Synonym for polarAngle.
Definition: Vector3.hh:183
double phi(const PhiMapping mapping=ZERO_2PI) const
Synonym for azimuthalAngle.
Definition: Vector3.hh:166
bool cmpMomByRap(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by increasing rapidity.
Definition: Vector4.hh:1411
Three-dimensional specialisation of Vector.
Definition: Vector3.hh:28
bool cmpMomByAscEt(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by increasing transverse energy.
Definition: Vector4.hh:1368
FourVector & operator+=(const FourVector &v)
Add to this 4-vector.
Definition: Vector4.hh:206
Vector3 rhoVec() const
Synonym for polarVec.
Definition: Vector4.hh:130
std::ostream & operator<<(std::ostream &os, const AnalysisInfo &ai)
Stream an AnalysisInfo as a text description.
Definition: AnalysisInfo.hh:356
FourVector & operator/=(double a)
Divide by a scalar.
Definition: Vector4.hh:200
Specialized version of the FourVector with momentum/energy functionality.
Definition: Vector4.hh:306
double eta() const
Synonym for pseudorapidity.
Definition: Vector3.hh:202
double Et2() const
Calculate the transverse energy .
Definition: Vector4.hh:642
static FourMomentum mkRapPhiME(double y, double phi, double mass, double E)
Make a vector from (y,phi,energy) coordinates and the mass.
Definition: Vector4.hh:793
static FourMomentum mkXYZM(double px, double py, double pz, double mass)
Make a vector from (px,py,pz) coordinates and the mass.
Definition: Vector4.hh:778
FourMomentum reverse() const
Multiply space components only by -1.
Definition: Vector4.hh:757
FourMomentum & setPM(double px, double py, double pz, double mass)
Set the p coordinates and mass simultaneously.
Definition: Vector4.hh:388
std::enable_if< std::is_arithmetic< NUM >::value, NUM >::type sqr(NUM a)
Named number-type squaring operation.
Definition: MathUtils.hh:219
double rap() const
Alias for rapidity.
Definition: Vector4.hh:601
double polarRadius2() const
Square of the polar radius (.
Definition: Vector3.hh:128
double mod() const
Calculate the modulus of a vector. .
Definition: VectorN.hh:95
double rho() const
Synonym for polarRadius.
Definition: Vector4.hh:117
double perp2() const
Synonym for polarRadius2.
Definition: Vector3.hh:132
bool cmpMomByAbsEta(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by increasing absolute eta (pseudorapidity)
Definition: Vector4.hh:1401
FourVector reverse() const
Multiply space components only by -1.
Definition: Vector4.hh:225
std::enable_if< std::is_arithmetic< NUM >::value, int >::type sign(NUM val)
Find the sign of a number.
Definition: MathUtils.hh:266
bool cmpMomByDescRap(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by decreasing rapidity.
Definition: Vector4.hh:1416
double pT2() const
Calculate the squared transverse momentum .
Definition: Vector4.hh:624
Cmp< T > cmp(const T &t1, const T &t2)
Global helper function for easy creation of Cmp objects.
Definition: Cmp.hh:255
bool cmpMomByAbsRap(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by increasing absolute rapidity.
Definition: Vector4.hh:1421