YAP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UnitSpinAmplitude.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_UnitSpinAmplitude_h
22 #define yap_UnitSpinAmplitude_h
23 
24 #include "ClebschGordan.h"
25 #include "Constants.h"
26 #include "ParticleCombination.h"
27 #include "Spin.h"
28 #include "SpinAmplitude.h"
29 
30 namespace yap {
31 
38 {
39 public:
40 
42  const std::complex<double> calc(int two_M, const SpinProjectionVector& two_m,
43  const DataPoint& d, const std::shared_ptr<ParticleCombination>& pc) const override
44  { return Complex_1; }
45 
51  virtual const std::complex<double> amplitude(const DataPoint& d, const std::shared_ptr<ParticleCombination>& pc,
52  int two_M, const SpinProjectionVector& two_m) const override
53  { return Complex_1; }
54 
56  virtual std::string formalism() const override
57  { return "unit-valued"; }
58 
60  friend class SpinAmplitudeCache;
61 
62 protected:
63 
69  UnitSpinAmplitude(Model& m, unsigned two_J, const SpinVector& two_j, unsigned l, unsigned two_s)
70  : SpinAmplitude(m, two_J, two_j, l, two_s, equal_always)
71  {
72  // check if all spins are 0 for non-res decays
73  if (two_j.size() > 2 and (two_J != 0 or l != 0 or two_s != 0 or std::any_of(two_j.begin(), two_j.end(), [](unsigned j){return j != 0;})))
74  throw exceptions::Exception("More than 2 daughters, but not all spins are 0", "UnitSpinAmplitude::UnitSpinAmplitude");
75 
76  // for 2 daughters, loop over all possibilities
77  for (auto two_M : projections(two_J)) {
78  for (const auto& two_m : projections(two_j)) {
79  if (two_m.size() > 2) {
80  addAmplitude(two_M, two_m, true);
81  } else {
82  try {
83  if (ClebschGordan::nonzeroCoupling(two_j[0], two_m[0], two_j[1], two_m[1], l, two_s, two_J))
84  addAmplitude(two_M, two_m, true);
85  } catch (const exceptions::InconsistentSpinProjection&) { /* ignore */ }
86  }
87  }
88  }
89  }
90 
91 };
92 
93 }
94 
95 #endif
const SpinProjectionVector projections(unsigned two_j)
Definition: Spin.h:77
Implements a spin amplitude that always returns Complex_1.
Definition: UnitSpinAmplitude.h:37
virtual std::string formalism() const override
Definition: UnitSpinAmplitude.h:56
Class for holding data and cached values per data point for fast calculation.
Definition: DataPoint.h:35
constexpr bool equal_always(const std::shared_ptr< const ParticleCombination > &A, const std::shared_ptr< const ParticleCombination > &B)
compare shared_ptr's to ParticleCombination, returning true always
Definition: ParticleCombination.h:113
Base class for handling YAP exceptions.
Definition: Exceptions.h:39
Caches SpinAmplitudes.
Definition: SpinAmplitudeCache.h:39
Class implementing a PWA model.
Definition: Model.h:56
UnitSpinAmplitude(Model &m, unsigned two_J, const SpinVector &two_j, unsigned l, unsigned two_s)
Definition: UnitSpinAmplitude.h:69
virtual const std::complex< double > amplitude(const DataPoint &d, const std::shared_ptr< ParticleCombination > &pc, int two_M, const SpinProjectionVector &two_m) const override
Definition: UnitSpinAmplitude.h:51
void addAmplitude(int two_M, const SpinProjectionVector &two_m, bool store_null=false)
Definition: SpinAmplitude.cxx:86
constexpr auto Complex_1
complex one
Definition: Constants.h:38
const std::complex< double > calc(int two_M, const SpinProjectionVector &two_m, const DataPoint &d, const std::shared_ptr< ParticleCombination > &pc) const override
Definition: UnitSpinAmplitude.h:42
Abstract base class implementing a spin amplitude.
Definition: SpinAmplitude.h:46