YAP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
QuantumNumbers.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_QuantumNumbers_h
22 #define yap_QuantumNumbers_h
23 
24 #include "Spin.h"
25 
26 #include <ostream>
27 #include <string>
28 
29 namespace yap {
30 
34 
36 {
37 public:
38 
41 
43  constexpr QuantumNumbers(unsigned twoJ, int P, int C, unsigned twoI, int G, int Q)
44  : TwoJ_(twoJ), P_(P), C_(C), TwoI_(twoI), G_(G), Q_(Q) {}
45 
47  constexpr QuantumNumbers(unsigned twoI, unsigned twoJ, int P, int Q)
48  : QuantumNumbers(twoJ, P, 0, twoI, 0, Q) {}
49 
51  constexpr QuantumNumbers(unsigned twoJ, int P, int Q)
52  : QuantumNumbers(twoJ, P, 0, 0, 0, Q) {}
53 
55  constexpr QuantumNumbers(unsigned twoJ, int Q)
56  : QuantumNumbers(twoJ, 0, 0, 0, 0, Q) {}
57 
61  : QuantumNumbers(0, 0, 0, 0) {}
62 
64 
66  virtual bool consistent() const;
67 
70 
72  constexpr unsigned twoJ() const
73  { return TwoJ_; }
74 
76  constexpr double J() const
77  { return TwoJ_ * 0.5; }
78 
80  constexpr int P() const
81  { return P_; }
82 
84  constexpr int C() const
85  { return C_; }
86 
88  constexpr unsigned twoI() const
89  { return TwoI_; }
90 
92  constexpr double I() const
93  { return TwoI_ * 0.5; }
94 
96  constexpr int G() const
97  { return G_; }
98 
100  constexpr int Q() const
101  { return Q_; }
102 
104 
107 
109  void setJ(double J)
110  { TwoJ_ = 2 * J; }
111 
113  void setTwoJ(unsigned J)
114  { TwoJ_ = J; }
115 
117 
118 private:
119 
121  unsigned TwoJ_;
122 
124  int P_;
125 
127  int C_;
128 
130  unsigned TwoI_;
131 
133  int G_;
134 
136  int Q_;
137 
138 };
139 
141 bool operator==(const QuantumNumbers& lhs, const QuantumNumbers& rhs);
142 
144 inline bool operator!=(const QuantumNumbers& lhs, const QuantumNumbers& rhs)
145 { return !(lhs == rhs); }
146 
148 inline std::string to_string(const QuantumNumbers& Q)
149 { return spin_to_string(Q.twoJ()) + (Q.P() > 0 ? "+" : "-") + (Q.C() == 0 ? "" : (Q.C() > 0 ? "+" : "-")); }
150 
152 inline std::string debug_string(const QuantumNumbers& Q)
153 { return (std::to_string(Q.twoJ()) + " " + std::to_string(Q.P()) + " " + std::to_string(Q.C()) + " " + std::to_string(Q.twoI()) + " " + std::to_string(Q.G()) + " " + std::to_string(Q.Q())); }
154 
156 inline std::ostream& operator<< (std::ostream& os, const QuantumNumbers& Q)
157 { os << "JP" << ((Q.C() == 0) ? "" : "C") << " = " << to_string(Q); return os; }
158 
159 }
160 
161 #endif
unsigned TwoJ_
Spin * 2.
Definition: QuantumNumbers.h:121
constexpr unsigned twoJ() const
Definition: QuantumNumbers.h:72
bool operator==(const CachedValue::Status &S, const CalculationStatus &s)
equality operator for checking the CalculationStatus
Definition: CachedValue.h:153
constexpr int P() const
Definition: QuantumNumbers.h:80
int G_
G-parity.
Definition: QuantumNumbers.h:133
bool operator!=(const CachedValue::Status &S, const CalculationStatus &s)
inequality operator for checking the CalculationStatus
Definition: CachedValue.h:157
constexpr int C() const
Definition: QuantumNumbers.h:84
std::string to_string(const QuantumNumbers &Q)
convert to string
Definition: QuantumNumbers.h:148
constexpr int Q() const
Definition: QuantumNumbers.h:100
constexpr unsigned twoI() const
Definition: QuantumNumbers.h:88
constexpr double I() const
Definition: QuantumNumbers.h:92
constexpr QuantumNumbers(unsigned twoJ, int P, int Q)
JPQ constructor.
Definition: QuantumNumbers.h:51
std::ostream & operator<<(std::ostream &os, const DecayChannel &dc)
<< operator
Definition: DecayChannel.h:127
QuantumNumbers()
Definition: QuantumNumbers.h:60
constexpr QuantumNumbers(unsigned twoJ, int P, int C, unsigned twoI, int G, int Q)
Constructor.
Definition: QuantumNumbers.h:43
std::string spin_to_string(int twoJ)
convert 2*J to string (e.g. 1/2, 1, 3/2, etc.)
Definition: Spin.h:36
void setJ(double J)
Set Spin.
Definition: QuantumNumbers.h:109
unsigned TwoI_
Isospin * 2.
Definition: QuantumNumbers.h:130
constexpr QuantumNumbers(unsigned twoI, unsigned twoJ, int P, int Q)
IJPQ constructor.
Definition: QuantumNumbers.h:47
std::string debug_string(const QuantumNumbers &Q)
convert to string
Definition: QuantumNumbers.h:152
virtual bool consistent() const
check consistency
Definition: QuantumNumbers.cxx:8
constexpr double J() const
Definition: QuantumNumbers.h:76
std::string to_string(const CachedValue::Status &S)
streaming operator for CachedValue::Status
Definition: CachedValue.cxx:27
constexpr QuantumNumbers(unsigned twoJ, int Q)
JQ constructor.
Definition: QuantumNumbers.h:55
void setTwoJ(unsigned J)
Set 2 * Spin.
Definition: QuantumNumbers.h:113
Quantum numbers of a Particle.
Definition: QuantumNumbers.h:35
int P_
Parity.
Definition: QuantumNumbers.h:124
int C_
C-parity.
Definition: QuantumNumbers.h:127
int Q_
Electric charge.
Definition: QuantumNumbers.h:136
constexpr int G() const
Definition: QuantumNumbers.h:96