Rivet API documentation

Rivet 4.1.3
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/Vector3.hh"
7#include "Rivet/Math/VectorN.hh"
8#include "Rivet/Tools/TypeTraits.hh"
9
10// Forward declaration
11namespace fastjet {
12 class PseudoJet;
13}
14
15namespace Rivet {
16
17
18 class FourVector;
19 typedef FourVector Vector4;
20 typedef FourVector V4;
21
22 class FourMomentum;
23 typedef FourMomentum P4;
24
25 class LorentzTransform;
26 FourVector transform(const LorentzTransform& lt, const FourVector& v4);
27
28
32 class FourVector : public Vector<4> {
33 friend FourVector multiply(const double a, const FourVector& v);
34 friend FourVector multiply(const FourVector& v, const double a);
35 friend FourVector add(const FourVector& a, const FourVector& b);
36 friend FourVector transform(const LorentzTransform& lt, const FourVector& v4);
37
38 public:
39
40 FourVector()
41 : Vector<4>() { }
42
43 template <typename V4TYPE, typename std::enable_if<HasXYZT<V4TYPE>::value, int>::type DUMMY = 0>
44 FourVector(const V4TYPE& other) {
45 this->setT(other.t());
46 this->setX(other.x());
47 this->setY(other.y());
48 this->setZ(other.z());
49 }
50
51 FourVector(const Vector<4>& other)
52 : Vector<4>(other) { }
53
54 FourVector(const double t, const double x, const double y, const double z) {
55 this->setT(t);
56 this->setX(x);
57 this->setY(y);
58 this->setZ(z);
59 }
60
61 FourVector(double t, const Vector3& v3) {
62 this->setT(t);
63 this->setX(v3.x());
64 this->setY(v3.y());
65 this->setZ(v3.z());
66 }
67
68 virtual ~FourVector() { }
69
74 operator fastjet::PseudoJet() const;
75
76
77 public:
78
79 double t() const {
80 return get(0);
81 }
82 double t2() const {
83 return sqr(t());
84 }
85 FourVector& setT(const double t) {
86 set(0, t);
87 return *this;
88 }
89
90 double x() const {
91 return get(1);
92 }
93 double x2() const {
94 return sqr(x());
95 }
96 FourVector& setX(const double x) {
97 set(1, x);
98 return *this;
99 }
100
101 double y() const {
102 return get(2);
103 }
104 double y2() const {
105 return sqr(y());
106 }
107 FourVector& setY(const double y) {
108 set(2, y);
109 return *this;
110 }
111
112 double z() const {
113 return get(3);
114 }
115 double z2() const {
116 return sqr(z());
117 }
118 FourVector& setZ(const double z) {
119 set(3, z);
120 return *this;
121 }
122
123 double invariant() const {
124 // Done this way for numerical precision
125 return (t() + z()) * (t() - z()) - x() * x() - y() * y();
126 }
127
128 bool isNull() const {
129 return Rivet::isZero(invariant());
130 }
131
133 double angle(const FourVector& v) const {
134 return vector3().angle(v.vector3());
135 }
136
137 double angle(const Vector3& v3) const {
138 return vector3().angle(v3);
139 }
140
144 double polarRadius2() const {
145 return vector3().polarRadius2();
146 }
147
148 double perp2() const {
149 return vector3().perp2();
150 }
151
152 double rho2() const {
153 return vector3().rho2();
154 }
155
157 double polarRadius() const {
158 return vector3().polarRadius();
159 }
160
161 double perp() const {
162 return vector3().perp();
163 }
164
165 double rho() const {
166 return vector3().rho();
167 }
168
171 return vector3().polarVec();
172 }
173
174 Vector3 perpVec() const {
175 return vector3().perpVec();
176 }
177
178 Vector3 rhoVec() const {
179 return vector3().rhoVec();
180 }
181
183 double azimuthalAngle(const PhiMapping mapping = ZERO_2PI) const {
184 return vector3().azimuthalAngle(mapping);
185 }
186
187 double phi(const PhiMapping mapping = ZERO_2PI) const {
188 return vector3().phi(mapping);
189 }
190
192 double polarAngle() const {
193 return vector3().polarAngle();
194 }
195
196 double theta() const {
197 return vector3().theta();
198 }
199
201 double pseudorapidity() const {
202 return vector3().pseudorapidity();
203 }
204
205 double eta() const {
206 return vector3().eta();
207 }
208
210 double abspseudorapidity() const {
211 return fabs(eta());
212 }
213
214 double abseta() const {
215 return fabs(eta());
216 }
217
219 Vector3 vector3() const {
220 return Vector3(get(1), get(2), get(3));
221 }
222
223 Vector3 v3() const {
224 return vector3();
225 }
226
228 operator Vector3() const {
229 return vector3();
230 }
231
232
233 public:
234
236 double contract(const FourVector& v) const {
237 const double result = t() * v.t() - x() * v.x() - y() * v.y() - z() * v.z();
238 return result;
239 }
240
242 double dot(const FourVector& v) const {
243 return contract(v);
244 }
245
247 double operator*(const FourVector& v) const {
248 return contract(v);
249 }
250
252 FourVector& operator*=(double a) {
253 _vec = multiply(a, *this)._vec;
254 return *this;
255 }
256
258 FourVector& operator/=(double a) {
259 _vec = multiply(1.0 / a, *this)._vec;
260 return *this;
261 }
262
264 FourVector& operator+=(const FourVector& v) {
265 _vec = add(*this, v)._vec;
266 return *this;
267 }
268
270 FourVector& operator-=(const FourVector& v) {
271 _vec = add(*this, -v)._vec;
272 return *this;
273 }
274
276 FourVector operator-() const {
277 FourVector result;
278 result._vec = -_vec;
279 return result;
280 }
281
283 FourVector reverse() const {
284 FourVector result = -*this;
285 result.setT(-result.t());
286 return result;
287 }
288 };
289
290
292 inline double contract(const FourVector& a, const FourVector& b) {
293 return a.contract(b);
294 }
295
297 inline double dot(const FourVector& a, const FourVector& b) {
298 return contract(a, b);
299 }
300
301 inline FourVector multiply(const double a, const FourVector& v) {
302 FourVector result;
303 result._vec = a * v._vec;
304 return result;
305 }
306
307 inline FourVector multiply(const FourVector& v, const double a) {
308 return multiply(a, v);
309 }
310
311 inline FourVector operator*(const double a, const FourVector& v) {
312 return multiply(a, v);
313 }
314
315 inline FourVector operator*(const FourVector& v, const double a) {
316 return multiply(a, v);
317 }
318
319 inline FourVector operator/(const FourVector& v, const double a) {
320 return multiply(1.0 / a, v);
321 }
322
323 inline FourVector add(const FourVector& a, const FourVector& b) {
324 FourVector result;
325 result._vec = a._vec + b._vec;
326 return result;
327 }
328
329 inline FourVector operator+(const FourVector& a, const FourVector& b) {
330 return add(a, b);
331 }
332
333 inline FourVector operator-(const FourVector& a, const FourVector& b) {
334 return add(a, -b);
335 }
336
339 inline double invariant(const FourVector& lv) {
340 return lv.invariant();
341 }
342
344 inline double angle(const FourVector& a, const FourVector& b) {
345 return a.angle(b);
346 }
347
349 inline double angle(const Vector3& a, const FourVector& b) {
350 return angle(a, b.vector3());
351 }
352
354 inline double angle(const FourVector& a, const Vector3& b) {
355 return a.angle(b);
356 }
357
358
360
361
363 class FourMomentum : public FourVector {
364 friend FourMomentum multiply(const double a, const FourMomentum& v);
365 friend FourMomentum multiply(const FourMomentum& v, const double a);
366 friend FourMomentum add(const FourMomentum& a, const FourMomentum& b);
367 friend FourMomentum transform(const LorentzTransform& lt, const FourMomentum& v4);
368
369 public:
370
371 FourMomentum() { }
372
373 template <typename V4TYPE, typename std::enable_if<HasXYZT<V4TYPE>::value, int>::type DUMMY = 0>
374 FourMomentum(const V4TYPE& other) {
375 this->setE(other.t());
376 this->setPx(other.x());
377 this->setPy(other.y());
378 this->setPz(other.z());
379 }
380
381 FourMomentum(const Vector<4>& other)
382 : FourVector(other) { }
383
384 FourMomentum(const double E, const double px, const double py, const double pz) {
385 this->setE(E);
386 this->setPx(px);
387 this->setPy(py);
388 this->setPz(pz);
389 }
390
391 FourMomentum(const Vector3& v3, double m) {
392 const double e = sqrt(v3.mod2() + m * m);
393 this->setE(e);
394 this->setPx(v3.x());
395 this->setPy(v3.y());
396 this->setPz(v3.z());
397 }
398
399 ~FourMomentum() { }
400
401 public:
402
403
406
408 FourMomentum& setE(double E) {
409 setT(E);
410 return *this;
411 }
412
414 FourMomentum& setPx(double px) {
415 setX(px);
416 return *this;
417 }
418
420 FourMomentum& setPy(double py) {
421 setY(py);
422 return *this;
423 }
424
426 FourMomentum& setPz(double pz) {
427 setZ(pz);
428 return *this;
429 }
430
431
433 FourMomentum& setPE(double px, double py, double pz, double E) {
434 if (E < 0) throw std::invalid_argument("Negative energy given as argument: " + to_str(E));
435 setPx(px);
436 setPy(py);
437 setPz(pz);
438 setE(E);
439 return *this;
440 }
441
442 FourMomentum& setXYZE(double px, double py, double pz, double E) {
443 return setPE(px, py, pz, E);
444 }
445 // /// Near-alias with switched arg order
446 // FourMomentum& setEP(double E, double px, double py, double pz) {
447 // return setPE(px, py, pz, E);
448 // }
449 // /// Alias for setEP
450 // FourMomentum& setEXYZ(double E, double px, double py, double pz) {
451 // return setEP(E, px, py, pz);
452 // }
453
454
456 FourMomentum& setPM(double px, double py, double pz, double mass) {
457 if (mass < 0) throw std::invalid_argument("Negative mass given as argument: " + to_str(mass));
458 const double E = sqrt(sqr(mass) + sqr(px) + sqr(py) + sqr(pz));
459 // setPx(px); setPy(py); setPz(pz); setE(E);
460 return setPE(px, py, pz, E);
461 }
462
463 FourMomentum& setXYZM(double px, double py, double pz, double mass) {
464 return setPM(px, py, pz, mass);
465 }
466
467
472 FourMomentum& setEtaPhiME(double eta, double phi, double mass, double E) {
473 if (mass < 0) throw std::invalid_argument("Negative mass given as argument");
474 if (E < 0) throw std::invalid_argument("Negative energy given as argument");
475 const double theta = 2 * atan(exp(-eta));
476 if (theta < 0 || theta > M_PI) throw std::domain_error("Polar angle outside 0..pi in calculation");
478 return *this;
479 }
480
485 FourMomentum& setEtaPhiMPt(double eta, double phi, double mass, double pt) {
486 if (mass < 0) throw std::invalid_argument("Negative mass given as argument");
487 if (pt < 0) throw std::invalid_argument("Negative transverse momentum given as argument");
488 const double theta = 2 * atan(exp(-eta));
489 if (theta < 0 || theta > M_PI) throw std::domain_error("Polar angle outside 0..pi in calculation");
490 const double p = pt / sin(theta);
491 const double E = sqrt(sqr(p) + sqr(mass));
493 return *this;
494 }
495
504 FourMomentum& setRapPhiME(double y, double phi, double mass, double E) {
505 if (mass < 0) throw std::invalid_argument("Negative mass given as argument");
506 if (E < 0) throw std::invalid_argument("Negative energy given as argument");
507 const double sqrt_pt2_m2 = E / cosh(y);
508 const double pt = sqrt(sqr(sqrt_pt2_m2) - sqr(mass));
509 if (pt < 0) throw std::domain_error("Negative transverse momentum in calculation");
510 const double pz = sqrt_pt2_m2 * sinh(y);
511 const double px = pt * cos(phi);
512 const double py = pt * sin(phi);
513 setPE(px, py, pz, E);
514 return *this;
515 }
516
521 FourMomentum& setRapPhiMPt(double y, double phi, double mass, double pt) {
522 if (mass < 0) throw std::invalid_argument("Negative mass given as argument");
523 if (pt < 0) throw std::invalid_argument("Negative transverse mass given as argument");
524 const double E = sqrt(sqr(pt) + sqr(mass)) * cosh(y);
525 if (E < 0) throw std::domain_error("Negative energy in calculation");
526 setRapPhiME(y, phi, mass, E);
527 return *this;
528 }
529
535 FourMomentum& setThetaPhiME(double theta, double phi, double mass, double E) {
536 if (theta < 0 || theta > M_PI)
537 throw std::invalid_argument("Polar angle outside 0..pi given as argument");
538 if (mass < 0) throw std::invalid_argument("Negative mass given as argument");
539 if (E < 0) throw std::invalid_argument("Negative energy given as argument");
540 const double p = sqrt(sqr(E) - sqr(mass));
541 const double pz = p * cos(theta);
542 const double pt = p * sin(theta);
543 if (pt < 0) throw std::invalid_argument("Negative transverse momentum in calculation");
544 const double px = pt * cos(phi);
545 const double py = pt * sin(phi);
546 setPE(px, py, pz, E);
547 return *this;
548 }
549
555 FourMomentum& setThetaPhiMPt(double theta, double phi, double mass, double pt) {
556 if (theta < 0 || theta > M_PI)
557 throw std::invalid_argument("Polar angle outside 0..pi given as argument");
558 if (mass < 0) throw std::invalid_argument("Negative mass given as argument");
559 if (pt < 0) throw std::invalid_argument("Negative transverse momentum given as argument");
560 const double p = pt / sin(theta);
561 const double px = pt * cos(phi);
562 const double py = pt * sin(phi);
563 const double pz = p * cos(theta);
564 const double E = sqrt(sqr(p) + sqr(mass));
565 setPE(px, py, pz, E);
566 return *this;
567 }
568
572 FourMomentum& setPtPhiME(double pt, double phi, double mass, double E) {
573 if (pt < 0) throw std::invalid_argument("Negative transverse momentum given as argument");
574 if (mass < 0) throw std::invalid_argument("Negative mass given as argument");
575 if (E < 0) throw std::invalid_argument("Negative energy given as argument");
576 const double px = pt * cos(phi);
577 const double py = pt * sin(phi);
578 const double pz = sqrt(sqr(E) - sqr(mass) - sqr(pt));
579 setPE(px, py, pz, E);
580 return *this;
581 }
582
584
585
588
590 double E() const {
591 return t();
592 }
593
594 double E2() const {
595 return t2();
596 }
597
599 double px() const {
600 return x();
601 }
602
603 double px2() const {
604 return x2();
605 }
606
608 double py() const {
609 return y();
610 }
611
612 double py2() const {
613 return y2();
614 }
615
617 double pz() const {
618 return z();
619 }
620
621 double pz2() const {
622 return z2();
623 }
624
625
629 double mass() const {
630 // assert(Rivet::isZero(mass2()) || mass2() > 0);
631 // if (Rivet::isZero(mass2())) {
632 // return 0.0;
633 // } else {
634 // return sqrt(mass2());
635 // }
636 return sign(mass2()) * sqrt(fabs(mass2()));
637 }
638
640 double mass2() const {
641 return invariant();
642 }
643
644
646 Vector3 p3() const {
647 return vector3();
648 }
649
651 double p() const {
652 return p3().mod();
653 }
654
656 double p2() const {
657 return p3().mod2();
658 }
659
660
662 double rapidity() const {
663 if (E() == 0.0) return 0.0;
664 if (E() == fabs(pz())) return std::copysign(INF, pz());
665 return 0.5 * std::log((E() + pz()) / (E() - pz()));
666 }
667
668 double rap() const {
669 return rapidity();
670 }
671
673 double absrapidity() const {
674 return fabs(rapidity());
675 }
676
677 double absrap() const {
678 return fabs(rap());
679 }
680
682 Vector3 pTvec() const {
683 return p3().polarVec();
684 }
685
686 Vector3 ptvec() const {
687 return pTvec();
688 }
689
691 double pT2() const {
692 return vector3().polarRadius2();
693 }
694
695 double pt2() const {
696 return vector3().polarRadius2();
697 }
698
700 double pT() const {
701 return sqrt(pT2());
702 }
703
704 double pt() const {
705 return sqrt(pT2());
706 }
707
709 double Et2() const {
710 return Et() * Et();
711 }
712
713 double Et() const {
714 return E() * sin(polarAngle());
715 }
716
718
719
722
725 double gamma() const {
726 return sqrt(E2() / mass2());
727 }
728
732 return gamma() * p3().unit();
733 }
734
737 double beta() const {
738 return p() / E();
739 }
740
743 Vector3 betaVec() const {
744 // return Vector3(px()/E(), py()/E(), pz()/E());
745 return p3() / E();
746 }
747
749
750
752
755
757 FourMomentum& operator*=(double a) {
758 _vec = multiply(a, *this)._vec;
759 return *this;
760 }
761
763 FourMomentum& operator/=(double a) {
764 _vec = multiply(1.0 / a, *this)._vec;
765 return *this;
766 }
767
769 FourMomentum& operator+=(const FourMomentum& v) {
770 _vec = add(*this, v)._vec;
771 return *this;
772 }
773
775 FourMomentum& operator-=(const FourMomentum& v) {
776 _vec = add(*this, -v)._vec;
777 return *this;
778 }
779
781 FourMomentum operator-() const {
782 FourMomentum result;
783 result._vec = -_vec;
784 return result;
785 }
786
788 FourMomentum reverse() const {
789 FourMomentum result = -*this;
790 result.setE(-result.E());
791 return result;
792 }
793
795
796
798
799
802
804 static FourMomentum mkXYZE(double px, double py, double pz, double E) {
805 return FourMomentum().setPE(px, py, pz, E);
806 }
807
809 static FourMomentum mkXYZM(double px, double py, double pz, double mass) {
810 return FourMomentum().setPM(px, py, pz, mass);
811 }
812
814 static FourMomentum mkEtaPhiME(double eta, double phi, double mass, double E) {
815 return FourMomentum().setEtaPhiME(eta, phi, mass, E);
816 }
817
819 static FourMomentum mkEtaPhiMPt(double eta, double phi, double mass, double pt) {
820 return FourMomentum().setEtaPhiMPt(eta, phi, mass, pt);
821 }
822
824 static FourMomentum mkRapPhiME(double y, double phi, double mass, double E) {
825 return FourMomentum().setRapPhiME(y, phi, mass, E);
826 }
827
829 static FourMomentum mkRapPhiMPt(double y, double phi, double mass, double pt) {
830 return FourMomentum().setRapPhiMPt(y, phi, mass, pt);
831 }
832
834 static FourMomentum mkThetaPhiME(double theta, double phi, double mass, double E) {
835 return FourMomentum().setThetaPhiME(theta, phi, mass, E);
836 }
837
839 static FourMomentum mkThetaPhiMPt(double theta, double phi, double mass, double pt) {
840 return FourMomentum().setThetaPhiMPt(theta, phi, mass, pt);
841 }
842
844 static FourMomentum mkPtPhiME(double pt, double phi, double mass, double E) {
845 return FourMomentum().setPtPhiME(pt, phi, mass, E);
846 }
847
849 };
850
851
852 inline FourMomentum multiply(const double a, const FourMomentum& v) {
853 FourMomentum result;
854 result._vec = a * v._vec;
855 return result;
856 }
857
858 inline FourMomentum multiply(const FourMomentum& v, const double a) {
859 return multiply(a, v);
860 }
861
862 inline FourMomentum operator*(const double a, const FourMomentum& v) {
863 return multiply(a, v);
864 }
865
866 inline FourMomentum operator*(const FourMomentum& v, const double a) {
867 return multiply(a, v);
868 }
869
870 inline FourMomentum operator/(const FourMomentum& v, const double a) {
871 return multiply(1.0 / a, v);
872 }
873
874 inline FourMomentum add(const FourMomentum& a, const FourMomentum& b) {
875 FourMomentum result;
876 result._vec = a._vec + b._vec;
877 return result;
878 }
879
880 inline FourMomentum operator+(const FourMomentum& a, const FourMomentum& b) {
881 return add(a, b);
882 }
883
884 inline FourMomentum operator-(const FourMomentum& a, const FourMomentum& b) {
885 return add(a, -b);
886 }
887
888
890
891
894
903 inline double deltaR2(const FourVector& a, const FourVector& b, RapScheme scheme = PSEUDORAPIDITY) {
904 switch (scheme) {
905 case PSEUDORAPIDITY: return deltaR2(a.vector3(), b.vector3());
906 case RAPIDITY: {
907 const FourMomentum* ma = dynamic_cast<const FourMomentum*>(&a);
908 const FourMomentum* mb = dynamic_cast<const FourMomentum*>(&b);
909 if (!ma || !mb) {
910 string err =
911 "deltaR with scheme RAPIDITY can only be called with FourMomentum objects, not FourVectors";
912 throw std::runtime_error(err);
913 }
914 return deltaR2(*ma, *mb, scheme);
915 }
916 default: throw std::runtime_error("The specified deltaR scheme is not yet implemented");
917 }
918 }
919
928 inline double deltaR(const FourVector& a, const FourVector& b, RapScheme scheme = PSEUDORAPIDITY) {
929 return sqrt(deltaR2(a, b, scheme));
930 }
931
932
939 inline double deltaR2(const FourVector& v, double eta2, double phi2, RapScheme scheme = PSEUDORAPIDITY) {
940 switch (scheme) {
941 case PSEUDORAPIDITY: return deltaR2(v.vector3(), eta2, phi2);
942 case RAPIDITY: {
943 const FourMomentum* mv = dynamic_cast<const FourMomentum*>(&v);
944 if (!mv) {
945 string err =
946 "deltaR with scheme RAPIDITY can only be called with FourMomentum objects, not FourVectors";
947 throw std::runtime_error(err);
948 }
949 return deltaR2(*mv, eta2, phi2, scheme);
950 }
951 default: throw std::runtime_error("The specified deltaR scheme is not yet implemented");
952 }
953 }
954
961 inline double deltaR(const FourVector& v, double eta2, double phi2, RapScheme scheme = PSEUDORAPIDITY) {
962 return sqrt(deltaR2(v, eta2, phi2, scheme));
963 }
964
965
972 inline double deltaR2(double eta1, double phi1, const FourVector& v, RapScheme scheme = PSEUDORAPIDITY) {
973 switch (scheme) {
974 case PSEUDORAPIDITY: return deltaR2(eta1, phi1, v.vector3());
975 case RAPIDITY: {
976 const FourMomentum* mv = dynamic_cast<const FourMomentum*>(&v);
977 if (!mv) {
978 string err =
979 "deltaR with scheme RAPIDITY can only be called with FourMomentum objects, not FourVectors";
980 throw std::runtime_error(err);
981 }
982 return deltaR2(eta1, phi1, *mv, scheme);
983 }
984 default: throw std::runtime_error("The specified deltaR scheme is not yet implemented");
985 }
986 }
987
994 inline double deltaR(double eta1, double phi1, const FourVector& v, RapScheme scheme = PSEUDORAPIDITY) {
995 return sqrt(deltaR2(eta1, phi1, v, scheme));
996 }
997
998
1005 inline double deltaR2(const FourMomentum& a, const FourMomentum& b, RapScheme scheme = PSEUDORAPIDITY) {
1006 switch (scheme) {
1007 case PSEUDORAPIDITY: return deltaR2(a.vector3(), b.vector3());
1008 case RAPIDITY: return deltaR2(a.rapidity(), a.azimuthalAngle(), b.rapidity(), b.azimuthalAngle());
1009 default: throw std::runtime_error("The specified deltaR scheme is not yet implemented");
1010 }
1011 }
1012
1019 inline double deltaR(const FourMomentum& a, const FourMomentum& b, RapScheme scheme = PSEUDORAPIDITY) {
1020 return sqrt(deltaR2(a, b, scheme));
1021 }
1022
1023
1029 inline double deltaR2(const FourMomentum& v, double eta2, double phi2, RapScheme scheme = PSEUDORAPIDITY) {
1030 switch (scheme) {
1031 case PSEUDORAPIDITY: return deltaR2(v.vector3(), eta2, phi2);
1032 case RAPIDITY: return deltaR2(v.rapidity(), v.azimuthalAngle(), eta2, phi2);
1033 default: throw std::runtime_error("The specified deltaR scheme is not yet implemented");
1034 }
1035 }
1036
1042 inline double deltaR(const FourMomentum& v, double eta2, double phi2, RapScheme scheme = PSEUDORAPIDITY) {
1043 return sqrt(deltaR2(v, eta2, phi2, scheme));
1044 }
1045
1046
1052 inline double deltaR2(double eta1, double phi1, const FourMomentum& v, RapScheme scheme = PSEUDORAPIDITY) {
1053 switch (scheme) {
1054 case PSEUDORAPIDITY: return deltaR2(eta1, phi1, v.vector3());
1055 case RAPIDITY: return deltaR2(eta1, phi1, v.rapidity(), v.azimuthalAngle());
1056 default: throw std::runtime_error("The specified deltaR scheme is not yet implemented");
1057 }
1058 }
1059
1065 inline double deltaR(double eta1, double phi1, const FourMomentum& v, RapScheme scheme = PSEUDORAPIDITY) {
1066 return sqrt(deltaR2(eta1, phi1, v, scheme));
1067 }
1068
1069
1075 inline double deltaR2(const FourMomentum& a, const FourVector& b, RapScheme scheme = PSEUDORAPIDITY) {
1076 switch (scheme) {
1077 case PSEUDORAPIDITY: return deltaR2(a.vector3(), b.vector3());
1078 case RAPIDITY:
1080 default: throw std::runtime_error("The specified deltaR scheme is not yet implemented");
1081 }
1082 }
1083
1089 inline double deltaR(const FourMomentum& a, const FourVector& b, RapScheme scheme = PSEUDORAPIDITY) {
1090 return sqrt(deltaR2(a, b, scheme));
1091 }
1092
1093
1099 inline double deltaR2(const FourVector& a, const FourMomentum& b, RapScheme scheme = PSEUDORAPIDITY) {
1100 return deltaR2(b, a, scheme); //< note reversed args
1101 }
1102
1108 inline double deltaR(const FourVector& a, const FourMomentum& b, RapScheme scheme = PSEUDORAPIDITY) {
1109 return deltaR(b, a, scheme); //< note reversed args
1110 }
1111
1112
1115 inline double deltaR2(const FourMomentum& a, const Vector3& b) {
1116 return deltaR2(a.vector3(), b);
1117 }
1118
1121 inline double deltaR(const FourMomentum& a, const Vector3& b) {
1122 return deltaR(a.vector3(), b);
1123 }
1124
1127 inline double deltaR2(const Vector3& a, const FourMomentum& b) {
1128 return deltaR2(a, b.vector3());
1129 }
1130
1133 inline double deltaR(const Vector3& a, const FourMomentum& b) {
1134 return deltaR(a, b.vector3());
1135 }
1136
1139 inline double deltaR2(const FourVector& a, const Vector3& b) {
1140 return deltaR2(a.vector3(), b);
1141 }
1142
1145 inline double deltaR(const FourVector& a, const Vector3& b) {
1146 return deltaR(a.vector3(), b);
1147 }
1148
1151 inline double deltaR2(const Vector3& a, const FourVector& b) {
1152 return deltaR2(a, b.vector3());
1153 }
1154
1157 inline double deltaR(const Vector3& a, const FourVector& b) {
1158 return deltaR(a, b.vector3());
1159 }
1160
1162
1163
1165
1166
1169
1171 inline double deltaPhi(const FourMomentum& a, const FourMomentum& b, bool sign = false) {
1172 return deltaPhi(a.vector3(), b.vector3(), sign);
1173 }
1174
1176 inline double deltaPhi(const FourMomentum& v, double phi2, bool sign = false) {
1177 return deltaPhi(v.vector3(), phi2, sign);
1178 }
1179
1181 inline double deltaPhi(double phi1, const FourMomentum& v, bool sign = false) {
1182 return deltaPhi(phi1, v.vector3(), sign);
1183 }
1184
1186 inline double deltaPhi(const FourVector& a, const FourVector& b, bool sign = false) {
1187 return deltaPhi(a.vector3(), b.vector3(), sign);
1188 }
1189
1191 inline double deltaPhi(const FourVector& v, double phi2, bool sign = false) {
1192 return deltaPhi(v.vector3(), phi2, sign);
1193 }
1194
1196 inline double deltaPhi(double phi1, const FourVector& v, bool sign = false) {
1197 return deltaPhi(phi1, v.vector3(), sign);
1198 }
1199
1201 inline double deltaPhi(const FourVector& a, const FourMomentum& b, bool sign = false) {
1202 return deltaPhi(a.vector3(), b.vector3(), sign);
1203 }
1204
1206 inline double deltaPhi(const FourMomentum& a, const FourVector& b, bool sign = false) {
1207 return deltaPhi(a.vector3(), b.vector3(), sign);
1208 }
1209
1211 inline double deltaPhi(const FourVector& a, const Vector3& b, bool sign = false) {
1212 return deltaPhi(a.vector3(), b, sign);
1213 }
1214
1216 inline double deltaPhi(const Vector3& a, const FourVector& b, bool sign = false) {
1217 return deltaPhi(a, b.vector3(), sign);
1218 }
1219
1221 inline double deltaPhi(const FourMomentum& a, const Vector3& b, bool sign = false) {
1222 return deltaPhi(a.vector3(), b, sign);
1223 }
1224
1226 inline double deltaPhi(const Vector3& a, const FourMomentum& b, bool sign = false) {
1227 return deltaPhi(a, b.vector3(), sign);
1228 }
1229
1231
1232
1234
1235
1238
1240 inline double deltaEta(const FourMomentum& a, const FourMomentum& b, bool sign = false) {
1241 return deltaEta(a.vector3(), b.vector3(), sign);
1242 }
1243
1245 inline double deltaEta(const FourMomentum& v, double eta2, bool sign = false) {
1246 return deltaEta(v.vector3(), eta2, sign);
1247 }
1248
1250 inline double deltaEta(double eta1, const FourMomentum& v, bool sign = false) {
1251 return deltaEta(eta1, v.vector3(), sign);
1252 }
1253
1255 inline double deltaEta(const FourVector& a, const FourVector& b, bool sign = false) {
1256 return deltaEta(a.vector3(), b.vector3(), sign);
1257 }
1258
1260 inline double deltaEta(const FourVector& v, double eta2, bool sign = false) {
1261 return deltaEta(v.vector3(), eta2, sign);
1262 }
1263
1265 inline double deltaEta(double eta1, const FourVector& v, bool sign = false) {
1266 return deltaEta(eta1, v.vector3(), sign);
1267 }
1268
1270 inline double deltaEta(const FourVector& a, const FourMomentum& b, bool sign = false) {
1271 return deltaEta(a.vector3(), b.vector3(), sign);
1272 }
1273
1275 inline double deltaEta(const FourMomentum& a, const FourVector& b, bool sign = false) {
1276 return deltaEta(a.vector3(), b.vector3(), sign);
1277 }
1278
1280 inline double deltaEta(const FourVector& a, const Vector3& b, bool sign = false) {
1281 return deltaEta(a.vector3(), b, sign);
1282 }
1283
1285 inline double deltaEta(const Vector3& a, const FourVector& b, bool sign = false) {
1286 return deltaEta(a, b.vector3(), sign);
1287 }
1288
1290 inline double deltaEta(const FourMomentum& a, const Vector3& b, bool sign = false) {
1291 return deltaEta(a.vector3(), b, sign);
1292 }
1293
1295 inline double deltaEta(const Vector3& a, const FourMomentum& b, bool sign = false) {
1296 return deltaEta(a, b.vector3(), sign);
1297 }
1298
1300
1301
1304
1306 inline double deltaRap(const FourMomentum& a, const FourMomentum& b, bool sign = false) {
1307 return deltaRap(a.rapidity(), b.rapidity(), sign);
1308 }
1309
1311 inline double deltaRap(const FourMomentum& v, double y2, bool sign = false) {
1312 return deltaRap(v.rapidity(), y2, sign);
1313 }
1314
1316 inline double deltaRap(double y1, const FourMomentum& v, bool sign = false) {
1317 return deltaRap(y1, v.rapidity(), sign);
1318 }
1319
1321
1322
1324
1325
1328
1331
1333 inline bool cmpMomByPt(const FourMomentum& a, const FourMomentum& b) {
1334 return a.pt() > b.pt();
1335 }
1336
1337 inline bool cmpMomByAscPt(const FourMomentum& a, const FourMomentum& b) {
1338 return a.pt() < b.pt();
1339 }
1340
1342 inline bool cmpMomByP(const FourMomentum& a, const FourMomentum& b) {
1343 return a.vector3().mod() > b.vector3().mod();
1344 }
1345
1346 inline bool cmpMomByAscP(const FourMomentum& a, const FourMomentum& b) {
1347 return a.vector3().mod() < b.vector3().mod();
1348 }
1349
1351 inline bool cmpMomByEt(const FourMomentum& a, const FourMomentum& b) {
1352 return a.Et() > b.Et();
1353 }
1354
1355 inline bool cmpMomByAscEt(const FourMomentum& a, const FourMomentum& b) {
1356 return a.Et() < b.Et();
1357 }
1358
1360 inline bool cmpMomByE(const FourMomentum& a, const FourMomentum& b) {
1361 return a.E() > b.E();
1362 }
1363
1364 inline bool cmpMomByAscE(const FourMomentum& a, const FourMomentum& b) {
1365 return a.E() < b.E();
1366 }
1367
1369 inline bool cmpMomByMass(const FourMomentum& a, const FourMomentum& b) {
1370 return a.mass() > b.mass();
1371 }
1372
1373 inline bool cmpMomByAscMass(const FourMomentum& a, const FourMomentum& b) {
1374 return a.mass() < b.mass();
1375 }
1376
1378 inline bool cmpMomByEta(const FourMomentum& a, const FourMomentum& b) {
1379 return a.eta() < b.eta();
1380 }
1381
1383 inline bool cmpMomByDescEta(const FourMomentum& a, const FourMomentum& b) {
1384 return a.pseudorapidity() > b.pseudorapidity();
1385 }
1386
1388 inline bool cmpMomByAbsEta(const FourMomentum& a, const FourMomentum& b) {
1389 return fabs(a.eta()) < fabs(b.eta());
1390 }
1391
1393 inline bool cmpMomByDescAbsEta(const FourMomentum& a, const FourMomentum& b) {
1394 return fabs(a.eta()) > fabs(b.eta());
1395 }
1396
1398 inline bool cmpMomByRap(const FourMomentum& a, const FourMomentum& b) {
1399 return a.rapidity() < b.rapidity();
1400 }
1401
1403 inline bool cmpMomByDescRap(const FourMomentum& a, const FourMomentum& b) {
1404 return a.rapidity() > b.rapidity();
1405 }
1406
1408 inline bool cmpMomByAbsRap(const FourMomentum& a, const FourMomentum& b) {
1409 return fabs(a.rapidity()) < fabs(b.rapidity());
1410 }
1411
1413 inline bool cmpMomByDescAbsRap(const FourMomentum& a, const FourMomentum& b) {
1414 return fabs(a.rapidity()) > fabs(b.rapidity());
1415 }
1416
1418
1419
1421 template <typename MOMS, typename CMP>
1422 inline MOMS& isortBy(MOMS& pbs, const CMP& cmp) {
1423 std::sort(pbs.begin(), pbs.end(), cmp);
1424 return pbs;
1425 }
1426
1427 template <typename MOMS, typename CMP>
1428 inline MOMS sortBy(const MOMS& pbs, const CMP& cmp) {
1429 MOMS rtn = pbs;
1430 std::sort(rtn.begin(), rtn.end(), cmp);
1431 return rtn;
1432 }
1433
1435 template <typename MOMS>
1436 inline MOMS& isortByPt(MOMS& pbs) {
1437 return isortBy(pbs, cmpMomByPt);
1438 }
1439
1440 template <typename MOMS>
1441 inline MOMS sortByPt(const MOMS& pbs) {
1442 return sortBy(pbs, cmpMomByPt);
1443 }
1444
1446 template <typename MOMS>
1447 inline MOMS& isortByE(MOMS& pbs) {
1448 return isortBy(pbs, cmpMomByE);
1449 }
1450
1451 template <typename MOMS>
1452 inline MOMS sortByE(const MOMS& pbs) {
1453 return sortBy(pbs, cmpMomByE);
1454 }
1455
1457 template <typename MOMS>
1458 inline MOMS& isortByEt(MOMS& pbs) {
1459 return isortBy(pbs, cmpMomByEt);
1460 }
1461
1462 template <typename MOMS>
1463 inline MOMS sortByEt(const MOMS& pbs) {
1464 return sortBy(pbs, cmpMomByEt);
1465 }
1466
1468
1469
1472
1474 inline double mass(const FourMomentum& a, const FourMomentum& b) {
1475 return (a + b).mass();
1476 }
1477
1479 inline double mass2(const FourMomentum& a, const FourMomentum& b) {
1480 return (a + b).mass2();
1481 }
1482
1489 inline double mT(const FourMomentum& vis, const FourMomentum& invis) {
1490 return mT(vis.p3(), invis.p3());
1491 }
1492
1499 inline double mT(const FourMomentum& vis, const Vector3& invis) {
1500 return mT(vis.p3(), invis);
1501 }
1502
1509 inline double mT(const Vector3& vis, const FourMomentum& invis) {
1510 return mT(vis, invis.p3());
1511 }
1512
1519 inline double mT(const FourMomentum& vis, const Vector4& invis) {
1520 return mT(vis.p3(), invis.vector3());
1521 }
1522
1529 inline double mT(const Vector4& vis, const FourMomentum& invis) {
1530 return mT(vis.vector3(), invis.p3());
1531 }
1532
1534 inline double pT(const FourMomentum& vis, const FourMomentum& invis) {
1535 return pT(vis.p3(), invis.p3());
1536 }
1537
1539 inline double pT(const FourMomentum& vis, const Vector3& invis) {
1540 return pT(vis.p3(), invis);
1541 }
1542
1544 inline double pT(const Vector3& vis, const FourMomentum& invis) {
1545 return pT(vis, invis.p3());
1546 }
1547
1549
1550
1552
1553
1556
1558 inline std::string toString(const FourVector& lv) {
1559 std::ostringstream out;
1560 out << "(" << (fabs(lv.t()) < 1E-30 ? 0.0 : lv.t()) << "; " << (fabs(lv.x()) < 1E-30 ? 0.0 : lv.x())
1561 << ", " << (fabs(lv.y()) < 1E-30 ? 0.0 : lv.y()) << ", " << (fabs(lv.z()) < 1E-30 ? 0.0 : lv.z())
1562 << ")";
1563 return out.str();
1564 }
1565
1567 inline std::ostream& operator<<(std::ostream& out, const FourVector& lv) {
1568 out << toString(lv);
1569 return out;
1570 }
1571
1573
1576 typedef std::vector<FourVector> FourVectors;
1577 typedef std::vector<FourMomentum> FourMomenta;
1579
1581
1582
1583}
1584
1585#endif
Specialized version of the FourVector with momentum/energy functionality.
Definition Vector4.hh:363
double p2() const
Get the modulus-squared of the 3-momentum.
Definition Vector4.hh:656
double E2() const
Get energy-squared .
Definition Vector4.hh:594
double mass() const
Get the mass (the Lorentz self-invariant).
Definition Vector4.hh:629
double pz2() const
Get z-squared .
Definition Vector4.hh:621
double rapidity() const
Calculate the rapidity.
Definition Vector4.hh:662
FourMomentum reverse() const
Multiply space components only by -1.
Definition Vector4.hh:788
double px() const
Get x-component of momentum .
Definition Vector4.hh:599
FourMomentum & setPtPhiME(double pt, double phi, double mass, double E)
Definition Vector4.hh:572
FourMomentum & setRapPhiMPt(double y, double phi, double mass, double pt)
Definition Vector4.hh:521
Vector3 p3() const
Get 3-momentum part, .
Definition Vector4.hh:646
FourMomentum & setPz(double pz)
Set z-component of momentum .
Definition Vector4.hh:426
double p() const
Get the modulus of the 3-momentum.
Definition Vector4.hh:651
FourMomentum & setXYZE(double px, double py, double pz, double E)
Alias for setPE.
Definition Vector4.hh:442
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:834
Vector3 gammaVec() const
Definition Vector4.hh:731
double pt() const
Calculate the transverse momentum .
Definition Vector4.hh:704
FourMomentum & setPE(double px, double py, double pz, double E)
Set the p coordinates and energy simultaneously.
Definition Vector4.hh:433
double py() const
Get y-component of momentum .
Definition Vector4.hh:608
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:824
double beta() const
Definition Vector4.hh:737
double Et() const
Calculate the transverse energy .
Definition Vector4.hh:713
double Et2() const
Calculate the transverse energy .
Definition Vector4.hh:709
static FourMomentum mkXYZE(double px, double py, double pz, double E)
Make a vector from (px,py,pz,E) coordinates.
Definition Vector4.hh:804
FourMomentum & setPy(double py)
Set y-component of momentum .
Definition Vector4.hh:420
double rap() const
Alias for rapidity.
Definition Vector4.hh:668
FourMomentum & setPx(double px)
Set x-component of momentum .
Definition Vector4.hh:414
double pt2() const
Calculate the squared transverse momentum .
Definition Vector4.hh:695
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:844
Vector3 pTvec() const
Calculate the transverse momentum vector .
Definition Vector4.hh:682
FourMomentum & setRapPhiME(double y, double phi, double mass, double E)
Definition Vector4.hh:504
Vector3 ptvec() const
Synonym for pTvec.
Definition Vector4.hh:686
double mass2() const
Get the squared mass (the Lorentz self-invariant).
Definition Vector4.hh:640
FourMomentum & setEtaPhiMPt(double eta, double phi, double mass, double pt)
Definition Vector4.hh:485
double pz() const
Get z-component of momentum .
Definition Vector4.hh:617
double py2() const
Get y-squared .
Definition Vector4.hh:612
double absrap() const
Absolute rapidity.
Definition Vector4.hh:677
double pT2() const
Calculate the squared transverse momentum .
Definition Vector4.hh:691
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:814
double px2() const
Get x-squared .
Definition Vector4.hh:603
Vector3 betaVec() const
Definition Vector4.hh:743
FourMomentum & operator-=(const FourMomentum &v)
Subtract from this 4-vector. NB time as well as space components are subtracted.
Definition Vector4.hh:775
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:809
FourMomentum & setThetaPhiME(double theta, double phi, double mass, double E)
Definition Vector4.hh:535
double E() const
Get energy (time component of momentum).
Definition Vector4.hh:590
FourMomentum & setXYZM(double px, double py, double pz, double mass)
Alias for setPM.
Definition Vector4.hh:463
FourMomentum & operator+=(const FourMomentum &v)
Add to this 4-vector. NB time as well as space components are added.
Definition Vector4.hh:769
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:819
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:829
double pT() const
Calculate the transverse momentum .
Definition Vector4.hh:700
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:839
FourMomentum & setThetaPhiMPt(double theta, double phi, double mass, double pt)
Definition Vector4.hh:555
FourMomentum operator-() const
Multiply all components (time and space) by -1.
Definition Vector4.hh:781
double absrapidity() const
Absolute rapidity.
Definition Vector4.hh:673
FourMomentum & setEtaPhiME(double eta, double phi, double mass, double E)
Definition Vector4.hh:472
FourMomentum & operator/=(double a)
Divide by a scalar.
Definition Vector4.hh:763
FourMomentum & setE(double E)
Set energy (time component of momentum).
Definition Vector4.hh:408
double gamma() const
Definition Vector4.hh:725
FourMomentum & operator*=(double a)
Multiply by a scalar.
Definition Vector4.hh:757
FourMomentum & setPM(double px, double py, double pz, double mass)
Set the p coordinates and mass simultaneously.
Definition Vector4.hh:456
Specialisation of VectorN to a general (non-momentum) Lorentz 4-vector.
Definition Vector4.hh:32
FourVector operator-() const
Multiply all components (space and time) by -1.
Definition Vector4.hh:276
double perp2() const
Synonym for polarRadius2.
Definition Vector4.hh:148
FourVector & operator/=(double a)
Divide by a scalar.
Definition Vector4.hh:258
double rho() const
Synonym for polarRadius.
Definition Vector4.hh:165
Vector3 perpVec() const
Synonym for polarVec.
Definition Vector4.hh:174
Vector3 vector3() const
Get the spatial part of the 4-vector as a 3-vector.
Definition Vector4.hh:219
double angle(const FourVector &v) const
Angle between this vector and another.
Definition Vector4.hh:133
double phi(const PhiMapping mapping=ZERO_2PI) const
Synonym for azimuthalAngle.
Definition Vector4.hh:187
double contract(const FourVector &v) const
Contract two 4-vectors, with metric signature (+ - - -).
Definition Vector4.hh:236
double abseta() const
Get the directly (alias).
Definition Vector4.hh:214
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:183
double dot(const FourVector &v) const
Contract two 4-vectors, with metric signature (+ - - -).
Definition Vector4.hh:242
double perp() const
Synonym for polarRadius.
Definition Vector4.hh:161
FourVector & operator*=(double a)
Multiply by a scalar.
Definition Vector4.hh:252
double operator*(const FourVector &v) const
Contract two 4-vectors, with metric signature (+ - - -).
Definition Vector4.hh:247
double eta() const
Synonym for pseudorapidity.
Definition Vector4.hh:205
double theta() const
Synonym for polarAngle.
Definition Vector4.hh:196
double pseudorapidity() const
Pseudorapidity (defined purely by the 3-vector components).
Definition Vector4.hh:201
Vector3 v3() const
Short "p3-like" alias for vector3.
Definition Vector4.hh:223
double polarRadius() const
Magnitude of projection of 3-vector on to the plane.
Definition Vector4.hh:157
Vector3 rhoVec() const
Synonym for polarVec.
Definition Vector4.hh:178
double angle(const Vector3 &v3) const
Angle between this vector and another (3-vector).
Definition Vector4.hh:137
Vector3 polarVec() const
Projection of 3-vector on to the plane.
Definition Vector4.hh:170
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:144
FourVector reverse() const
Multiply space components only by -1.
Definition Vector4.hh:283
double polarAngle() const
Angle subtended by the 3-vector and the z-axis.
Definition Vector4.hh:192
FourVector & operator-=(const FourVector &v)
Subtract from this 4-vector. NB time as well as space components are subtracted.
Definition Vector4.hh:270
double abspseudorapidity() const
Get the directly.
Definition Vector4.hh:210
FourVector & operator+=(const FourVector &v)
Add to this 4-vector.
Definition Vector4.hh:264
double rho2() const
Synonym for polarRadius2.
Definition Vector4.hh:152
Object implementing Lorentz transform calculations and boosts.
Definition LorentzTrans.hh:21
Three-dimensional specialisation of Vector.
Definition Vector3.hh:39
Vector3 rhoVec() const
Synonym for polarVec.
Definition Vector3.hh:169
double polarRadius() const
Polar radius.
Definition Vector3.hh:187
double rho() const
Synonym for polarRadius.
Definition Vector3.hh:195
double eta() const
Synonym for pseudorapidity.
Definition Vector3.hh:259
double perp() const
Synonym for polarRadius.
Definition Vector3.hh:191
double perp2() const
Synonym for polarRadius2.
Definition Vector3.hh:178
double pseudorapidity() const
Purely geometric approximation to rapidity.
Definition Vector3.hh:251
Vector3 unit() const
Synonym for unitVec.
Definition Vector3.hh:154
double theta() const
Synonym for polarAngle.
Definition Vector3.hh:239
double phi(const PhiMapping mapping=ZERO_2PI) const
Synonym for azimuthalAngle.
Definition Vector3.hh:212
double polarRadius2() const
Square of the polar radius (.
Definition Vector3.hh:174
Vector3 perpVec() const
Synonym for polarVec.
Definition Vector3.hh:165
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:203
double rho2() const
Synonym for polarRadius2.
Definition Vector3.hh:182
double angle(const Vector3 &v) const
Angle in radians to another vector.
Definition Vector3.hh:136
double polarAngle() const
Angle subtended by the vector and the z-axis.
Definition Vector3.hh:232
Vector3 polarVec() const
Polar projection of this vector into the x-y plane.
Definition Vector3.hh:159
A minimal base class for -dimensional vectors.
Definition VectorN.hh:23
double mod() const
Calculate the modulus of a vector. .
Definition VectorN.hh:99
double mod2() const
Calculate the modulus-squared of a vector. .
Definition VectorN.hh:88
Vector< N > & set(const size_t index, const double value)
Definition VectorN.hh:63
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:1422
MOMS & isortByE(MOMS &pbs)
Sort a container of momenta by E (decreasing) and return by reference for non-const inputs.
Definition Vector4.hh:1447
MOMS & isortByEt(MOMS &pbs)
Sort a container of momenta by Et (decreasing) and return by reference for non-const inputs.
Definition Vector4.hh:1458
bool cmpMomByDescEta(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by decreasing eta (pseudorapidity).
Definition Vector4.hh:1383
bool cmpMomByMass(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by decreasing mass.
Definition Vector4.hh:1369
bool cmpMomByP(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by decreasing 3-momentum magnitude |p|.
Definition Vector4.hh:1342
bool cmpMomByAscEt(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by increasing transverse energy.
Definition Vector4.hh:1355
bool cmpMomByRap(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by increasing rapidity.
Definition Vector4.hh:1398
bool cmpMomByE(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by decreasing energy.
Definition Vector4.hh:1360
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:1428
bool cmpMomByAbsRap(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by increasing absolute rapidity.
Definition Vector4.hh:1408
MOMS sortByPt(const MOMS &pbs)
Sort a container of momenta by pT (decreasing) and return by value for const inputs.
Definition Vector4.hh:1441
MOMS sortByEt(const MOMS &pbs)
Sort a container of momenta by Et (decreasing) and return by value for const inputs.
Definition Vector4.hh:1463
bool cmpMomByEt(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by decreasing transverse energy.
Definition Vector4.hh:1351
bool cmpMomByAscPt(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by increasing pT.
Definition Vector4.hh:1337
bool cmpMomByAscP(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by increasing 3-momentum magnitude |p|.
Definition Vector4.hh:1346
bool cmpMomByAscMass(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by increasing mass.
Definition Vector4.hh:1373
MOMS sortByE(const MOMS &pbs)
Sort a container of momenta by E (decreasing) and return by value for const inputs.
Definition Vector4.hh:1452
bool cmpMomByPt(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by decreasing pT.
Definition Vector4.hh:1333
bool cmpMomByAbsEta(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by increasing absolute eta (pseudorapidity).
Definition Vector4.hh:1388
bool cmpMomByDescAbsEta(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by increasing absolute eta (pseudorapidity).
Definition Vector4.hh:1393
bool cmpMomByEta(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by increasing eta (pseudorapidity).
Definition Vector4.hh:1378
bool cmpMomByAscE(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by increasing energy.
Definition Vector4.hh:1364
bool cmpMomByDescAbsRap(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by decreasing absolute rapidity.
Definition Vector4.hh:1413
MOMS & isortByPt(MOMS &pbs)
Sort a container of momenta by pT (decreasing) and return by reference for non-const inputs.
Definition Vector4.hh:1436
bool cmpMomByDescRap(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by decreasing rapidity.
Definition Vector4.hh:1403
double mass(const FourMomentum &a, const FourMomentum &b)
Calculate mass of two 4-vectors.
Definition Vector4.hh:1474
double mass2(const FourMomentum &a, const FourMomentum &b)
Calculate mass^2 of two 4-vectors.
Definition Vector4.hh:1479
double pT(const Vector3 &a, const Vector3 &b)
Calculate transverse momentum of pair of 3-vectors.
Definition Vector3.hh:691
std::vector< FourVector > FourVectors
Definition Vector4.hh:1576
double E(const ParticleBase &p)
Unbound function access to E.
Definition ParticleBaseUtils.hh:829
string to_str(const T &x)
Convert any object to a string.
Definition Utils.hh:80
Definition LHCbCommon.hh:9
constexpr std::enable_if_t< std::is_arithmetic_v< NUM >, int > sign(NUM val)
Find the sign of a number.
Definition MathUtils.hh:295
double deltaR(double rap1, double phi1, double rap2, double phi2)
Definition MathUtils.hh:754
double deltaPhi(double phi1, double phi2, bool sign=false)
Calculate the difference between two angles in radians.
Definition MathUtils.hh:724
double deltaEta(double eta1, double eta2, bool sign=false)
Definition MathUtils.hh:732
PhiMapping
Enum for range of to be mapped into.
Definition MathConstants.hh:49
double deltaR2(double rap1, double phi1, double rap2, double phi2)
Definition MathUtils.hh:747
double mT(double pT1, double pT2, double dphi)
Definition MathUtils.hh:777
std::ostream & operator<<(std::ostream &os, const AnalysisInfo &ai)
Stream an AnalysisInfo as a text description.
Definition AnalysisInfo.hh:463
std::enable_if_t< std::is_floating_point_v< NUM >, bool > isZero(NUM val, double tolerance=1e-8)
Compare a number to zero.
Definition MathUtils.hh:23
std::enable_if_t< std::is_arithmetic_v< NUM >, NUM > sqr(NUM a)
Named number-type squaring operation.
Definition MathUtils.hh:237
double invariant(const FourVector &lv)
Definition Vector4.hh:339
double contract(const FourVector &a, const FourVector &b)
Contract two 4-vectors, with metric signature (+ - - -).
Definition Vector4.hh:292
double add(double a, double b, double tolerance=1e-5)
Add two numbers with FP fuzziness.
Definition MathUtils.hh:248
RapScheme
Enum for rapidity variable to be used in calculating , applying rapidity cuts, etc.
Definition MathConstants.hh:46
double deltaRap(double y1, double y2, bool sign=false)
Definition MathUtils.hh:740
Cmp< T > cmp(const T &t1, const T &t2)
Global helper function for easy creation of Cmp objects.
Definition Cmp.hh:253
std::string toString(const AnalysisInfo &ai)
String representation.
double angle(const Vector2 &a, const Vector2 &b)
Angle (in radians) between two 2-vectors.
Definition Vector2.hh:194
double rapidity(double E, double pz)
Calculate a rapidity value from the supplied energy E and longitudinal momentum pz.
Definition MathUtils.hh:759