Rivet: /Users/chrisg/software/rivet/include/Rivet/Math/Vector4.hh Source File

| Rivet 3.1.9

Vector4.hh
1#ifndef RIVET_MATH_VECTOR4
2#define RIVET_MATH_VECTOR4
3
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"
9
10// Forward declaration
11namespace fastjet { class PseudoJet; }
12
13namespace Rivet {
14
15
16 class FourVector;
17 typedef FourVector Vector4;
18 typedef FourVector V4;
19
20 class FourMomentum;
21 typedef FourMomentum P4;
22
23 class LorentzTransform;
24 FourVector transform(const LorentzTransform& lt, const FourVector& v4);
25
26
30 class FourVector : public Vector<4> {
31 friend FourVector multiply(const double a, const FourVector& v);
32 friend FourVector multiply(const FourVector& v, const double a);
33 friend FourVector add(const FourVector& a, const FourVector& b);
34 friend FourVector transform(const LorentzTransform& lt, const FourVector& v4);
35
36 public:
37
38 FourVector() : Vector<4>() { }
39
40 template<typename V4TYPE, typename std::enable_if<HasXYZT<V4TYPE>::value, int>::type DUMMY=0>
41 FourVector(const V4TYPE& other) {
42 this->setT(other.t());
43 this->setX(other.x());
44 this->setY(other.y());
45 this->setZ(other.z());
46 }
47
48 FourVector(const Vector<4>& other)
49 : Vector<4>(other) { }
50
51 FourVector(const double t, const double x, const double y, const double z) {
52 this->setT(t);
53 this->setX(x);
54 this->setY(y);
55 this->setZ(z);
56 }
57
58 virtual ~FourVector() { }
59
64 operator fastjet::PseudoJet () const;
65
66
67 public:
68
69 double t() const { return get(0); }
70 double t2() const { return sqr(t()); }
71 FourVector& setT(const double t) { set(0, t); return *this; }
72
73 double x() const { return get(1); }
74 double x2() const { return sqr(x()); }
75 FourVector& setX(const double x) { set(1, x); return *this; }
76
77 double y() const { return get(2); }
78 double y2() const { return sqr(y()); }
79 FourVector& setY(const double y) { set(2, y); return *this; }
80
81 double z() const { return get(3); }
82 double z2() const { return sqr(z()); }
83 FourVector& setZ(const double z) { set(3, z); return *this; }
84
85 double invariant() const {
86 // Done this way for numerical precision
87 return (t() + z())*(t() - z()) - x()*x() - y()*y();
88 }
89
90 bool isNull() const {
91 return Rivet::isZero(invariant());
92 }
93
95 double angle(const FourVector& v) const {
96 return vector3().angle( v.vector3() );
97 }
99 double angle(const Vector3& v3) const {
100 return vector3().angle(v3);
101 }
102
106 double polarRadius2() const {
107 return vector3().polarRadius2();
108 }
110 double perp2() const {
111 return vector3().perp2();
112 }
114 double rho2() const {
115 return vector3().rho2();
116 }
117
119 double polarRadius() const {
120 return vector3().polarRadius();
121 }
123 double perp() const {
124 return vector3().perp();
125 }
127 double rho() const {
128 return vector3().rho();
129 }
130
132 Vector3 polarVec() const {
133 return vector3().polarVec();
134 }
136 Vector3 perpVec() const {
137 return vector3().perpVec();
138 }
140 Vector3 rhoVec() const {
141 return vector3().rhoVec();
142 }
143
145 double azimuthalAngle(const PhiMapping mapping=ZERO_2PI) const {
146 return vector3().azimuthalAngle(mapping);
147 }
149 double phi(const PhiMapping mapping=ZERO_2PI) const {
150 return vector3().phi(mapping);
151 }
152
154 double polarAngle() const {
155 return vector3().polarAngle();
156 }
158 double theta() const {
159 return vector3().theta();
160 }
161
163 double pseudorapidity() const {
164 return vector3().pseudorapidity();
165 }
167 double eta() const {
168 return vector3().eta();
169 }
170
172 double abspseudorapidity() const { return fabs(eta()); }
174 double abseta() const { return fabs(eta()); }
175
177 Vector3 vector3() const {
178 return Vector3(get(1), get(2), get(3));
179 }
180
182 operator Vector3 () const { return vector3(); }
183
184
185 public:
186
188 double contract(const FourVector& v) const {
189 const double result = t()*v.t() - x()*v.x() - y()*v.y() - z()*v.z();
190 return result;
191 }
192
194 double dot(const FourVector& v) const {
195 return contract(v);
196 }
197
199 double operator * (const FourVector& v) const {
200 return contract(v);
201 }
202
204 FourVector& operator *= (double a) {
205 _vec = multiply(a, *this)._vec;
206 return *this;
207 }
208
210 FourVector& operator /= (double a) {
211 _vec = multiply(1.0/a, *this)._vec;
212 return *this;
213 }
214
216 FourVector& operator += (const FourVector& v) {
217 _vec = add(*this, v)._vec;
218 return *this;
219 }
220
222 FourVector& operator -= (const FourVector& v) {
223 _vec = add(*this, -v)._vec;
224 return *this;
225 }
226
228 FourVector operator - () const {
229 FourVector result;
230 result._vec = -_vec;
231 return result;
232 }
233
235 FourVector reverse() const {
236 FourVector result = -*this;
237 result.setT(-result.t());
238 return result;
239 }
240
241 };
242
243
245 inline double contract(const FourVector& a, const FourVector& b) {
246 return a.contract(b);
247 }
248
250 inline double dot(const FourVector& a, const FourVector& b) {
251 return contract(a, b);
252 }
253
254 inline FourVector multiply(const double a, const FourVector& v) {
255 FourVector result;
256 result._vec = a * v._vec;
257 return result;
258 }
259
260 inline FourVector multiply(const FourVector& v, const double a) {
261 return multiply(a, v);
262 }
263
264 inline FourVector operator * (const double a, const FourVector& v) {
265 return multiply(a, v);
266 }
267
268 inline FourVector operator * (const FourVector& v, const double a) {
269 return multiply(a, v);
270 }
271
272 inline FourVector operator / (const FourVector& v, const double a) {
273 return multiply(1.0/a, v);
274 }
275
276 inline FourVector add(const FourVector& a, const FourVector& b) {
277 FourVector result;
278 result._vec = a._vec + b._vec;
279 return result;
280 }
281
282 inline FourVector operator+(const FourVector& a, const FourVector& b) {
283 return add(a, b);
284 }
285
286 inline FourVector operator-(const FourVector& a, const FourVector& b) {
287 return add(a, -b);
288 }
289
292 inline double invariant(const FourVector& lv) {
293 return lv.invariant();
294 }
295
297 inline double angle(const FourVector& a, const FourVector& b) {
298 return a.angle(b);
299 }
300
302 inline double angle(const Vector3& a, const FourVector& b) {
303 return angle( a, b.vector3() );
304 }
305
307 inline double angle(const FourVector& a, const Vector3& b) {
308 return a.angle(b);
309 }
310
311
313
314
316 class FourMomentum : public FourVector {
317 friend FourMomentum multiply(const double a, const FourMomentum& v);
318 friend FourMomentum multiply(const FourMomentum& v, const double a);
319 friend FourMomentum add(const FourMomentum& a, const FourMomentum& b);
320 friend FourMomentum transform(const LorentzTransform& lt, const FourMomentum& v4);
321
322 public:
323 FourMomentum() { }
324
325 template<typename V4TYPE, typename std::enable_if<HasXYZT<V4TYPE>::value, int>::type DUMMY=0>
326 FourMomentum(const V4TYPE& other) {
327 this->setE(other.t());
328 this->setPx(other.x());
329 this->setPy(other.y());
330 this->setPz(other.z());
331 }
332
333 FourMomentum(const Vector<4>& other)
334 : FourVector(other) { }
335
336 FourMomentum(const double E, const double px, const double py, const double pz) {
337 this->setE(E);
338 this->setPx(px);
339 this->setPy(py);
340 this->setPz(pz);
341 }
342
343 ~FourMomentum() {}
344
345 public:
346
347
349
350
352 FourMomentum& setE(double E) {
353 setT(E);
354 return *this;
355 }
356
358 FourMomentum& setPx(double px) {
359 setX(px);
360 return *this;
361 }
362
364 FourMomentum& setPy(double py) {
365 setY(py);
366 return *this;
367 }
368
370 FourMomentum& setPz(double pz) {
371 setZ(pz);
372 return *this;
373 }
374
375
377 FourMomentum& setPE(double px, double py, double pz, double E) {
378 if (E < 0)
379 throw std::invalid_argument("Negative energy given as argument: " + to_str(E));
380 setPx(px); setPy(py); setPz(pz); setE(E);
381 return *this;
382 }
384 FourMomentum& setXYZE(double px, double py, double pz, double E) {
385 return setPE(px, py, pz, E);
386 }
387 // /// Near-alias with switched arg order
388 // FourMomentum& setEP(double E, double px, double py, double pz) {
389 // return setPE(px, py, pz, E);
390 // }
391 // /// Alias for setEP
392 // FourMomentum& setEXYZ(double E, double px, double py, double pz) {
393 // return setEP(E, px, py, pz);
394 // }
395
396
398 FourMomentum& setPM(double px, double py, double pz, double mass) {
399 if (mass < 0)
400 throw std::invalid_argument("Negative mass given as argument: " + to_str(mass));
401 const double E = sqrt( sqr(mass) + sqr(px) + sqr(py) + sqr(pz) );
402 // setPx(px); setPy(py); setPz(pz); setE(E);
403 return setPE(px, py, pz, E);
404 }
406 FourMomentum& setXYZM(double px, double py, double pz, double mass) {
407 return setPM(px, py, pz, mass);
408 }
409
410
415 FourMomentum& setEtaPhiME(double eta, double phi, double mass, double E) {
416 if (mass < 0)
417 throw std::invalid_argument("Negative mass given as argument");
418 if (E < 0)
419 throw std::invalid_argument("Negative energy given as argument");
420 const double theta = 2 * atan(exp(-eta));
421 if (theta < 0 || theta > M_PI)
422 throw std::domain_error("Polar angle outside 0..pi in calculation");
423 setThetaPhiME(theta, phi, mass, E);
424 return *this;
425 }
426
431 FourMomentum& setEtaPhiMPt(double eta, double phi, double mass, double pt) {
432 if (mass < 0)
433 throw std::invalid_argument("Negative mass given as argument");
434 if (pt < 0)
435 throw std::invalid_argument("Negative transverse momentum given as argument");
436 const double theta = 2 * atan(exp(-eta));
437 if (theta < 0 || theta > M_PI)
438 throw std::domain_error("Polar angle outside 0..pi in calculation");
439 const double p = pt / sin(theta);
440 const double E = sqrt( sqr(p) + sqr(mass) );
441 setThetaPhiME(theta, phi, mass, E);
442 return *this;
443 }
444
453 FourMomentum& setRapPhiME(double y, double phi, double mass, double E) {
454 if (mass < 0)
455 throw std::invalid_argument("Negative mass given as argument");
456 if (E < 0)
457 throw std::invalid_argument("Negative energy given as argument");
458 const double sqrt_pt2_m2 = E / cosh(y);
459 const double pt = sqrt( sqr(sqrt_pt2_m2) - sqr(mass) );
460 if (pt < 0)
461 throw std::domain_error("Negative transverse momentum in calculation");
462 const double pz = sqrt_pt2_m2 * sinh(y);
463 const double px = pt * cos(phi);
464 const double py = pt * sin(phi);
465 setPE(px, py, pz, E);
466 return *this;
467 }
468
473 FourMomentum& setRapPhiMPt(double y, double phi, double mass, double pt) {
474 if (mass < 0)
475 throw std::invalid_argument("Negative mass given as argument");
476 if (pt < 0)
477 throw std::invalid_argument("Negative transverse mass given as argument");
478 const double E = sqrt( sqr(pt) + sqr(mass) ) * cosh(y);
479 if (E < 0)
480 throw std::domain_error("Negative energy in calculation");
481 setRapPhiME(y, phi, mass, E);
482 return *this;
483 }
484
490 FourMomentum& setThetaPhiME(double theta, double phi, double mass, double E) {
491 if (theta < 0 || theta > M_PI)
492 throw std::invalid_argument("Polar angle outside 0..pi given as argument");
493 if (mass < 0)
494 throw std::invalid_argument("Negative mass given as argument");
495 if (E < 0)
496 throw std::invalid_argument("Negative energy given as argument");
497 const double p = sqrt( sqr(E) - sqr(mass) );
498 const double pz = p * cos(theta);
499 const double pt = p * sin(theta);
500 if (pt < 0)
501 throw std::invalid_argument("Negative transverse momentum in calculation");
502 const double px = pt * cos(phi);
503 const double py = pt * sin(phi);
504 setPE(px, py, pz, E);
505 return *this;
506 }
507
513 FourMomentum& setThetaPhiMPt(double theta, double phi, double mass, double pt) {
514 if (theta < 0 || theta > M_PI)
515 throw std::invalid_argument("Polar angle outside 0..pi given as argument");
516 if (mass < 0)
517 throw std::invalid_argument("Negative mass given as argument");
518 if (pt < 0)
519 throw std::invalid_argument("Negative transverse momentum given as argument");
520 const double p = pt / sin(theta);
521 const double px = pt * cos(phi);
522 const double py = pt * sin(phi);
523 const double pz = p * cos(theta);
524 const double E = sqrt( sqr(p) + sqr(mass) );
525 setPE(px, py, pz, E);
526 return *this;
527 }
528
532 FourMomentum& setPtPhiME(double pt, double phi, double mass, double E) {
533 if (pt < 0)
534 throw std::invalid_argument("Negative transverse momentum given as argument");
535 if (mass < 0)
536 throw std::invalid_argument("Negative mass given as argument");
537 if (E < 0)
538 throw std::invalid_argument("Negative energy given as argument");
539 const double px = pt * cos(phi);
540 const double py = pt * sin(phi);
541 const double pz = sqrt(sqr(E) - sqr(mass) - sqr(pt));
542 setPE(px, py, pz, E);
543 return *this;
544 }
545
547
548
550
551
553 double E() const { return t(); }
555 double E2() const { return t2(); }
556
558 double px() const { return x(); }
560 double px2() const { return x2(); }
561
563 double py() const { return y(); }
565 double py2() const { return y2(); }
566
568 double pz() const { return z(); }
570 double pz2() const { return z2(); }
571
572
576 double mass() const {
577 // assert(Rivet::isZero(mass2()) || mass2() > 0);
578 // if (Rivet::isZero(mass2())) {
579 // return 0.0;
580 // } else {
581 // return sqrt(mass2());
582 // }
583 return sign(mass2()) * sqrt(fabs(mass2()));
584 }
585
587 double mass2() const {
588 return invariant();
589 }
590
591
593 Vector3 p3() const { return vector3(); }
594
596 double p() const {
597 return p3().mod();
598 }
599
601 double p2() const {
602 return p3().mod2();
603 }
604
605
607 double rapidity() const {
608 return 0.5 * std::log( (E() + pz()) / (E() - pz()) );
609 }
611 double rap() const {
612 return rapidity();
613 }
614
616 double absrapidity() const {
617 return fabs(rapidity());
618 }
620 double absrap() const {
621 return fabs(rap());
622 }
623
625 Vector3 pTvec() const {
626 return p3().polarVec();
627 }
629 Vector3 ptvec() const {
630 return pTvec();
631 }
632
634 double pT2() const {
635 return vector3().polarRadius2();
636 }
638 double pt2() const {
639 return vector3().polarRadius2();
640 }
641
643 double pT() const {
644 return sqrt(pT2());
645 }
647 double pt() const {
648 return sqrt(pT2());
649 }
650
652 double Et2() const {
653 return Et() * Et();
654 }
656 double Et() const {
657 return E() * sin(polarAngle());
658 }
659
661
662
664
665
668 double gamma() const {
669 return sqrt(E2()/mass2());
670 }
671
674 Vector3 gammaVec() const {
675 return gamma() * p3().unit();
676 }
677
680 double beta() const {
681 return p()/E();
682 }
683
686 Vector3 betaVec() const {
687 // return Vector3(px()/E(), py()/E(), pz()/E());
688 return p3()/E();
689 }
690
692
693
695
696
698
701 struct byEAscending {
702 bool operator()(const FourMomentum& left, const FourMomentum& right) const{
703 const double pt2left = left.E();
704 const double pt2right = right.E();
705 return pt2left < pt2right;
706 }
707
708 bool operator()(const FourMomentum* left, const FourMomentum* right) const{
709 return (*this)(*left, *right);
710 }
711 };
712
713
716 struct byEDescending {
717 bool operator()(const FourMomentum& left, const FourMomentum& right) const{
718 return byEAscending()(right, left);
719 }
720
721 bool operator()(const FourMomentum* left, const FourVector* right) const{
722 return (*this)(*left, *right);
723 }
724 };
725
727
728
730
731
733
734
736 FourMomentum& operator*=(double a) {
737 _vec = multiply(a, *this)._vec;
738 return *this;
739 }
740
742 FourMomentum& operator/=(double a) {
743 _vec = multiply(1.0/a, *this)._vec;
744 return *this;
745 }
746
748 FourMomentum& operator+=(const FourMomentum& v) {
749 _vec = add(*this, v)._vec;
750 return *this;
751 }
752
754 FourMomentum& operator-=(const FourMomentum& v) {
755 _vec = add(*this, -v)._vec;
756 return *this;
757 }
758
760 FourMomentum operator-() const {
761 FourMomentum result;
762 result._vec = -_vec;
763 return result;
764 }
765
767 FourMomentum reverse() const {
768 FourMomentum result = -*this;
769 result.setE(-result.E());
770 return result;
771 }
772
774
775
777
778
780
781
783 static FourMomentum mkXYZE(double px, double py, double pz, double E) {
784 return FourMomentum().setPE(px, py, pz, E);
785 }
786
788 static FourMomentum mkXYZM(double px, double py, double pz, double mass) {
789 return FourMomentum().setPM(px, py, pz, mass);
790 }
791
793 static FourMomentum mkEtaPhiME(double eta, double phi, double mass, double E) {
794 return FourMomentum().setEtaPhiME(eta, phi, mass, E);
795 }
796
798 static FourMomentum mkEtaPhiMPt(double eta, double phi, double mass, double pt) {
799 return FourMomentum().setEtaPhiMPt(eta, phi, mass, pt);
800 }
801
803 static FourMomentum mkRapPhiME(double y, double phi, double mass, double E) {
804 return FourMomentum().setRapPhiME(y, phi, mass, E);
805 }
806
808 static FourMomentum mkRapPhiMPt(double y, double phi, double mass, double pt) {
809 return FourMomentum().setRapPhiMPt(y, phi, mass, pt);
810 }
811
813 static FourMomentum mkThetaPhiME(double theta, double phi, double mass, double E) {
814 return FourMomentum().setThetaPhiME(theta, phi, mass, E);
815 }
816
818 static FourMomentum mkThetaPhiMPt(double theta, double phi, double mass, double pt) {
819 return FourMomentum().setThetaPhiMPt(theta, phi, mass, pt);
820 }
821
823 static FourMomentum mkPtPhiME(double pt, double phi, double mass, double E) {
824 return FourMomentum().setPtPhiME(pt, phi, mass, E);
825 }
826
828
829
830 };
831
832
833 inline FourMomentum multiply(const double a, const FourMomentum& v) {
834 FourMomentum result;
835 result._vec = a * v._vec;
836 return result;
837 }
838
839 inline FourMomentum multiply(const FourMomentum& v, const double a) {
840 return multiply(a, v);
841 }
842
843 inline FourMomentum operator*(const double a, const FourMomentum& v) {
844 return multiply(a, v);
845 }
846
847 inline FourMomentum operator*(const FourMomentum& v, const double a) {
848 return multiply(a, v);
849 }
850
851 inline FourMomentum operator/(const FourMomentum& v, const double a) {
852 return multiply(1.0/a, v);
853 }
854
855 inline FourMomentum add(const FourMomentum& a, const FourMomentum& b) {
856 FourMomentum result;
857 result._vec = a._vec + b._vec;
858 return result;
859 }
860
861 inline FourMomentum operator+(const FourMomentum& a, const FourMomentum& b) {
862 return add(a, b);
863 }
864
865 inline FourMomentum operator-(const FourMomentum& a, const FourMomentum& b) {
866 return add(a, -b);
867 }
868
869
871
872
874
875
884 inline double deltaR2(const FourVector& a, const FourVector& b,
885 RapScheme scheme=PSEUDORAPIDITY) {
886 switch (scheme) {
887 case PSEUDORAPIDITY :
888 return deltaR2(a.vector3(), b.vector3());
889 case RAPIDITY:
890 {
891 const FourMomentum* ma = dynamic_cast<const FourMomentum*>(&a);
892 const FourMomentum* mb = dynamic_cast<const FourMomentum*>(&b);
893 if (!ma || !mb) {
894 string err = "deltaR with scheme RAPIDITY can only be called with FourMomentum objects, not FourVectors";
895 throw std::runtime_error(err);
896 }
897 return deltaR2(*ma, *mb, scheme);
898 }
899 default:
900 throw std::runtime_error("The specified deltaR scheme is not yet implemented");
901 }
902 }
903
912 inline double deltaR(const FourVector& a, const FourVector& b,
913 RapScheme scheme=PSEUDORAPIDITY) {
914 return sqrt(deltaR2(a, b, scheme));
915 }
916
917
918
925 inline double deltaR2(const FourVector& v,
926 double eta2, double phi2,
927 RapScheme scheme=PSEUDORAPIDITY) {
928 switch (scheme) {
929 case PSEUDORAPIDITY :
930 return deltaR2(v.vector3(), eta2, phi2);
931 case RAPIDITY:
932 {
933 const FourMomentum* mv = dynamic_cast<const FourMomentum*>(&v);
934 if (!mv) {
935 string err = "deltaR with scheme RAPIDITY can only be called with FourMomentum objects, not FourVectors";
936 throw std::runtime_error(err);
937 }
938 return deltaR2(*mv, eta2, phi2, scheme);
939 }
940 default:
941 throw std::runtime_error("The specified deltaR scheme is not yet implemented");
942 }
943 }
944
951 inline double deltaR(const FourVector& v,
952 double eta2, double phi2,
953 RapScheme scheme=PSEUDORAPIDITY) {
954 return sqrt(deltaR2(v, eta2, phi2, scheme));
955 }
956
957
964 inline double deltaR2(double eta1, double phi1,
965 const FourVector& v,
966 RapScheme scheme=PSEUDORAPIDITY) {
967 switch (scheme) {
968 case PSEUDORAPIDITY :
969 return deltaR2(eta1, phi1, v.vector3());
970 case RAPIDITY:
971 {
972 const FourMomentum* mv = dynamic_cast<const FourMomentum*>(&v);
973 if (!mv) {
974 string err = "deltaR with scheme RAPIDITY can only be called with FourMomentum objects, not FourVectors";
975 throw std::runtime_error(err);
976 }
977 return deltaR2(eta1, phi1, *mv, scheme);
978 }
979 default:
980 throw std::runtime_error("The specified deltaR scheme is not yet implemented");
981 }
982 }
983
990 inline double deltaR(double eta1, double phi1,
991 const FourVector& v,
992 RapScheme scheme=PSEUDORAPIDITY) {
993 return sqrt(deltaR2(eta1, phi1, v, scheme));
994 }
995
996
1003 inline double deltaR2(const FourMomentum& a, const FourMomentum& b,
1004 RapScheme scheme=PSEUDORAPIDITY) {
1005 switch (scheme) {
1006 case PSEUDORAPIDITY:
1007 return deltaR2(a.vector3(), b.vector3());
1008 case RAPIDITY:
1009 return deltaR2(a.rapidity(), a.azimuthalAngle(), b.rapidity(), b.azimuthalAngle());
1010 default:
1011 throw std::runtime_error("The specified deltaR scheme is not yet implemented");
1012 }
1013 }
1014
1021 inline double deltaR(const FourMomentum& a, const FourMomentum& b,
1022 RapScheme scheme=PSEUDORAPIDITY) {
1023 return sqrt(deltaR2(a, b, scheme));
1024 }
1025
1026
1032 inline double deltaR2(const FourMomentum& v,
1033 double eta2, double phi2,
1034 RapScheme scheme=PSEUDORAPIDITY) {
1035 switch (scheme) {
1036 case PSEUDORAPIDITY:
1037 return deltaR2(v.vector3(), eta2, phi2);
1038 case RAPIDITY:
1039 return deltaR2(v.rapidity(), v.azimuthalAngle(), eta2, phi2);
1040 default:
1041 throw std::runtime_error("The specified deltaR scheme is not yet implemented");
1042 }
1043 }
1044
1050 inline double deltaR(const FourMomentum& v,
1051 double eta2, double phi2,
1052 RapScheme scheme=PSEUDORAPIDITY) {
1053 return sqrt(deltaR2(v, eta2, phi2, scheme));
1054 }
1055
1056
1062 inline double deltaR2(double eta1, double phi1,
1063 const FourMomentum& v,
1064 RapScheme scheme=PSEUDORAPIDITY) {
1065 switch (scheme) {
1066 case PSEUDORAPIDITY:
1067 return deltaR2(eta1, phi1, v.vector3());
1068 case RAPIDITY:
1069 return deltaR2(eta1, phi1, v.rapidity(), v.azimuthalAngle());
1070 default:
1071 throw std::runtime_error("The specified deltaR scheme is not yet implemented");
1072 }
1073 }
1074
1080 inline double deltaR(double eta1, double phi1,
1081 const FourMomentum& v,
1082 RapScheme scheme=PSEUDORAPIDITY) {
1083 return sqrt(deltaR2(eta1, phi1, v, scheme));
1084 }
1085
1086
1092 inline double deltaR2(const FourMomentum& a, const FourVector& b,
1093 RapScheme scheme=PSEUDORAPIDITY) {
1094 switch (scheme) {
1095 case PSEUDORAPIDITY:
1096 return deltaR2(a.vector3(), b.vector3());
1097 case RAPIDITY:
1098 return deltaR2(a.rapidity(), a.azimuthalAngle(), FourMomentum(b).rapidity(), b.azimuthalAngle());
1099 default:
1100 throw std::runtime_error("The specified deltaR scheme is not yet implemented");
1101 }
1102 }
1103
1109 inline double deltaR(const FourMomentum& a, const FourVector& b,
1110 RapScheme scheme=PSEUDORAPIDITY) {
1111 return sqrt(deltaR2(a, b, scheme));
1112 }
1113
1114
1120 inline double deltaR2(const FourVector& a, const FourMomentum& b,
1121 RapScheme scheme=PSEUDORAPIDITY) {
1122 return deltaR2(b, a, scheme); //< note reversed args
1123 }
1124
1130 inline double deltaR(const FourVector& a, const FourMomentum& b,
1131 RapScheme scheme=PSEUDORAPIDITY) {
1132 return deltaR(b, a, scheme); //< note reversed args
1133 }
1134
1135
1138 inline double deltaR2(const FourMomentum& a, const Vector3& b) {
1139 return deltaR2(a.vector3(), b);
1140 }
1141
1144 inline double deltaR(const FourMomentum& a, const Vector3& b) {
1145 return deltaR(a.vector3(), b);
1146 }
1147
1150 inline double deltaR2(const Vector3& a, const FourMomentum& b) {
1151 return deltaR2(a, b.vector3());
1152 }
1153
1156 inline double deltaR(const Vector3& a, const FourMomentum& b) {
1157 return deltaR(a, b.vector3());
1158 }
1159
1162 inline double deltaR2(const FourVector& a, const Vector3& b) {
1163 return deltaR2(a.vector3(), b);
1164 }
1165
1168 inline double deltaR(const FourVector& a, const Vector3& b) {
1169 return deltaR(a.vector3(), b);
1170 }
1171
1174 inline double deltaR2(const Vector3& a, const FourVector& b) {
1175 return deltaR2(a, b.vector3());
1176 }
1177
1180 inline double deltaR(const Vector3& a, const FourVector& b) {
1181 return deltaR(a, b.vector3());
1182 }
1183
1185
1186
1188
1189
1191
1192
1194 inline double deltaPhi(const FourMomentum& a, const FourMomentum& b, bool sign=false) {
1195 return deltaPhi(a.vector3(), b.vector3(), sign);
1196 }
1197
1199 inline double deltaPhi(const FourMomentum& v, double phi2, bool sign=false) {
1200 return deltaPhi(v.vector3(), phi2, sign);
1201 }
1202
1204 inline double deltaPhi(double phi1, const FourMomentum& v, bool sign=false) {
1205 return deltaPhi(phi1, v.vector3(), sign);
1206 }
1207
1209 inline double deltaPhi(const FourVector& a, const FourVector& b, bool sign=false) {
1210 return deltaPhi(a.vector3(), b.vector3(), sign);
1211 }
1212
1214 inline double deltaPhi(const FourVector& v, double phi2, bool sign=false) {
1215 return deltaPhi(v.vector3(), phi2, sign);
1216 }
1217
1219 inline double deltaPhi(double phi1, const FourVector& v, bool sign=false) {
1220 return deltaPhi(phi1, v.vector3(), sign);
1221 }
1222
1224 inline double deltaPhi(const FourVector& a, const FourMomentum& b, bool sign=false) {
1225 return deltaPhi(a.vector3(), b.vector3(), sign);
1226 }
1227
1229 inline double deltaPhi(const FourMomentum& a, const FourVector& b, bool sign=false) {
1230 return deltaPhi(a.vector3(), b.vector3(), sign);
1231 }
1232
1234 inline double deltaPhi(const FourVector& a, const Vector3& b, bool sign=false) {
1235 return deltaPhi(a.vector3(), b, sign);
1236 }
1237
1239 inline double deltaPhi(const Vector3& a, const FourVector& b, bool sign=false) {
1240 return deltaPhi(a, b.vector3(), sign);
1241 }
1242
1244 inline double deltaPhi(const FourMomentum& a, const Vector3& b, bool sign=false) {
1245 return deltaPhi(a.vector3(), b, sign);
1246 }
1247
1249 inline double deltaPhi(const Vector3& a, const FourMomentum& b, bool sign=false) {
1250 return deltaPhi(a, b.vector3(), sign);
1251 }
1252
1254
1255
1257
1258
1260
1261
1263 inline double deltaEta(const FourMomentum& a, const FourMomentum& b, bool sign=false) {
1264 return deltaEta(a.vector3(), b.vector3(), sign);
1265 }
1266
1268 inline double deltaEta(const FourMomentum& v, double eta2, bool sign=false) {
1269 return deltaEta(v.vector3(), eta2, sign);
1270 }
1271
1273 inline double deltaEta(double eta1, const FourMomentum& v, bool sign=false) {
1274 return deltaEta(eta1, v.vector3(), sign);
1275 }
1276
1278 inline double deltaEta(const FourVector& a, const FourVector& b, bool sign=false) {
1279 return deltaEta(a.vector3(), b.vector3(), sign);
1280 }
1281
1283 inline double deltaEta(const FourVector& v, double eta2, bool sign=false) {
1284 return deltaEta(v.vector3(), eta2, sign);
1285 }
1286
1288 inline double deltaEta(double eta1, const FourVector& v, bool sign=false) {
1289 return deltaEta(eta1, v.vector3(), sign);
1290 }
1291
1293 inline double deltaEta(const FourVector& a, const FourMomentum& b, bool sign=false) {
1294 return deltaEta(a.vector3(), b.vector3(), sign);
1295 }
1296
1298 inline double deltaEta(const FourMomentum& a, const FourVector& b, bool sign=false) {
1299 return deltaEta(a.vector3(), b.vector3(), sign);
1300 }
1301
1303 inline double deltaEta(const FourVector& a, const Vector3& b, bool sign=false) {
1304 return deltaEta(a.vector3(), b, sign);
1305 }
1306
1308 inline double deltaEta(const Vector3& a, const FourVector& b, bool sign=false) {
1309 return deltaEta(a, b.vector3(), sign);
1310 }
1311
1313 inline double deltaEta(const FourMomentum& a, const Vector3& b, bool sign=false) {
1314 return deltaEta(a.vector3(), b, sign);
1315 }
1316
1318 inline double deltaEta(const Vector3& a, const FourMomentum& b, bool sign=false) {
1319 return deltaEta(a, b.vector3(), sign);
1320 }
1321
1323
1324
1326
1327
1329 inline double deltaRap(const FourMomentum& a, const FourMomentum& b, bool sign=false) {
1330 return deltaRap(a.rapidity(), b.rapidity(), sign);
1331 }
1332
1334 inline double deltaRap(const FourMomentum& v, double y2, bool sign=false) {
1335 return deltaRap(v.rapidity(), y2, sign);
1336 }
1337
1339 inline double deltaRap(double y1, const FourMomentum& v, bool sign=false) {
1340 return deltaRap(y1, v.rapidity(), sign);
1341 }
1342
1344
1345
1347
1348
1351
1354
1356 inline bool cmpMomByPt(const FourMomentum& a, const FourMomentum& b) {
1357 return a.pt() > b.pt();
1358 }
1360 inline bool cmpMomByAscPt(const FourMomentum& a, const FourMomentum& b) {
1361 return a.pt() < b.pt();
1362 }
1363
1365 inline bool cmpMomByP(const FourMomentum& a, const FourMomentum& b) {
1366 return a.vector3().mod() > b.vector3().mod();
1367 }
1369 inline bool cmpMomByAscP(const FourMomentum& a, const FourMomentum& b) {
1370 return a.vector3().mod() < b.vector3().mod();
1371 }
1372
1374 inline bool cmpMomByEt(const FourMomentum& a, const FourMomentum& b) {
1375 return a.Et() > b.Et();
1376 }
1378 inline bool cmpMomByAscEt(const FourMomentum& a, const FourMomentum& b) {
1379 return a.Et() < b.Et();
1380 }
1381
1383 inline bool cmpMomByE(const FourMomentum& a, const FourMomentum& b) {
1384 return a.E() > b.E();
1385 }
1387 inline bool cmpMomByAscE(const FourMomentum& a, const FourMomentum& b) {
1388 return a.E() < b.E();
1389 }
1390
1392 inline bool cmpMomByMass(const FourMomentum& a, const FourMomentum& b) {
1393 return a.mass() > b.mass();
1394 }
1396 inline bool cmpMomByAscMass(const FourMomentum& a, const FourMomentum& b) {
1397 return a.mass() < b.mass();
1398 }
1399
1401 inline bool cmpMomByEta(const FourMomentum& a, const FourMomentum& b) {
1402 return a.eta() < b.eta();
1403 }
1404
1406 inline bool cmpMomByDescEta(const FourMomentum& a, const FourMomentum& b) {
1407 return a.pseudorapidity() > b.pseudorapidity();
1408 }
1409
1411 inline bool cmpMomByAbsEta(const FourMomentum& a, const FourMomentum& b) {
1412 return fabs(a.eta()) < fabs(b.eta());
1413 }
1414
1416 inline bool cmpMomByDescAbsEta(const FourMomentum& a, const FourMomentum& b) {
1417 return fabs(a.eta()) > fabs(b.eta());
1418 }
1419
1421 inline bool cmpMomByRap(const FourMomentum& a, const FourMomentum& b) {
1422 return a.rapidity() < b.rapidity();
1423 }
1424
1426 inline bool cmpMomByDescRap(const FourMomentum& a, const FourMomentum& b) {
1427 return a.rapidity() > b.rapidity();
1428 }
1429
1431 inline bool cmpMomByAbsRap(const FourMomentum& a, const FourMomentum& b) {
1432 return fabs(a.rapidity()) < fabs(b.rapidity());
1433 }
1434
1436 inline bool cmpMomByDescAbsRap(const FourMomentum& a, const FourMomentum& b) {
1437 return fabs(a.rapidity()) > fabs(b.rapidity());
1438 }
1439
1441
1442
1444 template<typename MOMS, typename CMP>
1445 inline MOMS& isortBy(MOMS& pbs, const CMP& cmp) {
1446 std::sort(pbs.begin(), pbs.end(), cmp);
1447 return pbs;
1448 }
1450 template<typename MOMS, typename CMP>
1451 inline MOMS sortBy(const MOMS& pbs, const CMP& cmp) {
1452 MOMS rtn = pbs;
1453 std::sort(rtn.begin(), rtn.end(), cmp);
1454 return rtn;
1455 }
1456
1458 template<typename MOMS>
1459 inline MOMS& isortByPt(MOMS& pbs) {
1460 return isortBy(pbs, cmpMomByPt);
1461 }
1463 template<typename MOMS>
1464 inline MOMS sortByPt(const MOMS& pbs) {
1465 return sortBy(pbs, cmpMomByPt);
1466 }
1467
1469 template<typename MOMS>
1470 inline MOMS& isortByE(MOMS& pbs) {
1471 return isortBy(pbs, cmpMomByE);
1472 }
1474 template<typename MOMS>
1475 inline MOMS sortByE(const MOMS& pbs) {
1476 return sortBy(pbs, cmpMomByE);
1477 }
1478
1480 template<typename MOMS>
1481 inline MOMS& isortByEt(MOMS& pbs) {
1482 return isortBy(pbs, cmpMomByEt);
1483 }
1485 template<typename MOMS>
1486 inline MOMS sortByEt(const MOMS& pbs) {
1487 return sortBy(pbs, cmpMomByEt);
1488 }
1489
1491
1492
1495
1497 inline double mT(const FourMomentum& vis, const FourMomentum& invis) {
1498 return mT(vis.p3(), invis.p3());
1499 }
1500
1502 inline double mT(const FourMomentum& vis, const Vector3& invis) {
1503 return mT(vis.p3(), invis);
1504 }
1505
1507 inline double mT(const Vector3& vis, const FourMomentum& invis) {
1508 return mT(vis, invis.p3());
1509 }
1510
1512
1513
1515
1516
1519
1521 inline std::string toString(const FourVector& lv) {
1522 std::ostringstream out;
1523 out << "(" << (fabs(lv.t()) < 1E-30 ? 0.0 : lv.t())
1524 << "; " << (fabs(lv.x()) < 1E-30 ? 0.0 : lv.x())
1525 << ", " << (fabs(lv.y()) < 1E-30 ? 0.0 : lv.y())
1526 << ", " << (fabs(lv.z()) < 1E-30 ? 0.0 : lv.z())
1527 << ")";
1528 return out.str();
1529 }
1530
1532 inline std::ostream& operator<<(std::ostream& out, const FourVector& lv) {
1533 out << toString(lv);
1534 return out;
1535 }
1536
1538
1541 typedef std::vector<FourVector> FourVectors;
1542 typedef std::vector<FourMomentum> FourMomenta;
1544
1546
1547
1548}
1549
1550#endif
Rivet::FourMomentum
Specialized version of the FourVector with momentum/energy functionality.
Definition Vector4.hh:316
Rivet::FourVector
Specialisation of VectorN to a general (non-momentum) Lorentz 4-vector.
Definition Vector4.hh:30
Rivet::LorentzTransform
Object implementing Lorentz transform calculations and boosts.
Definition LorentzTrans.hh:21
Rivet::Vector3
Three-dimensional specialisation of Vector.
Definition Vector3.hh:40
Rivet::Vector3::rhoVec
Vector3 rhoVec() const
Synonym for polarVec.
Definition Vector3.hh:140
Rivet::Vector3::polarRadius
double polarRadius() const
Polar radius.
Definition Vector3.hh:158
Rivet::Vector3::rho
double rho() const
Synonym for polarRadius.
Definition Vector3.hh:166
Rivet::Vector3::eta
double eta() const
Synonym for pseudorapidity.
Definition Vector3.hh:219
Rivet::Vector3::perp
double perp() const
Synonym for polarRadius.
Definition Vector3.hh:162
Rivet::Vector3::perp2
double perp2() const
Synonym for polarRadius2.
Definition Vector3.hh:149
Rivet::Vector3::pseudorapidity
double pseudorapidity() const
Purely geometric approximation to rapidity.
Definition Vector3.hh:212
Rivet::Vector3::unit
Vector3 unit() const
Synonym for unitVec.
Definition Vector3.hh:124
Rivet::Vector3::theta
double theta() const
Synonym for polarAngle.
Definition Vector3.hh:200
Rivet::Vector3::phi
double phi(const PhiMapping mapping=ZERO_2PI) const
Synonym for azimuthalAngle.
Definition Vector3.hh:183
Rivet::Vector3::polarRadius2
double polarRadius2() const
Square of the polar radius (.
Definition Vector3.hh:145
Rivet::Vector3::perpVec
Vector3 perpVec() const
Synonym for polarVec.
Definition Vector3.hh:136
Rivet::Vector3::azimuthalAngle
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:174
Rivet::Vector3::rho2
double rho2() const
Synonym for polarRadius2.
Definition Vector3.hh:153
Rivet::Vector3::angle
double angle(const Vector3 &v) const
Angle in radians to another vector.
Definition Vector3.hh:108
Rivet::Vector3::polarAngle
double polarAngle() const
Angle subtended by the vector and the z-axis.
Definition Vector3.hh:193
Rivet::Vector3::polarVec
Vector3 polarVec() const
Polar projection of this vector into the x-y plane.
Definition Vector3.hh:130
Rivet::Vector
A minimal base class for -dimensional vectors.
Definition VectorN.hh:23
Rivet::Vector::mod
double mod() const
Calculate the modulus of a vector. .
Definition VectorN.hh:95
Rivet::Vector::mod2
double mod2() const
Calculate the modulus-squared of a vector. .
Definition VectorN.hh:84
Rivet::Vector< 4 >::set
Vector< N > & set(const size_t index, const double value)
Set indexed value.
Definition VectorN.hh:60
Rivet::isortBy
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:1445
Rivet::isortByE
MOMS & isortByE(MOMS &pbs)
Sort a container of momenta by E (decreasing) and return by reference for non-const inputs.
Definition Vector4.hh:1470
Rivet::isortByEt
MOMS & isortByEt(MOMS &pbs)
Sort a container of momenta by Et (decreasing) and return by reference for non-const inputs.
Definition Vector4.hh:1481
Rivet::cmpMomByDescEta
bool cmpMomByDescEta(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by decreasing eta (pseudorapidity)
Definition Vector4.hh:1406
Rivet::cmpMomByMass
bool cmpMomByMass(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by decreasing mass.
Definition Vector4.hh:1392
Rivet::cmpMomByP
bool cmpMomByP(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by decreasing 3-momentum magnitude |p|.
Definition Vector4.hh:1365
Rivet::cmpMomByAscEt
bool cmpMomByAscEt(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by increasing transverse energy.
Definition Vector4.hh:1378
Rivet::cmpMomByRap
bool cmpMomByRap(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by increasing rapidity.
Definition Vector4.hh:1421
Rivet::cmpMomByE
bool cmpMomByE(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by decreasing energy.
Definition Vector4.hh:1383
Rivet::sortBy
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:1451
Rivet::cmpMomByAbsRap
bool cmpMomByAbsRap(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by increasing absolute rapidity.
Definition Vector4.hh:1431
Rivet::sortByPt
MOMS sortByPt(const MOMS &pbs)
Sort a container of momenta by pT (decreasing) and return by value for const inputs.
Definition Vector4.hh:1464
Rivet::sortByEt
MOMS sortByEt(const MOMS &pbs)
Sort a container of momenta by Et (decreasing) and return by value for const inputs.
Definition Vector4.hh:1486
Rivet::cmpMomByEt
bool cmpMomByEt(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by decreasing transverse energy.
Definition Vector4.hh:1374
Rivet::cmpMomByAscPt
bool cmpMomByAscPt(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by increasing pT.
Definition Vector4.hh:1360
Rivet::cmpMomByAscP
bool cmpMomByAscP(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by increasing 3-momentum magnitude |p|.
Definition Vector4.hh:1369
Rivet::cmpMomByAscMass
bool cmpMomByAscMass(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by increasing mass.
Definition Vector4.hh:1396
Rivet::sortByE
MOMS sortByE(const MOMS &pbs)
Sort a container of momenta by E (decreasing) and return by value for const inputs.
Definition Vector4.hh:1475
Rivet::cmpMomByPt
bool cmpMomByPt(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by decreasing pT.
Definition Vector4.hh:1356
Rivet::cmpMomByAbsEta
bool cmpMomByAbsEta(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by increasing absolute eta (pseudorapidity)
Definition Vector4.hh:1411
Rivet::cmpMomByDescAbsEta
bool cmpMomByDescAbsEta(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by increasing absolute eta (pseudorapidity)
Definition Vector4.hh:1416
Rivet::cmpMomByEta
bool cmpMomByEta(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by increasing eta (pseudorapidity)
Definition Vector4.hh:1401
Rivet::cmpMomByAscE
bool cmpMomByAscE(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by increasing energy.
Definition Vector4.hh:1387
Rivet::cmpMomByDescAbsRap
bool cmpMomByDescAbsRap(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by decreasing absolute rapidity.
Definition Vector4.hh:1436
Rivet::isortByPt
MOMS & isortByPt(MOMS &pbs)
Sort a container of momenta by pT (decreasing) and return by reference for non-const inputs.
Definition Vector4.hh:1459
Rivet::FourVectors
std::vector< FourVector > FourVectors
Definition Vector4.hh:1541
Rivet::cmpMomByDescRap
bool cmpMomByDescRap(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by decreasing rapidity.
Definition Vector4.hh:1426
Rivet::FourVector::operator-
FourVector operator-() const
Multiply all components (space and time) by -1.
Definition Vector4.hh:228
Rivet::FourMomentum::p2
double p2() const
Get the modulus-squared of the 3-momentum.
Definition Vector4.hh:601
Rivet::FourMomentum::E2
double E2() const
Get energy-squared .
Definition Vector4.hh:555
Rivet::FourMomentum::mass
double mass() const
Get the mass (the Lorentz self-invariant).
Definition Vector4.hh:576
Rivet::FourMomentum::pz2
double pz2() const
Get z-squared .
Definition Vector4.hh:570
Rivet::FourMomentum::rapidity
double rapidity() const
Calculate the rapidity.
Definition Vector4.hh:607
Rivet::FourMomentum::reverse
FourMomentum reverse() const
Multiply space components only by -1.
Definition Vector4.hh:767
Rivet::FourVector::perp2
double perp2() const
Synonym for polarRadius2.
Definition Vector4.hh:110
Rivet::FourMomentum::px
double px() const
Get x-component of momentum .
Definition Vector4.hh:558
Rivet::FourMomentum::setPtPhiME
FourMomentum & setPtPhiME(double pt, double phi, double mass, double E)
Definition Vector4.hh:532
Rivet::FourMomentum::setRapPhiMPt
FourMomentum & setRapPhiMPt(double y, double phi, double mass, double pt)
Definition Vector4.hh:473
Rivet::FourMomentum::p3
Vector3 p3() const
Get 3-momentum part, .
Definition Vector4.hh:593
Rivet::FourVector::operator/=
FourVector & operator/=(double a)
Divide by a scalar.
Definition Vector4.hh:210
Rivet::FourVector::rho
double rho() const
Synonym for polarRadius.
Definition Vector4.hh:127
Rivet::FourMomentum::setPz
FourMomentum & setPz(double pz)
Set z-component of momentum .
Definition Vector4.hh:370
Rivet::FourMomentum::p
double p() const
Get the modulus of the 3-momentum.
Definition Vector4.hh:596
Rivet::FourMomentum::setXYZE
FourMomentum & setXYZE(double px, double py, double pz, double E)
Alias for setPE.
Definition Vector4.hh:384
Rivet::FourMomentum::mkThetaPhiME
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:813
Rivet::FourVector::perpVec
Vector3 perpVec() const
Synonym for polarVec.
Definition Vector4.hh:136
Rivet::FourVector::vector3
Vector3 vector3() const
Get the spatial part of the 4-vector as a 3-vector.
Definition Vector4.hh:177
Rivet::FourVector::angle
double angle(const FourVector &v) const
Angle between this vector and another.
Definition Vector4.hh:95
Rivet::FourMomentum::gammaVec
Vector3 gammaVec() const
Definition Vector4.hh:674
Rivet::FourMomentum::pt
double pt() const
Calculate the transverse momentum .
Definition Vector4.hh:647
Rivet::FourVector::phi
double phi(const PhiMapping mapping=ZERO_2PI) const
Synonym for azimuthalAngle.
Definition Vector4.hh:149
Rivet::FourVector::contract
double contract(const FourVector &v) const
Contract two 4-vectors, with metric signature (+ - - -).
Definition Vector4.hh:188
Rivet::FourMomentum::setPE
FourMomentum & setPE(double px, double py, double pz, double E)
Set the p coordinates and energy simultaneously.
Definition Vector4.hh:377
Rivet::FourMomentum::py
double py() const
Get y-component of momentum .
Definition Vector4.hh:563
Rivet::FourVector::abseta
double abseta() const
Get the directly (alias).
Definition Vector4.hh:174
Rivet::FourMomentum::mkRapPhiME
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:803
Rivet::FourMomentum::beta
double beta() const
Definition Vector4.hh:680
Rivet::FourMomentum::Et
double Et() const
Calculate the transverse energy .
Definition Vector4.hh:656
Rivet::FourMomentum::Et2
double Et2() const
Calculate the transverse energy .
Definition Vector4.hh:652
Rivet::FourVector::azimuthalAngle
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:145
Rivet::FourMomentum::mkXYZE
static FourMomentum mkXYZE(double px, double py, double pz, double E)
Make a vector from (px,py,pz,E) coordinates.
Definition Vector4.hh:783
Rivet::FourMomentum::setPy
FourMomentum & setPy(double py)
Set y-component of momentum .
Definition Vector4.hh:364
Rivet::FourMomentum::rap
double rap() const
Alias for rapidity.
Definition Vector4.hh:611
Rivet::FourMomentum::setPx
FourMomentum & setPx(double px)
Set x-component of momentum .
Definition Vector4.hh:358
Rivet::FourMomentum::pt2
double pt2() const
Calculate the squared transverse momentum .
Definition Vector4.hh:638
Rivet::FourVector::dot
double dot(const FourVector &v) const
Contract two 4-vectors, with metric signature (+ - - -).
Definition Vector4.hh:194
Rivet::FourVector::perp
double perp() const
Synonym for polarRadius.
Definition Vector4.hh:123
Rivet::FourMomentum::mkPtPhiME
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:823
Rivet::FourMomentum::pTvec
Vector3 pTvec() const
Calculate the transverse momentum vector .
Definition Vector4.hh:625
Rivet::FourVector::operator*=
FourVector & operator*=(double a)
Multiply by a scalar.
Definition Vector4.hh:204
Rivet::FourVector::operator*
double operator*(const FourVector &v) const
Contract two 4-vectors, with metric signature (+ - - -).
Definition Vector4.hh:199
Rivet::FourVector::eta
double eta() const
Synonym for pseudorapidity.
Definition Vector4.hh:167
Rivet::FourMomentum::setRapPhiME
FourMomentum & setRapPhiME(double y, double phi, double mass, double E)
Definition Vector4.hh:453
Rivet::FourVector::theta
double theta() const
Synonym for polarAngle.
Definition Vector4.hh:158
Rivet::FourMomentum::ptvec
Vector3 ptvec() const
Synonym for pTvec.
Definition Vector4.hh:629
Rivet::FourMomentum::mass2
double mass2() const
Get the squared mass (the Lorentz self-invariant).
Definition Vector4.hh:587
Rivet::FourMomentum::setEtaPhiMPt
FourMomentum & setEtaPhiMPt(double eta, double phi, double mass, double pt)
Definition Vector4.hh:431
Rivet::FourMomentum::pz
double pz() const
Get z-component of momentum .
Definition Vector4.hh:568
Rivet::FourVector::pseudorapidity
double pseudorapidity() const
Pseudorapidity (defined purely by the 3-vector components)
Definition Vector4.hh:163
Rivet::FourMomentum::py2
double py2() const
Get y-squared .
Definition Vector4.hh:565
Rivet::FourMomentum::absrap
double absrap() const
Absolute rapidity.
Definition Vector4.hh:620
Rivet::FourMomentum::pT2
double pT2() const
Calculate the squared transverse momentum .
Definition Vector4.hh:634
Rivet::FourVector::polarRadius
double polarRadius() const
Magnitude of projection of 3-vector on to the plane.
Definition Vector4.hh:119
Rivet::FourMomentum::mkEtaPhiME
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:793
Rivet::FourMomentum::px2
double px2() const
Get x-squared .
Definition Vector4.hh:560
Rivet::FourMomentum::betaVec
Vector3 betaVec() const
Definition Vector4.hh:686
Rivet::FourVector::rhoVec
Vector3 rhoVec() const
Synonym for polarVec.
Definition Vector4.hh:140
Rivet::FourVector::angle
double angle(const Vector3 &v3) const
Angle between this vector and another (3-vector)
Definition Vector4.hh:99
Rivet::FourVector::polarVec
Vector3 polarVec() const
Projection of 3-vector on to the plane.
Definition Vector4.hh:132
Rivet::FourVector::polarRadius2
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:106
Rivet::FourVector::reverse
FourVector reverse() const
Multiply space components only by -1.
Definition Vector4.hh:235
Rivet::FourMomentum::operator-=
FourMomentum & operator-=(const FourMomentum &v)
Subtract from this 4-vector. NB time as well as space components are subtracted.
Definition Vector4.hh:754
Rivet::FourMomentum::mkXYZM
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:788
Rivet::FourMomentum::setThetaPhiME
FourMomentum & setThetaPhiME(double theta, double phi, double mass, double E)
Definition Vector4.hh:490
Rivet::FourMomentum::E
double E() const
Get energy (time component of momentum).
Definition Vector4.hh:553
Rivet::FourMomentum::setXYZM
FourMomentum & setXYZM(double px, double py, double pz, double mass)
Alias for setPM.
Definition Vector4.hh:406
Rivet::FourMomentum::operator+=
FourMomentum & operator+=(const FourMomentum &v)
Add to this 4-vector. NB time as well as space components are added.
Definition Vector4.hh:748
Rivet::FourMomentum::mkEtaPhiMPt
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:798
Rivet::FourMomentum::mkRapPhiMPt
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:808
Rivet::FourMomentum::pT
double pT() const
Calculate the transverse momentum .
Definition Vector4.hh:643
Rivet::FourVector::polarAngle
double polarAngle() const
Angle subtended by the 3-vector and the z-axis.
Definition Vector4.hh:154
Rivet::FourVector::operator-=
FourVector & operator-=(const FourVector &v)
Subtract from this 4-vector. NB time as well as space components are subtracted.
Definition Vector4.hh:222
Rivet::FourMomentum::mkThetaPhiMPt
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:818
Rivet::FourVector::abspseudorapidity
double abspseudorapidity() const
Get the directly.
Definition Vector4.hh:172
Rivet::FourVector::operator+=
FourVector & operator+=(const FourVector &v)
Add to this 4-vector.
Definition Vector4.hh:216
Rivet::FourMomentum::setThetaPhiMPt
FourMomentum & setThetaPhiMPt(double theta, double phi, double mass, double pt)
Definition Vector4.hh:513
Rivet::FourMomentum::operator-
FourMomentum operator-() const
Multiply all components (time and space) by -1.
Definition Vector4.hh:760
Rivet::FourMomentum::absrapidity
double absrapidity() const
Absolute rapidity.
Definition Vector4.hh:616
Rivet::FourMomentum::setEtaPhiME
FourMomentum & setEtaPhiME(double eta, double phi, double mass, double E)
Definition Vector4.hh:415
Rivet::FourMomentum::operator/=
FourMomentum & operator/=(double a)
Divide by a scalar.
Definition Vector4.hh:742
Rivet::FourVector::rho2
double rho2() const
Synonym for polarRadius2.
Definition Vector4.hh:114
Rivet::FourMomentum::setE
FourMomentum & setE(double E)
Set energy (time component of momentum).
Definition Vector4.hh:352
Rivet::FourMomentum::gamma
double gamma() const
Definition Vector4.hh:668
Rivet::FourMomentum::operator*=
FourMomentum & operator*=(double a)
Multiply by a scalar.
Definition Vector4.hh:736
Rivet::FourMomentum::setPM
FourMomentum & setPM(double px, double py, double pz, double mass)
Set the p coordinates and mass simultaneously.
Definition Vector4.hh:398
Rivet::to_str
string to_str(const T &x)
Convert any object to a string.
Definition Utils.hh:66
Rivet
Definition MC_Cent_pPb.hh:10
Rivet::deltaR
double deltaR(double rap1, double phi1, double rap2, double phi2)
Definition MathUtils.hh:699
Rivet::deltaPhi
double deltaPhi(double phi1, double phi2, bool sign=false)
Calculate the difference between two angles in radians.
Definition MathUtils.hh:669
Rivet::deltaEta
double deltaEta(double eta1, double eta2, bool sign=false)
Definition MathUtils.hh:677
Rivet::PhiMapping
PhiMapping
Enum for range of to be mapped into.
Definition MathConstants.hh:49
Rivet::deltaR2
double deltaR2(double rap1, double phi1, double rap2, double phi2)
Definition MathUtils.hh:692
Rivet::mT
double mT(double pT1, double pT2, double dphi)
Definition MathUtils.hh:721
Rivet::operator<<
std::ostream & operator<<(std::ostream &os, const AnalysisInfo &ai)
Stream an AnalysisInfo as a text description.
Definition AnalysisInfo.hh:368
Rivet::invariant
double invariant(const FourVector &lv)
Definition Vector4.hh:292
Rivet::sign
constexpr std::enable_if< std::is_arithmetic< NUM >::value, int >::type sign(NUM val)
Find the sign of a number.
Definition MathUtils.hh:266
Rivet::contract
double contract(const FourVector &a, const FourVector &b)
Contract two 4-vectors, with metric signature (+ - - -).
Definition Vector4.hh:245
Rivet::RapScheme
RapScheme
Enum for rapidity variable to be used in calculating , applying rapidity cuts, etc.
Definition MathConstants.hh:46
Rivet::deltaRap
double deltaRap(double y1, double y2, bool sign=false)
Definition MathUtils.hh:685
Rivet::cmp
Cmp< T > cmp(const T &t1, const T &t2)
Global helper function for easy creation of Cmp objects.
Definition Cmp.hh:255
Rivet::toString
std::string toString(const AnalysisInfo &ai)
String representation.
Rivet::sqr
std::enable_if< std::is_arithmetic< NUM >::value, NUM >::type sqr(NUM a)
Named number-type squaring operation.
Definition MathUtils.hh:219
Rivet::isZero
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
Rivet::angle
double angle(const Vector2 &a, const Vector2 &b)
Angle (in radians) between two 2-vectors.
Definition Vector2.hh:177
Rivet::rapidity
double rapidity(double E, double pz)
Calculate a rapidity value from the supplied energy E and longitudinal momentum pz.
Definition MathUtils.hh:704