source: trunk/source/particles/management/src/G4ParticlePropertyTable.cc @ 1199

Last change on this file since 1199 was 824, checked in by garnier, 16 years ago

import all except CVS

File size: 8.3 KB
Line 
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,v 1.4 2007/03/11 07:17:35 kurasige Exp $
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"
40#include "G4ParticlePropertyTable.hh"
41
42// Static class variable: ptr to single instance of class
43G4ParticlePropertyTable* G4ParticlePropertyTable::fgParticlePropertyTable =0;
44
45////////////////////
46G4ParticlePropertyTable* G4ParticlePropertyTable::GetParticlePropertyTable()
47{
48  static G4ParticlePropertyTable theParticlePropertyTable;
49  if (!fgParticlePropertyTable){
50    fgParticlePropertyTable =  &theParticlePropertyTable;
51  }
52  return fgParticlePropertyTable;
53}
54
55/////////////////////////////////////////////////////////////
56G4ParticlePropertyTable::~G4ParticlePropertyTable()
57{
58  for (size_t idx=0; idx<arrayDataObject.size(); idx++){
59    delete arrayDataObject[idx];
60  }
61  arrayDataObject.clear();
62}
63
64/////////////////////////////////////////////////////////////
65G4ParticlePropertyTable::G4ParticlePropertyTable():
66  verboseLevel(1)
67{
68  fParticleTable = G4ParticleTable::GetParticleTable();   
69}
70
71////////////////////////
72G4ParticlePropertyTable::G4ParticlePropertyTable(const G4ParticlePropertyTable &right)
73{
74  *this = right;
75}
76     
77////////////////////////
78const G4ParticlePropertyTable & G4ParticlePropertyTable::operator=(const G4ParticlePropertyTable &right)
79{
80  if (this != &right) {
81    fParticleTable = right.fParticleTable;
82    verboseLevel   = right.verboseLevel; 
83  }
84  return *this;
85}
86 
87////////////////////////
88G4int G4ParticlePropertyTable::operator==(const G4ParticlePropertyTable &) const
89{
90  return true;
91}
92
93////////////////////////
94G4int G4ParticlePropertyTable::operator!=(const G4ParticlePropertyTable &) const
95{
96  return false;
97}
98
99/////////////////////////////////////////////////////////////
100void G4ParticlePropertyTable::Clear()
101{
102  for (size_t idx=0; idx<arrayDataObject.size(); idx++){
103    delete arrayDataObject[idx];
104  }
105  arrayDataObject.clear();
106}
107
108/////////////////////////////////////////////////////////////////////
109G4ParticlePropertyData* G4ParticlePropertyTable::GetParticleProperty(const G4String& aParticleName)
110{
111  G4ParticleDefinition* aParticle = fParticleTable->FindParticle(aParticleName);
112  if (aParticle ==0 ) return 0;
113
114  return GetParticleProperty(aParticle);
115}
116
117//////////////////////////////////////
118G4ParticlePropertyData*  G4ParticlePropertyTable::GetParticleProperty(const G4ParticleDefinition* aParticle)
119{
120  if (aParticle ==0 ) return 0;
121  G4ParticlePropertyData* pData = new G4ParticlePropertyData(aParticle->GetParticleName());
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
147//////////////////////////
148G4bool G4ParticlePropertyTable::SetParticleProperty(const G4ParticlePropertyData& pData)
149{
150  G4StateManager* pStateMan = G4StateManager::GetStateManager();
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
163  G4ParticleDefinition* aParticle = fParticleTable->FindParticle(pData.theParticleName);
164  if (aParticle ==0 ) {
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}
234
235
236
237
238
239
Note: See TracBrowser for help on using the repository browser.