YAP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HelicityAngles.h
Go to the documentation of this file.
1 /* YAP - Yet another PWA toolkit
2  Copyright 2015, Technische Universitaet Muenchen,
3  Authors: Daniel Greenwald, Johannes Rauch
4 
5  This program is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 
20 
21 #ifndef yap_HelicityAngles_h
22 #define yap_HelicityAngles_h
23 
24 #include "fwd/CachedValue.h"
25 #include "fwd/Model.h"
26 #include "fwd/ParticleCombination.h"
27 #include "fwd/StatusManager.h"
28 
29 #include "Constants.h"
30 #include "CoordinateSystem.h"
31 #include "Rotation.h"
32 #include "StaticDataAccessor.h"
33 #include "ThreeVector.h"
34 
35 #include <memory>
36 
37 namespace yap {
38 
62 {
63 public:
64 
68 
72  virtual void calculate(DataPoint& d, StatusManager& sm) const override;
73 
75  double phi(const DataPoint& d, const std::shared_ptr<ParticleCombination>& pc) const;
76 
78  std::shared_ptr<RealCachedValue>& phi()
79  { return Phi_; }
80 
82  const std::shared_ptr<RealCachedValue>& phi() const
83  { return Phi_; }
84 
86  double theta(const DataPoint& d, const std::shared_ptr<ParticleCombination>& pc) const;
87 
89  std::shared_ptr<RealCachedValue>& theta()
90  { return Theta_; }
91 
93  const std::shared_ptr<RealCachedValue>& theta() const
94  { return Theta_; }
95 
97  friend class Model;
98 
100  friend class DataAccessor;
101 
102 protected:
103 
105  void virtual addToStaticDataAccessors() override;
106 
108  void calculateAngles(DataPoint& d, const std::shared_ptr<ParticleCombination>& pc,
109  const CoordinateSystem<double, 3>& C, const FourMatrix<double>& boosts,
110  StatusManager& sm) const;
111 
113  void addParticleCombination(std::shared_ptr<ParticleCombination> pc) override;
114 
115 private:
116 
118  std::shared_ptr<RealCachedValue> Phi_;
119 
121  std::shared_ptr<RealCachedValue> Theta_;
122 
123 };
124 
129 template <typename T>
130 CoordinateSystem<T, 3> helicityFrame(const ThreeVector<T>& V, const CoordinateSystem<T, 3>& C)
131 {
132  constexpr T epsilon = T(5) * std::numeric_limits<T>::epsilon();
133 
134  // if V is 0, return C
135  if (norm(V) <= epsilon)
136  return C;
137 
138  CoordinateSystem<double, 3> vC;
139 
140  // Set Z to V direction
141  vC[2] = unit(V);
142 
143  // calc angle between new Z and old Z
144  auto theta = angle(vC[2], C[2]);
145 
146  // if Z direction is same, return C
147  if (std::abs(theta) <= epsilon)
148  return C;
149 
150  // if Z direction is opposite, return C rotated 180 degrees around Y axis
151  if (std::abs(theta - pi<double>()) <= epsilon)
152  return rotation<T>(C[1], rad(180.)) * C;
153 
154  // Y := (C's Z) cross Z
155  vC[1] = unit(cross(C[2], vC[2]));
156 
157  // X := Y cross Z (right-handed)
158  vC[0] = cross(vC[1], vC[2]);
159 
160  return vC;
161 }
162 
163 
164 }
165 
166 #endif
const CoordinateSystem< T, 3 > helicityFrame(const FourVector< T > &V, const CoordinateSystem< T, 3 > &C)
Definition: FourVector.h:131
std::shared_ptr< RealCachedValue > & phi()
access azimuthal angle
Definition: HelicityAngles.h:78
constexpr T theta(const ThreeVector< T > &V, const CoordinateSystem< T, 3 > &C)
Definition: CoordinateSystem.h:101
void calculateAngles(DataPoint &d, const std::shared_ptr< ParticleCombination > &pc, const CoordinateSystem< double, 3 > &C, const FourMatrix< double > &boosts, StatusManager &sm) const
recursive helicity-angle calculator that travels down decay trees for all channels ...
Definition: HelicityAngles.cxx:60
constexpr T abs(const Vector< T, N > &A)
Definition: Vector.h:371
Class for holding data and cached values per data point for fast calculation.
Definition: DataPoint.h:35
Base class for all data accessors that will only write to DataPoint once at initial data loading...
Definition: StaticDataAccessor.h:36
virtual void calculate(DataPoint &d, StatusManager &sm) const override
Definition: HelicityAngles.cxx:47
void addParticleCombination(std::shared_ptr< ParticleCombination > pc) override
override to throw on adding non-two-body PC
Definition: HelicityAngles.cxx:107
Definition: StatusManager.h:32
Class implementing a PWA model.
Definition: Model.h:56
const CoordinateSystem< T, N > unit(const CoordinateSystem< T, N > &C)
Definition: CoordinateSystem.h:52
virtual void addToStaticDataAccessors() override
add to model's StaticDataAccessors_
Definition: HelicityAngles.cxx:24
Calculates, stores and gives access to helicity angles.
Definition: HelicityAngles.h:61
const std::shared_ptr< RealCachedValue > & theta() const
access polar angle (const)
Definition: HelicityAngles.h:93
std::shared_ptr< RealCachedValue > Theta_
Polar angle.
Definition: HelicityAngles.h:121
Abstract base class for all objects accessing DataPoint's.
Definition: DataAccessor.h:38
std::shared_ptr< RealCachedValue > & theta()
access polar angle
Definition: HelicityAngles.h:89
constexpr T rad(const T &d)
convert degrees to radians
Definition: Constants.h:59
const std::shared_ptr< RealCachedValue > & phi() const
access azimuthal angle (const)
Definition: HelicityAngles.h:82
constexpr ThreeVector< T > cross(const ThreeVector< T > &A, const ThreeVector< T > &B) noexcept
Definition: ThreeVector.h:33
HelicityAngles(Model &m)
Definition: HelicityAngles.cxx:15
std::shared_ptr< RealCachedValue > Phi_
Azimuthal angle.
Definition: HelicityAngles.h:118