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