Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4ParticlePropertyTable.cc
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// G4ParticlePropertyTable class implementation
27//
28// Author: H.Kurashige, 9 June 2003 - First implementation
29// --------------------------------------------------------------------
30
32
33#include "G4ParticleTable.hh"
34#include "G4StateManager.hh"
35#include "G4ios.hh"
36#include "globals.hh"
37
38// Static class variable: ptr to single instance of class
39//
40G4ThreadLocal G4ParticlePropertyTable* G4ParticlePropertyTable::fgParticlePropertyTable = nullptr;
41
43{
44 if (fgParticlePropertyTable == nullptr) {
45 fgParticlePropertyTable = new G4ParticlePropertyTable;
46 }
47 return fgParticlePropertyTable;
48}
49
51{
52 for (const auto& idx : arrayDataObject) {
53 delete idx;
54 }
55 arrayDataObject.clear();
56}
57
62
64{
65 for (const auto& idx : arrayDataObject) {
66 delete idx;
67 }
68 arrayDataObject.clear();
69}
70
72{
73 G4ParticleDefinition* aParticle = fParticleTable->FindParticle(aParticleName);
74 if (aParticle == nullptr) return nullptr;
75
76 return GetParticleProperty(aParticle);
77}
78
81{
82 if (aParticle == nullptr) return nullptr;
83 auto pData = new G4ParticlePropertyData(aParticle->GetParticleName());
84 pData->thePDGMass = aParticle->GetPDGMass();
85 pData->thePDGWidth = aParticle->GetPDGWidth();
86 pData->thePDGCharge = aParticle->GetPDGCharge();
87 pData->thePDGiSpin = aParticle->GetPDGiSpin();
88 pData->thePDGiParity = aParticle->GetPDGiParity();
89 pData->thePDGiConjugation = aParticle->GetPDGiConjugation();
90 pData->thePDGiGParity = aParticle->GetPDGiGParity();
91 pData->thePDGiIsospin = aParticle->GetPDGiIsospin();
92 pData->thePDGiIsospin3 = aParticle->GetPDGiIsospin3();
93 pData->thePDGMagneticMoment = aParticle->GetPDGMagneticMoment();
94 pData->theLeptonNumber = aParticle->GetLeptonNumber();
95 pData->theBaryonNumber = aParticle->GetBaryonNumber();
96 pData->thePDGEncoding = aParticle->GetPDGEncoding();
97 pData->theAntiPDGEncoding = aParticle->GetAntiPDGEncoding();
98 pData->thePDGLifeTime = aParticle->GetPDGLifeTime();
99 for (std::size_t flv = 0; flv < G4ParticlePropertyData::NumberOfQuarkFlavor; ++flv) {
100 pData->theQuarkContent[flv] = aParticle->theQuarkContent[flv];
101 pData->theAntiQuarkContent[flv] = aParticle->theAntiQuarkContent[flv];
102 }
103
104 arrayDataObject.push_back(pData);
105
106 return pData;
107}
108
110{
112 if (pStateMan->GetCurrentState() != G4State_PreInit) {
113#ifdef G4VERBOSE
114 if (verboseLevel > 0) {
115 G4cout << "G4ParticlePropertyTable::GetParticleProperty() ";
116 G4cout << " for " << pData.theParticleName << G4endl;
117 G4cout << " Particle properties can be modified only in Pre_Init state";
118 G4cout << G4endl;
119 }
120#endif
121 return false;
122 }
123
124 G4ParticleDefinition* aParticle = fParticleTable->FindParticle(pData.theParticleName);
125 if (aParticle == nullptr) {
126#ifdef G4VERBOSE
127 if (verboseLevel > 1) {
128 G4cout << "G4ParticlePropertyTable::GetParticleProperty() ";
129 G4cout << " for " << pData.theParticleName << G4endl;
130 G4cout << " Particle does not exist" << G4endl;
131 }
132#endif
133 return false;
134 }
135
136 if (pData.fPDGMassModified) {
137 aParticle->thePDGMass = pData.thePDGMass;
138 }
139 if (pData.fPDGWidthModified) {
140 aParticle->thePDGMass = pData.thePDGMass;
141 }
142 if (pData.fPDGChargeModified) {
143 aParticle->thePDGCharge = pData.thePDGCharge;
144 }
145 if (pData.fPDGiSpinModified) {
146 aParticle->thePDGiSpin = pData.thePDGiSpin;
147 aParticle->thePDGSpin = 0.5 * pData.thePDGiSpin;
148 }
149 if (pData.fPDGiParityModified) {
150 aParticle->thePDGiParity = pData.thePDGiParity;
151 }
152 if (pData.fPDGiConjugationModified) {
153 aParticle->thePDGiConjugation = pData.thePDGiConjugation;
154 }
155 if (pData.fPDGiGParityModified) {
156 aParticle->thePDGiGParity = pData.thePDGiGParity;
157 }
158 if (pData.fPDGiIsospinModified) {
159 aParticle->thePDGiIsospin = pData.thePDGiIsospin;
160 aParticle->thePDGIsospin = 0.5 * pData.thePDGiIsospin;
161 }
162 if (pData.fPDGiIsospin3Modified) {
163 aParticle->thePDGiIsospin3 = pData.thePDGiIsospin3;
164 aParticle->thePDGIsospin3 = 0.5 * pData.thePDGiIsospin3;
165 }
166 if (pData.fPDGMagneticMomentModified) {
167 aParticle->thePDGMagneticMoment = pData.thePDGMagneticMoment;
168 }
169 if (pData.fLeptonNumberModified) {
170 aParticle->theLeptonNumber = pData.theLeptonNumber;
171 }
172 if (pData.fBaryonNumberModified) {
173 aParticle->theBaryonNumber = pData.theBaryonNumber;
174 }
175 if (pData.fPDGEncodingModified) {
176 aParticle->thePDGEncoding = pData.thePDGEncoding;
177 }
178 if (pData.fAntiPDGEncodingModified) {
179 aParticle->theAntiPDGEncoding = pData.theAntiPDGEncoding;
180 }
181 if (pData.fPDGLifeTimeModified) {
182 aParticle->thePDGLifeTime = pData.thePDGLifeTime;
183 }
184 for (std::size_t flv = 0; flv < G4ParticlePropertyData::NumberOfQuarkFlavor; ++flv) {
185 if (pData.fQuarkContentModified) {
186 aParticle->theQuarkContent[flv] = pData.theQuarkContent[flv];
187 }
188 if (pData.fAntiQuarkContentModified) {
189 aParticle->theAntiQuarkContent[flv] = pData.theAntiQuarkContent[flv];
190 }
191 }
192
193 return true;
194}
@ G4State_PreInit
bool G4bool
Definition G4Types.hh:86
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout
G4double GetPDGMagneticMoment() const
G4int theAntiQuarkContent[NumberOfQuarkFlavor]
G4int theQuarkContent[NumberOfQuarkFlavor]
G4double GetPDGLifeTime() const
const G4String & GetParticleName() const
G4ParticlePropertyData * GetParticleProperty(const G4String &aParticleName)
static G4ParticlePropertyTable * GetParticlePropertyTable()
std::vector< G4ParticlePropertyData * > arrayDataObject
G4bool SetParticleProperty(const G4ParticlePropertyData &newProperty)
G4ParticleDefinition * FindParticle(G4int PDGEncoding)
static G4ParticleTable * GetParticleTable()
const G4ApplicationState & GetCurrentState() const
static G4StateManager * GetStateManager()
#define G4ThreadLocal
Definition tls.hh:77