Rivet  3.1.4
Vector4.hh
1 #ifndef RIVET_MATH_VECTOR4
2 #define RIVET_MATH_VECTOR4
3 
4 #include "Rivet/Math/MathConstants.hh"
5 #include "Rivet/Math/MathUtils.hh"
6 #include "Rivet/Math/VectorN.hh"
7 #include "Rivet/Math/Vector3.hh"
8 
9 namespace Rivet {
10 
11 
12  class FourVector;
13  class FourMomentum;
14  class LorentzTransform;
15  typedef FourVector Vector4;
16  FourVector transform(const LorentzTransform& lt, const FourVector& v4);
17 
18 
22  class FourVector : public Vector<4> {
23  friend FourVector multiply(const double a, const FourVector& v);
24  friend FourVector multiply(const FourVector& v, const double a);
25  friend FourVector add(const FourVector& a, const FourVector& b);
26  friend FourVector transform(const LorentzTransform& lt, const FourVector& v4);
27 
28  public:
29 
30  FourVector() : Vector<4>() { }
31 
32  template<typename V4>
33  FourVector(const V4& other) {
34  this->setT(other.t());
35  this->setX(other.x());
36  this->setY(other.y());
37  this->setZ(other.z());
38  }
39 
40  FourVector(const Vector<4>& other)
41  : Vector<4>(other) { }
42 
43  FourVector(const double t, const double x, const double y, const double z) {
44  this->setT(t);
45  this->setX(x);
46  this->setY(y);
47  this->setZ(z);
48  }
49 
50  virtual ~FourVector() { }
51 
52  public:
53 
54  double t() const { return get(0); }
55  double t2() const { return sqr(t()); }
56  FourVector& setT(const double t) { set(0, t); return *this; }
57 
58  double x() const { return get(1); }
59  double x2() const { return sqr(x()); }
60  FourVector& setX(const double x) { set(1, x); return *this; }
61 
62  double y() const { return get(2); }
63  double y2() const { return sqr(y()); }
64  FourVector& setY(const double y) { set(2, y); return *this; }
65 
66  double z() const { return get(3); }
67  double z2() const { return sqr(z()); }
68  FourVector& setZ(const double z) { set(3, z); return *this; }
69 
70  double invariant() const {
71  // Done this way for numerical precision
72  return (t() + z())*(t() - z()) - x()*x() - y()*y();
73  }
74 
75  bool isNull() const {
76  return Rivet::isZero(invariant());
77  }
78 
80  double angle(const FourVector& v) const {
81  return vector3().angle( v.vector3() );
82  }
84  double angle(const Vector3& v3) const {
85  return vector3().angle(v3);
86  }
87 
91  double polarRadius2() const {
92  return vector3().polarRadius2();
93  }
95  double perp2() const {
96  return vector3().perp2();
97  }
99  double rho2() const {
100  return vector3().rho2();
101  }
102 
104  double polarRadius() const {
105  return vector3().polarRadius();
106  }
108  double perp() const {
109  return vector3().perp();
110  }
112  double rho() const {
113  return vector3().rho();
114  }
115 
117  Vector3 polarVec() const {
118  return vector3().polarVec();
119  }
121  Vector3 perpVec() const {
122  return vector3().perpVec();
123  }
125  Vector3 rhoVec() const {
126  return vector3().rhoVec();
127  }
128 
130  double azimuthalAngle(const PhiMapping mapping=ZERO_2PI) const {
131  return vector3().azimuthalAngle(mapping);
132  }
134  double phi(const PhiMapping mapping=ZERO_2PI) const {
135  return vector3().phi(mapping);
136  }
137 
139  double polarAngle() const {
140  return vector3().polarAngle();
141  }
143  double theta() const {
144  return vector3().theta();
145  }
146 
148  double pseudorapidity() const {
149  return vector3().pseudorapidity();
150  }
152  double eta() const {
153  return vector3().eta();
154  }
155 
157  double abspseudorapidity() const { return fabs(eta()); }
159  double abseta() const { return fabs(eta()); }
160 
162  Vector3 vector3() const {
163  return Vector3(get(1), get(2), get(3));
164  }
165 
167  operator Vector3 () const { return vector3(); }
168 
169 
170  public:
171 
173  double contract(const FourVector& v) const {
174  const double result = t()*v.t() - x()*v.x() - y()*v.y() - z()*v.z();
175  return result;
176  }
177 
179  double dot(const FourVector& v) const {
180  return contract(v);
181  }
182 
184  double operator*(const FourVector& v) const {
185  return contract(v);
186  }
187 
189  FourVector& operator*=(double a) {
190  _vec = multiply(a, *this)._vec;
191  return *this;
192  }
193 
195  FourVector& operator/=(double a) {
196  _vec = multiply(1.0/a, *this)._vec;
197  return *this;
198  }
199 
201  FourVector& operator+=(const FourVector& v) {
202  _vec = add(*this, v)._vec;
203  return *this;
204  }
205 
207  FourVector& operator-=(const FourVector& v) {
208  _vec = add(*this, -v)._vec;
209  return *this;
210  }
211 
213  FourVector operator-() const {
214  FourVector result;
215  result._vec = -_vec;
216  return result;
217  }
218 
220  FourVector reverse() const {
221  FourVector result = -*this;
222  result.setT(-result.t());
223  return result;
224  }
225 
226  };
227 
228 
230  inline double contract(const FourVector& a, const FourVector& b) {
231  return a.contract(b);
232  }
233 
235  inline double dot(const FourVector& a, const FourVector& b) {
236  return contract(a, b);
237  }
238 
239  inline FourVector multiply(const double a, const FourVector& v) {
240  FourVector result;
241  result._vec = a * v._vec;
242  return result;
243  }
244 
245  inline FourVector multiply(const FourVector& v, const double a) {
246  return multiply(a, v);
247  }
248 
249  inline FourVector operator*(const double a, const FourVector& v) {
250  return multiply(a, v);
251  }
252 
253  inline FourVector operator*(const FourVector& v, const double a) {
254  return multiply(a, v);
255  }
256 
257  inline FourVector operator/(const FourVector& v, const double a) {
258  return multiply(1.0/a, v);
259  }
260 
261  inline FourVector add(const FourVector& a, const FourVector& b) {
262  FourVector result;
263  result._vec = a._vec + b._vec;
264  return result;
265  }
266 
267  inline FourVector operator+(const FourVector& a, const FourVector& b) {
268  return add(a, b);
269  }
270 
271  inline FourVector operator-(const FourVector& a, const FourVector& b) {
272  return add(a, -b);
273  }
274 
277  inline double invariant(const FourVector& lv) {
278  return lv.invariant();
279  }
280 
282  inline double angle(const FourVector& a, const FourVector& b) {
283  return a.angle(b);
284  }
285 
287  inline double angle(const Vector3& a, const FourVector& b) {
288  return angle( a, b.vector3() );
289  }
290 
292  inline double angle(const FourVector& a, const Vector3& b) {
293  return a.angle(b);
294  }
295 
296 
298 
299 
301  class FourMomentum : public FourVector {
302  friend FourMomentum multiply(const double a, const FourMomentum& v);
303  friend FourMomentum multiply(const FourMomentum& v, const double a);
304  friend FourMomentum add(const FourMomentum& a, const FourMomentum& b);
305  friend FourMomentum transform(const LorentzTransform& lt, const FourMomentum& v4);
306 
307  public:
308  FourMomentum() { }
309 
310  template<typename V4>
311  FourMomentum(const V4& other) {
312  this->setE(other.t());
313  this->setPx(other.x());
314  this->setPy(other.y());
315  this->setPz(other.z());
316  }
317 
318  FourMomentum(const Vector<4>& other)
319  : FourVector(other) { }
320 
321  FourMomentum(const double E, const double px, const double py, const double pz) {
322  this->setE(E);
323  this->setPx(px);
324  this->setPy(py);
325  this->setPz(pz);
326  }
327 
328  ~FourMomentum() {}
329 
330  public:
331 
332 
334 
335 
337  FourMomentum& setE(double E) {
338  setT(E);
339  return *this;
340  }
341 
343  FourMomentum& setPx(double px) {
344  setX(px);
345  return *this;
346  }
347 
349  FourMomentum& setPy(double py) {
350  setY(py);
351  return *this;
352  }
353 
355  FourMomentum& setPz(double pz) {
356  setZ(pz);
357  return *this;
358  }
359 
360 
362  FourMomentum& setPE(double px, double py, double pz, double E) {
363  if (E < 0)
364  throw std::invalid_argument("Negative energy given as argument: " + to_str(E));
365  setPx(px); setPy(py); setPz(pz); setE(E);
366  return *this;
367  }
369  FourMomentum& setXYZE(double px, double py, double pz, double E) {
370  return setPE(px, py, pz, E);
371  }
372  // /// Near-alias with switched arg order
373  // FourMomentum& setEP(double E, double px, double py, double pz) {
374  // return setPE(px, py, pz, E);
375  // }
376  // /// Alias for setEP
377  // FourMomentum& setEXYZ(double E, double px, double py, double pz) {
378  // return setEP(E, px, py, pz);
379  // }
380 
381 
383  FourMomentum& setPM(double px, double py, double pz, double mass) {
384  if (mass < 0)
385  throw std::invalid_argument("Negative mass given as argument: " + to_str(mass));
386  const double E = sqrt( sqr(mass) + sqr(px) + sqr(py) + sqr(pz) );
387  // setPx(px); setPy(py); setPz(pz); setE(E);
388  return setPE(px, py, pz, E);
389  }
391  FourMomentum& setXYZM(double px, double py, double pz, double mass) {
392  return setPM(px, py, pz, mass);
393  }
394 
395 
400  FourMomentum& setEtaPhiME(double eta, double phi, double mass, double E) {
401  if (mass < 0)
402  throw std::invalid_argument("Negative mass given as argument");
403  if (E < 0)
404  throw std::invalid_argument("Negative energy given as argument");
405  const double theta = 2 * atan(exp(-eta));
406  if (theta < 0 || theta > M_PI)
407  throw std::domain_error("Polar angle outside 0..pi in calculation");
408  setThetaPhiME(theta, phi, mass, E);
409  return *this;
410  }
411 
416  FourMomentum& setEtaPhiMPt(double eta, double phi, double mass, double pt) {
417  if (mass < 0)
418  throw std::invalid_argument("Negative mass given as argument");
419  if (pt < 0)
420  throw std::invalid_argument("Negative transverse momentum given as argument");
421  const double theta = 2 * atan(exp(-eta));
422  if (theta < 0 || theta > M_PI)
423  throw std::domain_error("Polar angle outside 0..pi in calculation");
424  const double p = pt / sin(theta);
425  const double E = sqrt( sqr(p) + sqr(mass) );
426  setThetaPhiME(theta, phi, mass, E);
427  return *this;
428  }
429 
438  FourMomentum& setRapPhiME(double y, double phi, double mass, double E) {
439  if (mass < 0)
440  throw std::invalid_argument("Negative mass given as argument");
441  if (E < 0)
442  throw std::invalid_argument("Negative energy given as argument");
443  const double sqrt_pt2_m2 = E / cosh(y);
444  const double pt = sqrt( sqr(sqrt_pt2_m2) - sqr(mass) );
445  if (pt < 0)
446  throw std::domain_error("Negative transverse momentum in calculation");
447  const double pz = sqrt_pt2_m2 * sinh(y);
448  const double px = pt * cos(phi);
449  const double py = pt * sin(phi);
450  setPE(px, py, pz, E);
451  return *this;
452  }
453 
458  FourMomentum& setRapPhiMPt(double y, double phi, double mass, double pt) {
459  if (mass < 0)
460  throw std::invalid_argument("Negative mass given as argument");
461  if (pt < 0)
462  throw std::invalid_argument("Negative transverse mass given as argument");
463  const double E = sqrt( sqr(pt) + sqr(mass) ) * cosh(y);
464  if (E < 0)
465  throw std::domain_error("Negative energy in calculation");
466  setRapPhiME(y, phi, mass, E);
467  return *this;
468  }
469 
475  FourMomentum& setThetaPhiME(double theta, double phi, double mass, double E) {
476  if (theta < 0 || theta > M_PI)
477  throw std::invalid_argument("Polar angle outside 0..pi given as argument");
478  if (mass < 0)
479  throw std::invalid_argument("Negative mass given as argument");
480  if (E < 0)
481  throw std::invalid_argument("Negative energy given as argument");
482  const double p = sqrt( sqr(E) - sqr(mass) );
483  const double pz = p * cos(theta);
484  const double pt = p * sin(theta);
485  if (pt < 0)
486  throw std::invalid_argument("Negative transverse momentum in calculation");
487  const double px = pt * cos(phi);
488  const double py = pt * sin(phi);
489  setPE(px, py, pz, E);
490  return *this;
491  }
492 
498  FourMomentum& setThetaPhiMPt(double theta, double phi, double mass, double pt) {
499  if (theta < 0 || theta > M_PI)
500  throw std::invalid_argument("Polar angle outside 0..pi given as argument");
501  if (mass < 0)
502  throw std::invalid_argument("Negative mass given as argument");
503  if (pt < 0)
504  throw std::invalid_argument("Negative transverse momentum given as argument");
505  const double p = pt / sin(theta);
506  const double px = pt * cos(phi);
507  const double py = pt * sin(phi);
508  const double pz = p * cos(theta);
509  const double E = sqrt( sqr(p) + sqr(mass) );
510  setPE(px, py, pz, E);
511  return *this;
512  }
513 
517  FourMomentum& setPtPhiME(double pt, double phi, double mass, double E) {
518  if (pt < 0)
519  throw std::invalid_argument("Negative transverse momentum given as argument");
520  if (mass < 0)
521  throw std::invalid_argument("Negative mass given as argument");
522  if (E < 0)
523  throw std::invalid_argument("Negative energy given as argument");
524  const double px = pt * cos(phi);
525  const double py = pt * sin(phi);
526  const double pz = sqrt(sqr(E) - sqr(mass) - sqr(pt));
527  setPE(px, py, pz, E);
528  return *this;
529  }
530 
532 
533 
535 
536 
538  double E() const { return t(); }
540  double E2() const { return t2(); }
541 
543  double px() const { return x(); }
545  double px2() const { return x2(); }
546 
548  double py() const { return y(); }
550  double py2() const { return y2(); }
551 
553  double pz() const { return z(); }
555  double pz2() const { return z2(); }
556 
557 
561  double mass() const {
562  // assert(Rivet::isZero(mass2()) || mass2() > 0);
563  // if (Rivet::isZero(mass2())) {
564  // return 0.0;
565  // } else {
566  // return sqrt(mass2());
567  // }
568  return sign(mass2()) * sqrt(fabs(mass2()));
569  }
570 
572  double mass2() const {
573  return invariant();
574  }
575 
576 
578  Vector3 p3() const { return vector3(); }
579 
581  double p() const {
582  return p3().mod();
583  }
584 
586  double p2() const {
587  return p3().mod2();
588  }
589 
590 
592  double rapidity() const {
593  return 0.5 * std::log( (E() + pz()) / (E() - pz()) );
594  }
596  double rap() const {
597  return rapidity();
598  }
599 
601  double absrapidity() const {
602  return fabs(rapidity());
603  }
605  double absrap() const {
606  return fabs(rap());
607  }
608 
610  Vector3 pTvec() const {
611  return p3().polarVec();
612  }
614  Vector3 ptvec() const {
615  return pTvec();
616  }
617 
619  double pT2() const {
620  return vector3().polarRadius2();
621  }
623  double pt2() const {
624  return vector3().polarRadius2();
625  }
626 
628  double pT() const {
629  return sqrt(pT2());
630  }
632  double pt() const {
633  return sqrt(pT2());
634  }
635 
637  double Et2() const {
638  return Et() * Et();
639  }
641  double Et() const {
642  return E() * sin(polarAngle());
643  }
644 
646 
647 
649 
650 
653  double gamma() const {
654  return sqrt(E2()/mass2());
655  }
656 
659  Vector3 gammaVec() const {
660  return gamma() * p3().unit();
661  }
662 
665  double beta() const {
666  return p()/E();
667  }
668 
671  Vector3 betaVec() const {
672  // return Vector3(px()/E(), py()/E(), pz()/E());
673  return p3()/E();
674  }
675 
677 
678 
680 
681 
683 
686  struct byEAscending {
687  bool operator()(const FourMomentum& left, const FourMomentum& right) const{
688  const double pt2left = left.E();
689  const double pt2right = right.E();
690  return pt2left < pt2right;
691  }
692 
693  bool operator()(const FourMomentum* left, const FourMomentum* right) const{
694  return (*this)(*left, *right);
695  }
696  };
697 
698 
701  struct byEDescending {
702  bool operator()(const FourMomentum& left, const FourMomentum& right) const{
703  return byEAscending()(right, left);
704  }
705 
706  bool operator()(const FourMomentum* left, const FourVector* right) const{
707  return (*this)(*left, *right);
708  }
709  };
710 
712 
713 
715 
716 
718 
719 
721  FourMomentum& operator*=(double a) {
722  _vec = multiply(a, *this)._vec;
723  return *this;
724  }
725 
727  FourMomentum& operator/=(double a) {
728  _vec = multiply(1.0/a, *this)._vec;
729  return *this;
730  }
731 
733  FourMomentum& operator+=(const FourMomentum& v) {
734  _vec = add(*this, v)._vec;
735  return *this;
736  }
737 
739  FourMomentum& operator-=(const FourMomentum& v) {
740  _vec = add(*this, -v)._vec;
741  return *this;
742  }
743 
745  FourMomentum operator-() const {
746  FourMomentum result;
747  result._vec = -_vec;
748  return result;
749  }
750 
752  FourMomentum reverse() const {
753  FourMomentum result = -*this;
754  result.setE(-result.E());
755  return result;
756  }
757 
759 
760 
762 
763 
765 
766 
768  static FourMomentum mkXYZE(double px, double py, double pz, double E) {
769  return FourMomentum().setPE(px, py, pz, E);
770  }
771 
773  static FourMomentum mkXYZM(double px, double py, double pz, double mass) {
774  return FourMomentum().setPM(px, py, pz, mass);
775  }
776 
778  static FourMomentum mkEtaPhiME(double eta, double phi, double mass, double E) {
779  return FourMomentum().setEtaPhiME(eta, phi, mass, E);
780  }
781 
783  static FourMomentum mkEtaPhiMPt(double eta, double phi, double mass, double pt) {
784  return FourMomentum().setEtaPhiMPt(eta, phi, mass, pt);
785  }
786 
788  static FourMomentum mkRapPhiME(double y, double phi, double mass, double E) {
789  return FourMomentum().setRapPhiME(y, phi, mass, E);
790  }
791 
793  static FourMomentum mkRapPhiMPt(double y, double phi, double mass, double pt) {
794  return FourMomentum().setRapPhiMPt(y, phi, mass, pt);
795  }
796 
798  static FourMomentum mkThetaPhiME(double theta, double phi, double mass, double E) {
799  return FourMomentum().setThetaPhiME(theta, phi, mass, E);
800  }
801 
803  static FourMomentum mkThetaPhiMPt(double theta, double phi, double mass, double pt) {
804  return FourMomentum().setThetaPhiMPt(theta, phi, mass, pt);
805  }
806 
808  static FourMomentum mkPtPhiME(double pt, double phi, double mass, double E) {
809  return FourMomentum().setPtPhiME(pt, phi, mass, E);
810  }
811 
813 
814 
815  };
816 
817 
818 
819  inline FourMomentum multiply(const double a, const FourMomentum& v) {
820  FourMomentum result;
821  result._vec = a * v._vec;
822  return result;
823  }
824 
825  inline FourMomentum multiply(const FourMomentum& v, const double a) {
826  return multiply(a, v);
827  }
828 
829  inline FourMomentum operator*(const double a, const FourMomentum& v) {
830  return multiply(a, v);
831  }
832 
833  inline FourMomentum operator*(const FourMomentum& v, const double a) {
834  return multiply(a, v);
835  }
836 
837  inline FourMomentum operator/(const FourMomentum& v, const double a) {
838  return multiply(1.0/a, v);
839  }
840 
841  inline FourMomentum add(const FourMomentum& a, const FourMomentum& b) {
842  FourMomentum result;
843  result._vec = a._vec + b._vec;
844  return result;
845  }
846 
847  inline FourMomentum operator+(const FourMomentum& a, const FourMomentum& b) {
848  return add(a, b);
849  }
850 
851  inline FourMomentum operator-(const FourMomentum& a, const FourMomentum& b) {
852  return add(a, -b);
853  }
854 
855 
857 
858 
860 
861 
870  inline double deltaR2(const FourVector& a, const FourVector& b,
871  RapScheme scheme=PSEUDORAPIDITY) {
872  switch (scheme) {
873  case PSEUDORAPIDITY :
874  return deltaR2(a.vector3(), b.vector3());
875  case RAPIDITY:
876  {
877  const FourMomentum* ma = dynamic_cast<const FourMomentum*>(&a);
878  const FourMomentum* mb = dynamic_cast<const FourMomentum*>(&b);
879  if (!ma || !mb) {
880  string err = "deltaR with scheme RAPIDITY can only be called with FourMomentum objects, not FourVectors";
881  throw std::runtime_error(err);
882  }
883  return deltaR2(*ma, *mb, scheme);
884  }
885  default:
886  throw std::runtime_error("The specified deltaR scheme is not yet implemented");
887  }
888  }
889 
898  inline double deltaR(const FourVector& a, const FourVector& b,
899  RapScheme scheme=PSEUDORAPIDITY) {
900  return sqrt(deltaR2(a, b, scheme));
901  }
902 
903 
904 
911  inline double deltaR2(const FourVector& v,
912  double eta2, double phi2,
913  RapScheme scheme=PSEUDORAPIDITY) {
914  switch (scheme) {
915  case PSEUDORAPIDITY :
916  return deltaR2(v.vector3(), eta2, phi2);
917  case RAPIDITY:
918  {
919  const FourMomentum* mv = dynamic_cast<const FourMomentum*>(&v);
920  if (!mv) {
921  string err = "deltaR with scheme RAPIDITY can only be called with FourMomentum objects, not FourVectors";
922  throw std::runtime_error(err);
923  }
924  return deltaR2(*mv, eta2, phi2, scheme);
925  }
926  default:
927  throw std::runtime_error("The specified deltaR scheme is not yet implemented");
928  }
929  }
930 
937  inline double deltaR(const FourVector& v,
938  double eta2, double phi2,
939  RapScheme scheme=PSEUDORAPIDITY) {
940  return sqrt(deltaR2(v, eta2, phi2, scheme));
941  }
942 
943 
950  inline double deltaR2(double eta1, double phi1,
951  const FourVector& v,
952  RapScheme scheme=PSEUDORAPIDITY) {
953  switch (scheme) {
954  case PSEUDORAPIDITY :
955  return deltaR2(eta1, phi1, v.vector3());
956  case RAPIDITY:
957  {
958  const FourMomentum* mv = dynamic_cast<const FourMomentum*>(&v);
959  if (!mv) {
960  string err = "deltaR with scheme RAPIDITY can only be called with FourMomentum objects, not FourVectors";
961  throw std::runtime_error(err);
962  }
963  return deltaR2(eta1, phi1, *mv, scheme);
964  }
965  default:
966  throw std::runtime_error("The specified deltaR scheme is not yet implemented");
967  }
968  }
969 
976  inline double deltaR(double eta1, double phi1,
977  const FourVector& v,
978  RapScheme scheme=PSEUDORAPIDITY) {
979  return sqrt(deltaR2(eta1, phi1, v, scheme));
980  }
981 
982 
989  inline double deltaR2(const FourMomentum& a, const FourMomentum& b,
990  RapScheme scheme=PSEUDORAPIDITY) {
991  switch (scheme) {
992  case PSEUDORAPIDITY:
993  return deltaR2(a.vector3(), b.vector3());
994  case RAPIDITY:
995  return deltaR2(a.rapidity(), a.azimuthalAngle(), b.rapidity(), b.azimuthalAngle());
996  default:
997  throw std::runtime_error("The specified deltaR scheme is not yet implemented");
998  }
999  }
1000 
1007  inline double deltaR(const FourMomentum& a, const FourMomentum& b,
1008  RapScheme scheme=PSEUDORAPIDITY) {
1009  return sqrt(deltaR2(a, b, scheme));
1010  }
1011 
1012 
1018  inline double deltaR2(const FourMomentum& v,
1019  double eta2, double phi2,
1020  RapScheme scheme=PSEUDORAPIDITY) {
1021  switch (scheme) {
1022  case PSEUDORAPIDITY:
1023  return deltaR2(v.vector3(), eta2, phi2);
1024  case RAPIDITY:
1025  return deltaR2(v.rapidity(), v.azimuthalAngle(), eta2, phi2);
1026  default:
1027  throw std::runtime_error("The specified deltaR scheme is not yet implemented");
1028  }
1029  }
1030 
1036  inline double deltaR(const FourMomentum& v,
1037  double eta2, double phi2,
1038  RapScheme scheme=PSEUDORAPIDITY) {
1039  return sqrt(deltaR2(v, eta2, phi2, scheme));
1040  }
1041 
1042 
1048  inline double deltaR2(double eta1, double phi1,
1049  const FourMomentum& v,
1050  RapScheme scheme=PSEUDORAPIDITY) {
1051  switch (scheme) {
1052  case PSEUDORAPIDITY:
1053  return deltaR2(eta1, phi1, v.vector3());
1054  case RAPIDITY:
1055  return deltaR2(eta1, phi1, v.rapidity(), v.azimuthalAngle());
1056  default:
1057  throw std::runtime_error("The specified deltaR scheme is not yet implemented");
1058  }
1059  }
1060 
1066  inline double deltaR(double eta1, double phi1,
1067  const FourMomentum& v,
1068  RapScheme scheme=PSEUDORAPIDITY) {
1069  return sqrt(deltaR2(eta1, phi1, v, scheme));
1070  }
1071 
1072 
1078  inline double deltaR2(const FourMomentum& a, const FourVector& b,
1079  RapScheme scheme=PSEUDORAPIDITY) {
1080  switch (scheme) {
1081  case PSEUDORAPIDITY:
1082  return deltaR2(a.vector3(), b.vector3());
1083  case RAPIDITY:
1084  return deltaR2(a.rapidity(), a.azimuthalAngle(), FourMomentum(b).rapidity(), b.azimuthalAngle());
1085  default:
1086  throw std::runtime_error("The specified deltaR scheme is not yet implemented");
1087  }
1088  }
1089 
1095  inline double deltaR(const FourMomentum& a, const FourVector& b,
1096  RapScheme scheme=PSEUDORAPIDITY) {
1097  return sqrt(deltaR2(a, b, scheme));
1098  }
1099 
1100 
1106  inline double deltaR2(const FourVector& a, const FourMomentum& b,
1107  RapScheme scheme=PSEUDORAPIDITY) {
1108  return deltaR2(b, a, scheme); //< note reversed args
1109  }
1110 
1116  inline double deltaR(const FourVector& a, const FourMomentum& b,
1117  RapScheme scheme=PSEUDORAPIDITY) {
1118  return deltaR(b, a, scheme); //< note reversed args
1119  }
1120 
1121 
1124  inline double deltaR2(const FourMomentum& a, const Vector3& b) {
1125  return deltaR2(a.vector3(), b);
1126  }
1127 
1130  inline double deltaR(const FourMomentum& a, const Vector3& b) {
1131  return deltaR(a.vector3(), b);
1132  }
1133 
1136  inline double deltaR2(const Vector3& a, const FourMomentum& b) {
1137  return deltaR2(a, b.vector3());
1138  }
1139 
1142  inline double deltaR(const Vector3& a, const FourMomentum& b) {
1143  return deltaR(a, b.vector3());
1144  }
1145 
1148  inline double deltaR2(const FourVector& a, const Vector3& b) {
1149  return deltaR2(a.vector3(), b);
1150  }
1151 
1154  inline double deltaR(const FourVector& a, const Vector3& b) {
1155  return deltaR(a.vector3(), b);
1156  }
1157 
1160  inline double deltaR2(const Vector3& a, const FourVector& b) {
1161  return deltaR2(a, b.vector3());
1162  }
1163 
1166  inline double deltaR(const Vector3& a, const FourVector& b) {
1167  return deltaR(a, b.vector3());
1168  }
1169 
1171 
1172 
1174 
1175 
1177 
1178 
1180  inline double deltaPhi(const FourMomentum& a, const FourMomentum& b, bool sign=false) {
1181  return deltaPhi(a.vector3(), b.vector3(), sign);
1182  }
1183 
1185  inline double deltaPhi(const FourMomentum& v, double phi2, bool sign=false) {
1186  return deltaPhi(v.vector3(), phi2, sign);
1187  }
1188 
1190  inline double deltaPhi(double phi1, const FourMomentum& v, bool sign=false) {
1191  return deltaPhi(phi1, v.vector3(), sign);
1192  }
1193 
1195  inline double deltaPhi(const FourVector& a, const FourVector& b, bool sign=false) {
1196  return deltaPhi(a.vector3(), b.vector3(), sign);
1197  }
1198 
1200  inline double deltaPhi(const FourVector& v, double phi2, bool sign=false) {
1201  return deltaPhi(v.vector3(), phi2, sign);
1202  }
1203 
1205  inline double deltaPhi(double phi1, const FourVector& v, bool sign=false) {
1206  return deltaPhi(phi1, v.vector3(), sign);
1207  }
1208 
1210  inline double deltaPhi(const FourVector& a, const FourMomentum& b, bool sign=false) {
1211  return deltaPhi(a.vector3(), b.vector3(), sign);
1212  }
1213 
1215  inline double deltaPhi(const FourMomentum& a, const FourVector& b, bool sign=false) {
1216  return deltaPhi(a.vector3(), b.vector3(), sign);
1217  }
1218 
1220  inline double deltaPhi(const FourVector& a, const Vector3& b, bool sign=false) {
1221  return deltaPhi(a.vector3(), b, sign);
1222  }
1223 
1225  inline double deltaPhi(const Vector3& a, const FourVector& b, bool sign=false) {
1226  return deltaPhi(a, b.vector3(), sign);
1227  }
1228 
1230  inline double deltaPhi(const FourMomentum& a, const Vector3& b, bool sign=false) {
1231  return deltaPhi(a.vector3(), b, sign);
1232  }
1233 
1235  inline double deltaPhi(const Vector3& a, const FourMomentum& b, bool sign=false) {
1236  return deltaPhi(a, b.vector3(), sign);
1237  }
1238 
1240 
1241 
1243 
1244 
1246 
1247 
1249  inline double deltaEta(const FourMomentum& a, const FourMomentum& b, bool sign=false) {
1250  return deltaEta(a.vector3(), b.vector3(), sign);
1251  }
1252 
1254  inline double deltaEta(const FourMomentum& v, double eta2, bool sign=false) {
1255  return deltaEta(v.vector3(), eta2, sign);
1256  }
1257 
1259  inline double deltaEta(double eta1, const FourMomentum& v, bool sign=false) {
1260  return deltaEta(eta1, v.vector3(), sign);
1261  }
1262 
1264  inline double deltaEta(const FourVector& a, const FourVector& b, bool sign=false) {
1265  return deltaEta(a.vector3(), b.vector3(), sign);
1266  }
1267 
1269  inline double deltaEta(const FourVector& v, double eta2, bool sign=false) {
1270  return deltaEta(v.vector3(), eta2, sign);
1271  }
1272 
1274  inline double deltaEta(double eta1, const FourVector& v, bool sign=false) {
1275  return deltaEta(eta1, v.vector3(), sign);
1276  }
1277 
1279  inline double deltaEta(const FourVector& a, const FourMomentum& b, bool sign=false) {
1280  return deltaEta(a.vector3(), b.vector3(), sign);
1281  }
1282 
1284  inline double deltaEta(const FourMomentum& a, const FourVector& b, bool sign=false) {
1285  return deltaEta(a.vector3(), b.vector3(), sign);
1286  }
1287 
1289  inline double deltaEta(const FourVector& a, const Vector3& b, bool sign=false) {
1290  return deltaEta(a.vector3(), b, sign);
1291  }
1292 
1294  inline double deltaEta(const Vector3& a, const FourVector& b, bool sign=false) {
1295  return deltaEta(a, b.vector3(), sign);
1296  }
1297 
1299  inline double deltaEta(const FourMomentum& a, const Vector3& b, bool sign=false) {
1300  return deltaEta(a.vector3(), b, sign);
1301  }
1302 
1304  inline double deltaEta(const Vector3& a, const FourMomentum& b, bool sign=false) {
1305  return deltaEta(a, b.vector3(), sign);
1306  }
1307 
1309 
1310 
1312 
1313 
1315  inline double deltaRap(const FourMomentum& a, const FourMomentum& b, bool sign=false) {
1316  return deltaRap(a.rapidity(), b.rapidity(), sign);
1317  }
1318 
1320  inline double deltaRap(const FourMomentum& v, double y2, bool sign=false) {
1321  return deltaRap(v.rapidity(), y2, sign);
1322  }
1323 
1325  inline double deltaRap(double y1, const FourMomentum& v, bool sign=false) {
1326  return deltaRap(y1, v.rapidity(), sign);
1327  }
1328 
1330 
1331 
1333 
1334 
1337 
1340 
1342  inline bool cmpMomByPt(const FourMomentum& a, const FourMomentum& b) {
1343  return a.pt() > b.pt();
1344  }
1346  inline bool cmpMomByAscPt(const FourMomentum& a, const FourMomentum& b) {
1347  return a.pt() < b.pt();
1348  }
1349 
1351  inline bool cmpMomByP(const FourMomentum& a, const FourMomentum& b) {
1352  return a.vector3().mod() > b.vector3().mod();
1353  }
1355  inline bool cmpMomByAscP(const FourMomentum& a, const FourMomentum& b) {
1356  return a.vector3().mod() < b.vector3().mod();
1357  }
1358 
1360  inline bool cmpMomByEt(const FourMomentum& a, const FourMomentum& b) {
1361  return a.Et() > b.Et();
1362  }
1364  inline bool cmpMomByAscEt(const FourMomentum& a, const FourMomentum& b) {
1365  return a.Et() < b.Et();
1366  }
1367 
1369  inline bool cmpMomByE(const FourMomentum& a, const FourMomentum& b) {
1370  return a.E() > b.E();
1371  }
1373  inline bool cmpMomByAscE(const FourMomentum& a, const FourMomentum& b) {
1374  return a.E() < b.E();
1375  }
1376 
1378  inline bool cmpMomByMass(const FourMomentum& a, const FourMomentum& b) {
1379  return a.mass() > b.mass();
1380  }
1382  inline bool cmpMomByAscMass(const FourMomentum& a, const FourMomentum& b) {
1383  return a.mass() < b.mass();
1384  }
1385 
1387  inline bool cmpMomByEta(const FourMomentum& a, const FourMomentum& b) {
1388  return a.eta() < b.eta();
1389  }
1390 
1392  inline bool cmpMomByDescEta(const FourMomentum& a, const FourMomentum& b) {
1393  return a.pseudorapidity() > b.pseudorapidity();
1394  }
1395 
1397  inline bool cmpMomByAbsEta(const FourMomentum& a, const FourMomentum& b) {
1398  return fabs(a.eta()) < fabs(b.eta());
1399  }
1400 
1402  inline bool cmpMomByDescAbsEta(const FourMomentum& a, const FourMomentum& b) {
1403  return fabs(a.eta()) > fabs(b.eta());
1404  }
1405 
1407  inline bool cmpMomByRap(const FourMomentum& a, const FourMomentum& b) {
1408  return a.rapidity() < b.rapidity();
1409  }
1410 
1412  inline bool cmpMomByDescRap(const FourMomentum& a, const FourMomentum& b) {
1413  return a.rapidity() > b.rapidity();
1414  }
1415 
1417  inline bool cmpMomByAbsRap(const FourMomentum& a, const FourMomentum& b) {
1418  return fabs(a.rapidity()) < fabs(b.rapidity());
1419  }
1420 
1422  inline bool cmpMomByDescAbsRap(const FourMomentum& a, const FourMomentum& b) {
1423  return fabs(a.rapidity()) > fabs(b.rapidity());
1424  }
1425 
1427 
1428 
1430  template<typename MOMS, typename CMP>
1431  inline MOMS& isortBy(MOMS& pbs, const CMP& cmp) {
1432  std::sort(pbs.begin(), pbs.end(), cmp);
1433  return pbs;
1434  }
1436  template<typename MOMS, typename CMP>
1437  inline MOMS sortBy(const MOMS& pbs, const CMP& cmp) {
1438  MOMS rtn = pbs;
1439  std::sort(rtn.begin(), rtn.end(), cmp);
1440  return rtn;
1441  }
1442 
1444  template<typename MOMS>
1445  inline MOMS& isortByPt(MOMS& pbs) {
1446  return isortBy(pbs, cmpMomByPt);
1447  }
1449  template<typename MOMS>
1450  inline MOMS sortByPt(const MOMS& pbs) {
1451  return sortBy(pbs, cmpMomByPt);
1452  }
1453 
1455  template<typename MOMS>
1456  inline MOMS& isortByE(MOMS& pbs) {
1457  return isortBy(pbs, cmpMomByE);
1458  }
1460  template<typename MOMS>
1461  inline MOMS sortByE(const MOMS& pbs) {
1462  return sortBy(pbs, cmpMomByE);
1463  }
1464 
1466  template<typename MOMS>
1467  inline MOMS& isortByEt(MOMS& pbs) {
1468  return isortBy(pbs, cmpMomByEt);
1469  }
1471  template<typename MOMS>
1472  inline MOMS sortByEt(const MOMS& pbs) {
1473  return sortBy(pbs, cmpMomByEt);
1474  }
1475 
1477 
1478 
1481 
1483  inline double mT(const FourMomentum& vis, const FourMomentum& invis) {
1484  return mT(vis.p3(), invis.p3());
1485  }
1486 
1488  inline double mT(const FourMomentum& vis, const Vector3& invis) {
1489  return mT(vis.p3(), invis);
1490  }
1491 
1493  inline double mT(const Vector3& vis, const FourMomentum& invis) {
1494  return mT(vis, invis.p3());
1495  }
1496 
1498 
1499 
1501 
1502 
1505 
1507  inline std::string toString(const FourVector& lv) {
1508  std::ostringstream out;
1509  out << "(" << (fabs(lv.t()) < 1E-30 ? 0.0 : lv.t())
1510  << "; " << (fabs(lv.x()) < 1E-30 ? 0.0 : lv.x())
1511  << ", " << (fabs(lv.y()) < 1E-30 ? 0.0 : lv.y())
1512  << ", " << (fabs(lv.z()) < 1E-30 ? 0.0 : lv.z())
1513  << ")";
1514  return out.str();
1515  }
1516 
1518  inline std::ostream& operator<<(std::ostream& out, const FourVector& lv) {
1519  out << toString(lv);
1520  return out;
1521  }
1522 
1524 
1527  typedef std::vector<FourVector> FourVectors;
1528  typedef std::vector<FourMomentum> FourMomenta;
1530 
1532 
1533 
1534 }
1535 
1536 #endif
FourMomentum & setPy(double py)
Set y-component of momentum .
Definition: Vector4.hh:349
FourVector operator-() const
Multiply all components (space and time) by -1.
Definition: Vector4.hh:213
bool cmpMomByAscE(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by increasing energy.
Definition: Vector4.hh:1373
Definition: MC_Cent_pPb.hh:10
double abseta() const
Get the directly (alias).
Definition: Vector4.hh:159
double py2() const
Get y-squared .
Definition: Vector4.hh:550
FourMomentum & setXYZM(double px, double py, double pz, double mass)
Alias for setPM.
Definition: Vector4.hh:391
Vector3 rhoVec() const
Synonym for polarVec.
Definition: Vector3.hh:121
double pT() const
Calculate the transverse momentum .
Definition: Vector4.hh:628
FourMomentum & operator+=(const FourMomentum &v)
Add to this 4-vector. NB time as well as space components are added.
Definition: Vector4.hh:733
Vector3 betaVec() const
Definition: Vector4.hh:671
double perp() const
Synonym for polarRadius.
Definition: Vector4.hh:108
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:543
double mod2() const
Calculate the modulus-squared of a vector. .
Definition: VectorN.hh:84
double eta() const
Synonym for pseudorapidity.
Definition: Vector4.hh:152
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:793
FourMomentum & setPz(double pz)
Set z-component of momentum .
Definition: Vector4.hh:355
FourVector & operator*=(double a)
Multiply by a scalar.
Definition: Vector4.hh:189
double polarRadius() const
Polar radius.
Definition: Vector3.hh:139
double absrap() const
Absolute rapidity.
Definition: Vector4.hh:605
bool cmpMomByMass(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by decreasing mass.
Definition: Vector4.hh:1378
double pt2() const
Calculate the squared transverse momentum .
Definition: Vector4.hh:623
bool cmpMomByDescAbsRap(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by decreasing absolute rapidity.
Definition: Vector4.hh:1422
Vector3 polarVec() const
Projection of 3-vector on to the plane.
Definition: Vector4.hh:117
double azimuthalAngle(const PhiMapping mapping=ZERO_2PI) const
Angle subtended by the 3-vector&#39;s projection in x-y and the x-axis.
Definition: Vector4.hh:130
double Et() const
Calculate the transverse energy .
Definition: Vector4.hh:641
bool cmpMomByEt(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by decreasing transverse energy.
Definition: Vector4.hh:1360
Vector3 ptvec() const
Synonym for pTvec.
Definition: Vector4.hh:614
double rho() const
Synonym for polarRadius.
Definition: Vector3.hh:147
Vector3 gammaVec() const
Definition: Vector4.hh:659
double absrapidity() const
Absolute rapidity.
Definition: Vector4.hh:601
double p2() const
Get the modulus-squared of the 3-momentum.
Definition: Vector4.hh:586
FourMomentum & operator*=(double a)
Multiply by a scalar.
Definition: Vector4.hh:721
double perp() const
Synonym for polarRadius.
Definition: Vector3.hh:143
bool cmpMomByEta(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by increasing eta (pseudorapidity)
Definition: Vector4.hh:1387
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:798
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:1431
FourMomentum & setE(double E)
Set energy (time component of momentum).
Definition: Vector4.hh:337
double contract(const FourVector &v) const
Contract two 4-vectors, with metric signature (+ - - -).
Definition: Vector4.hh:173
bool cmpMomByPt(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by decreasing pT.
Definition: Vector4.hh:1342
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:783
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:778
double mass2() const
Get the squared mass (the Lorentz self-invariant).
Definition: Vector4.hh:572
double abspseudorapidity() const
Get the directly.
Definition: Vector4.hh:157
MOMS sortByE(const MOMS &pbs)
Sort a container of momenta by E (decreasing) and return by value for const inputs.
Definition: Vector4.hh:1461
bool cmpMomByDescEta(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by decreasing eta (pseudorapidity)
Definition: Vector4.hh:1392
double rapidity() const
Calculate the rapidity.
Definition: Vector4.hh:592
MOMS sortByPt(const MOMS &pbs)
Sort a container of momenta by pT (decreasing) and return by value for const inputs.
Definition: Vector4.hh:1450
double pz2() const
Get z-squared .
Definition: Vector4.hh:555
FourMomentum & operator-=(const FourMomentum &v)
Subtract from this 4-vector. NB time as well as space components are subtracted.
Definition: Vector4.hh:739
Vector3 p3() const
Get 3-momentum part, .
Definition: Vector4.hh:578
double pseudorapidity() const
Pseudorapidity (defined purely by the 3-vector components)
Definition: Vector4.hh:148
bool cmpMomByE(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by decreasing energy.
Definition: Vector4.hh:1369
double polarRadius() const
Magnitude of projection of 3-vector on to the plane.
Definition: Vector4.hh:104
double E2() const
Get energy-squared .
Definition: Vector4.hh:540
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:475
bool cmpMomByAscPt(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by increasing pT.
Definition: Vector4.hh:1346
double angle(const Vector3 &v) const
Angle in radians to another vector.
Definition: Vector3.hh:89
FourMomentum & setEtaPhiMPt(double eta, double phi, double mass, double pt)
Definition: Vector4.hh:416
bool cmpMomByP(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by decreasing 3-momentum magnitude |p|.
Definition: Vector4.hh:1351
Vector3 polarVec() const
Polar projection of this vector into the x-y plane.
Definition: Vector3.hh:111
FourMomentum & setPtPhiME(double pt, double phi, double mass, double E)
Definition: Vector4.hh:517
FourMomentum & setThetaPhiMPt(double theta, double phi, double mass, double pt)
Definition: Vector4.hh:498
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:808
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:343
double polarAngle() const
Angle subtended by the vector and the z-axis.
Definition: Vector3.hh:174
PhiMapping
Enum for range of to be mapped into.
Definition: MathConstants.hh:49
double gamma() const
Definition: Vector4.hh:653
double dot(const FourVector &v) const
Contract two 4-vectors, with metric signature (+ - - -).
Definition: Vector4.hh:179
double pseudorapidity() const
Purely geometric approximation to rapidity.
Definition: Vector3.hh:190
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:1437
double angle(const Vector3 &v3) const
Angle between this vector and another (3-vector)
Definition: Vector4.hh:84
double rho2() const
Synonym for polarRadius2.
Definition: Vector3.hh:134
double mass() const
Get the mass (the Lorentz self-invariant).
Definition: Vector4.hh:561
double beta() const
Definition: Vector4.hh:665
double rho2() const
Synonym for polarRadius2.
Definition: Vector4.hh:99
Object implementing Lorentz transform calculations and boosts.
Definition: LorentzTrans.hh:21
FourMomentum operator-() const
Multiply all components (time and space) by -1.
Definition: Vector4.hh:745
MOMS sortByEt(const MOMS &pbs)
Sort a container of momenta by Et (decreasing) and return by value for const inputs.
Definition: Vector4.hh:1472
bool cmpMomByDescAbsEta(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by increasing absolute eta (pseudorapidity)
Definition: Vector4.hh:1402
MOMS & isortByEt(MOMS &pbs)
Sort a container of momenta by Et (decreasing) and return by reference for non-const inputs...
Definition: Vector4.hh:1467
bool cmpMomByAscMass(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by increasing mass.
Definition: Vector4.hh:1382
Specialisation of VectorN to a general (non-momentum) Lorentz 4-vector.
Definition: Vector4.hh:22
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:581
double invariant(const FourVector &lv)
Definition: Vector4.hh:277
static FourMomentum mkXYZE(double px, double py, double pz, double E)
Make a vector from (px,py,pz,E) coordinates.
Definition: Vector4.hh:768
std::vector< FourVector > FourVectors
Definition: Vector4.hh:1527
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:91
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:538
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:1456
Vector3 perpVec() const
Synonym for polarVec.
Definition: Vector4.hh:121
bool cmpMomByAscP(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by increasing 3-momentum magnitude |p|.
Definition: Vector4.hh:1355
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:727
Vector3 perpVec() const
Synonym for polarVec.
Definition: Vector3.hh:117
double operator*(const FourVector &v) const
Contract two 4-vectors, with metric signature (+ - - -).
Definition: Vector4.hh:184
FourMomentum & setRapPhiMPt(double y, double phi, double mass, double pt)
Definition: Vector4.hh:458
double perp2() const
Synonym for polarRadius2.
Definition: Vector4.hh:95
double pt() const
Calculate the transverse momentum .
Definition: Vector4.hh:632
Vector3 vector3() const
Get the spatial part of the 4-vector as a 3-vector.
Definition: Vector4.hh:162
Vector3 unit() const
Synonym for unitVec.
Definition: Vector3.hh:105
FourMomentum & setXYZE(double px, double py, double pz, double E)
Alias for setPE.
Definition: Vector4.hh:369
MOMS & isortByPt(MOMS &pbs)
Sort a container of momenta by pT (decreasing) and return by reference for non-const inputs...
Definition: Vector4.hh:1445
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:803
FourMomentum & setRapPhiME(double y, double phi, double mass, double E)
Definition: Vector4.hh:438
double angle(const FourVector &v) const
Angle between this vector and another.
Definition: Vector4.hh:80
double theta() const
Synonym for polarAngle.
Definition: Vector4.hh:143
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:139
Vector3 pTvec() const
Calculate the transverse momentum vector .
Definition: Vector4.hh:610
FourMomentum & setEtaPhiME(double eta, double phi, double mass, double E)
Definition: Vector4.hh:400
double pz() const
Get z-component of momentum .
Definition: Vector4.hh:553
double phi(const PhiMapping mapping=ZERO_2PI) const
Synonym for azimuthalAngle.
Definition: Vector4.hh:134
double py() const
Get y-component of momentum .
Definition: Vector4.hh:548
double azimuthalAngle(const PhiMapping mapping=ZERO_2PI) const
Angle subtended by the vector&#39;s projection in x-y and the x-axis.
Definition: Vector3.hh:155
FourVector & operator-=(const FourVector &v)
Subtract from this 4-vector. NB time as well as space components are subtracted.
Definition: Vector4.hh:207
double px2() const
Get x-squared .
Definition: Vector4.hh:545
FourMomentum & setPE(double px, double py, double pz, double E)
Set the p coordinates and energy simultaneously.
Definition: Vector4.hh:362
double theta() const
Synonym for polarAngle.
Definition: Vector3.hh:181
double phi(const PhiMapping mapping=ZERO_2PI) const
Synonym for azimuthalAngle.
Definition: Vector3.hh:164
bool cmpMomByRap(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by increasing rapidity.
Definition: Vector4.hh:1407
Three-dimensional specialisation of Vector.
Definition: Vector3.hh:26
bool cmpMomByAscEt(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by increasing transverse energy.
Definition: Vector4.hh:1364
FourVector & operator+=(const FourVector &v)
Add to this 4-vector.
Definition: Vector4.hh:201
Vector3 rhoVec() const
Synonym for polarVec.
Definition: Vector4.hh:125
std::ostream & operator<<(std::ostream &os, const AnalysisInfo &ai)
Stream an AnalysisInfo as a text description.
Definition: AnalysisInfo.hh:365
FourVector & operator/=(double a)
Divide by a scalar.
Definition: Vector4.hh:195
Specialized version of the FourVector with momentum/energy functionality.
Definition: Vector4.hh:301
double eta() const
Synonym for pseudorapidity.
Definition: Vector3.hh:200
double Et2() const
Calculate the transverse energy .
Definition: Vector4.hh:637
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:788
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:773
FourMomentum reverse() const
Multiply space components only by -1.
Definition: Vector4.hh:752
FourMomentum & setPM(double px, double py, double pz, double mass)
Set the p coordinates and mass simultaneously.
Definition: Vector4.hh:383
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:596
double polarRadius2() const
Square of the polar radius (.
Definition: Vector3.hh:126
double mod() const
Calculate the modulus of a vector. .
Definition: VectorN.hh:95
double rho() const
Synonym for polarRadius.
Definition: Vector4.hh:112
double perp2() const
Synonym for polarRadius2.
Definition: Vector3.hh:130
bool cmpMomByAbsEta(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by increasing absolute eta (pseudorapidity)
Definition: Vector4.hh:1397
FourVector reverse() const
Multiply space components only by -1.
Definition: Vector4.hh:220
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:1412
double pT2() const
Calculate the squared transverse momentum .
Definition: Vector4.hh:619
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:1417