Geant4 11.1.1
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
31#include "G4ios.hh"
32#include "globals.hh"
33#include "G4StateManager.hh"
34#include "G4ParticleTable.hh"
36
37// Static class variable: ptr to single instance of class
38//
40 G4ParticlePropertyTable::fgParticlePropertyTable = nullptr;
41
42// --------------------------------------------------------------------
44{
45 if (fgParticlePropertyTable == nullptr)
46 {
47 fgParticlePropertyTable = new G4ParticlePropertyTable;
48 }
49 return fgParticlePropertyTable;
50}
51
52// --------------------------------------------------------------------
54{
55 for (std::size_t idx=0; idx<arrayDataObject.size(); ++idx)
56 {
57 delete arrayDataObject[idx];
58 }
59 arrayDataObject.clear();
60}
61
62// --------------------------------------------------------------------
64{
66}
67
68// --------------------------------------------------------------------
70{
71 for (std::size_t idx=0; idx<arrayDataObject.size(); ++idx)
72 {
73 delete arrayDataObject[idx];
74 }
75 arrayDataObject.clear();
76}
77
78// --------------------------------------------------------------------
81{
82 G4ParticleDefinition* aParticle = fParticleTable->FindParticle(aParticleName);
83 if (aParticle == nullptr ) return nullptr;
84
85 return GetParticleProperty(aParticle);
86}
87
88// --------------------------------------------------------------------
91{
92 if (aParticle == nullptr ) return nullptr;
94 = new G4ParticlePropertyData(aParticle->GetParticleName());
95 pData->thePDGMass = aParticle->GetPDGMass();
96 pData->thePDGWidth = aParticle->GetPDGWidth();
97 pData->thePDGCharge = aParticle->GetPDGCharge();
98 pData->thePDGiSpin = aParticle->GetPDGiSpin();
99 pData->thePDGiParity = aParticle->GetPDGiParity();
100 pData->thePDGiConjugation = aParticle->GetPDGiConjugation();
101 pData->thePDGiGParity = aParticle->GetPDGiGParity();
102 pData->thePDGiIsospin = aParticle->GetPDGiIsospin();
103 pData->thePDGiIsospin3 = aParticle->GetPDGiIsospin3();
104 pData->thePDGMagneticMoment = aParticle->GetPDGMagneticMoment();
105 pData->theLeptonNumber = aParticle->GetLeptonNumber();
106 pData->theBaryonNumber = aParticle->GetBaryonNumber();
107 pData->thePDGEncoding = aParticle->GetPDGEncoding();
108 pData->theAntiPDGEncoding = aParticle->GetAntiPDGEncoding();
109 pData->thePDGLifeTime = aParticle->GetPDGLifeTime();
110 for (std::size_t flv=0;
111 flv<G4ParticlePropertyData::NumberOfQuarkFlavor; ++flv)
112 {
113 pData->theQuarkContent[flv] = aParticle->theQuarkContent[flv];
114 pData->theAntiQuarkContent[flv] = aParticle->theAntiQuarkContent[flv];
115 }
116
117 arrayDataObject.push_back(pData);
118
119 return pData;
120}
121
122// --------------------------------------------------------------------
125{
127 if (pStateMan->GetCurrentState() != G4State_PreInit)
128 {
129#ifdef G4VERBOSE
130 if (verboseLevel>0)
131 {
132 G4cout << "G4ParticlePropertyTable::GetParticleProperty() ";
133 G4cout << " for " << pData.theParticleName << G4endl;
134 G4cout << " Particle properties can be modified only in Pre_Init state";
135 G4cout << G4endl;
136 }
137#endif
138 return false;
139 }
140
141 G4ParticleDefinition* aParticle
142 = fParticleTable->FindParticle(pData.theParticleName);
143 if (aParticle == nullptr )
144 {
145#ifdef G4VERBOSE
146 if (verboseLevel>1)
147 {
148 G4cout << "G4ParticlePropertyTable::GetParticleProperty() ";
149 G4cout << " for " << pData.theParticleName << G4endl;
150 G4cout << " Particle does not exist" << G4endl;
151 }
152#endif
153 return false;
154 }
155
156 if (pData.fPDGMassModified) {
157 aParticle->thePDGMass = pData.thePDGMass;
158 }
159 if (pData.fPDGWidthModified) {
160 aParticle->thePDGMass = pData.thePDGMass;
161 }
162 if (pData.fPDGChargeModified) {
163 aParticle->thePDGCharge = pData.thePDGCharge;
164 }
165 if (pData.fPDGiSpinModified) {
166 aParticle->thePDGiSpin = pData.thePDGiSpin;
167 aParticle->thePDGSpin = 0.5*pData.thePDGiSpin;
168 }
169 if (pData.fPDGiParityModified) {
170 aParticle->thePDGiParity = pData.thePDGiParity;
171 }
172 if (pData.fPDGiConjugationModified) {
173 aParticle->thePDGiConjugation = pData.thePDGiConjugation;
174 }
175 if (pData.fPDGiGParityModified) {
176 aParticle->thePDGiGParity = pData.thePDGiGParity;
177 }
178 if (pData.fPDGiIsospinModified) {
179 aParticle->thePDGiIsospin = pData.thePDGiIsospin;
180 aParticle->thePDGIsospin = 0.5*pData.thePDGiIsospin;
181 }
182 if (pData.fPDGiIsospin3Modified) {
183 aParticle->thePDGiIsospin3 = pData.thePDGiIsospin3;
184 aParticle->thePDGIsospin3 = 0.5*pData.thePDGiIsospin3;
185 }
186 if (pData.fPDGMagneticMomentModified) {
187 aParticle->thePDGMagneticMoment = pData.thePDGMagneticMoment;
188 }
189 if (pData.fLeptonNumberModified) {
190 aParticle->theLeptonNumber = pData.theLeptonNumber;
191 }
192 if (pData.fBaryonNumberModified) {
193 aParticle->theBaryonNumber = pData.theBaryonNumber;
194 }
195 if (pData.fPDGEncodingModified) {
196 aParticle->thePDGEncoding = pData.thePDGEncoding;
197 }
198 if (pData.fAntiPDGEncodingModified) {
199 aParticle->theAntiPDGEncoding = pData.theAntiPDGEncoding;
200 }
201 if (pData.fPDGLifeTimeModified) {
202 aParticle->thePDGLifeTime = pData.thePDGLifeTime;
203 }
204 for (std::size_t flv=0;
205 flv<G4ParticlePropertyData::NumberOfQuarkFlavor; ++flv)
206 {
207 if (pData.fQuarkContentModified)
208 {
209 aParticle->theQuarkContent[flv] = pData.theQuarkContent[flv];
210 }
211 if (pData.fAntiQuarkContentModified)
212 {
213 aParticle->theAntiQuarkContent[flv] = pData.theAntiQuarkContent[flv];
214 }
215 }
216
217 return true;
218}
@ G4State_PreInit
bool G4bool
Definition: G4Types.hh:86
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
G4double GetPDGMagneticMoment() const
G4int theAntiQuarkContent[NumberOfQuarkFlavor]
G4double GetPDGWidth() const
G4double GetPDGCharge() const
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