Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 // $Id: G4ParticlePropertyTable.cc 72955 2013-08-14 14:23:14Z gcosmo $
27 //
28 // class G4ParticlePropertyTable
29 //
30 // Implementation
31 //
32 // History:
33 // first implementation by H Kurashige 9 June 2003
34 // Add magnetic moment by H Kurashige Mar 2007
35 
36 #include "G4ios.hh"
37 #include "globals.hh"
38 #include "G4StateManager.hh"
39 #include "G4ParticleTable.hh"
41 
42 // Static class variable: ptr to single instance of class
43 G4ThreadLocal G4ParticlePropertyTable* G4ParticlePropertyTable::fgParticlePropertyTable =0;
44 
47 {
48  if (!fgParticlePropertyTable)
49  {
50  fgParticlePropertyTable = new G4ParticlePropertyTable;
51  }
52  return fgParticlePropertyTable;
53 }
54 
57 {
58  for (size_t idx=0; idx<arrayDataObject.size(); idx++){
59  delete arrayDataObject[idx];
60  }
61  arrayDataObject.clear();
62 }
63 
66  verboseLevel(1)
67 {
69 }
70 
73 {
75  *this = right;
76 }
77 
80 {
81  if (this != &right) {
83  verboseLevel = right.verboseLevel;
84  }
85  return *this;
86 }
87 
90 {
91  return true;
92 }
93 
96 {
97  return false;
98 }
99 
102 {
103  for (size_t idx=0; idx<arrayDataObject.size(); idx++){
104  delete arrayDataObject[idx];
105  }
106  arrayDataObject.clear();
107 }
108 
111 {
112  G4ParticleDefinition* aParticle = fParticleTable->FindParticle(aParticleName);
113  if (aParticle ==0 ) return 0;
114 
115  return GetParticleProperty(aParticle);
116 }
117 
120 {
121  if (aParticle ==0 ) return 0;
123  pData->thePDGMass = aParticle->GetPDGMass();
124  pData->thePDGWidth = aParticle->GetPDGWidth();
125  pData->thePDGCharge = aParticle->GetPDGCharge();
126  pData->thePDGiSpin = aParticle->GetPDGiSpin();
127  pData->thePDGiParity = aParticle->GetPDGiParity();
128  pData->thePDGiConjugation = aParticle->GetPDGiConjugation();
129  pData->thePDGiGParity = aParticle->GetPDGiGParity();
130  pData->thePDGiIsospin = aParticle->GetPDGiIsospin();
131  pData->thePDGiIsospin3 = aParticle->GetPDGiIsospin3();
132  pData->thePDGMagneticMoment = aParticle->GetPDGMagneticMoment();
133  pData->theLeptonNumber = aParticle->GetLeptonNumber();
134  pData->theBaryonNumber = aParticle->GetBaryonNumber();
135  pData->thePDGEncoding = aParticle->GetPDGEncoding();
136  pData->theAntiPDGEncoding = aParticle->GetAntiPDGEncoding();
137  pData->thePDGLifeTime = aParticle->GetPDGLifeTime();
138  for (size_t flv=0; flv<G4ParticlePropertyData::NumberOfQuarkFlavor; ++flv) {
139  pData->theQuarkContent[flv] = aParticle->theQuarkContent[flv];
140  pData->theAntiQuarkContent[flv] = aParticle->theAntiQuarkContent[flv];
141  }
142 
143  arrayDataObject.push_back(pData);
144 
145  return pData;
146 }
147 
150 {
152  if (pStateMan->GetCurrentState() != G4State_PreInit){
153 #ifdef G4VERBOSE
154  if (verboseLevel>0){
155  G4cout << "G4ParticlePropertyTable::GetParticleProperty() ";
156  G4cout << " for " << pData.theParticleName << G4endl;
157  G4cout << " Particle properties can be modified only in Pre_Init state";
158  G4cout << G4endl;
159  }
160 #endif
161  return false;
162  }
163 
164  G4ParticleDefinition* aParticle = fParticleTable->FindParticle(pData.theParticleName);
165  if (aParticle ==0 ) {
166 #ifdef G4VERBOSE
167  if (verboseLevel>1){
168  G4cout << "G4ParticlePropertyTable::GetParticleProperty() ";
169  G4cout << " for " << pData.theParticleName << G4endl;
170  G4cout << " Particle does not exist" << G4endl;
171  }
172 #endif
173  return false;
174  }
175 
176  if (pData.fPDGMassModified) {
177  aParticle->thePDGMass = pData.thePDGMass;
178  }
179  if (pData.fPDGWidthModified) {
180  aParticle->thePDGMass = pData.thePDGMass;
181  }
182  if (pData.fPDGChargeModified) {
183  aParticle->thePDGCharge = pData.thePDGCharge;
184  }
185  if (pData.fPDGiSpinModified) {
186  aParticle->thePDGiSpin = pData.thePDGiSpin;
187  aParticle->thePDGSpin = 0.5*pData.thePDGiSpin;
188  }
189  if (pData.fPDGiParityModified) {
190  aParticle->thePDGiParity = pData.thePDGiParity;
191  }
192  if (pData.fPDGiConjugationModified) {
193  aParticle->thePDGiConjugation = pData.thePDGiConjugation;
194  }
195  if (pData.fPDGiGParityModified) {
196  aParticle->thePDGiGParity = pData.thePDGiGParity;
197  }
198  if (pData.fPDGiIsospinModified) {
199  aParticle->thePDGiIsospin = pData.thePDGiIsospin;
200  aParticle->thePDGIsospin = 0.5*pData.thePDGiIsospin;
201  }
202  if (pData.fPDGiIsospin3Modified) {
203  aParticle->thePDGiIsospin3 = pData.thePDGiIsospin3;
204  aParticle->thePDGIsospin3 = 0.5*pData.thePDGiIsospin3;
205  }
206  if (pData.fPDGMagneticMomentModified) {
207  aParticle->thePDGMagneticMoment = pData.thePDGMagneticMoment;
208  }
209  if (pData.fLeptonNumberModified) {
210  aParticle->theLeptonNumber = pData.theLeptonNumber;
211  }
212  if (pData.fBaryonNumberModified) {
213  aParticle->theBaryonNumber = pData.theBaryonNumber;
214  }
215  if (pData.fPDGEncodingModified) {
216  aParticle->thePDGEncoding = pData.thePDGEncoding;
217  }
218  if (pData.fAntiPDGEncodingModified) {
219  aParticle->theAntiPDGEncoding = pData.theAntiPDGEncoding;
220  }
221  if (pData.fPDGLifeTimeModified) {
222  aParticle->thePDGLifeTime = pData.thePDGLifeTime;
223  }
224  for (size_t flv=0; flv<G4ParticlePropertyData::NumberOfQuarkFlavor; ++flv) {
225  if (pData.fQuarkContentModified){
226  aParticle->theQuarkContent[flv] = pData.theQuarkContent[flv];
227  }
228  if (pData.fAntiQuarkContentModified){
229  aParticle->theAntiQuarkContent[flv] = pData.theAntiQuarkContent[flv];
230  }
231  }
232 
233  return true;
234 }
G4bool SetParticleProperty(const G4ParticlePropertyData &newProperty)
std::vector< G4ParticlePropertyData * > arrayDataObject
G4ParticleDefinition * FindParticle(G4int PDGEncoding)
G4ParticlePropertyData * GetParticleProperty(const G4String &aParticleName)
static G4ParticlePropertyTable * GetParticlePropertyTable()
#define G4ThreadLocal
Definition: tls.hh:89
int G4int
Definition: G4Types.hh:78
const G4String & GetParticleName() const
G4int GetAntiPDGEncoding() const
static G4StateManager * GetStateManager()
G4double GetPDGWidth() const
G4GLOB_DLL std::ostream G4cout
bool G4bool
Definition: G4Types.hh:79
G4ApplicationState GetCurrentState() const
G4int GetPDGiConjugation() const
G4int theAntiQuarkContent[NumberOfQuarkFlavor]
G4double GetPDGMass() const
static G4ParticleTable * GetParticleTable()
G4int theQuarkContent[NumberOfQuarkFlavor]
G4double GetPDGLifeTime() const
#define G4endl
Definition: G4ios.hh:61
G4double GetPDGMagneticMoment() const
G4int operator!=(const G4ParticlePropertyTable &right) const
G4double GetPDGCharge() const
G4ParticlePropertyTable & operator=(const G4ParticlePropertyTable &right)
G4int operator==(const G4ParticlePropertyTable &right) const