Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 // G4ParticlePropertyTable class implementatio << 26 // $Id: G4ParticlePropertyTable.cc,v 1.3 2006/06/29 19:26:02 gunter Exp $ 27 // 27 // 28 // Author: H.Kurashige, 9 June 2003 - First im << 28 // class G4ParticlePropertyTable 29 // ------------------------------------------- << 29 // 30 << 30 // Implementation 31 #include "G4ParticlePropertyTable.hh" << 31 // >> 32 // History: >> 33 // first implementation by H Kurashige 9 June 2003 32 34 33 #include "G4ParticleTable.hh" << 34 #include "G4StateManager.hh" << 35 #include "G4ios.hh" 35 #include "G4ios.hh" 36 #include "globals.hh" 36 #include "globals.hh" >> 37 #include "G4StateManager.hh" >> 38 #include "G4ParticleTable.hh" >> 39 #include "G4ParticlePropertyTable.hh" 37 40 38 // Static class variable: ptr to single instan 41 // Static class variable: ptr to single instance of class 39 // << 42 G4ParticlePropertyTable* G4ParticlePropertyTable::fgParticlePropertyTable =0; 40 G4ThreadLocal G4ParticlePropertyTable* G4Parti << 41 43 >> 44 //////////////////// 42 G4ParticlePropertyTable* G4ParticlePropertyTab 45 G4ParticlePropertyTable* G4ParticlePropertyTable::GetParticlePropertyTable() 43 { 46 { 44 if (fgParticlePropertyTable == nullptr) { << 47 static G4ParticlePropertyTable theParticlePropertyTable; 45 fgParticlePropertyTable = new G4ParticlePr << 48 if (!fgParticlePropertyTable){ >> 49 fgParticlePropertyTable = &theParticlePropertyTable; 46 } 50 } 47 return fgParticlePropertyTable; 51 return fgParticlePropertyTable; 48 } 52 } 49 53 >> 54 ///////////////////////////////////////////////////////////// 50 G4ParticlePropertyTable::~G4ParticlePropertyTa 55 G4ParticlePropertyTable::~G4ParticlePropertyTable() 51 { 56 { 52 for (const auto& idx : arrayDataObject) { << 57 for (size_t idx=0; idx<arrayDataObject.size(); idx++){ 53 delete idx; << 58 delete arrayDataObject[idx]; 54 } 59 } 55 arrayDataObject.clear(); 60 arrayDataObject.clear(); 56 } 61 } 57 62 58 G4ParticlePropertyTable::G4ParticlePropertyTab << 63 ///////////////////////////////////////////////////////////// >> 64 G4ParticlePropertyTable::G4ParticlePropertyTable(): >> 65 verboseLevel(1) >> 66 { >> 67 fParticleTable = G4ParticleTable::GetParticleTable(); >> 68 } >> 69 >> 70 //////////////////////// >> 71 G4ParticlePropertyTable::G4ParticlePropertyTable(const G4ParticlePropertyTable &right) >> 72 { >> 73 *this = right; >> 74 } >> 75 >> 76 //////////////////////// >> 77 const G4ParticlePropertyTable & G4ParticlePropertyTable::operator=(const G4ParticlePropertyTable &right) >> 78 { >> 79 if (this != &right) { >> 80 fParticleTable = right.fParticleTable; >> 81 verboseLevel = right.verboseLevel; >> 82 } >> 83 return *this; >> 84 } >> 85 >> 86 //////////////////////// >> 87 G4int G4ParticlePropertyTable::operator==(const G4ParticlePropertyTable &) const >> 88 { >> 89 return true; >> 90 } >> 91 >> 92 //////////////////////// >> 93 G4int G4ParticlePropertyTable::operator!=(const G4ParticlePropertyTable &) const 59 { 94 { 60 fParticleTable = G4ParticleTable::GetParticl << 95 return false; 61 } 96 } 62 97 >> 98 ///////////////////////////////////////////////////////////// 63 void G4ParticlePropertyTable::Clear() 99 void G4ParticlePropertyTable::Clear() 64 { 100 { 65 for (const auto& idx : arrayDataObject) { << 101 for (size_t idx=0; idx<arrayDataObject.size(); idx++){ 66 delete idx; << 102 delete arrayDataObject[idx]; 67 } 103 } 68 arrayDataObject.clear(); 104 arrayDataObject.clear(); 69 } 105 } 70 106 >> 107 ///////////////////////////////////////////////////////////////////// 71 G4ParticlePropertyData* G4ParticlePropertyTabl 108 G4ParticlePropertyData* G4ParticlePropertyTable::GetParticleProperty(const G4String& aParticleName) 72 { 109 { 73 G4ParticleDefinition* aParticle = fParticleT 110 G4ParticleDefinition* aParticle = fParticleTable->FindParticle(aParticleName); 74 if (aParticle == nullptr) return nullptr; << 111 if (aParticle ==0 ) return 0; 75 112 76 return GetParticleProperty(aParticle); 113 return GetParticleProperty(aParticle); 77 } 114 } 78 115 79 G4ParticlePropertyData* << 116 ////////////////////////////////////// 80 G4ParticlePropertyTable::GetParticleProperty(c << 117 G4ParticlePropertyData* G4ParticlePropertyTable::GetParticleProperty(const G4ParticleDefinition* aParticle) 81 { 118 { 82 if (aParticle == nullptr) return nullptr; << 119 if (aParticle ==0 ) return 0; 83 auto pData = new G4ParticlePropertyData(aPar << 120 G4ParticlePropertyData* pData = new G4ParticlePropertyData(aParticle->GetParticleName()); 84 pData->thePDGMass = aParticle->GetPDGMass(); << 121 pData->thePDGMass = aParticle->GetPDGMass(); 85 pData->thePDGWidth = aParticle->GetPDGWidth( << 122 pData->thePDGWidth = aParticle->GetPDGWidth(); 86 pData->thePDGCharge = aParticle->GetPDGCharg << 123 pData->thePDGCharge = aParticle->GetPDGCharge(); 87 pData->thePDGiSpin = aParticle->GetPDGiSpin( << 124 pData->thePDGiSpin = aParticle->GetPDGiSpin(); 88 pData->thePDGiParity = aParticle->GetPDGiPar << 125 pData->thePDGiParity = aParticle->GetPDGiParity(); 89 pData->thePDGiConjugation = aParticle->GetPD << 126 pData->thePDGiConjugation = aParticle->GetPDGiConjugation(); 90 pData->thePDGiGParity = aParticle->GetPDGiGP << 127 pData->thePDGiGParity = aParticle->GetPDGiGParity(); 91 pData->thePDGiIsospin = aParticle->GetPDGiIs << 128 pData->thePDGiIsospin = aParticle->GetPDGiIsospin(); 92 pData->thePDGiIsospin3 = aParticle->GetPDGiI << 129 pData->thePDGiIsospin3 = aParticle->GetPDGiIsospin3(); 93 pData->thePDGMagneticMoment = aParticle->Get << 130 pData->theLeptonNumber = aParticle->GetLeptonNumber(); 94 pData->theLeptonNumber = aParticle->GetLepto << 131 pData->theBaryonNumber = aParticle->GetBaryonNumber(); 95 pData->theBaryonNumber = aParticle->GetBaryo << 132 pData->thePDGEncoding = aParticle->GetPDGEncoding(); 96 pData->thePDGEncoding = aParticle->GetPDGEnc << 133 pData->theAntiPDGEncoding = aParticle->GetAntiPDGEncoding(); 97 pData->theAntiPDGEncoding = aParticle->GetAn << 134 pData->thePDGLifeTime = aParticle->GetPDGLifeTime(); 98 pData->thePDGLifeTime = aParticle->GetPDGLif << 135 for (size_t flv=0; flv<G4ParticlePropertyData::NumberOfQuarkFlavor; ++flv) { 99 for (std::size_t flv = 0; flv < G4ParticlePr << 136 pData->theQuarkContent[flv] = aParticle->theQuarkContent[flv]; 100 pData->theQuarkContent[flv] = aParticle->t << 101 pData->theAntiQuarkContent[flv] = aParticl 137 pData->theAntiQuarkContent[flv] = aParticle->theAntiQuarkContent[flv]; 102 } 138 } 103 139 104 arrayDataObject.push_back(pData); 140 arrayDataObject.push_back(pData); 105 << 141 106 return pData; 142 return pData; 107 } 143 } 108 144 >> 145 ////////////////////////// 109 G4bool G4ParticlePropertyTable::SetParticlePro 146 G4bool G4ParticlePropertyTable::SetParticleProperty(const G4ParticlePropertyData& pData) 110 { 147 { 111 G4StateManager* pStateMan = G4StateManager:: 148 G4StateManager* pStateMan = G4StateManager::GetStateManager(); 112 if (pStateMan->GetCurrentState() != G4State_ << 149 if (pStateMan->GetCurrentState() != G4State_PreInit){ 113 #ifdef G4VERBOSE 150 #ifdef G4VERBOSE 114 if (verboseLevel > 0) { << 151 if (verboseLevel>0){ 115 G4cout << "G4ParticlePropertyTable::GetP 152 G4cout << "G4ParticlePropertyTable::GetParticleProperty() "; 116 G4cout << " for " << pData.theParticleNa 153 G4cout << " for " << pData.theParticleName << G4endl; 117 G4cout << " Particle properties can be m 154 G4cout << " Particle properties can be modified only in Pre_Init state"; 118 G4cout << G4endl; 155 G4cout << G4endl; 119 } 156 } 120 #endif 157 #endif 121 return false; 158 return false; 122 } << 159 } 123 160 124 G4ParticleDefinition* aParticle = fParticleT 161 G4ParticleDefinition* aParticle = fParticleTable->FindParticle(pData.theParticleName); 125 if (aParticle == nullptr) { << 162 if (aParticle ==0 ) { 126 #ifdef G4VERBOSE 163 #ifdef G4VERBOSE 127 if (verboseLevel > 1) { << 164 if (verboseLevel>1){ 128 G4cout << "G4ParticlePropertyTable::GetP 165 G4cout << "G4ParticlePropertyTable::GetParticleProperty() "; 129 G4cout << " for " << pData.theParticleNa 166 G4cout << " for " << pData.theParticleName << G4endl; 130 G4cout << " Particle does not exist" << 167 G4cout << " Particle does not exist" << G4endl; 131 } 168 } 132 #endif 169 #endif 133 return false; 170 return false; 134 } 171 } 135 172 136 if (pData.fPDGMassModified) { << 173 if (pData.fPDGMassModified) { 137 aParticle->thePDGMass = pData.thePDGMass; 174 aParticle->thePDGMass = pData.thePDGMass; 138 } 175 } 139 if (pData.fPDGWidthModified) { 176 if (pData.fPDGWidthModified) { 140 aParticle->thePDGMass = pData.thePDGMass; 177 aParticle->thePDGMass = pData.thePDGMass; 141 } 178 } 142 if (pData.fPDGChargeModified) { 179 if (pData.fPDGChargeModified) { 143 aParticle->thePDGCharge = pData.thePDGChar << 180 aParticle->thePDGCharge = pData.thePDGCharge; 144 } 181 } 145 if (pData.fPDGiSpinModified) { 182 if (pData.fPDGiSpinModified) { 146 aParticle->thePDGiSpin = pData.thePDGiSpin 183 aParticle->thePDGiSpin = pData.thePDGiSpin; 147 aParticle->thePDGSpin = 0.5 * pData.thePDG << 184 aParticle->thePDGSpin = 0.5*pData.thePDGiSpin; 148 } 185 } 149 if (pData.fPDGiParityModified) { 186 if (pData.fPDGiParityModified) { 150 aParticle->thePDGiParity = pData.thePDGiPa 187 aParticle->thePDGiParity = pData.thePDGiParity; 151 } 188 } 152 if (pData.fPDGiConjugationModified) { 189 if (pData.fPDGiConjugationModified) { 153 aParticle->thePDGiConjugation = pData.theP 190 aParticle->thePDGiConjugation = pData.thePDGiConjugation; 154 } 191 } 155 if (pData.fPDGiGParityModified) { 192 if (pData.fPDGiGParityModified) { 156 aParticle->thePDGiGParity = pData.thePDGiG 193 aParticle->thePDGiGParity = pData.thePDGiGParity; 157 } 194 } 158 if (pData.fPDGiIsospinModified) { 195 if (pData.fPDGiIsospinModified) { 159 aParticle->thePDGiIsospin = pData.thePDGiI 196 aParticle->thePDGiIsospin = pData.thePDGiIsospin; 160 aParticle->thePDGIsospin = 0.5 * pData.the << 197 aParticle->thePDGIsospin = 0.5*pData.thePDGiIsospin; 161 } 198 } 162 if (pData.fPDGiIsospin3Modified) { 199 if (pData.fPDGiIsospin3Modified) { 163 aParticle->thePDGiIsospin3 = pData.thePDGi 200 aParticle->thePDGiIsospin3 = pData.thePDGiIsospin3; 164 aParticle->thePDGIsospin3 = 0.5 * pData.th << 201 aParticle->thePDGIsospin3 = 0.5*pData.thePDGiIsospin3; 165 } << 166 if (pData.fPDGMagneticMomentModified) { << 167 aParticle->thePDGMagneticMoment = pData.th << 168 } 202 } 169 if (pData.fLeptonNumberModified) { 203 if (pData.fLeptonNumberModified) { 170 aParticle->theLeptonNumber = pData.theLept << 204 aParticle->theLeptonNumber = pData.theLeptonNumber; 171 } 205 } 172 if (pData.fBaryonNumberModified) { 206 if (pData.fBaryonNumberModified) { 173 aParticle->theBaryonNumber = pData.theBary << 207 aParticle->theBaryonNumber = pData.theBaryonNumber; 174 } 208 } 175 if (pData.fPDGEncodingModified) { 209 if (pData.fPDGEncodingModified) { 176 aParticle->thePDGEncoding = pData.thePDGEn << 210 aParticle->thePDGEncoding = pData.thePDGEncoding; 177 } 211 } 178 if (pData.fAntiPDGEncodingModified) { 212 if (pData.fAntiPDGEncodingModified) { 179 aParticle->theAntiPDGEncoding = pData.theA << 213 aParticle->theAntiPDGEncoding = pData.theAntiPDGEncoding; 180 } 214 } 181 if (pData.fPDGLifeTimeModified) { 215 if (pData.fPDGLifeTimeModified) { 182 aParticle->thePDGLifeTime = pData.thePDGLi << 216 aParticle->thePDGLifeTime = pData.thePDGLifeTime; 183 } 217 } 184 for (std::size_t flv = 0; flv < G4ParticlePr << 218 for (size_t flv=0; flv<<G4ParticlePropertyData::NumberOfQuarkFlavor; ++flv) { 185 if (pData.fQuarkContentModified) { << 219 if (pData.fQuarkContentModified){ 186 aParticle->theQuarkContent[flv] = pData. 220 aParticle->theQuarkContent[flv] = pData.theQuarkContent[flv]; 187 } 221 } 188 if (pData.fAntiQuarkContentModified) { << 222 if (pData.fAntiQuarkContentModified){ 189 aParticle->theAntiQuarkContent[flv] = pD 223 aParticle->theAntiQuarkContent[flv] = pData.theAntiQuarkContent[flv]; 190 } 224 } 191 } 225 } 192 << 226 193 return true; 227 return true; 194 } 228 } >> 229 >> 230 >> 231 >> 232 >> 233 >> 234 195 235