ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4ParticlePropertyTable.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4ParticlePropertyTable.cc
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 //
27 // class G4ParticlePropertyTable
28 //
29 // Implementation
30 //
31 // History:
32 // first implementation by H Kurashige 9 June 2003
33 // Add magnetic moment by H Kurashige Mar 2007
34 
35 #include "G4ios.hh"
36 #include "globals.hh"
37 #include "G4StateManager.hh"
38 #include "G4ParticleTable.hh"
40 
41 // Static class variable: ptr to single instance of class
43 
46 {
47  if (fgParticlePropertyTable == nullptr)
48  {
50  }
52 }
53 
56 {
57  for (size_t idx=0; idx<arrayDataObject.size(); idx++){
58  delete arrayDataObject[idx];
59  }
60  arrayDataObject.clear();
61 }
62 
65  verboseLevel(1)
66 {
68 }
69 
72 {
74  *this = right;
75 }
76 
79 {
80  if (this != &right) {
82  verboseLevel = right.verboseLevel;
83  }
84  return *this;
85 }
86 
89 {
90  return true;
91 }
92 
95 {
96  return false;
97 }
98 
101 {
102  for (size_t idx=0; idx<arrayDataObject.size(); idx++){
103  delete arrayDataObject[idx];
104  }
105  arrayDataObject.clear();
106 }
107 
110 {
111  G4ParticleDefinition* aParticle = fParticleTable->FindParticle(aParticleName);
112  if (aParticle == nullptr ) return nullptr;
113 
114  return GetParticleProperty(aParticle);
115 }
116 
119 {
120  if (aParticle == nullptr ) return nullptr;
122  pData->thePDGMass = aParticle->GetPDGMass();
123  pData->thePDGWidth = aParticle->GetPDGWidth();
124  pData->thePDGCharge = aParticle->GetPDGCharge();
125  pData->thePDGiSpin = aParticle->GetPDGiSpin();
126  pData->thePDGiParity = aParticle->GetPDGiParity();
127  pData->thePDGiConjugation = aParticle->GetPDGiConjugation();
128  pData->thePDGiGParity = aParticle->GetPDGiGParity();
129  pData->thePDGiIsospin = aParticle->GetPDGiIsospin();
130  pData->thePDGiIsospin3 = aParticle->GetPDGiIsospin3();
131  pData->thePDGMagneticMoment = aParticle->GetPDGMagneticMoment();
132  pData->theLeptonNumber = aParticle->GetLeptonNumber();
133  pData->theBaryonNumber = aParticle->GetBaryonNumber();
134  pData->thePDGEncoding = aParticle->GetPDGEncoding();
135  pData->theAntiPDGEncoding = aParticle->GetAntiPDGEncoding();
136  pData->thePDGLifeTime = aParticle->GetPDGLifeTime();
137  for (size_t flv=0; flv<G4ParticlePropertyData::NumberOfQuarkFlavor; ++flv) {
138  pData->theQuarkContent[flv] = aParticle->theQuarkContent[flv];
139  pData->theAntiQuarkContent[flv] = aParticle->theAntiQuarkContent[flv];
140  }
141 
142  arrayDataObject.push_back(pData);
143 
144  return pData;
145 }
146 
149 {
151  if (pStateMan->GetCurrentState() != G4State_PreInit){
152 #ifdef G4VERBOSE
153  if (verboseLevel>0){
154  G4cout << "G4ParticlePropertyTable::GetParticleProperty() ";
155  G4cout << " for " << pData.theParticleName << G4endl;
156  G4cout << " Particle properties can be modified only in Pre_Init state";
157  G4cout << G4endl;
158  }
159 #endif
160  return false;
161  }
162 
164  if (aParticle == nullptr ) {
165 #ifdef G4VERBOSE
166  if (verboseLevel>1){
167  G4cout << "G4ParticlePropertyTable::GetParticleProperty() ";
168  G4cout << " for " << pData.theParticleName << G4endl;
169  G4cout << " Particle does not exist" << G4endl;
170  }
171 #endif
172  return false;
173  }
174 
175  if (pData.fPDGMassModified) {
176  aParticle->thePDGMass = pData.thePDGMass;
177  }
178  if (pData.fPDGWidthModified) {
179  aParticle->thePDGMass = pData.thePDGMass;
180  }
181  if (pData.fPDGChargeModified) {
182  aParticle->thePDGCharge = pData.thePDGCharge;
183  }
184  if (pData.fPDGiSpinModified) {
185  aParticle->thePDGiSpin = pData.thePDGiSpin;
186  aParticle->thePDGSpin = 0.5*pData.thePDGiSpin;
187  }
188  if (pData.fPDGiParityModified) {
189  aParticle->thePDGiParity = pData.thePDGiParity;
190  }
191  if (pData.fPDGiConjugationModified) {
192  aParticle->thePDGiConjugation = pData.thePDGiConjugation;
193  }
194  if (pData.fPDGiGParityModified) {
195  aParticle->thePDGiGParity = pData.thePDGiGParity;
196  }
197  if (pData.fPDGiIsospinModified) {
198  aParticle->thePDGiIsospin = pData.thePDGiIsospin;
199  aParticle->thePDGIsospin = 0.5*pData.thePDGiIsospin;
200  }
201  if (pData.fPDGiIsospin3Modified) {
202  aParticle->thePDGiIsospin3 = pData.thePDGiIsospin3;
203  aParticle->thePDGIsospin3 = 0.5*pData.thePDGiIsospin3;
204  }
205  if (pData.fPDGMagneticMomentModified) {
206  aParticle->thePDGMagneticMoment = pData.thePDGMagneticMoment;
207  }
208  if (pData.fLeptonNumberModified) {
209  aParticle->theLeptonNumber = pData.theLeptonNumber;
210  }
211  if (pData.fBaryonNumberModified) {
212  aParticle->theBaryonNumber = pData.theBaryonNumber;
213  }
214  if (pData.fPDGEncodingModified) {
215  aParticle->thePDGEncoding = pData.thePDGEncoding;
216  }
217  if (pData.fAntiPDGEncodingModified) {
218  aParticle->theAntiPDGEncoding = pData.theAntiPDGEncoding;
219  }
220  if (pData.fPDGLifeTimeModified) {
221  aParticle->thePDGLifeTime = pData.thePDGLifeTime;
222  }
223  for (size_t flv=0; flv<G4ParticlePropertyData::NumberOfQuarkFlavor; ++flv) {
224  if (pData.fQuarkContentModified){
225  aParticle->theQuarkContent[flv] = pData.theQuarkContent[flv];
226  }
227  if (pData.fAntiQuarkContentModified){
228  aParticle->theAntiQuarkContent[flv] = pData.theAntiQuarkContent[flv];
229  }
230  }
231 
232  return true;
233 }