Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/Geant4/G4FermiDataTypes.hh was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 //
0027 // G4FermiBreakUpAN alternative FermiBreakUp model
0028 // by A. Novikov (January 2025)
0029 //
0030 
0031 #ifndef G4FERMIDATATYPES_HH
0032 #define G4FERMIDATATYPES_HH
0033 
0034 #include "G4LorentzVector.hh"
0035 #include "G4ThreeVector.hh"
0036 #include "globals.hh"
0037 
0038 namespace
0039 {
0040   static constexpr G4int MAX_Z = 9;
0041   static constexpr G4int MAX_A = 17;
0042 }
0043 
0044 class G4FermiAtomicMass
0045 {
0046   public:
0047     using ValueType = std::uint32_t;
0048 
0049     G4FermiAtomicMass() = default;
0050 
0051     explicit constexpr G4FermiAtomicMass(ValueType mass) : mass_(mass) {}
0052 
0053     G4FermiAtomicMass(const G4FermiAtomicMass& other) = default;
0054 
0055     G4FermiAtomicMass(G4FermiAtomicMass&& other) = default;
0056 
0057     G4FermiAtomicMass& operator=(const G4FermiAtomicMass& other) = default;
0058 
0059     G4FermiAtomicMass& operator=(G4FermiAtomicMass&& other) = default;
0060 
0061     constexpr operator std::uint32_t() const { return mass_; }
0062 
0063     constexpr operator G4int() const { return mass_; }
0064 
0065     constexpr operator G4double() const { return mass_; }
0066 
0067     G4bool operator<(const G4FermiAtomicMass& other) const { return mass_ < other.mass_; }
0068 
0069     G4bool operator>(const G4FermiAtomicMass& other) const { return mass_ > other.mass_; }
0070 
0071     G4bool operator<=(const G4FermiAtomicMass& other) const { return mass_ <= other.mass_; }
0072 
0073     G4bool operator>=(const G4FermiAtomicMass& other) const { return mass_ >= other.mass_; }
0074 
0075     G4bool operator==(const G4FermiAtomicMass& other) const { return mass_ == other.mass_; }
0076 
0077     G4bool operator!=(const G4FermiAtomicMass& other) const { return mass_ != other.mass_; }
0078 
0079   private:
0080     ValueType mass_;
0081 };
0082 
0083 class G4FermiChargeNumber
0084 {
0085   public:
0086     using ValueType = std::uint32_t;
0087 
0088     G4FermiChargeNumber() = default;
0089 
0090     explicit constexpr G4FermiChargeNumber(ValueType charge) : charge_(charge) {}
0091 
0092     G4FermiChargeNumber(const G4FermiChargeNumber& other) = default;
0093 
0094     G4FermiChargeNumber(G4FermiChargeNumber&& other) = default;
0095 
0096     G4FermiChargeNumber& operator=(const G4FermiChargeNumber& other) = default;
0097 
0098     G4FermiChargeNumber& operator=(G4FermiChargeNumber&& other) = default;
0099 
0100     constexpr operator std::uint32_t() const { return charge_; }
0101 
0102     constexpr operator G4int() const { return charge_; }
0103 
0104     constexpr operator G4double() const { return charge_; }
0105 
0106     G4bool operator<(const G4FermiChargeNumber& other) const { return charge_ < other.charge_; }
0107 
0108     G4bool operator>(const G4FermiChargeNumber& other) const { return charge_ > other.charge_; }
0109 
0110     G4bool operator<=(const G4FermiChargeNumber& other) const { return charge_ <= other.charge_; }
0111 
0112     G4bool operator>=(const G4FermiChargeNumber& other) const { return charge_ >= other.charge_; }
0113 
0114     G4bool operator==(const G4FermiChargeNumber& other) const { return charge_ == other.charge_; }
0115 
0116     G4bool operator!=(const G4FermiChargeNumber& other) const { return charge_ != other.charge_; }
0117 
0118   private:
0119     ValueType charge_;
0120 };
0121 
0122 struct G4FermiNucleiData
0123 {
0124     G4FermiAtomicMass atomicMass;
0125     G4FermiChargeNumber chargeNumber;
0126 
0127     G4bool operator<(const G4FermiNucleiData& other) const
0128     {
0129       return atomicMass < other.atomicMass
0130              || (atomicMass == other.atomicMass && chargeNumber < other.chargeNumber);
0131     }
0132 
0133     G4bool operator==(const G4FermiNucleiData& other) const
0134     {
0135       return atomicMass == other.atomicMass && chargeNumber == other.chargeNumber;
0136     }
0137 
0138     G4bool operator!=(const G4FermiNucleiData& other) const
0139     {
0140       return atomicMass != other.atomicMass || chargeNumber != other.chargeNumber;
0141     }
0142 };
0143 
0144 namespace std
0145 {
0146 template<>
0147 struct hash<G4FermiNucleiData>
0148 {
0149     std::size_t operator()(const G4FermiNucleiData& key) const
0150     {
0151       auto mass = G4int(key.atomicMass);
0152       auto charge = G4int(key.chargeNumber);
0153       return (mass * (mass + 1)) / 2 + charge;
0154     }
0155 };
0156 
0157 std::string to_string(G4FermiAtomicMass mass);
0158 std::string to_string(G4FermiChargeNumber charge);
0159 
0160 std::ostream& operator<<(std::ostream& out, const G4FermiAtomicMass& mass);
0161 std::istream& operator>>(std::istream& in, G4FermiAtomicMass& mass);
0162 
0163 std::ostream& operator<<(std::ostream& out, const G4FermiChargeNumber& charge);
0164 std::istream& operator>>(std::istream& in, G4FermiChargeNumber& charge);
0165 }  // namespace std
0166 
0167 constexpr G4FermiAtomicMass operator""_m(unsigned long long mass)
0168 {
0169   return G4FermiAtomicMass(static_cast<std::uint32_t>(mass));
0170 }
0171 
0172 constexpr G4FermiChargeNumber operator""_c(unsigned long long charge)
0173 {
0174   return G4FermiChargeNumber(static_cast<std::uint32_t>(charge));
0175 }
0176 
0177 #define FERMI_ASSERT_MSG(COND, MSG)  \
0178   if (!(COND)) {                     \
0179     G4ExceptionDescription ed;       \
0180     ed << "assertion failed: \"" << #COND << '\"' << " at " << __FILE__ << ':' << __LINE__ \
0181             << '\n'  \
0182             << MSG;  \
0183     G4Exception("G4FermiBreakUpAN: ", "fermi03", FatalException, ed, ""); \
0184 }
0185 
0186 #endif  // G4FERMIDATATYPES_HH