Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4FermiDataTypes.hh
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26//
27// G4FermiBreakUpAN alternative FermiBreakUp model
28// by A. Novikov (January 2025)
29//
30
31#ifndef G4FERMIDATATYPES_HH
32#define G4FERMIDATATYPES_HH
33
34#include "G4LorentzVector.hh"
35#include "G4ThreeVector.hh"
36#include "globals.hh"
37
38namespace
39{
40 static constexpr G4int MAX_Z = 9;
41 static constexpr G4int MAX_A = 17;
42}
43
45{
46 public:
47 using ValueType = std::uint32_t;
48
49 G4FermiAtomicMass() = default;
50
51 explicit constexpr G4FermiAtomicMass(ValueType mass) : mass_(mass) {}
52
53 G4FermiAtomicMass(const G4FermiAtomicMass& other) = default;
54
56
58
60
61 constexpr operator std::uint32_t() const { return mass_; }
62
63 constexpr operator G4int() const { return mass_; }
64
65 constexpr operator G4double() const { return mass_; }
66
67 G4bool operator<(const G4FermiAtomicMass& other) const { return mass_ < other.mass_; }
68
69 G4bool operator>(const G4FermiAtomicMass& other) const { return mass_ > other.mass_; }
70
71 G4bool operator<=(const G4FermiAtomicMass& other) const { return mass_ <= other.mass_; }
72
73 G4bool operator>=(const G4FermiAtomicMass& other) const { return mass_ >= other.mass_; }
74
75 G4bool operator==(const G4FermiAtomicMass& other) const { return mass_ == other.mass_; }
76
77 G4bool operator!=(const G4FermiAtomicMass& other) const { return mass_ != other.mass_; }
78
79 private:
80 ValueType mass_;
81};
82
84{
85 public:
86 using ValueType = std::uint32_t;
87
89
90 explicit constexpr G4FermiChargeNumber(ValueType charge) : charge_(charge) {}
91
93
95
97
99
100 constexpr operator std::uint32_t() const { return charge_; }
101
102 constexpr operator G4int() const { return charge_; }
103
104 constexpr operator G4double() const { return charge_; }
105
106 G4bool operator<(const G4FermiChargeNumber& other) const { return charge_ < other.charge_; }
107
108 G4bool operator>(const G4FermiChargeNumber& other) const { return charge_ > other.charge_; }
109
110 G4bool operator<=(const G4FermiChargeNumber& other) const { return charge_ <= other.charge_; }
111
112 G4bool operator>=(const G4FermiChargeNumber& other) const { return charge_ >= other.charge_; }
113
114 G4bool operator==(const G4FermiChargeNumber& other) const { return charge_ == other.charge_; }
115
116 G4bool operator!=(const G4FermiChargeNumber& other) const { return charge_ != other.charge_; }
117
118 private:
119 ValueType charge_;
120};
121
123{
126
128 {
129 return atomicMass < other.atomicMass
130 || (atomicMass == other.atomicMass && chargeNumber < other.chargeNumber);
131 }
132
134 {
135 return atomicMass == other.atomicMass && chargeNumber == other.chargeNumber;
136 }
137
139 {
140 return atomicMass != other.atomicMass || chargeNumber != other.chargeNumber;
141 }
142};
143
144namespace std
145{
146template<>
148{
149 std::size_t operator()(const G4FermiNucleiData& key) const
150 {
151 auto mass = G4int(key.atomicMass);
152 auto charge = G4int(key.chargeNumber);
153 return (mass * (mass + 1)) / 2 + charge;
154 }
155};
156
157std::string to_string(G4FermiAtomicMass mass);
158std::string to_string(G4FermiChargeNumber charge);
159
160std::ostream& operator<<(std::ostream& out, const G4FermiAtomicMass& mass);
161std::istream& operator>>(std::istream& in, G4FermiAtomicMass& mass);
162
163std::ostream& operator<<(std::ostream& out, const G4FermiChargeNumber& charge);
164std::istream& operator>>(std::istream& in, G4FermiChargeNumber& charge);
165} // namespace std
166
167constexpr G4FermiAtomicMass operator""_m(unsigned long long mass)
168{
169 return G4FermiAtomicMass(static_cast<std::uint32_t>(mass));
170}
171
172constexpr G4FermiChargeNumber operator""_c(unsigned long long charge)
173{
174 return G4FermiChargeNumber(static_cast<std::uint32_t>(charge));
175}
176
177#define FERMI_ASSERT_MSG(COND, MSG) \
178 if (!(COND)) { \
179 G4ExceptionDescription ed; \
180 ed << "assertion failed: \"" << #COND << '\"' << " at " << __FILE__ << ':' << __LINE__ \
181 << '\n' \
182 << MSG; \
183 G4Exception("G4FermiBreakUpAN: ", "fermi03", FatalException, ed, ""); \
184}
185
186#endif // G4FERMIDATATYPES_HH
double G4double
Definition G4Types.hh:83
bool G4bool
Definition G4Types.hh:86
int G4int
Definition G4Types.hh:85
G4bool operator<(const G4FermiAtomicMass &other) const
G4bool operator==(const G4FermiAtomicMass &other) const
G4bool operator>=(const G4FermiAtomicMass &other) const
std::uint32_t ValueType
G4bool operator>(const G4FermiAtomicMass &other) const
constexpr G4FermiAtomicMass(ValueType mass)
G4FermiAtomicMass & operator=(const G4FermiAtomicMass &other)=default
G4FermiAtomicMass(G4FermiAtomicMass &&other)=default
G4bool operator<=(const G4FermiAtomicMass &other) const
G4FermiAtomicMass(const G4FermiAtomicMass &other)=default
G4bool operator!=(const G4FermiAtomicMass &other) const
G4FermiAtomicMass()=default
G4FermiAtomicMass & operator=(G4FermiAtomicMass &&other)=default
G4bool operator>(const G4FermiChargeNumber &other) const
G4bool operator<=(const G4FermiChargeNumber &other) const
G4bool operator==(const G4FermiChargeNumber &other) const
G4FermiChargeNumber(G4FermiChargeNumber &&other)=default
G4bool operator!=(const G4FermiChargeNumber &other) const
G4FermiChargeNumber(const G4FermiChargeNumber &other)=default
G4FermiChargeNumber()=default
G4bool operator>=(const G4FermiChargeNumber &other) const
G4FermiChargeNumber & operator=(const G4FermiChargeNumber &other)=default
G4bool operator<(const G4FermiChargeNumber &other) const
constexpr G4FermiChargeNumber(ValueType charge)
G4FermiChargeNumber & operator=(G4FermiChargeNumber &&other)=default
std::istream & operator>>(std::istream &in, G4FermiAtomicMass &mass)
std::ostream & operator<<(std::ostream &out, const G4FermiAtomicMass &mass)
std::string to_string(G4FermiAtomicMass mass)
G4bool operator!=(const G4FermiNucleiData &other) const
G4FermiChargeNumber chargeNumber
G4bool operator==(const G4FermiNucleiData &other) const
G4bool operator<(const G4FermiNucleiData &other) const
G4FermiAtomicMass atomicMass
std::size_t operator()(const G4FermiNucleiData &key) const