ComPWA
Common Partial-Wave-Analysis Framework
RelativisticBreitWigner.cpp
Go to the documentation of this file.
1 // Copyright (c) 2013, 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 
6 
7 namespace ComPWA {
8 namespace Physics {
9 namespace Dynamics {
10 
16 
19  std::shared_ptr<ComPWA::FunctionTree::Value<std::vector<double>>>
20  InvMassSquared) {
21  size_t sampleSize = InvMassSquared->values().size();
22 
23  BreitWignerFunction BWFunction(
25  if (Params.Type == "relativisticBreitWigner") {
26  } else if (Params.Type == "relativisticBreitWignerAC") {
28  } else {
29  LOG(INFO) << "Relativistic BreitWigner of type " << Params.Type
30  << " is unknown. Using standard defintion as fallback!";
31  }
32 
33  using namespace ComPWA::FunctionTree;
34  auto tr = std::make_shared<TreeNode>(
35  MComplex("", sampleSize), std::make_shared<BreitWignerStrategy>(
36  Params.FormFactorFunctor, BWFunction));
37 
38  tr->addNodes({createLeaf(Params.Mass), createLeaf(Params.Width),
39  createLeaf((int)Params.L, "L"), createLeaf(Params.MesonRadius),
40  createLeaf(InvMassSquared),
41  createLeaf(Params.DaughterInvariantMasses.first),
42  createLeaf(Params.DaughterInvariantMasses.second)});
43 
44  return tr;
45 };
46 
48  std::shared_ptr<Parameter> &out) {
49  if (out && checkType != out->type())
50  throw BadParameter(
51  "BreitWignerStrat::execute() | Parameter type mismatch!");
52 
53 #ifndef NDEBUG
54  // Check parameter type
55  if (checkType != out->type())
56  throw(
57  WrongParType("BreitWignerStrat::execute() | "
58  "Output parameter is of type " +
59  std::string(ComPWA::FunctionTree::ParNames[out->type()]) +
60  " and conflicts with expected type " +
61  std::string(ComPWA::FunctionTree::ParNames[checkType])));
62 
63  // How many parameters do we expect?
64  size_t nInt = paras.intValues().size();
65  size_t nDouble = paras.doubleValues().size();
66  nDouble += paras.doubleParameters().size();
67  size_t nComplex = paras.complexValues().size();
68  size_t nMInteger = paras.mIntValues().size();
69  size_t nMDouble = paras.mDoubleValues().size();
70  size_t nMComplex = paras.mComplexValues().size();
71 
72  // Check size of parameter list
73  if (nInt != 1)
74  throw(BadParameter("BreitWignerStrat::execute() | "
75  "Number of IntParameters does not match: " +
76  std::to_string(nInt) + " given but " + "1 expected."));
77  if (nDouble != 3)
78  throw(BadParameter("BreitWignerStrat::execute() | "
79  "Number of FitParameters does not match: " +
80  std::to_string(nDouble) + " given but " +
81  "3 expected."));
82  if (nComplex != 0)
83  throw(BadParameter("BreitWignerStrat::execute() | "
84  "Number of ComplexParameters does not match: " +
85  std::to_string(nComplex) + " given but " +
86  "0 expected."));
87  if (nMInteger != 0)
88  throw(BadParameter("BreitWignerStrat::execute() | "
89  "Number of MultiInt does not match: " +
90  std::to_string(nMInteger) + " given but " +
91  "0 expected."));
92  if (nMDouble != 3)
93  throw(BadParameter("BreitWignerStrat::execute() | "
94  "Number of MultiDoubles does not match: " +
95  std::to_string(nMDouble) + " given but " +
96  "3 expected."));
97  if (nMComplex != 0)
98  throw(BadParameter("BreitWignerStrat::execute() | "
99  "Number of MultiComplexes does not match: " +
100  std::to_string(nMComplex) + " given but " +
101  "0 expected."));
102 #endif
103 
104  size_t n = paras.mDoubleValue(0)->values().size();
105  if (!out)
106  out = ComPWA::FunctionTree::MComplex("", n);
107  auto par =
108  std::static_pointer_cast<Value<std::vector<std::complex<double>>>>(out);
109  auto &results = par->values(); // reference
110  if (results.size() != n) {
111  results.resize(n);
112  }
113  // Get parameters from ParameterList:
114  // We use the same order of the parameters as was used during tree
115  // construction.
116  double m0 = paras.doubleParameter(0)->value();
117  double Gamma0 = paras.doubleParameter(1)->value();
118  double MesonRadius = paras.doubleParameter(2)->value();
119  unsigned int orbitL = paras.intValue(0)->value();
120 
121  auto s = paras.mDoubleValue(0)->values();
122  auto sa = paras.mDoubleValue(1)->values();
123  auto sb = paras.mDoubleValue(2)->values();
124 
125  if (sa.size() == 1 && sb.size() == 1) {
126  double ma = std::sqrt(sa.at(0));
127  double mb = std::sqrt(sb.at(0));
128  std::transform(paras.mDoubleValue(0)->values().begin(),
129  paras.mDoubleValue(0)->values().end(), results.begin(),
130  [&](double s) {
131  return BWFunction(s, m0, ma, mb, Gamma0, orbitL,
132  MesonRadius, FormFactorFunctor);
133  });
134  } else if (sa.size() == 1) {
135  double ma = std::sqrt(sa.at(0));
136  for (size_t i = 0; i < s.size(); ++i) {
137  results[i] = BWFunction(s[i], m0, ma, std::sqrt(sb[i]), Gamma0, orbitL,
138  MesonRadius, FormFactorFunctor);
139  }
140  } else if (sb.size() == 1) {
141  double mb = std::sqrt(sb.at(0));
142  for (size_t i = 0; i < s.size(); ++i) {
143  results[i] = BWFunction(s[i], m0, std::sqrt(sa[i]), mb, Gamma0, orbitL,
144  MesonRadius, FormFactorFunctor);
145  }
146  } else {
147  for (size_t i = 0; i < s.size(); ++i) {
148  results[i] = BWFunction(s[i], m0, std::sqrt(sa[i]), std::sqrt(sb[i]),
149  Gamma0, orbitL, MesonRadius, FormFactorFunctor);
150  }
151  }
152 }
153 
154 } // namespace Dynamics
155 } // namespace Physics
156 } // namespace ComPWA
virtual std::shared_ptr< Value< int > > intValue(size_t i)
Parameter not existing.
Definition: Exceptions.hpp:62
std::function< std::complex< double >(double, double, double, double, double, unsigned int, double, std::shared_ptr< FormFactor >)> BreitWignerFunction
std::shared_ptr< FormFactor > FormFactorFunctor
Form factor function object.
Base class for internal parameter.
Definition: Parameter.hpp:79
std::complex< double > relativisticBreitWigner(double mSq, double mR, double ma, double mb, double width, unsigned int L, double mesonRadius, std::shared_ptr< FormFactor > FormFactorFunctor)
Relativistic Breit-Wigner model with barrier factors.
virtual std::vector< std::shared_ptr< Value< std::vector< int > > > > & mIntValues()
TreeNode is the basic building block of the FunctionTree.
Definition: TreeNode.hpp:35
std::shared_ptr< ComPWA::FunctionTree::FitParameter > Width
Decay width of resonant state.
std::shared_ptr< ComPWA::FunctionTree::FitParameter > MesonRadius
Meson radius of resonant state.
virtual std::vector< std::shared_ptr< Value< std::vector< double > > > > & mDoubleValues()
static const char *const ParNames[7]
Names of the parameter types, should be extended if an new parameter type is added.
Definition: Parameter.hpp:46
std::shared_ptr< TreeNode > createLeaf(std::shared_ptr< Parameter > parameter)
Definition: TreeNode.cpp:156
std::complex< double > relativisticBreitWignerAnalyticCont(double mSq, double mR, double ma, double mb, double width, unsigned int L, double mesonRadius, std::shared_ptr< FormFactor > FormFactorFunctor)
Relativistic Breit-Wigner model with barrier factors.
virtual std::vector< std::shared_ptr< Value< std::complex< double > > > > & complexValues()
std::shared_ptr< Value< std::vector< std::complex< double > > > > MComplex(std::string name, size_t s, std::complex< double > el=std::complex< double >(0., 0.))
Definition: Value.hpp:120
unsigned int L
Orbital Angular Momentum between two daughters in Resonance decay.
std::shared_ptr< ComPWA::FunctionTree::TreeNode > createFunctionTree(InputInfo Params, std::shared_ptr< ComPWA::FunctionTree::Value< std::vector< double >>> InvMassSquared)
virtual std::shared_ptr< FitParameter > doubleParameter(size_t i) const
virtual std::vector< std::shared_ptr< Value< std::vector< std::complex< double > > > > > & mComplexValues()
virtual std::vector< std::shared_ptr< Value< double > > > & doubleValues()
std::pair< std::shared_ptr< ComPWA::FunctionTree::Value< std::vector< double > > >, std::shared_ptr< ComPWA::FunctionTree::Value< std::vector< double > > > > DaughterInvariantMasses
Invariant Masses of daughter particles.
virtual std::vector< std::shared_ptr< FitParameter > > & doubleParameters()
virtual std::vector< std::shared_ptr< Value< int > > > & intValues()
std::shared_ptr< ComPWA::FunctionTree::FitParameter > Mass
Resonance mass.
virtual void execute(ComPWA::FunctionTree::ParameterList &paras, std::shared_ptr< ComPWA::FunctionTree::Parameter > &out)
virtual T & values()
Reference on the value.
Definition: Value.hpp:49
This class provides a list of parameters and values of different types.
Parameter of wrong type.
Definition: Exceptions.hpp:111
virtual std::shared_ptr< Value< std::vector< double > > > mDoubleValue(size_t i) const