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 // G4ParticlePropertyTable class implementation 27 // 27 // 28 // Author: H.Kurashige, 9 June 2003 - First im 28 // Author: H.Kurashige, 9 June 2003 - First implementation 29 // ------------------------------------------- 29 // -------------------------------------------------------------------- 30 30 31 #include "G4ParticlePropertyTable.hh" << 32 << 33 #include "G4ParticleTable.hh" << 34 #include "G4StateManager.hh" << 35 #include "G4ios.hh" 31 #include "G4ios.hh" 36 #include "globals.hh" 32 #include "globals.hh" >> 33 #include "G4StateManager.hh" >> 34 #include "G4ParticleTable.hh" >> 35 #include "G4ParticlePropertyTable.hh" 37 36 38 // Static class variable: ptr to single instan 37 // Static class variable: ptr to single instance of class 39 // 38 // 40 G4ThreadLocal G4ParticlePropertyTable* G4Parti << 39 G4ThreadLocal G4ParticlePropertyTable* >> 40 G4ParticlePropertyTable::fgParticlePropertyTable = nullptr; 41 41 >> 42 // -------------------------------------------------------------------- 42 G4ParticlePropertyTable* G4ParticlePropertyTab 43 G4ParticlePropertyTable* G4ParticlePropertyTable::GetParticlePropertyTable() 43 { 44 { 44 if (fgParticlePropertyTable == nullptr) { << 45 if (fgParticlePropertyTable == nullptr) 45 fgParticlePropertyTable = new G4ParticlePr << 46 { >> 47 fgParticlePropertyTable = new G4ParticlePropertyTable; 46 } 48 } 47 return fgParticlePropertyTable; 49 return fgParticlePropertyTable; 48 } 50 } 49 51 >> 52 // -------------------------------------------------------------------- 50 G4ParticlePropertyTable::~G4ParticlePropertyTa 53 G4ParticlePropertyTable::~G4ParticlePropertyTable() 51 { 54 { 52 for (const auto& idx : arrayDataObject) { << 55 for (std::size_t idx=0; idx<arrayDataObject.size(); ++idx) 53 delete idx; << 56 { >> 57 delete arrayDataObject[idx]; 54 } 58 } 55 arrayDataObject.clear(); 59 arrayDataObject.clear(); 56 } 60 } 57 61 >> 62 // -------------------------------------------------------------------- 58 G4ParticlePropertyTable::G4ParticlePropertyTab 63 G4ParticlePropertyTable::G4ParticlePropertyTable() 59 { 64 { 60 fParticleTable = G4ParticleTable::GetParticl << 65 fParticleTable = G4ParticleTable::GetParticleTable(); 61 } 66 } 62 << 67 >> 68 // -------------------------------------------------------------------- 63 void G4ParticlePropertyTable::Clear() 69 void G4ParticlePropertyTable::Clear() 64 { 70 { 65 for (const auto& idx : arrayDataObject) { << 71 for (std::size_t idx=0; idx<arrayDataObject.size(); ++idx) 66 delete idx; << 72 { >> 73 delete arrayDataObject[idx]; 67 } 74 } 68 arrayDataObject.clear(); 75 arrayDataObject.clear(); 69 } 76 } 70 77 71 G4ParticlePropertyData* G4ParticlePropertyTabl << 78 // -------------------------------------------------------------------- >> 79 G4ParticlePropertyData* >> 80 G4ParticlePropertyTable::GetParticleProperty(const G4String& aParticleName) 72 { 81 { 73 G4ParticleDefinition* aParticle = fParticleT 82 G4ParticleDefinition* aParticle = fParticleTable->FindParticle(aParticleName); 74 if (aParticle == nullptr) return nullptr; << 83 if (aParticle == nullptr ) return nullptr; 75 84 76 return GetParticleProperty(aParticle); 85 return GetParticleProperty(aParticle); 77 } 86 } 78 87 79 G4ParticlePropertyData* << 88 // -------------------------------------------------------------------- 80 G4ParticlePropertyTable::GetParticleProperty(c << 89 G4ParticlePropertyData* G4ParticlePropertyTable:: 81 { << 90 GetParticleProperty(const G4ParticleDefinition* aParticle) 82 if (aParticle == nullptr) return nullptr; << 91 { 83 auto pData = new G4ParticlePropertyData(aPar << 92 if (aParticle == nullptr ) return nullptr; 84 pData->thePDGMass = aParticle->GetPDGMass(); << 93 G4ParticlePropertyData* pData 85 pData->thePDGWidth = aParticle->GetPDGWidth( << 94 = new G4ParticlePropertyData(aParticle->GetParticleName()); 86 pData->thePDGCharge = aParticle->GetPDGCharg << 95 pData->thePDGMass = aParticle->GetPDGMass(); 87 pData->thePDGiSpin = aParticle->GetPDGiSpin( << 96 pData->thePDGWidth = aParticle->GetPDGWidth(); 88 pData->thePDGiParity = aParticle->GetPDGiPar << 97 pData->thePDGCharge = aParticle->GetPDGCharge(); 89 pData->thePDGiConjugation = aParticle->GetPD << 98 pData->thePDGiSpin = aParticle->GetPDGiSpin(); 90 pData->thePDGiGParity = aParticle->GetPDGiGP << 99 pData->thePDGiParity = aParticle->GetPDGiParity(); 91 pData->thePDGiIsospin = aParticle->GetPDGiIs << 100 pData->thePDGiConjugation = aParticle->GetPDGiConjugation(); 92 pData->thePDGiIsospin3 = aParticle->GetPDGiI << 101 pData->thePDGiGParity = aParticle->GetPDGiGParity(); 93 pData->thePDGMagneticMoment = aParticle->Get << 102 pData->thePDGiIsospin = aParticle->GetPDGiIsospin(); 94 pData->theLeptonNumber = aParticle->GetLepto << 103 pData->thePDGiIsospin3 = aParticle->GetPDGiIsospin3(); 95 pData->theBaryonNumber = aParticle->GetBaryo << 104 pData->thePDGMagneticMoment = aParticle->GetPDGMagneticMoment(); 96 pData->thePDGEncoding = aParticle->GetPDGEnc << 105 pData->theLeptonNumber = aParticle->GetLeptonNumber(); 97 pData->theAntiPDGEncoding = aParticle->GetAn << 106 pData->theBaryonNumber = aParticle->GetBaryonNumber(); 98 pData->thePDGLifeTime = aParticle->GetPDGLif << 107 pData->thePDGEncoding = aParticle->GetPDGEncoding(); 99 for (std::size_t flv = 0; flv < G4ParticlePr << 108 pData->theAntiPDGEncoding = aParticle->GetAntiPDGEncoding(); 100 pData->theQuarkContent[flv] = aParticle->t << 109 pData->thePDGLifeTime = aParticle->GetPDGLifeTime(); >> 110 for (std::size_t flv=0; >> 111 flv<G4ParticlePropertyData::NumberOfQuarkFlavor; ++flv) >> 112 { >> 113 pData->theQuarkContent[flv] = aParticle->theQuarkContent[flv]; 101 pData->theAntiQuarkContent[flv] = aParticl 114 pData->theAntiQuarkContent[flv] = aParticle->theAntiQuarkContent[flv]; 102 } 115 } 103 116 104 arrayDataObject.push_back(pData); 117 arrayDataObject.push_back(pData); 105 << 118 106 return pData; 119 return pData; 107 } 120 } 108 121 109 G4bool G4ParticlePropertyTable::SetParticlePro << 122 // -------------------------------------------------------------------- >> 123 G4bool G4ParticlePropertyTable:: >> 124 SetParticleProperty(const G4ParticlePropertyData& pData) 110 { 125 { 111 G4StateManager* pStateMan = G4StateManager:: 126 G4StateManager* pStateMan = G4StateManager::GetStateManager(); 112 if (pStateMan->GetCurrentState() != G4State_ << 127 if (pStateMan->GetCurrentState() != G4State_PreInit) >> 128 { 113 #ifdef G4VERBOSE 129 #ifdef G4VERBOSE 114 if (verboseLevel > 0) { << 130 if (verboseLevel>0) >> 131 { 115 G4cout << "G4ParticlePropertyTable::GetP 132 G4cout << "G4ParticlePropertyTable::GetParticleProperty() "; 116 G4cout << " for " << pData.theParticleNa 133 G4cout << " for " << pData.theParticleName << G4endl; 117 G4cout << " Particle properties can be m 134 G4cout << " Particle properties can be modified only in Pre_Init state"; 118 G4cout << G4endl; 135 G4cout << G4endl; 119 } 136 } 120 #endif 137 #endif 121 return false; 138 return false; 122 } << 139 } 123 140 124 G4ParticleDefinition* aParticle = fParticleT << 141 G4ParticleDefinition* aParticle 125 if (aParticle == nullptr) { << 142 = fParticleTable->FindParticle(pData.theParticleName); >> 143 if (aParticle == nullptr ) >> 144 { 126 #ifdef G4VERBOSE 145 #ifdef G4VERBOSE 127 if (verboseLevel > 1) { << 146 if (verboseLevel>1) >> 147 { 128 G4cout << "G4ParticlePropertyTable::GetP 148 G4cout << "G4ParticlePropertyTable::GetParticleProperty() "; 129 G4cout << " for " << pData.theParticleNa 149 G4cout << " for " << pData.theParticleName << G4endl; 130 G4cout << " Particle does not exist" << 150 G4cout << " Particle does not exist" << G4endl; 131 } 151 } 132 #endif 152 #endif 133 return false; 153 return false; 134 } 154 } 135 155 136 if (pData.fPDGMassModified) { << 156 if (pData.fPDGMassModified) { 137 aParticle->thePDGMass = pData.thePDGMass; 157 aParticle->thePDGMass = pData.thePDGMass; 138 } 158 } 139 if (pData.fPDGWidthModified) { 159 if (pData.fPDGWidthModified) { 140 aParticle->thePDGMass = pData.thePDGMass; 160 aParticle->thePDGMass = pData.thePDGMass; 141 } 161 } 142 if (pData.fPDGChargeModified) { 162 if (pData.fPDGChargeModified) { 143 aParticle->thePDGCharge = pData.thePDGChar << 163 aParticle->thePDGCharge = pData.thePDGCharge; 144 } 164 } 145 if (pData.fPDGiSpinModified) { 165 if (pData.fPDGiSpinModified) { 146 aParticle->thePDGiSpin = pData.thePDGiSpin 166 aParticle->thePDGiSpin = pData.thePDGiSpin; 147 aParticle->thePDGSpin = 0.5 * pData.thePDG << 167 aParticle->thePDGSpin = 0.5*pData.thePDGiSpin; 148 } 168 } 149 if (pData.fPDGiParityModified) { 169 if (pData.fPDGiParityModified) { 150 aParticle->thePDGiParity = pData.thePDGiPa 170 aParticle->thePDGiParity = pData.thePDGiParity; 151 } 171 } 152 if (pData.fPDGiConjugationModified) { 172 if (pData.fPDGiConjugationModified) { 153 aParticle->thePDGiConjugation = pData.theP 173 aParticle->thePDGiConjugation = pData.thePDGiConjugation; 154 } 174 } 155 if (pData.fPDGiGParityModified) { 175 if (pData.fPDGiGParityModified) { 156 aParticle->thePDGiGParity = pData.thePDGiG 176 aParticle->thePDGiGParity = pData.thePDGiGParity; 157 } 177 } 158 if (pData.fPDGiIsospinModified) { 178 if (pData.fPDGiIsospinModified) { 159 aParticle->thePDGiIsospin = pData.thePDGiI 179 aParticle->thePDGiIsospin = pData.thePDGiIsospin; 160 aParticle->thePDGIsospin = 0.5 * pData.the << 180 aParticle->thePDGIsospin = 0.5*pData.thePDGiIsospin; 161 } 181 } 162 if (pData.fPDGiIsospin3Modified) { 182 if (pData.fPDGiIsospin3Modified) { 163 aParticle->thePDGiIsospin3 = pData.thePDGi 183 aParticle->thePDGiIsospin3 = pData.thePDGiIsospin3; 164 aParticle->thePDGIsospin3 = 0.5 * pData.th << 184 aParticle->thePDGIsospin3 = 0.5*pData.thePDGiIsospin3; 165 } 185 } 166 if (pData.fPDGMagneticMomentModified) { 186 if (pData.fPDGMagneticMomentModified) { 167 aParticle->thePDGMagneticMoment = pData.th 187 aParticle->thePDGMagneticMoment = pData.thePDGMagneticMoment; 168 } << 188 } 169 if (pData.fLeptonNumberModified) { 189 if (pData.fLeptonNumberModified) { 170 aParticle->theLeptonNumber = pData.theLept << 190 aParticle->theLeptonNumber = pData.theLeptonNumber; 171 } 191 } 172 if (pData.fBaryonNumberModified) { 192 if (pData.fBaryonNumberModified) { 173 aParticle->theBaryonNumber = pData.theBary << 193 aParticle->theBaryonNumber = pData.theBaryonNumber; 174 } 194 } 175 if (pData.fPDGEncodingModified) { 195 if (pData.fPDGEncodingModified) { 176 aParticle->thePDGEncoding = pData.thePDGEn << 196 aParticle->thePDGEncoding = pData.thePDGEncoding; 177 } 197 } 178 if (pData.fAntiPDGEncodingModified) { 198 if (pData.fAntiPDGEncodingModified) { 179 aParticle->theAntiPDGEncoding = pData.theA << 199 aParticle->theAntiPDGEncoding = pData.theAntiPDGEncoding; 180 } 200 } 181 if (pData.fPDGLifeTimeModified) { 201 if (pData.fPDGLifeTimeModified) { 182 aParticle->thePDGLifeTime = pData.thePDGLi << 202 aParticle->thePDGLifeTime = pData.thePDGLifeTime; 183 } 203 } 184 for (std::size_t flv = 0; flv < G4ParticlePr << 204 for (std::size_t flv=0; 185 if (pData.fQuarkContentModified) { << 205 flv<G4ParticlePropertyData::NumberOfQuarkFlavor; ++flv) >> 206 { >> 207 if (pData.fQuarkContentModified) >> 208 { 186 aParticle->theQuarkContent[flv] = pData. 209 aParticle->theQuarkContent[flv] = pData.theQuarkContent[flv]; 187 } 210 } 188 if (pData.fAntiQuarkContentModified) { << 211 if (pData.fAntiQuarkContentModified) >> 212 { 189 aParticle->theAntiQuarkContent[flv] = pD 213 aParticle->theAntiQuarkContent[flv] = pData.theAntiQuarkContent[flv]; 190 } 214 } 191 } 215 } 192 << 216 193 return true; 217 return true; 194 } 218 } 195 219