| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "Tools.h" | ||
| 2 | |||
| 3 | namespace iguana::physics::tools { | ||
| 4 | |||
| 5 |
1/2✗ Branch 2 → 3 not taken.
✓ Branch 2 → 4 taken 353 times.
|
353 | std::optional<double> PlaneAngle( |
| 6 | ROOT::Math::XYZVector const v_a, | ||
| 7 | ROOT::Math::XYZVector const v_b, | ||
| 8 | ROOT::Math::XYZVector const v_c, | ||
| 9 | ROOT::Math::XYZVector const v_d) | ||
| 10 | { | ||
| 11 | auto cross_ab = v_a.Cross(v_b); // A x B | ||
| 12 | auto cross_cd = v_c.Cross(v_d); // C x D | ||
| 13 | |||
| 14 | auto sgn = cross_ab.Dot(v_d); // (A x B) . D | ||
| 15 |
1/2✗ Branch 2 → 3 not taken.
✓ Branch 2 → 4 taken 353 times.
|
353 | if(!(std::abs(sgn) > 0)) |
| 16 | ✗ | return std::nullopt; | |
| 17 |
1/2✗ Branch 4 → 5 not taken.
✓ Branch 4 → 6 taken 353 times.
|
353 | sgn /= std::abs(sgn); // sign of (A x B) . D |
| 18 | |||
| 19 | auto numer = cross_ab.Dot(cross_cd); // (A x B) . (C x D) | ||
| 20 |
1/2✗ Branch 4 → 5 not taken.
✓ Branch 4 → 6 taken 353 times.
|
353 | auto denom = cross_ab.R() * cross_cd.R(); // |A x B| * |C x D| |
| 21 |
1/2✗ Branch 4 → 5 not taken.
✓ Branch 4 → 6 taken 353 times.
|
353 | if(!(std::abs(denom) > 0)) |
| 22 | ✗ | return std::nullopt; | |
| 23 | 353 | return sgn * std::acos(numer / denom); | |
| 24 | } | ||
| 25 | |||
| 26 |
1/2✗ Branch 2 → 3 not taken.
✓ Branch 2 → 4 taken 414 times.
|
414 | std::optional<ROOT::Math::XYZVector> ProjectVector( |
| 27 | ROOT::Math::XYZVector const v_a, | ||
| 28 | ROOT::Math::XYZVector const v_b) | ||
| 29 | { | ||
| 30 | auto denom = v_b.Dot(v_b); | ||
| 31 |
1/2✗ Branch 2 → 3 not taken.
✓ Branch 2 → 4 taken 414 times.
|
414 | if(!(std::abs(denom) > 0)) |
| 32 | ✗ | return std::nullopt; | |
| 33 | 414 | return v_b * (v_a.Dot(v_b) / denom); | |
| 34 | } | ||
| 35 | |||
| 36 | 414 | std::optional<ROOT::Math::XYZVector> RejectVector( | |
| 37 | ROOT::Math::XYZVector const v_a, | ||
| 38 | ROOT::Math::XYZVector const v_b) | ||
| 39 | { | ||
| 40 |
1/2✓ Branch 3 → 4 taken 414 times.
✗ Branch 3 → 5 not taken.
|
414 | auto v_c = ProjectVector(v_a, v_b); |
| 41 |
1/2✓ Branch 3 → 4 taken 414 times.
✗ Branch 3 → 5 not taken.
|
414 | if(v_c.has_value()) |
| 42 | return v_a - v_c.value(); | ||
| 43 | ✗ | return std::nullopt; | |
| 44 | } | ||
| 45 | |||
| 46 |
1/2✓ Branch 2 → 3 taken 61 times.
✗ Branch 2 → 4 not taken.
|
61 | std::optional<double> VectorAngle( |
| 47 | ROOT::Math::XYZVector const v_a, | ||
| 48 | ROOT::Math::XYZVector const v_b) | ||
| 49 | { | ||
| 50 | 61 | double m = v_a.R() * v_b.R(); | |
| 51 |
1/2✓ Branch 2 → 3 taken 61 times.
✗ Branch 2 → 4 not taken.
|
61 | if(m > 0) |
| 52 | 61 | return std::acos(v_a.Dot(v_b) / m); | |
| 53 | ✗ | return std::nullopt; | |
| 54 | } | ||
| 55 | |||
| 56 | template <typename MOMENTUM_TYPE, typename AXIS_TYPE> | ||
| 57 |
1/4std::optional<double> iguana::physics::tools::ParticleRapidity<ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> >, ROOT::Math::DisplacementVector3D<ROOT::Math::Cartesian3D<double>, ROOT::Math::DefaultCoordinateSystemTag> >(ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > const&, ROOT::Math::DisplacementVector3D<ROOT::Math::Cartesian3D<double>, ROOT::Math::DefaultCoordinateSystemTag> const&):
✗ Branch 2 → 3 not taken.
✗ Branch 2 → 4 not taken.
std::optional<double> iguana::physics::tools::ParticleRapidity<ROOT::Math::LorentzVector<ROOT::Math::PxPyPzM4D<double> >, ROOT::Math::DisplacementVector3D<ROOT::Math::Cartesian3D<double>, ROOT::Math::DefaultCoordinateSystemTag> >(ROOT::Math::LorentzVector<ROOT::Math::PxPyPzM4D<double> > const&, ROOT::Math::DisplacementVector3D<ROOT::Math::Cartesian3D<double>, ROOT::Math::DefaultCoordinateSystemTag> const&):
✓ Branch 2 → 3 taken 292 times.
✗ Branch 2 → 5 not taken.
|
292 | std::optional<double> ParticleRapidity( |
| 58 | MOMENTUM_TYPE const& momentum_vec, | ||
| 59 | AXIS_TYPE const& axis_vec) | ||
| 60 | { | ||
| 61 | auto norm = axis_vec.R(); | ||
| 62 |
1/4std::optional<double> iguana::physics::tools::ParticleRapidity<ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> >, ROOT::Math::DisplacementVector3D<ROOT::Math::Cartesian3D<double>, ROOT::Math::DefaultCoordinateSystemTag> >(ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > const&, ROOT::Math::DisplacementVector3D<ROOT::Math::Cartesian3D<double>, ROOT::Math::DefaultCoordinateSystemTag> const&):
✗ Branch 2 → 3 not taken.
✗ Branch 2 → 4 not taken.
std::optional<double> iguana::physics::tools::ParticleRapidity<ROOT::Math::LorentzVector<ROOT::Math::PxPyPzM4D<double> >, ROOT::Math::DisplacementVector3D<ROOT::Math::Cartesian3D<double>, ROOT::Math::DefaultCoordinateSystemTag> >(ROOT::Math::LorentzVector<ROOT::Math::PxPyPzM4D<double> > const&, ROOT::Math::DisplacementVector3D<ROOT::Math::Cartesian3D<double>, ROOT::Math::DefaultCoordinateSystemTag> const&):
✓ Branch 2 → 3 taken 292 times.
✗ Branch 2 → 5 not taken.
|
292 | if(std::abs(norm) > 0) { |
| 63 | 292 | auto pz = momentum_vec.Vect().Dot(axis_vec) / norm; | |
| 64 | auto e = momentum_vec.E(); | ||
| 65 | 292 | return 0.5 * std::log((e + pz) / (e - pz)); | |
| 66 | } | ||
| 67 | ✗ | return std::nullopt; | |
| 68 | } | ||
| 69 | template std::optional<double> ParticleRapidity( | ||
| 70 | ROOT::Math::LorentzVector<ROOT::Math::PxPyPzM4D<double>> const& momentum_vec, | ||
| 71 | ROOT::Math::DisplacementVector3D<ROOT::Math::Cartesian3D<double>> const& axis_vec); | ||
| 72 | template std::optional<double> ParticleRapidity( | ||
| 73 | ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double>> const& momentum_vec, | ||
| 74 | ROOT::Math::DisplacementVector3D<ROOT::Math::Cartesian3D<double>> const& axis_vec); | ||
| 75 | |||
| 76 | ✗ | double AdjustAnglePi(double ang) | |
| 77 | { | ||
| 78 | ✗ | while(ang > M_PI) | |
| 79 | ✗ | ang -= 2 * M_PI; | |
| 80 | ✗ | while(ang <= -M_PI) | |
| 81 | ✗ | ang += 2 * M_PI; | |
| 82 | ✗ | return ang; | |
| 83 | }; | ||
| 84 | |||
| 85 | ✗ | double AdjustAngleTwoPi(double ang) | |
| 86 | { | ||
| 87 | ✗ | while(ang > 2 * M_PI) | |
| 88 | ✗ | ang -= 2 * M_PI; | |
| 89 | ✗ | while(ang <= 0) | |
| 90 | ✗ | ang += 2 * M_PI; | |
| 91 | ✗ | return ang; | |
| 92 | }; | ||
| 93 | } | ||
| 94 |