Line | Branch | Exec | Source |
---|---|---|---|
1 | #include "Tools.h" | ||
2 | |||
3 | namespace iguana::physics::tools { | ||
4 | |||
5 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 316 times.
|
316 | 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 0 not taken.
✓ Branch 1 taken 316 times.
|
316 | if(!(std::abs(sgn) > 0)) |
16 | ✗ | return std::nullopt; | |
17 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 316 times.
|
316 | 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 0 not taken.
✓ Branch 1 taken 316 times.
|
316 | auto denom = cross_ab.R() * cross_cd.R(); // |A x B| * |C x D| |
21 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 316 times.
|
316 | if(!(std::abs(denom) > 0)) |
22 | ✗ | return std::nullopt; | |
23 | 316 | return sgn * std::acos(numer / denom); | |
24 | } | ||
25 | |||
26 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 374 times.
|
374 | 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 0 not taken.
✓ Branch 1 taken 374 times.
|
374 | if(!(std::abs(denom) > 0)) |
32 | ✗ | return std::nullopt; | |
33 | 374 | return v_b * ( v_a.Dot(v_b) / denom ); | |
34 | } | ||
35 | |||
36 | 374 | 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 0 taken 374 times.
✗ Branch 1 not taken.
|
374 | auto v_c = ProjectVector(v_a, v_b); |
41 |
1/2✓ Branch 0 taken 374 times.
✗ Branch 1 not taken.
|
374 | if(v_c.has_value()) |
42 | return v_a - v_c.value(); | ||
43 | ✗ | return std::nullopt; | |
44 | } | ||
45 | |||
46 |
1/2✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
|
58 | std::optional<double> VectorAngle( |
47 | ROOT::Math::XYZVector const v_a, | ||
48 | ROOT::Math::XYZVector const v_b) | ||
49 | { | ||
50 | 58 | double m = v_a.R() * v_b.R(); | |
51 |
1/2✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
|
58 | if(m > 0) |
52 | 58 | 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/2✓ Branch 0 taken 258 times.
✗ Branch 1 not taken.
|
258 | 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/2✓ Branch 0 taken 258 times.
✗ Branch 1 not taken.
|
258 | if(std::abs(norm) > 0) { |
63 | 258 | auto pz = momentum_vec.Vect().Dot(axis_vec) / norm; | |
64 | auto e = momentum_vec.E(); | ||
65 | 258 | 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 | } | ||
77 | |||
78 |