Documentation of MARTY
A Modern ARtificial Theoretical phYsicist
quantumNumber.h
Go to the documentation of this file.
1 // This file is part of MARTY.
2 //
3 // MARTY is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation, either version 3 of the License, or
6 // (at your option) any later version.
7 //
8 // MARTY is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with MARTY. If not, see <https://www.gnu.org/licenses/>.
15 
21 #ifndef QUANTUM_NUMBER_H_INCLUDED
22 #define QUANTUM_NUMBER_H_INCLUDED
23 
24 #include <map>
25 #include <string>
26 #include <vector>
27 
28 
29 namespace mty {
30 
31 class QuantumField;
32 
45 
46  public:
47 
51  using ID = unsigned short;
55  using Value = int;
56 
57  private:
58 
64  static inline ID current_id = 0;
65 
71  bool conserved;
72 
76  ID id;
77 
78  private:
79 
86  static inline std::map<ID, std::string>& name() {
87  static std::map<ID, std::string> m;
88  return m;
89  }
90 
91  public:
92 
102  explicit
103  QuantumNumber(std::string const& t_name,
104  bool t_conserved = true);
105 
109  QuantumNumber(QuantumNumber const&) = default;
113  QuantumNumber& operator=(QuantumNumber const&) = default;
114 
118  ~QuantumNumber();
119 
125  bool isConserved() const;
126 
134  std::string getName() const;
135 
140  void setConservedProperty(bool t_conserved);
141 
146  void setName(std::string const& t_name);
147 
156  bool appearsIn(std::vector<mty::QuantumField> const& fields) const;
157 
166  int computeQuantumNumber(std::vector<mty::QuantumField> const& field) const;
167 
172  inline ID getID() const {
173  return id;
174  }
175 
182  inline bool operator==(QuantumNumber const& other) const {
183  return id == other.id;
184  }
185 
192  inline bool operator!=(QuantumNumber const& other) const {
193  return id != other.id;
194  }
195 };
196 
197 }
198 
199 #endif
ID id
ID of the quantum number.
Definition: quantumNumber.h:76
bool operator==(QuantumNumber const &other) const
Compares the ids of two quantum numbers.
Definition: quantumNumber.h:182
bool conserved
Tells if the quantum number is conserved.
Definition: quantumNumber.h:71
bool operator!=(QuantumNumber const &other) const
Compares the ids of two quantum numbers.
Definition: quantumNumber.h:192
bool appearsIn(std::vector< mty::QuantumField > const &fields) const
Tells if one of the fields has a non trivial value for the quantum number.
Definition: quantumNumber.cpp:54
bool isConserved() const
Returns the conservation property of the quantum number.
Definition: quantumNumber.cpp:34
Namespace of MARTY.
Definition: 2HDM.h:31
static ID current_id
Current id of QuantumNumber.
Definition: quantumNumber.h:64
This class represents quantum numbers of a theory, like for example baryon number B...
Definition: quantumNumber.h:44
int computeQuantumNumber(std::vector< mty::QuantumField > const &field) const
Calculates the value of the total quantum numbers carried by a list of fields.
Definition: quantumNumber.cpp:63
~QuantumNumber()
Destructor.
Definition: quantumNumber.cpp:29
ID getID() const
Returns the id of the quantum number.
Definition: quantumNumber.h:172
void setConservedProperty(bool t_conserved)
Sets the conserved property of the quantum number.
Definition: quantumNumber.cpp:44
int Value
Integer type for quantum number value.
Definition: quantumNumber.h:55
unsigned short ID
Integer type for QuantumNumber id.
Definition: quantumNumber.h:51
QuantumNumber & operator=(QuantumNumber const &)=default
Defaulted copy assignement operator.
void setName(std::string const &t_name)
Sets the name of the quantum number.
Definition: quantumNumber.cpp:49
std::string getName() const
Returns the name of the quantum number.
Definition: quantumNumber.cpp:39
QuantumNumber(std::string const &t_name, bool t_conserved=true)
Constructor with 2 parameters.
Definition: quantumNumber.cpp:21
static std::map< ID, std::string > & name()
Returns the map between ids and names for quantumNumbers.
Definition: quantumNumber.h:86