ComPWA
Common Partial-Wave-Analysis Framework
Coupling.hpp
Go to the documentation of this file.
1 // Copyright (c) 2017 The ComPWA Team.
2 // This file is part of the ComPWA framework, check
3 // https://github.com/ComPWA/ComPWA/license.txt for details.
4 
5 #ifndef Coupling_h
6 #define Coupling_h
7 
9 #include "Core/Properties.hpp"
10 #include "FormFactor.hpp"
11 
12 namespace ComPWA {
13 namespace Physics {
14 namespace Dynamics {
15 
18 inline std::complex<double> couplingToWidth(double mR, double g,
19  std::complex<double> gamma,
20  std::complex<double> phspFactor) {
21  // calculate phsp factor
22  std::complex<double> res = std::norm(gamma) * g * g * phspFactor / mR;
23 
24 #ifndef NDEBUG
25  // check for NaN
26  if (std::isnan(res.real()) || std::isnan(res.imag()))
27  throw std::runtime_error("couplingToWidth() | Result is NaN!");
28  // check for inf
29  if (std::isinf(res.real()) || std::isinf(res.imag()))
30  throw std::runtime_error("couplingToWidth() | Result is inf!");
31 #endif
32 
33  return res;
34 }
35 
43 inline std::complex<double> widthToCoupling(double mR, double width,
44  std::complex<double> gamma,
45  std::complex<double> phspFactor) {
46 
47  auto denom = gamma * std::sqrt(phspFactor);
48  auto res = std::complex<double>(sqrt(mR * width), 0) / denom;
49 
50 #ifndef NDEBUG
51  // check for NaN
52  if (std::isnan(res.real()) || std::isnan(res.imag()))
53  throw std::runtime_error("AmpAbsDynamicalFunction::widthToCoupling() | "
54  "Result is NaN!");
55  // check for inf
56  if (std::isinf(res.real()) || std::isinf(res.imag()))
57  throw std::runtime_error("AbstractDynamicalFunction::widthToCoupling() | "
58  "Result is inf!");
59 #endif
60  return res;
61 }
62 
63 class Coupling {
64 public:
65  Coupling(){};
66  Coupling(double c, double massA, double massB)
67  : G(new ComPWA::FunctionTree::FitParameter("", c)),
68  MassA(new ComPWA::FunctionTree::FitParameter("", massA)),
69  MassB(new ComPWA::FunctionTree::FitParameter("", massB)){};
70 
72  const boost::property_tree::ptree tr) {
73  G = std::make_shared<ComPWA::FunctionTree::FitParameter>(tr.get_child(""));
74  std::string nameA = tr.get<std::string>("ParticleA");
75  std::string nameB = tr.get<std::string>("ParticleB");
76  auto mA = findParticle(partL, nameA).getMass();
77  auto mB = findParticle(partL, nameB).getMass();
78  MassA = std::make_shared<ComPWA::FunctionTree::FitParameter>(mA);
79  MassB = std::make_shared<ComPWA::FunctionTree::FitParameter>(mB);
80  };
81 
82  std::shared_ptr<ComPWA::FunctionTree::FitParameter> G;
83  std::shared_ptr<ComPWA::FunctionTree::FitParameter> MassA;
84  std::shared_ptr<ComPWA::FunctionTree::FitParameter> MassB;
85 };
86 
87 } // namespace Dynamics
88 } // namespace Physics
89 } // namespace ComPWA
90 
91 #endif
double phspFactor(double sqrtS, double ma, double mb)
Definition: FormFactor.hpp:32
ComPWA::FitParameter< double > getMass() const
Definition: Properties.hpp:35
Implementations of Parameter for various data types.
std::shared_ptr< ComPWA::FunctionTree::FitParameter > MassB
Definition: Coupling.hpp:84
const ParticleProperties & findParticle(const ParticleList &list, pid Pid)
Definition: Properties.hpp:93
std::set< ParticleProperties > ParticleList
Definition: Properties.hpp:84
std::shared_ptr< ComPWA::FunctionTree::FitParameter > MassA
Definition: Coupling.hpp:83
std::complex< double > widthToCoupling(double mR, double width, std::complex< double > gamma, std::complex< double > phspFactor)
Convert width to complex coupling.
Definition: Coupling.hpp:43
std::complex< double > couplingToWidth(double mR, double g, std::complex< double > gamma, std::complex< double > phspFactor)
Convert width to complex coupling.
Definition: Coupling.hpp:18
Coupling(double c, double massA, double massB)
Definition: Coupling.hpp:66
std::shared_ptr< ComPWA::FunctionTree::FitParameter > G
Definition: Coupling.hpp:80
Coupling(const ComPWA::ParticleList &partL, const boost::property_tree::ptree tr)
Definition: Coupling.hpp:71