Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:58:51

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 // G4ParticleDefinition
0027 //
0028 // Class description:
0029 //
0030 // This class contains all the static data of a particle.
0031 // It uses the process manager in order to collect all the processes
0032 // this kind of particle can undertake.
0033 
0034 // Authors: G.Cosmo, 2 December 1995 - Design, based on object model
0035 //          M.Asai, 29 January 1996 - First implementation
0036 // History:
0037 // - 1996-2003, H.Kurashige - Revisions
0038 // - 11.03.2003, H.Kurashige - Restructuring for Cuts per Region
0039 // - 25.01.2013, G.Cosmo, A.Dotti - Introduced thread-safety for MT
0040 // - 15.06.2017, K.L.Genser - Added support for MuonicAtom
0041 // --------------------------------------------------------------------
0042 #ifndef G4ParticleDefinition_hh
0043 #define G4ParticleDefinition_hh 1
0044 
0045 #include "G4PDefManager.hh"
0046 #include "G4ios.hh"
0047 #include "globals.hh"
0048 
0049 #include <CLHEP/Units/PhysicalConstants.h>
0050 
0051 #include <vector>
0052 
0053 class G4ProcessManager;
0054 class G4DecayTable;
0055 class G4ParticleTable;
0056 class G4ParticlePropertyTable;
0057 class G4VTrackingManager;
0058 
0059 using G4ParticleDefinitionSubInstanceManager = G4PDefManager;
0060 
0061 class G4ParticleDefinition
0062 {
0063     friend class G4ParticlePropertyTable;
0064 
0065   public:
0066     // Only one type of constructor can be used for G4ParticleDefinition.
0067     // If you want to create new particle, you must set name of the particle
0068     // at construction. Most of members seen as arguments of the constructor
0069     // (except last 3 arguments concerning with decay ) are  "constant"
0070     // and can not be changed later. (No "SET" methods are available)
0071     // Each type of particle must be constructed as a unique object
0072     // of special class derived from G4ParticleDefinition.
0073     // See G4ParticleTypes for detail
0074     // clang-format off
0075     G4ParticleDefinition(const G4String& aName, G4double mass, G4double width, G4double charge,
0076                          G4int iSpin, G4int iParity, G4int iConjugation, G4int iIsospin,
0077                          G4int iIsospinZ, G4int gParity, const G4String& pType, G4int lepton,
0078                          G4int baryon, G4int encoding, G4bool stable, G4double lifetime,
0079                          G4DecayTable* decaytable, G4bool shortlived = false,
0080                          const G4String& subType = "", G4int anti_encoding = 0,
0081                          G4double magneticMoment = 0.0);
0082     // clang-format on
0083 
0084     virtual ~G4ParticleDefinition();
0085 
0086     // Can not use "copy constructor", equality nor "default constructor"!
0087     G4ParticleDefinition(const G4ParticleDefinition&) = delete;
0088     G4ParticleDefinition& operator=(const G4ParticleDefinition&) = delete;
0089 
0090     G4bool operator==(const G4ParticleDefinition& right) const;
0091     G4bool operator!=(const G4ParticleDefinition& right) const;
0092 
0093     // With the following Getxxxx methods, one can get values
0094     // for members which can not be changed
0095 
0096     const G4String& GetParticleName() const { return theParticleName; }
0097 
0098     G4double GetPDGMass() const { return thePDGMass; }
0099     G4double GetPDGWidth() const { return thePDGWidth; }
0100     G4double GetPDGCharge() const { return thePDGCharge; }
0101 
0102     G4double GetPDGSpin() const { return thePDGSpin; }
0103     G4int GetPDGiSpin() const { return thePDGiSpin; }
0104     G4int GetPDGiParity() const { return thePDGiParity; }
0105     G4int GetPDGiConjugation() const { return thePDGiConjugation; }
0106     G4double GetPDGIsospin() const { return thePDGIsospin; }
0107     G4double GetPDGIsospin3() const { return thePDGIsospin3; }
0108     G4int GetPDGiIsospin() const { return thePDGiIsospin; }
0109     G4int GetPDGiIsospin3() const { return thePDGiIsospin3; }
0110     G4int GetPDGiGParity() const { return thePDGiGParity; }
0111 
0112     G4double GetPDGMagneticMoment() const { return thePDGMagneticMoment; }
0113     inline void SetPDGMagneticMoment(G4double mageticMoment);
0114 
0115     // Gives the anomaly of magnetic moment for spin 1/2 particles
0116     G4double CalculateAnomaly() const;
0117 
0118     const G4String& GetParticleType() const { return theParticleType; }
0119     const G4String& GetParticleSubType() const { return theParticleSubType; }
0120     G4int GetLeptonNumber() const { return theLeptonNumber; }
0121     G4int GetBaryonNumber() const { return theBaryonNumber; }
0122 
0123     G4int GetPDGEncoding() const { return thePDGEncoding; }
0124     G4int GetAntiPDGEncoding() const { return theAntiPDGEncoding; }
0125     inline void SetAntiPDGEncoding(G4int aEncoding);
0126 
0127     // Returns the number of quark with flavor contained in this particle.
0128     // The value of flavor is assigned as follows
0129     // 1:d, 2:u, 3:s, 4:c, 5:b, 6:t
0130     inline G4int GetQuarkContent(G4int flavor) const;
0131     inline G4int GetAntiQuarkContent(G4int flavor) const;
0132 
0133     G4bool IsShortLived() const { return fShortLivedFlag; }
0134 
0135     inline G4bool GetPDGStable() const;
0136     void SetPDGStable(const G4bool aFlag) { thePDGStable = aFlag; }
0137 
0138     inline G4double GetPDGLifeTime() const;
0139     void SetPDGLifeTime(G4double aLifeTime) { thePDGLifeTime = aLifeTime; }
0140 
0141     // Get life time of a generic ion through G4NuclideTable.
0142     inline G4double GetIonLifeTime() const;
0143 
0144     // Set/Get Decay Table
0145     //   !! Decay Table can be modified !!
0146     inline G4DecayTable* GetDecayTable() const;
0147     inline void SetDecayTable(G4DecayTable* aDecayTable);
0148 
0149     // Set/Get Process Manager
0150     //   !! Process Manager can be modified !!
0151     G4ProcessManager* GetProcessManager() const;
0152     void SetProcessManager(G4ProcessManager* aProcessManager);
0153 
0154     // Set/Get Tracking Manager; nullptr means the default
0155     //   !! Tracking Manager can be modified !!
0156     G4VTrackingManager* GetTrackingManager() const;
0157     void SetTrackingManager(G4VTrackingManager* aTrackingManager);
0158 
0159     // Get pointer to the particle table
0160     inline G4ParticleTable* GetParticleTable() const;
0161 
0162     // Get AtomicNumber and AtomicMass
0163     // These properties are defined for nucleus
0164     inline G4int GetAtomicNumber() const;
0165     inline G4int GetAtomicMass() const;
0166 
0167     // Prints information of data members.
0168     void DumpTable() const;
0169 
0170     // Control flag for output message
0171     //  0: Silent
0172     //  1: Warning message
0173     //  2: More
0174     inline void SetVerboseLevel(G4int value);
0175     inline G4int GetVerboseLevel() const;
0176 
0177     void SetApplyCutsFlag(G4bool);
0178     inline G4bool GetApplyCutsFlag() const;
0179 
0180     // True only if the particle is G4Ions
0181     // (it means that theProcessManager is same as one for G4GenricIon)
0182     inline G4bool IsGeneralIon() const;
0183 
0184     // True only if the particle is a G4MuonicAtom
0185     // (it means that theProcessManager is same as the one for G4MuonicAtom)
0186     inline G4bool IsMuonicAtom() const;
0187 
0188     // Returns the process manager master pointer.
0189     inline G4ProcessManager* GetMasterProcessManager() const;
0190 
0191     // Sets the shadow master pointer (not to be used by user)
0192     inline void SetMasterProcessManager(G4ProcessManager* aNewPM);
0193 
0194     // Returns the instance ID
0195     inline G4int GetInstanceID() const;
0196 
0197     // Returns the private data instance manager
0198     static const G4PDefManager& GetSubInstanceManager();
0199 
0200     // Clear memory allocated by sub-instance manager
0201     static void Clean();
0202 
0203     void SetParticleDefinitionID(G4int id = -1);
0204     inline G4int GetParticleDefinitionID() const;
0205 
0206     // The first two methods return "false" and 0, respectively,
0207     // if the particle is not an hypernucleus; else, they return
0208     // "true" and the number of Lambdas bound in the nucleus.
0209     // Similarly, the last two methods return "false" and 0,
0210     // respectively, if the particle is not an anti-hypernucleus;
0211     // else, they return "true" and the number of anti-Lambdas
0212     // bound in the anti-nucleus.
0213     // Notice that, for the time being, we are assuming that
0214     // (anti-)Lambda is the only type of (anti-)hyperon present
0215     // in all (anti-)hypernuclei.
0216     inline G4bool IsHypernucleus() const;
0217     inline G4int GetNumberOfLambdasInHypernucleus() const;
0218     inline G4bool IsAntiHypernucleus() const;
0219     inline G4int GetNumberOfAntiLambdasInAntiHypernucleus() const;
0220 
0221   protected:
0222     // Cannot be used
0223     G4ParticleDefinition();
0224 
0225     // Calculates quark and anti-quark contents
0226     // return value is the PDG encoding for this particle.
0227     // It means error if the return value is different from
0228     // this->thePDGEncoding.
0229     G4int FillQuarkContents();
0230 
0231     inline void SetParticleSubType(const G4String& subtype);
0232 
0233     inline void SetAtomicNumber(G4int);
0234     inline void SetAtomicMass(G4int);
0235 
0236     enum
0237     {
0238       NumberOfQuarkFlavor = 6
0239     };
0240 
0241     //  the number of quark (minus Sign means anti-quark) contents
0242     //  The value of flavor is assigned as follows
0243     //    0:d, 1:u, 2:s, 3:c, 4:b, 5:t
0244     G4int theQuarkContent[NumberOfQuarkFlavor];
0245     G4int theAntiQuarkContent[NumberOfQuarkFlavor];
0246 
0247     G4bool isGeneralIon = false;
0248     G4bool isMuonicAtom = false;
0249 
0250   private:
0251     // --- Shadow of master pointers
0252 
0253     // Each worker thread can access this field from the master thread
0254     // through this pointer.
0255     G4ProcessManager* theProcessManagerShadow = nullptr;
0256 
0257     // This field is used as instance ID.
0258     G4int g4particleDefinitionInstanceID = 0;
0259 
0260     // This field helps to use the class G4PDefManager introduced above.
0261     G4PART_DLL static G4PDefManager subInstanceManager;
0262 
0263     //  --- Following values can not be changed
0264     //  --- i.e. No Setxxxx Methods for them
0265 
0266     // The name of the particle.
0267     // Each object must have its specific name!!
0268     G4String theParticleName = "";
0269 
0270     //  --- Following member values must be defined with Units
0271 
0272     // The mass of the particle, in units of equivalent energy.
0273     G4double thePDGMass = 0.0;
0274 
0275     // The decay width of the particle, usually the width of a
0276     // Breit-Wigner function, assuming that you are near the
0277     // mass center anyway. (in units of equivalent energy)
0278     G4double thePDGWidth = 0.0;
0279 
0280     // The charge of the particle.(in units of Coulomb)
0281     G4double thePDGCharge = 0.0;
0282 
0283     //   --- Following members are quantum number
0284     //       i.e. discrete numbers can be allowed
0285     //       So, you can define them only by using integer in constructor
0286 
0287     // The total spin of the particle, also often denoted as
0288     // capital J, in units of 1/2.
0289     G4int thePDGiSpin = 0;
0290 
0291     // The total spin of the particle, in units of 1.
0292     G4double thePDGSpin = 0.0;
0293 
0294     // The parity quantum number, in units of 1. If the parity
0295     // is not defined for this particle, we will set this to 0.
0296     G4int thePDGiParity = 0;
0297 
0298     // This charge conjugation quantum number in units of 1.
0299     G4int thePDGiConjugation = 0;
0300 
0301     // The value of the G-parity quantum number.
0302     G4int thePDGiGParity = 0;
0303 
0304     // The isospin and its 3rd-component in units of 1/2.
0305     G4int thePDGiIsospin = 0;
0306     G4int thePDGiIsospin3 = 0;
0307 
0308     // The isospin quantum number in units of 1.
0309     G4double thePDGIsospin = 0.0;
0310     G4double thePDGIsospin3 = 0.0;
0311 
0312     // The magnetic moment.
0313     G4double thePDGMagneticMoment = 0.0;
0314 
0315     // The lepton quantum number.
0316     G4int theLeptonNumber = 0;
0317 
0318     // The baryon quantum number.
0319     G4int theBaryonNumber = 0;
0320 
0321     // More general textual type description of the particle.
0322     G4String theParticleType = "";
0323 
0324     // Textual type description of the particle
0325     // eg. pion, lamda etc.
0326     G4String theParticleSubType = "";
0327 
0328     // The Particle Data Group integer identifier of this particle
0329     G4int thePDGEncoding = 0;
0330 
0331     // The Particle Data Group integer identifier of the anti-particle
0332     G4int theAntiPDGEncoding = 0;
0333 
0334     // --- Following members can be changed after construction
0335 
0336     // Particles which have true value of this flag
0337     // will not be tracked by TrackingManager
0338     G4bool fShortLivedFlag = false;
0339 
0340     // Is an indicator that this particle is stable. It must
0341     // not decay. If the user tries to assign a kind of decay
0342     // object to it, it will refuse to take it.
0343     G4bool thePDGStable = false;
0344 
0345     // Is related to the decay width of the particle. The mean
0346     // life time is given in seconds.
0347     G4double thePDGLifeTime = 0.0;
0348 
0349     // Points DecayTable
0350     G4DecayTable* theDecayTable = nullptr;
0351 
0352     G4ParticleTable* theParticleTable = nullptr;
0353 
0354     G4int theAtomicNumber = 0;
0355     G4int theAtomicMass = 0;
0356 
0357     G4int verboseLevel = 1;
0358     G4bool fApplyCutsFlag = false;
0359 };
0360 
0361 #include "G4ParticleDefinition.icc"
0362 
0363 #endif