ComPWA
Common Partial-Wave-Analysis Framework
WignerD.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 
5 #include "WignerD.hpp"
6 
7 namespace ComPWA {
8 namespace Physics {
9 namespace HelicityFormalism {
10 
11 using namespace ComPWA::FunctionTree;
12 
13 std::shared_ptr<ComPWA::FunctionTree::TreeNode> WignerD::createFunctionTree(
14  double J, double MuPrime, double Mu,
15  std::shared_ptr<ComPWA::FunctionTree::Value<std::vector<double>>> Theta,
16  std::shared_ptr<ComPWA::FunctionTree::Value<std::vector<double>>> Phi) {
17 
18  // in case of spin zero do not explicitly include the WignerD
19  if ((double)J == 0)
20  return FunctionTree::createLeaf(1, "WignerD");
21 
22  auto tr = std::make_shared<ComPWA::FunctionTree::TreeNode>(
23  MComplex("", 0), std::make_shared<WignerDStrategy>());
24 
25  tr->addNodes({FunctionTree::createLeaf(J, "J"),
26  FunctionTree::createLeaf(MuPrime, "mu'"),
27  FunctionTree::createLeaf(Mu, "mu"),
30 
31  return tr;
32 }
33 
35  ParameterList &paras,
36  std::shared_ptr<ComPWA::FunctionTree::Parameter> &out) {
37 #ifndef NDEBUG
38  if (out && checkType != out->type()) {
39  throw(WrongParType(std::string("Output Type ") + ParNames[out->type()] +
40  std::string(" conflicts expected type ") +
41  ParNames[checkType] + std::string(" of ") + Name +
42  " Wigner strat"));
43  }
44 #endif
45 
46  double J = paras.doubleValue(0)->value();
47  double muPrime = paras.doubleValue(1)->value();
48  double mu = paras.doubleValue(2)->value();
49 
50  auto thetas = paras.mDoubleValue(0);
51  auto phis = paras.mDoubleValue(1);
52 
53  size_t n = thetas->values().size();
54  if (!out)
55  out = MComplex("", n);
56  auto par =
57  std::static_pointer_cast<Value<std::vector<std::complex<double>>>>(out);
58  auto &results = par->values(); // reference
59  if (results.size() != n) {
60  results.resize(n);
61  }
62  for (unsigned int ele = 0; ele < n; ele++) {
63  try {
64  results[ele] = WignerD::dynamicalFunction(
65  J, muPrime, mu, phis->values()[ele], thetas->values()[ele], 0.0);
66  } catch (std::exception &ex) {
67  LOG(ERROR) << "WignerDStrategy::execute() | " << ex.what();
68  throw std::runtime_error("WignerDStrategy::execute() | "
69  "Evaluation of dynamical function failed!");
70  }
71  } // end element loop
72 }
73 
74 } // namespace HelicityFormalism
75 } // namespace Physics
76 } // namespace ComPWA
double dynamicalFunction(double J, double muPrime, double mu, double beta)
Definition: WignerD.hpp:25
virtual void execute(ComPWA::FunctionTree::ParameterList &paras, std::shared_ptr< ComPWA::FunctionTree::Parameter > &out)
Definition: WignerD.cpp:34
std::shared_ptr< ComPWA::FunctionTree::TreeNode > createFunctionTree(double J, double MuPrime, double Mu, std::shared_ptr< ComPWA::FunctionTree::Value< std::vector< double >>> Theta, std::shared_ptr< ComPWA::FunctionTree::Value< std::vector< double >>> Phi)
Definition: WignerD.cpp:13
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::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
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
virtual std::shared_ptr< Value< double > > doubleValue(size_t i) const