Belle II Software light-2607-kasei
B2Vector3.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#pragma once
10
11
12#include <framework/logging/Logger.h>
13
14#include <TVector3.h>
15#include <Math/Vector3D.h>
16#include <string>
17#include <iostream> // std::cout, std::fixed
18#include <iomanip> // std::setprecision
19#include <typeinfo>
20#include <cmath>
21
22
23namespace Belle2 {
28
40
41 template<typename DataType>
42 class B2Vector3 {
43 protected:
45 static_assert(std::is_floating_point<DataType>::value, "B2Vector3 only works with floating point types");
47 DataType m_coordinates[3] {};
48 public:
50 typedef DataType value_type;
51
53 B2Vector3(void) : m_coordinates {static_cast<DataType>(0), static_cast<DataType>(0), static_cast<DataType>(0)} {};
55 B2Vector3(const DataType xVal, const DataType yVal, const DataType zVal): m_coordinates {xVal, yVal, zVal} {};
57 explicit B2Vector3(const DataType(& coords)[3]): m_coordinates {coords[0], coords[1], coords[2]} {};
59 explicit B2Vector3(const DataType(* coords)[3]): m_coordinates {(*coords)[0], (*coords)[1], (*coords)[2]} {};
61 // cppcheck-suppress noExplicitConstructor
62 B2Vector3(const TVector3& tVec3): m_coordinates {static_cast<DataType>(tVec3.X()), static_cast<DataType>(tVec3.Y()), static_cast<DataType>(tVec3.Z())} {};
64 // cppcheck-suppress noExplicitConstructor
65 B2Vector3(const TVector3* tVec3): m_coordinates {static_cast<DataType>(tVec3->X()), static_cast<DataType>(tVec3->Y()), static_cast<DataType>(tVec3->Z())} {};
67 explicit B2Vector3(const B2Vector3<DataType>& b2Vec3): m_coordinates {b2Vec3.X(), b2Vec3.Y(), b2Vec3.Z()} {};
69 explicit B2Vector3(const B2Vector3<DataType>* b2Vec3): m_coordinates {b2Vec3->X(), b2Vec3->Y(), b2Vec3->Z()} {};
71 template <typename OtherType> B2Vector3(const B2Vector3<OtherType>& b2Vec3):
72 m_coordinates {static_cast<DataType>(b2Vec3.X()), static_cast<DataType>(b2Vec3.Y()), static_cast<DataType>(b2Vec3.Z())} {};
73
74 template <typename OtherType> explicit B2Vector3(const B2Vector3<OtherType>* b2Vec3):
75 m_coordinates {static_cast<DataType>(b2Vec3->X()), static_cast<DataType>(b2Vec3->Y()), static_cast<DataType>(b2Vec3->Z())} {};
76
77 // cppcheck-suppress noExplicitConstructor
78 B2Vector3(const ROOT::Math::XYZVector& xyzVec): m_coordinates {static_cast<DataType>(xyzVec.X()), static_cast<DataType>(xyzVec.Y()), static_cast<DataType>(xyzVec.Z())} {};
80 // cppcheck-suppress noExplicitConstructor
81 B2Vector3(const ROOT::Math::XYZVector* xyzVec): m_coordinates {static_cast<DataType>(xyzVec->X()), static_cast<DataType>(xyzVec->Y()), static_cast<DataType>(xyzVec->Z())} {};
82
84 DataType operator()(unsigned i) const { return m_coordinates[i]; }
86 DataType operator[](unsigned i) const { return m_coordinates[i]; }
88 DataType& operator()(unsigned i) { return m_coordinates[i]; }
90 DataType& operator[](unsigned i) { return m_coordinates[i]; }
91
95 B2Vector3<DataType>& operator = (const TVector3& b);
97 B2Vector3<DataType>& operator = (const ROOT::Math::XYZVector& b);
98
100 operator TVector3() const { return GetTVector3(); }
102 operator ROOT::Math::XYZVector() const { return GetXYZVector(); }
103
105 bool operator == (const B2Vector3<DataType>& b) const { return X() == b.X() && Y() == b.Y() && Z() == b.Z(); }
107 bool operator == (const TVector3& b) const { return X() == b.X() && Y() == b.Y() && Z() == b.Z(); }
109 bool operator == (const ROOT::Math::XYZVector& b) const { return X() == b.X() && Y() == b.Y() && Z() == b.Z(); }
111 bool operator != (const B2Vector3<DataType>& b) const { return !(*this == b); }
113 bool operator != (const TVector3& b) const { return !(*this == b); }
115 bool operator != (const ROOT::Math::XYZVector& b) const { return !(*this == b); }
116
124 B2Vector3<DataType> operator - () const { return B2Vector3<DataType>(-X(), -Y(), -Z()); }
127 {
128 return B2Vector3<DataType>(X() + b.X(), Y() + b.Y(), Z() + b.Z());
129 }
130
132 {
133 return B2Vector3<DataType>(X() - b.X(), Y() - b.Y(), Z() - b.Z());
134 }
135
137 {
138 return B2Vector3<DataType>(a * X(), a * Y(), a * Z());
139 }
140
142 {
143 return B2Vector3<DataType>(X() / a, Y() / a, Z() / a);
144 }
145
146 DataType operator * (const B2Vector3<DataType>& b) const { return Dot(b); }
147
148
150 DataType Phi() const { return X() == 0 && Y() == 0 ? 0 : atan2(Y(), X()); }
152 DataType Theta() const { return X() == 0 && Y() == 0 && Z() == 0 ? 0 : atan2(Perp(), Z()); }
154 DataType CosTheta() const { const double pTot = Mag(); return pTot == 0 ? 1 : Z() / pTot; }
156 DataType Mag2() const { return X() * X() + Y() * Y() + Z() * Z(); }
158 DataType Mag() const { return std::hypot((double)Perp(), (double)Z()); }
159
161 void SetPhi(DataType phi)
162 {
163 const double perp = Perp();
164 SetX(perp * cos((double)phi));
165 SetY(perp * sin((double)phi));
166 }
167
169 void SetTheta(DataType theta)
170 {
171 const double ma = Mag();
172 const double ph = Phi();
173 const double ctheta = std::cos((double) theta);
174 const double stheta = std::sin((double) theta);
175 SetX(ma * stheta * std::cos(ph));
176 SetY(ma * stheta * std::cos(ph));
177 SetZ(ma * ctheta);
178 }
179
181 void SetMag(DataType mag)
182 {
183 double factor = Mag();
184 if (factor == 0) {
185 B2WARNING(name() << "::SetMag: zero vector can't be stretched");
186 } else {
187 factor = mag / factor;
188 SetX(X()*factor);
189 SetY(Y()*factor);
190 SetZ(Z()*factor);
191 }
192 }
193
195 DataType Perp2() const { return X() * X() + Y() * Y(); }
197 DataType Pt() const { return Perp(); }
199 DataType Perp() const { return std::hypot((double)X(), (double)Y()); }
200
202 void SetPerp(DataType r)
203 {
204 const double p = Perp();
205 if (p != 0.0) {
206 m_coordinates[0] *= r / p;
207 m_coordinates[1] *= r / p;
208 }
209 }
210
212 DataType Perp2(const B2Vector3<DataType>& axis) const
213 {
214 const double tot = axis.Mag2();
215 const double ss = Dot(axis);
216 double per = Mag2();
217 if (tot > 0.0) per -= ss * ss / tot;
218 if (per < 0) per = 0;
219 return per;
220 }
221
223 DataType Pt(const B2Vector3<DataType>& axis) const { return Perp(axis); }
225 DataType Perp(const B2Vector3<DataType>& axis) const { return std::sqrt(Perp2(axis)); }
227 DataType DeltaPhi(const B2Vector3<DataType>& v) const { return Mpi_pi(Phi() - v.Phi()); }
228
229
231 static DataType Mpi_pi(DataType angle)
232 {
233 if (std::isnan(angle)) {
234 B2ERROR(name() << "::Mpi_pi: function called with NaN");
235 return angle;
236 }
237 angle = std::remainder(angle, 2 * M_PI);
238 //for compatibility with ROOT we flip the sign for exactly pi
239 if (angle == M_PI) angle = -M_PI;
240 return angle;
241 }
242
244 DataType DeltaR(const B2Vector3<DataType>& v) const
245 {
246 const double deta = Eta() - v.Eta();
247 const double dphi = DeltaPhi(v);
248 return std::hypot(deta, dphi);
249 }
250
252 DataType DrEtaPhi(const B2Vector3<DataType>& v) const
253 {
254 return DeltaR(v);
255 }
256
258 void SetMagThetaPhi(DataType mag, DataType theta, DataType phi)
259 {
260 const double amag = std::abs(mag);
261 const double sinTheta = std::sin((double)theta);
262 m_coordinates[0] = amag * sinTheta * std::cos((double)phi);
263 m_coordinates[1] = amag * sinTheta * std::sin((double)phi);
264 m_coordinates[2] = amag * std::cos((double)theta);
265 }
266
269 {
270 const double tot = Mag2();
271 B2Vector3<DataType> p(X(), Y(), Z());
272 return tot > 0.0 ? p *= (1.0 / std::sqrt(tot)) : p;
273 }
274
277 {
278 const double xVal = std::abs((double)X());
279 const double yVal = std::abs((double)Y());
280 const double zVal = std::abs((double)Z());
281 if (xVal < yVal) {
282 return xVal < zVal ? B2Vector3<DataType>(0, Z(), -Y()) : B2Vector3<DataType>(Y(), -X(), 0);
283 } else {
284 return yVal < zVal ? B2Vector3<DataType>(-Z(), 0, X()) : B2Vector3<DataType>(Y(), -X(), 0);
285 }
286 }
287
289 DataType Dot(const B2Vector3<DataType>& p) const
290 {
291 return X() * p.X() + Y() * p.Y() + Z() * p.Z();
292 }
293
296 {
297 return B2Vector3<DataType>(Y() * p.Z() - p.Y() * Z(), Z() * p.X() - p.Z() * X(), X() * p.Y() - p.X() * Y());
298 }
299
301 DataType Angle(const B2Vector3<DataType>& q) const
302 {
303 const double ptot2 = Mag2() * q.Mag2();
304 if (ptot2 <= 0) {
305 return 0.0;
306 } else {
307 double arg = Dot(q) / std::sqrt(ptot2);
308 if (arg > 1.0) arg = 1.0;
309 if (arg < -1.0) arg = -1.0;
310 return std::acos(arg);
311 }
312 }
313
318 DataType PseudoRapidity() const
319 {
320 const double cosTheta = CosTheta();
321 if (std::abs(cosTheta) < 1) return -0.5 * std::log((1.0 - cosTheta) / (1.0 + cosTheta));
322 if (Z() == 0) return 0;
323 //B2WARNING(name() << "::PseudoRapidity: transverse momentum = 0! return +/- 10e10");
324 if (Z() > 0) return 10e10;
325 else return -10e10;
326 }
327
328
330 DataType Eta() const { return PseudoRapidity(); }
331
332
334 void RotateX(DataType angle)
335 {
336 //rotate vector around X
337 const double s = std::sin((double)angle);
338 const double c = std::cos((double)angle);
339 const double yOld = Y();
340 m_coordinates[1] = c * yOld - s * Z();
341 m_coordinates[2] = s * yOld + c * Z();
342 }
343
344
346 void RotateY(DataType angle)
347 {
348 //rotate vector around Y
349 const double s = std::sin((double)angle);
350 const double c = std::cos((double)angle);
351 const double zOld = Z();
352 m_coordinates[0] = s * zOld + c * X();
353 m_coordinates[2] = c * zOld - s * X();
354 }
355
356
358 void RotateZ(DataType angle)
359 {
360 //rotate vector around Z
361 const double s = std::sin((double)angle);
362 const double c = std::cos((double)angle);
363 const double xOld = X();
364 m_coordinates[0] = c * xOld - s * Y();
365 m_coordinates[1] = s * xOld + c * Y();
366 }
367
369 void RotateUz(const B2Vector3<DataType>& NewUzVector)
370 {
371 // NewUzVector must be normalized !
372
373 const double u1 = NewUzVector.X();
374 const double u2 = NewUzVector.Y();
375 const double u3 = NewUzVector.Z();
376 double up = u1 * u1 + u2 * u2;
377
378 if (up) {
379 up = std::sqrt(up);
380 DataType px = X(), py = Y(), pz = Z();
381 m_coordinates[0] = (u1 * u3 * px - u2 * py + u1 * up * pz) / up;
382 m_coordinates[1] = (u2 * u3 * px + u1 * py + u2 * up * pz) / up;
383 m_coordinates[2] = (u3 * u3 * px - px + u3 * up * pz) / up;
384 } else if (u3 < 0.) {
387 }
388 }
389
398 void Rotate(DataType alpha, const B2Vector3<DataType>& v)
399 {
401 *this = (n * (n.Dot(*this)) + cos(alpha) * ((n.Cross(*this)).Cross(n)) + sin(alpha) * (n.Cross(*this)));
402 }
403
405 void Abs()
406 {
407 m_coordinates[0] = std::abs(m_coordinates[0]);
408 m_coordinates[1] = std::abs(m_coordinates[1]);
409 m_coordinates[2] = std::abs(m_coordinates[2]);
410 }
411
413 void Sqrt()
414 {
415 Abs();
416 m_coordinates[0] = std::sqrt(m_coordinates[0]);
417 m_coordinates[1] = std::sqrt(m_coordinates[1]);
418 m_coordinates[2] = std::sqrt(m_coordinates[2]);
419 }
420
422 DataType at(unsigned i) const;
424 DataType x() const { return m_coordinates[0]; }
426 DataType y() const { return m_coordinates[1]; }
428 DataType z() const { return m_coordinates[2]; }
430 DataType X() const { return x(); }
432 DataType Y() const { return y(); }
434 DataType Z() const { return z(); }
436 DataType Px() const { return x(); }
438 DataType Py() const { return y(); }
440 DataType Pz() const { return z(); }
441
443 void GetXYZ(Double_t* carray) const;
445 void GetXYZ(Float_t* carray) const;
447 void GetXYZ(TVector3* tVec) const;
449 void GetXYZ(ROOT::Math::XYZVector* xyzVec) const;
451 TVector3 GetTVector3() const;
453 ROOT::Math::XYZVector GetXYZVector() const;
454
456 void SetX(DataType x) { m_coordinates[0] = x; }
458 void SetY(DataType y) { m_coordinates[1] = y; }
460 void SetZ(DataType z) { m_coordinates[2] = z; }
461
463 void SetXYZ(DataType x, DataType y, DataType z)
464 {
465 SetX(x); SetY(y); SetZ(z);
466 }
467
468 void SetXYZ(const TVector3& tVec);
470 void SetXYZ(const TVector3* tVec);
472 void SetXYZ(const ROOT::Math::XYZVector& xyzVec);
474 void SetXYZ(const ROOT::Math::XYZVector* xyzVec);
475
477 static std::string name();
478
480 std::string PrintString(unsigned precision = 4) const
481 {
482 return name() + " " + PrintStringXYZ(precision) + " " + PrintStringCyl(precision);
483 }
484
486 std::string PrintStringXYZ(unsigned precision = 4) const
487 {
488 std::ostringstream output;
489 output << "(x,y,z)=("
490 << std::fixed << std::setprecision(precision)
491 << X() << "," << Y() << "," << Z() << ")";
492 return output.str();
493 }
494
496 std::string PrintStringCyl(unsigned precision = 4) const
497 {
498 std::ostringstream output;
499 output << "(rho, theta, phi)=("
500 << std::fixed << std::setprecision(precision)
501 << Mag() << "," << Theta() * 180. / M_PI << "," << Phi() * 180. / M_PI << ")";
502 return output.str();
503 }
504
506 void Print()
507 {
508 //print vector parameters
509 Print(PrintString().c_str());
510 }
511
512 };
513
516
519
521 template <typename DataType>
522 Bool_t operator == (const TVector3& a, const B2Vector3<DataType>& b)
523 {
524 return (a.X() == b.X() && a.Y() == b.Y() && a.Z() == b.Z());
525 }
526
528 template < typename DataType>
529 Bool_t operator != (const TVector3& a, const B2Vector3<DataType>& b)
530 {
531 return !(a == b);
532 }
533
535 template < typename DataType>
537 {
538 return B2Vector3<DataType>(a * p.X(), a * p.Y(), a * p.Z());
539 }
540
542 template < typename DataType>
544 {
545 return B2Vector3<DataType>(a.X() + b.X(), a.Y() + b.Y(), a.Z() + b.Z());
546 }
547
549 template < typename DataType>
551 {
552 return B2Vector3<DataType>(a.X() - b.X(), a.Y() - b.Y(), a.Z() - b.Z());
553 }
554
556 template < typename DataType>
558 {
559 return B2Vector3<DataType>(a.X() + b.X(), a.Y() + b.Y(), a.Z() + b.Z());
560 }
561
563 template < typename DataType>
565 {
566 return B2Vector3<DataType>(a.X() - b.X(), a.Y() - b.Y(), a.Z() - b.Z());
567 }
568
570 template < typename DataType>
571 B2Vector3<DataType> operator + (const ROOT::Math::XYZVector& a, const B2Vector3<DataType>& b)
572 {
573 return B2Vector3<DataType>(a.X() + b.X(), a.Y() + b.Y(), a.Z() + b.Z());
574 }
575
577 template < typename DataType>
578 B2Vector3<DataType> operator - (const ROOT::Math::XYZVector& a, const B2Vector3<DataType>& b)
579 {
580 return B2Vector3<DataType>(a.X() - b.X(), a.Y() - b.Y(), a.Z() - b.Z());
581 }
582
584 template < typename DataType>
585 B2Vector3<DataType> operator + (const B2Vector3<DataType>& a, const ROOT::Math::XYZVector& b)
586 {
587 return B2Vector3<DataType>(a.X() + b.X(), a.Y() + b.Y(), a.Z() + b.Z());
588 }
589
591 template < typename DataType>
592 B2Vector3<DataType> operator - (const B2Vector3<DataType>& a, const ROOT::Math::XYZVector& b)
593 {
594 return B2Vector3<DataType>(a.X() - b.X(), a.Y() - b.Y(), a.Z() - b.Z());
595 }
596
597
599 template< typename DataType >
601 {
602 m_coordinates[0] = b.X();
603 m_coordinates[1] = b.Y();
604 m_coordinates[2] = b.Z();
605 return *this;
606 }
607
609 template< typename DataType >
611 {
612 m_coordinates[0] = b.X();
613 m_coordinates[1] = b.Y();
614 m_coordinates[2] = b.Z();
615 return *this;
616 }
617
619 template< typename DataType >
621 {
622 m_coordinates[0] = b.X();
623 m_coordinates[1] = b.Y();
624 m_coordinates[2] = b.Z();
625 return *this;
626 }
627
629 template< typename DataType >
631 {
632 m_coordinates[0] += b.X();
633 m_coordinates[1] += b.Y();
634 m_coordinates[2] += b.Z();
635 return *this;
636 }
637
638
640 template< typename DataType >
642 {
643 m_coordinates[0] -= b.X();
644 m_coordinates[1] -= b.Y();
645 m_coordinates[2] -= b.Z();
646 return *this;
647 }
648
650 template< typename DataType >
652 {
653 m_coordinates[0] *= a;
654 m_coordinates[1] *= a;
655 m_coordinates[2] *= a;
656 return *this;
657 }
658
660 template< typename DataType >
661 void B2Vector3<DataType>::SetXYZ(const TVector3& tVec)
662 {
663 m_coordinates[0] = static_cast<Double_t>(tVec.X());
664 m_coordinates[1] = static_cast<Double_t>(tVec.Y());
665 m_coordinates[2] = static_cast<Double_t>(tVec.Z());
666 }
667
669 template< typename DataType >
670 void B2Vector3<DataType>::SetXYZ(const TVector3* tVec)
671 {
672 m_coordinates[0] = static_cast<Double_t>(tVec->X());
673 m_coordinates[1] = static_cast<Double_t>(tVec->Y());
674 m_coordinates[2] = static_cast<Double_t>(tVec->Z());
675 }
676
678 template< typename DataType >
679 void B2Vector3<DataType>::SetXYZ(const ROOT::Math::XYZVector& xyzVec)
680 {
681 m_coordinates[0] = static_cast<Double_t>(xyzVec.X());
682 m_coordinates[1] = static_cast<Double_t>(xyzVec.Y());
683 m_coordinates[2] = static_cast<Double_t>(xyzVec.Z());
684 }
685
687 template< typename DataType >
688 void B2Vector3<DataType>::SetXYZ(const ROOT::Math::XYZVector* xyzVec)
689 {
690 m_coordinates[0] = static_cast<Double_t>(xyzVec->X());
691 m_coordinates[1] = static_cast<Double_t>(xyzVec->Y());
692 m_coordinates[2] = static_cast<Double_t>(xyzVec->Z());
693 }
694
695 template< typename DataType >
696 void B2Vector3<DataType>::GetXYZ(Double_t* carray) const
697 {
698 carray[0] = X();
699 carray[1] = Y();
700 carray[2] = Z();
701 }
702
703 template< typename DataType >
704 void B2Vector3<DataType>::GetXYZ(Float_t* carray) const
705 {
706 carray[0] = X();
707 carray[1] = Y();
708 carray[2] = Z();
709 }
710
712 template< typename DataType >
713 void B2Vector3<DataType>::GetXYZ(TVector3* tVec) const
714 {
715 tVec->SetXYZ(static_cast<Double_t>(X()),
716 static_cast<Double_t>(Y()),
717 static_cast<Double_t>(Z()));
718 }
719
721 template< typename DataType >
722 void B2Vector3<DataType>::GetXYZ(ROOT::Math::XYZVector* xyzVec) const
723 {
724 xyzVec->SetXYZ(static_cast<Double_t>(X()),
725 static_cast<Double_t>(Y()),
726 static_cast<Double_t>(Z()));
727 }
728
729
731 template< typename DataType >
733 {
734 return
735 TVector3(
736 static_cast<Double_t>(X()),
737 static_cast<Double_t>(Y()),
738 static_cast<Double_t>(Z())
739 );
740 }
741
742
744 template< typename DataType >
745 ROOT::Math::XYZVector B2Vector3<DataType>::GetXYZVector() const
746 {
747 return
748 ROOT::Math::XYZVector(
749 static_cast<Double_t>(X()),
750 static_cast<Double_t>(Y()),
751 static_cast<Double_t>(Z())
752 );
753 }
754
755
757 template < typename DataType>
758 DataType B2Vector3<DataType>::at(unsigned i) const
759 {
760 switch (i) {
761 case 0:
762 case 1:
763 case 2:
764 return m_coordinates[i];
765 }
766 B2FATAL(this->name() << "::access operator: given index (i=" << i << ") is out of bounds!");
767 return 0.;
768 }
769
771 template < typename DataType>
773 {
774 return std::string("B2Vector3<") + typeid(DataType).name() + std::string(">");
775 }
776
778} // end namespace Belle2
A fast and root compatible alternative to TVector3.
Definition B2Vector3.h:42
DataType Phi() const
The azimuth angle.
Definition B2Vector3.h:150
void SetMag(DataType mag)
Set magnitude keeping theta and phi constant.
Definition B2Vector3.h:181
B2Vector3< DataType > operator-() const
unary minus
Definition B2Vector3.h:124
DataType Pz() const
access variable Z (= .at(2) without boundary check)
Definition B2Vector3.h:440
B2Vector3(const B2Vector3< DataType > &b2Vec3)
Constructor expecting a B2Vector3 of same type.
Definition B2Vector3.h:67
DataType operator()(unsigned i) const
member access without boundary check
Definition B2Vector3.h:84
DataType Perp2() const
The transverse component squared (R^2 in cylindrical coordinate system).
Definition B2Vector3.h:195
void SetPerp(DataType r)
Set the transverse component keeping phi and z constant.
Definition B2Vector3.h:202
DataType y() const
access variable Y (= .at(1) without boundary check)
Definition B2Vector3.h:426
void SetX(DataType x)
set X/1st-coordinate
Definition B2Vector3.h:456
DataType Theta() const
The polar angle.
Definition B2Vector3.h:152
DataType CosTheta() const
Cosine of the polar angle.
Definition B2Vector3.h:154
B2Vector3< DataType > Cross(const B2Vector3< DataType > &p) const
Cross product.
Definition B2Vector3.h:295
DataType z() const
access variable Z (= .at(2) without boundary check)
Definition B2Vector3.h:428
B2Vector3(const B2Vector3< DataType > *b2Vec3)
Constructor expecting a pointer to a B2Vector3.
Definition B2Vector3.h:69
void SetMagThetaPhi(DataType mag, DataType theta, DataType phi)
setter with mag, theta, phi
Definition B2Vector3.h:258
std::string PrintStringXYZ(unsigned precision=4) const
create a string containing vector in cartesian coordinates
Definition B2Vector3.h:486
B2Vector3< DataType > Orthogonal() const
Vector orthogonal to this one.
Definition B2Vector3.h:276
DataType Eta() const
Returns the pseudo-rapidity.
Definition B2Vector3.h:330
B2Vector3< DataType > operator*(DataType a) const
Scaling of 3-vectors with a real number.
Definition B2Vector3.h:136
DataType DeltaPhi(const B2Vector3< DataType > &v) const
returns phi in the interval [-PI,PI)
Definition B2Vector3.h:227
void RotateY(DataType angle)
Rotates the B2Vector3 around the y-axis.
Definition B2Vector3.h:346
DataType operator[](unsigned i) const
member access without boundary check
Definition B2Vector3.h:86
std::string PrintString(unsigned precision=4) const
create a string containing vector in cartesian and spherical coordinates
Definition B2Vector3.h:480
DataType Mag() const
The magnitude (rho in spherical coordinate system).
Definition B2Vector3.h:158
DataType value_type
storage type of the vector
Definition B2Vector3.h:50
B2Vector3(const ROOT::Math::XYZVector &xyzVec)
Constructor expecting a XYZVector.
Definition B2Vector3.h:78
bool operator==(const B2Vector3< DataType > &b) const
Comparison for equality with a B2Vector3.
Definition B2Vector3.h:105
DataType x() const
access variable X (= .at(0) without boundary check)
Definition B2Vector3.h:424
B2Vector3(const DataType(*coords)[3])
Constructor using a pointer.
Definition B2Vector3.h:59
DataType DeltaR(const B2Vector3< DataType > &v) const
return deltaR with respect to input-vector
Definition B2Vector3.h:244
DataType Perp(const B2Vector3< DataType > &axis) const
The transverse component w.r.t.
Definition B2Vector3.h:225
DataType & operator()(unsigned i)
member access without boundary check
Definition B2Vector3.h:88
void RotateX(DataType angle)
Rotates the B2Vector3 around the x-axis.
Definition B2Vector3.h:334
void Abs()
calculates the absolute value of the coordinates element-wise
Definition B2Vector3.h:405
B2Vector3(const DataType(&coords)[3])
Constructor using a reference.
Definition B2Vector3.h:57
B2Vector3(const ROOT::Math::XYZVector *xyzVec)
Constructor expecting a pointer to a XYZVector.
Definition B2Vector3.h:81
DataType Pt(const B2Vector3< DataType > &axis) const
The transverse component w.r.t.
Definition B2Vector3.h:223
DataType Mag2() const
The magnitude squared (rho^2 in spherical coordinate system).
Definition B2Vector3.h:156
void SetTheta(DataType theta)
Set theta keeping mag and phi constant.
Definition B2Vector3.h:169
B2Vector3< DataType > operator+(const B2Vector3< DataType > &b) const
Addition of 3-vectors.
Definition B2Vector3.h:126
B2Vector3(const TVector3 &tVec3)
Constructor expecting a TVector3.
Definition B2Vector3.h:62
void RotateZ(DataType angle)
Rotates the B2Vector3 around the z-axis.
Definition B2Vector3.h:358
void Print()
just for backward compatibility, should not be used with new code
Definition B2Vector3.h:506
void Sqrt()
calculates the square root of the absolute values of the coordinates element-wise
Definition B2Vector3.h:413
void SetZ(DataType z)
set Z/3rd-coordinate
Definition B2Vector3.h:460
DataType Dot(const B2Vector3< DataType > &p) const
Scalar product.
Definition B2Vector3.h:289
void SetY(DataType y)
set Y/2nd-coordinate
Definition B2Vector3.h:458
B2Vector3(const B2Vector3< OtherType > *b2Vec3)
Constructor expecting a pointer to a B2Vector3 of different type.
Definition B2Vector3.h:74
DataType PseudoRapidity() const
Returns the pseudo-rapidity, i.e.
Definition B2Vector3.h:318
DataType DrEtaPhi(const B2Vector3< DataType > &v) const
return DrEtaPhi with respect to input-vector
Definition B2Vector3.h:252
bool operator!=(const B2Vector3< DataType > &b) const
Comparison != with a B2Vector3.
Definition B2Vector3.h:111
DataType Perp() const
The transverse component (R in cylindrical coordinate system).
Definition B2Vector3.h:199
B2Vector3(void)
empty Constructor sets everything to 0
Definition B2Vector3.h:53
DataType Perp2(const B2Vector3< DataType > &axis) const
The transverse component w.r.t.
Definition B2Vector3.h:212
B2Vector3(const B2Vector3< OtherType > &b2Vec3)
Constructor expecting a B2Vector3 of different type.
Definition B2Vector3.h:71
void RotateUz(const B2Vector3< DataType > &NewUzVector)
Rotates reference frame from Uz to newUz (unit vector).
Definition B2Vector3.h:369
DataType Py() const
access variable Y (= .at(1) without boundary check)
Definition B2Vector3.h:438
static DataType Mpi_pi(DataType angle)
returns given angle in the interval [-PI,PI)
Definition B2Vector3.h:231
B2Vector3< DataType > Unit() const
Unit vector parallel to this.
Definition B2Vector3.h:268
DataType Pt() const
The transverse component (R in cylindrical coordinate system).
Definition B2Vector3.h:197
B2Vector3(const TVector3 *tVec3)
Constructor expecting a pointer to a TVector3.
Definition B2Vector3.h:65
DataType Px() const
access variable X (= .at(0) without boundary check)
Definition B2Vector3.h:436
void SetXYZ(DataType x, DataType y, DataType z)
set all coordinates using data type
Definition B2Vector3.h:463
DataType Angle(const B2Vector3< DataType > &q) const
The angle w.r.t.
Definition B2Vector3.h:301
DataType & operator[](unsigned i)
member access without boundary check
Definition B2Vector3.h:90
std::string PrintStringCyl(unsigned precision=4) const
create a string containing vector in spherical coordinates
Definition B2Vector3.h:496
B2Vector3< DataType > operator/(DataType a) const
Scaling of 3-vectors with a real number.
Definition B2Vector3.h:141
void Rotate(DataType alpha, const B2Vector3< DataType > &v)
Rotation around an arbitrary axis v with angle alpha.
Definition B2Vector3.h:398
void SetPhi(DataType phi)
Set phi keeping mag and theta constant.
Definition B2Vector3.h:161
B2Vector3(const DataType xVal, const DataType yVal, const DataType zVal)
Constructor expecting 3 coordinates.
Definition B2Vector3.h:55
bool operator==(const DecayNode &node1, const DecayNode &node2)
Compare two Decay Nodes: They are equal if All daughter decay nodes are equal or one of the daughter ...
Definition DecayNode.cc:47
bool operator!=(const DecayNode &node1, const DecayNode &node2)
Not equal: See operator==.
Definition DecayNode.cc:64
void SetXYZ(const ROOT::Math::XYZVector *xyzVec)
set all coordinates using a pointer to XYZVector
Definition B2Vector3.h:688
void GetXYZ(ROOT::Math::XYZVector *xyzVec) const
directly copies coordinates to a XYZVector
Definition B2Vector3.h:722
void SetXYZ(const TVector3 &tVec)
set all coordinates using a reference to TVector3
Definition B2Vector3.h:661
B2Vector3< DataType > & operator-=(const B2Vector3< DataType > &b)
subtraction
Definition B2Vector3.h:641
void GetXYZ(Float_t *carray) const
directly copies coordinates to an array of float
Definition B2Vector3.h:704
TVector3 GetTVector3() const
returns a TVector3 containing the same coordinates
Definition B2Vector3.h:732
B2Vector3< float > B2Vector3F
typedef for common usage with float
Definition B2Vector3.h:518
void GetXYZ(TVector3 *tVec) const
directly copies coordinates to a TVector3
Definition B2Vector3.h:713
void SetXYZ(const TVector3 *tVec)
set all coordinates using a pointer to TVector3
Definition B2Vector3.h:670
ROOT::Math::XYZVector GetXYZVector() const
returns a XYZVector containing the same coordinates
Definition B2Vector3.h:745
B2Vector3< DataType > & operator+=(const B2Vector3< DataType > &b)
addition
Definition B2Vector3.h:630
B2Vector3< DataType > operator*(DataType a, const B2Vector3< DataType > &p)
non-memberfunction Scaling of 3-vectors with a real number
Definition B2Vector3.h:536
B2Vector3< DataType > operator-(const TVector3 &a, const B2Vector3< DataType > &b)
non-memberfunction for subtracting a TVector3 from a B2Vector3
Definition B2Vector3.h:550
B2Vector3< DataType > & operator*=(DataType a)
scaling with real numbers
Definition B2Vector3.h:651
void GetXYZ(Double_t *carray) const
directly copies coordinates to an array of double
Definition B2Vector3.h:696
B2Vector3< DataType > operator+(const TVector3 &a, const B2Vector3< DataType > &b)
non-memberfunction for adding a TVector3 to a B2Vector3
Definition B2Vector3.h:543
void SetXYZ(const ROOT::Math::XYZVector &xyzVec)
set all coordinates using a reference to XYZVector
Definition B2Vector3.h:679
B2Vector3< DataType > & operator=(const B2Vector3< DataType > &b)
Assignment via B2Vector3.
Definition B2Vector3.h:600
B2Vector3< double > B2Vector3D
typedef for common usage with double
Definition B2Vector3.h:515
DataType at(unsigned i) const
safe member access (with boundary check!)
Definition B2Vector3.h:758
static std::string name()
Returns the name of the B2Vector.
Definition B2Vector3.h:772
Abstract base class for different kinds of events.