G4ParticlePropertyTable.cc

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 // $Id$
00027 //
00028 // class G4ParticlePropertyTable
00029 //
00030 // Implementation
00031 //
00032 // History:
00033 // first implementation by H Kurashige 9 June 2003
00034 // Add   magnetic moment    by H Kurashige   Mar 2007
00035 
00036 #include "G4ios.hh"
00037 #include "globals.hh"
00038 #include "G4StateManager.hh"
00039 #include "G4ParticleTable.hh"
00040 #include "G4ParticlePropertyTable.hh"
00041 
00042 // Static class variable: ptr to single instance of class
00043 G4ParticlePropertyTable* G4ParticlePropertyTable::fgParticlePropertyTable =0;
00044 
00046 G4ParticlePropertyTable* G4ParticlePropertyTable::GetParticlePropertyTable()
00047 {
00048   static G4ParticlePropertyTable theParticlePropertyTable;
00049   if (!fgParticlePropertyTable){
00050     fgParticlePropertyTable =  &theParticlePropertyTable;
00051   }
00052   return fgParticlePropertyTable;
00053 }
00054 
00056 G4ParticlePropertyTable::~G4ParticlePropertyTable()
00057 {
00058   for (size_t idx=0; idx<arrayDataObject.size(); idx++){
00059     delete arrayDataObject[idx];
00060   }
00061   arrayDataObject.clear();
00062 }
00063 
00065 G4ParticlePropertyTable::G4ParticlePropertyTable():
00066   verboseLevel(1)
00067 {
00068   fParticleTable = G4ParticleTable::GetParticleTable();   
00069 }
00070 
00072 G4ParticlePropertyTable::G4ParticlePropertyTable(const G4ParticlePropertyTable &right)
00073 {
00074   fParticleTable = G4ParticleTable::GetParticleTable();   
00075   *this = right;
00076 }
00077       
00079 G4ParticlePropertyTable & G4ParticlePropertyTable::operator=(const G4ParticlePropertyTable &right)
00080 {
00081   if (this != &right) {
00082     fParticleTable = right.fParticleTable;
00083     verboseLevel   = right.verboseLevel; 
00084   }
00085   return *this;
00086 }
00087   
00089 G4int G4ParticlePropertyTable::operator==(const G4ParticlePropertyTable &) const
00090 {
00091   return true;
00092 }
00093 
00095 G4int G4ParticlePropertyTable::operator!=(const G4ParticlePropertyTable &) const
00096 {
00097   return false;
00098 }
00099 
00101 void G4ParticlePropertyTable::Clear()
00102 {
00103   for (size_t idx=0; idx<arrayDataObject.size(); idx++){
00104     delete arrayDataObject[idx];
00105   }
00106   arrayDataObject.clear();
00107 }
00108 
00110 G4ParticlePropertyData* G4ParticlePropertyTable::GetParticleProperty(const G4String& aParticleName)
00111 {
00112   G4ParticleDefinition* aParticle = fParticleTable->FindParticle(aParticleName);
00113   if (aParticle ==0 ) return 0;
00114 
00115   return GetParticleProperty(aParticle);
00116 }
00117 
00119 G4ParticlePropertyData*  G4ParticlePropertyTable::GetParticleProperty(const G4ParticleDefinition* aParticle)
00120 {
00121   if (aParticle ==0 ) return 0;
00122   G4ParticlePropertyData* pData = new G4ParticlePropertyData(aParticle->GetParticleName());
00123   pData->thePDGMass        = aParticle->GetPDGMass();
00124   pData->thePDGWidth       = aParticle->GetPDGWidth();
00125   pData->thePDGCharge      = aParticle->GetPDGCharge();
00126   pData->thePDGiSpin       = aParticle->GetPDGiSpin();
00127   pData->thePDGiParity     = aParticle->GetPDGiParity();
00128   pData->thePDGiConjugation  = aParticle->GetPDGiConjugation();
00129   pData->thePDGiGParity    = aParticle->GetPDGiGParity();
00130   pData->thePDGiIsospin    = aParticle->GetPDGiIsospin();
00131   pData->thePDGiIsospin3   = aParticle->GetPDGiIsospin3();
00132   pData->thePDGMagneticMoment   = aParticle->GetPDGMagneticMoment();
00133   pData->theLeptonNumber   = aParticle->GetLeptonNumber();
00134   pData->theBaryonNumber   = aParticle->GetBaryonNumber();
00135   pData->thePDGEncoding    = aParticle->GetPDGEncoding();
00136   pData->theAntiPDGEncoding  = aParticle->GetAntiPDGEncoding();
00137   pData->thePDGLifeTime    = aParticle->GetPDGLifeTime(); 
00138   for (size_t flv=0; flv<G4ParticlePropertyData::NumberOfQuarkFlavor; ++flv) {
00139     pData->theQuarkContent[flv]     = aParticle->theQuarkContent[flv];
00140     pData->theAntiQuarkContent[flv] = aParticle->theAntiQuarkContent[flv];
00141   }
00142 
00143   arrayDataObject.push_back(pData);
00144  
00145   return pData;
00146 }
00147 
00149 G4bool G4ParticlePropertyTable::SetParticleProperty(const G4ParticlePropertyData& pData)
00150 {
00151   G4StateManager* pStateMan = G4StateManager::GetStateManager();
00152   if (pStateMan->GetCurrentState() != G4State_PreInit){
00153 #ifdef G4VERBOSE
00154     if (verboseLevel>0){
00155       G4cout << "G4ParticlePropertyTable::GetParticleProperty() ";
00156       G4cout << " for " << pData.theParticleName << G4endl;
00157       G4cout << " Particle properties can be modified only in Pre_Init state";
00158       G4cout << G4endl;
00159     }
00160 #endif
00161     return false;
00162   } 
00163 
00164   G4ParticleDefinition* aParticle = fParticleTable->FindParticle(pData.theParticleName);
00165   if (aParticle ==0 ) {
00166 #ifdef G4VERBOSE
00167     if (verboseLevel>1){
00168       G4cout << "G4ParticlePropertyTable::GetParticleProperty() ";
00169       G4cout << " for " << pData.theParticleName << G4endl;
00170       G4cout << " Particle does not exist" << G4endl;
00171     }
00172 #endif
00173     return false;
00174   }
00175 
00176   if (pData.fPDGMassModified) { 
00177     aParticle->thePDGMass = pData.thePDGMass;
00178   }
00179   if (pData.fPDGWidthModified) {
00180     aParticle->thePDGMass = pData.thePDGMass;
00181   }
00182   if (pData.fPDGChargeModified) {
00183     aParticle->thePDGCharge  = pData.thePDGCharge;
00184   }
00185   if (pData.fPDGiSpinModified) {
00186     aParticle->thePDGiSpin = pData.thePDGiSpin;
00187     aParticle->thePDGSpin  = 0.5*pData.thePDGiSpin;
00188   }
00189   if (pData.fPDGiParityModified) {
00190     aParticle->thePDGiParity = pData.thePDGiParity;
00191   }
00192   if (pData.fPDGiConjugationModified) {
00193     aParticle->thePDGiConjugation = pData.thePDGiConjugation;
00194   }
00195   if (pData.fPDGiGParityModified) {
00196     aParticle->thePDGiGParity = pData.thePDGiGParity;
00197   }
00198   if (pData.fPDGiIsospinModified) {
00199     aParticle->thePDGiIsospin = pData.thePDGiIsospin;
00200     aParticle->thePDGIsospin  = 0.5*pData.thePDGiIsospin;
00201   }
00202   if (pData.fPDGiIsospin3Modified) {
00203     aParticle->thePDGiIsospin3 = pData.thePDGiIsospin3;
00204     aParticle->thePDGIsospin3  = 0.5*pData.thePDGiIsospin3;
00205   }
00206   if (pData.fPDGMagneticMomentModified) {
00207     aParticle->thePDGMagneticMoment = pData.thePDGMagneticMoment;
00208    }
00209   if (pData.fLeptonNumberModified) {
00210     aParticle->theLeptonNumber   = pData.theLeptonNumber;
00211   }
00212   if (pData.fBaryonNumberModified) {
00213     aParticle->theBaryonNumber   = pData.theBaryonNumber;
00214   }
00215   if (pData.fPDGEncodingModified) {
00216     aParticle->thePDGEncoding   =  pData.thePDGEncoding;
00217   }
00218   if (pData.fAntiPDGEncodingModified) {
00219     aParticle->theAntiPDGEncoding   =  pData.theAntiPDGEncoding;
00220   }
00221   if (pData.fPDGLifeTimeModified) {
00222     aParticle->thePDGLifeTime = pData.thePDGLifeTime; 
00223   }
00224   for (size_t flv=0; flv<<G4ParticlePropertyData::NumberOfQuarkFlavor; ++flv) {
00225     if (pData.fQuarkContentModified){
00226       aParticle->theQuarkContent[flv] = pData.theQuarkContent[flv];
00227     }
00228     if (pData.fAntiQuarkContentModified){
00229       aParticle->theAntiQuarkContent[flv] = pData.theAntiQuarkContent[flv];
00230     }
00231   }
00232   
00233   return true;
00234 }
00235 
00236 
00237 
00238 
00239 
00240 

Generated on Mon May 27 17:49:16 2013 for Geant4 by  doxygen 1.4.7