[824] | 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 | // |
---|
[1196] | 27 | // $Id: G4IonTable.cc,v 1.60 2009/09/23 12:13:48 kurasige Exp $ |
---|
| 28 | // GEANT4 tag $Name: geant4-09-03-cand-01 $ |
---|
[824] | 29 | // |
---|
| 30 | // |
---|
| 31 | // -------------------------------------------------------------- |
---|
| 32 | // GEANT 4 class implementation file |
---|
| 33 | // |
---|
| 34 | // History: first implementation, based on object model of |
---|
| 35 | // 27 June 1998 H.Kurashige |
---|
| 36 | // --------------------------------------------------------------- |
---|
| 37 | // modified GetIon 02 Aug., 98 H.Kurashige |
---|
| 38 | // added Remove() 06 Nov.,98 H.Kurashige |
---|
| 39 | // use G4NucleiPropoerties to get nuceli Mass 17 Nov.,98 H.Kurashige |
---|
| 40 | // use G4GenericIon for process List |
---|
| 41 | // modify fomula of Ion mass 09 Dec., 98 H.Kurashige |
---|
| 42 | // ----- |
---|
| 43 | // Modified GetIon methods 17 Aug. 99 H.Kurashige |
---|
| 44 | // New design using G4VIsotopeTable 5 Oct. 99 H.Kurashige |
---|
| 45 | // Modified Element Name for Z>103 06 Apr. 01 H.Kurashige |
---|
| 46 | // Remove test of cuts in SetCuts 16 Jan 03 V.Ivanchenko |
---|
| 47 | |
---|
| 48 | #include "G4IonTable.hh" |
---|
| 49 | #include "G4ParticleTable.hh" |
---|
| 50 | #include "G4StateManager.hh" |
---|
| 51 | #include "G4Ions.hh" |
---|
| 52 | #include "G4UImanager.hh" |
---|
| 53 | #include "G4NucleiProperties.hh" |
---|
| 54 | #include "G4HyperNucleiProperties.hh" |
---|
| 55 | |
---|
| 56 | #include "G4IsotopeProperty.hh" |
---|
| 57 | #include "G4VIsotopeTable.hh" |
---|
| 58 | |
---|
| 59 | #include "G4ios.hh" |
---|
| 60 | #include <iostream> |
---|
| 61 | #include <iomanip> |
---|
| 62 | |
---|
| 63 | #include <sstream> |
---|
| 64 | |
---|
| 65 | |
---|
| 66 | //////////////////// |
---|
| 67 | G4IonTable::G4IonTable() |
---|
| 68 | { |
---|
| 69 | fIonList = new G4IonList(); |
---|
| 70 | fIsotopeTableList = new std::vector<G4VIsotopeTable*>; |
---|
| 71 | } |
---|
| 72 | |
---|
| 73 | //////////////////// |
---|
| 74 | G4IonTable::~G4IonTable() |
---|
| 75 | { |
---|
| 76 | // delete IsotopeTable if exists |
---|
| 77 | if (fIsotopeTableList != 0) { |
---|
| 78 | for (size_t i = 0; i< fIsotopeTableList->size(); ++i) { |
---|
| 79 | G4VIsotopeTable* fIsotopeTable= (*fIsotopeTableList)[i]; |
---|
| 80 | delete fIsotopeTable; |
---|
| 81 | } |
---|
| 82 | fIsotopeTableList->clear(); |
---|
[850] | 83 | delete fIsotopeTableList; |
---|
[824] | 84 | } |
---|
| 85 | fIsotopeTableList =0; |
---|
| 86 | |
---|
| 87 | |
---|
| 88 | if (fIonList ==0) return; |
---|
| 89 | // remove all contents in the Ion List |
---|
| 90 | // No need to delete here because all particles are dynamic objects |
---|
| 91 | fIonList->clear(); |
---|
| 92 | |
---|
| 93 | delete fIonList; |
---|
| 94 | fIonList =0; |
---|
| 95 | } |
---|
| 96 | |
---|
| 97 | |
---|
| 98 | //////////////////// |
---|
| 99 | // -- CreateIon method ------ |
---|
| 100 | //////////////////// |
---|
| 101 | G4ParticleDefinition* G4IonTable::CreateIon(G4int Z, G4int A, |
---|
| 102 | G4double E, G4int J) |
---|
| 103 | { |
---|
| 104 | G4ParticleDefinition* ion=0; |
---|
| 105 | |
---|
| 106 | // check whether the cuurent state is not "PreInit" |
---|
| 107 | // to make sure that GenericIon has processes |
---|
| 108 | G4ApplicationState currentState = G4StateManager::GetStateManager()->GetCurrentState(); |
---|
| 109 | if (currentState == G4State_PreInit){ |
---|
| 110 | #ifdef G4VERBOSE |
---|
| 111 | if (GetVerboseLevel()>1) { |
---|
| 112 | G4cout << "G4IonTable::CreateIon() : can not create ion of "; |
---|
| 113 | G4cout << " Z =" << Z << " A = " << A << G4endl; |
---|
| 114 | G4cout << " because the current state is PreInit !!" << G4endl; |
---|
| 115 | } |
---|
| 116 | #endif |
---|
| 117 | G4Exception( "G4IonTable::CreateIon()","Illegal operation", |
---|
| 118 | JustWarning, "Can not create ions in PreInit state"); |
---|
| 119 | return 0; |
---|
| 120 | } |
---|
| 121 | |
---|
| 122 | // get ion name |
---|
| 123 | G4String name = GetIonName(Z, A, E); |
---|
| 124 | if ( name(0) == '?') { |
---|
| 125 | #ifdef G4VERBOSE |
---|
| 126 | if (GetVerboseLevel()>0) { |
---|
| 127 | G4cout << "G4IonTable::CreateIon() : can not create ions " << G4endl; |
---|
| 128 | G4cout << " Z =" << Z << " A = " << A << G4endl; |
---|
| 129 | } |
---|
| 130 | #endif |
---|
[1196] | 131 | return 0; |
---|
[824] | 132 | } |
---|
| 133 | |
---|
| 134 | G4double life = -1.0; |
---|
| 135 | G4DecayTable* decayTable =0; |
---|
| 136 | G4bool stable = true; |
---|
| 137 | G4double mu = 0.0; |
---|
| 138 | |
---|
[1196] | 139 | const G4IsotopeProperty* fProperty = FindIsotope(Z, A, E, J); |
---|
[824] | 140 | if (fProperty !=0 ){ |
---|
| 141 | E = fProperty->GetEnergy(); |
---|
| 142 | J = fProperty->GetiSpin(); |
---|
| 143 | life = fProperty->GetLifeTime(); |
---|
| 144 | mu = fProperty->GetMagneticMoment(); |
---|
| 145 | decayTable = fProperty->GetDecayTable(); |
---|
| 146 | } |
---|
| 147 | stable = life <= 0.; |
---|
| 148 | G4double mass = GetNucleusMass(Z, A)+ E; |
---|
| 149 | G4double charge = G4double(Z)*eplus; |
---|
| 150 | |
---|
| 151 | G4int encoding = GetNucleusEncoding(Z,A,E,J); |
---|
| 152 | |
---|
| 153 | // create an ion |
---|
| 154 | // spin, parity, isospin values are fixed |
---|
| 155 | // |
---|
| 156 | ion = new G4Ions( name, mass, 0.0*MeV, charge, |
---|
| 157 | J, +1, 0, |
---|
| 158 | 0, 0, 0, |
---|
| 159 | "nucleus", 0, A, encoding, |
---|
| 160 | stable, life, decayTable, false, |
---|
| 161 | "generic", 0, |
---|
| 162 | E ); |
---|
| 163 | ion->SetPDGMagneticMoment(mu); |
---|
| 164 | |
---|
| 165 | //No Anti particle registered |
---|
| 166 | ion->SetAntiPDGEncoding(0); |
---|
| 167 | |
---|
| 168 | #ifdef G4VERBOSE |
---|
[1196] | 169 | if (GetVerboseLevel()>1) { |
---|
| 170 | G4cout << "G4IonTable::CreateIon() : create ion of " << name |
---|
| 171 | << " " << Z << ", " << A |
---|
| 172 | << " encoding=" << encoding << G4endl; |
---|
[824] | 173 | } |
---|
| 174 | #endif |
---|
| 175 | |
---|
| 176 | // Add process manager to the ion |
---|
| 177 | AddProcessManager(name); |
---|
[1196] | 178 | |
---|
[824] | 179 | return ion; |
---|
| 180 | } |
---|
| 181 | |
---|
| 182 | |
---|
| 183 | //////////////////// |
---|
| 184 | G4ParticleDefinition* G4IonTable::CreateIon(G4int Z, G4int A, G4int L, |
---|
| 185 | G4double E, G4int J) |
---|
| 186 | { |
---|
| 187 | if (L==0) return CreateIon(A,Z,E,J); |
---|
| 188 | |
---|
| 189 | // create hyper nucleus |
---|
| 190 | G4ParticleDefinition* ion=0; |
---|
| 191 | |
---|
| 192 | // check whether the cuurent state is not "PreInit" |
---|
| 193 | // to make sure that GenericIon has processes |
---|
| 194 | G4ApplicationState currentState = G4StateManager::GetStateManager()->GetCurrentState(); |
---|
| 195 | if (currentState == G4State_PreInit){ |
---|
| 196 | #ifdef G4VERBOSE |
---|
| 197 | if (GetVerboseLevel()>1) { |
---|
| 198 | G4cout << "G4IonTable::CreateIon() : can not create ion of "; |
---|
| 199 | G4cout << " Z =" << Z << " A = " << A << " L = " <<L << G4endl; |
---|
| 200 | G4cout << " because the current state is PreInit !!" << G4endl; |
---|
| 201 | } |
---|
| 202 | #endif |
---|
| 203 | G4Exception( "G4IonTable::CreateIon()","Illegal operation", |
---|
| 204 | JustWarning, "Can not create ions in PreInit state"); |
---|
| 205 | return 0; |
---|
| 206 | } |
---|
| 207 | |
---|
| 208 | // get ion name |
---|
| 209 | G4String name = GetIonName(Z, A, L, E); |
---|
| 210 | if ( name(L) == '?') { |
---|
| 211 | #ifdef G4VERBOSE |
---|
| 212 | if (GetVerboseLevel()>0) { |
---|
| 213 | G4cout << "G4IonTable::CreateIon() : can not create ions " << G4endl; |
---|
| 214 | G4cout << " Z =" << Z << " A = " << A << " L = " << L << G4endl; |
---|
| 215 | } |
---|
| 216 | #endif |
---|
| 217 | return 0; |
---|
| 218 | } |
---|
| 219 | |
---|
| 220 | G4double life = -1.0; |
---|
| 221 | G4DecayTable* decayTable =0; |
---|
| 222 | G4bool stable = true; |
---|
| 223 | G4double mu = 0.0; |
---|
| 224 | G4double mass = GetNucleusMass(Z, A, L)+ E; |
---|
| 225 | G4double charge = G4double(Z)*eplus; |
---|
| 226 | |
---|
| 227 | G4int encoding = GetNucleusEncoding(Z,A,L,E,J); |
---|
| 228 | |
---|
| 229 | // create an ion |
---|
| 230 | // spin, parity, isospin values are fixed |
---|
| 231 | // |
---|
| 232 | ion = new G4Ions( name, mass, 0.0*MeV, charge, |
---|
| 233 | J, +1, 0, |
---|
| 234 | 0, 0, 0, |
---|
| 235 | "nucleus", 0, A, encoding, |
---|
| 236 | stable, life, decayTable, false, |
---|
| 237 | "generic", 0, |
---|
| 238 | E ); |
---|
| 239 | ion->SetPDGMagneticMoment(mu); |
---|
| 240 | |
---|
| 241 | //No Anti particle registered |
---|
| 242 | ion->SetAntiPDGEncoding(0); |
---|
| 243 | |
---|
| 244 | #ifdef G4VERBOSE |
---|
| 245 | if (GetVerboseLevel()>1) { |
---|
[1196] | 246 | G4cout << "G4IonTable::CreateIon() : create hyper ion of " << name |
---|
| 247 | << " encoding=" << encoding << G4endl; |
---|
[824] | 248 | } |
---|
| 249 | #endif |
---|
| 250 | |
---|
| 251 | // Add process manager to the ion |
---|
| 252 | AddProcessManager(name); |
---|
| 253 | |
---|
| 254 | return ion; |
---|
| 255 | } |
---|
| 256 | |
---|
| 257 | //////////////////// |
---|
| 258 | // -- GetIon methods ------ |
---|
| 259 | //////////////////// |
---|
| 260 | G4ParticleDefinition* G4IonTable::GetIon(G4int Z, G4int A, G4int , G4int ) |
---|
| 261 | { |
---|
| 262 | return GetIon(Z, A); |
---|
| 263 | } |
---|
| 264 | |
---|
| 265 | //////////////////// |
---|
| 266 | G4ParticleDefinition* G4IonTable::GetIon(G4int Z, G4int A, G4int J) |
---|
| 267 | { |
---|
| 268 | return GetIon( Z, A, 0.0, J); |
---|
| 269 | } |
---|
| 270 | |
---|
| 271 | //////////////////// |
---|
| 272 | G4ParticleDefinition* G4IonTable::GetIon(G4int encoding) |
---|
| 273 | { |
---|
| 274 | G4int Z, A, L, J; |
---|
| 275 | G4double E; |
---|
| 276 | if (!GetNucleusByEncoding(encoding,Z,A,L,E,J) ){ |
---|
| 277 | #ifdef G4VERBOSE |
---|
| 278 | if (GetVerboseLevel()>0) { |
---|
| 279 | G4cout << "G4IonTable::GetIon() : illegal encoding" << G4endl; |
---|
| 280 | G4cout << " CODE:" << encoding << G4endl; |
---|
| 281 | } |
---|
| 282 | #endif |
---|
| 283 | G4Exception( "G4IonTable::GetIon()","Illegal operation", |
---|
| 284 | JustWarning, "illegal encoding"); |
---|
| 285 | return 0; |
---|
| 286 | } |
---|
| 287 | // Only ground state is supported |
---|
| 288 | return GetIon( Z, A, L, 0.0, J); |
---|
| 289 | } |
---|
| 290 | |
---|
| 291 | //////////////////// |
---|
| 292 | G4ParticleDefinition* G4IonTable::GetIon(G4int Z, G4int A, G4double E, G4int J) |
---|
| 293 | { |
---|
| 294 | if ( (A<1) || (Z<=0) || (J<0) || (E<0.0) || (A>999) ) { |
---|
| 295 | #ifdef G4VERBOSE |
---|
| 296 | if (GetVerboseLevel()>0) { |
---|
| 297 | G4cout << "G4IonTable::GetIon() : illegal atomic number/mass" << G4endl; |
---|
| 298 | G4cout << " Z =" << Z << " A = " << A << " E = " << E/keV << G4endl; |
---|
| 299 | } |
---|
| 300 | #endif |
---|
| 301 | return 0; |
---|
| 302 | } |
---|
| 303 | |
---|
| 304 | // Search ions with A, Z |
---|
| 305 | G4ParticleDefinition* ion = FindIon(Z,A,E,J); |
---|
| 306 | |
---|
| 307 | // create ion |
---|
| 308 | if (ion == 0) { |
---|
| 309 | ion = CreateIon(Z, A, E, J); |
---|
| 310 | } |
---|
| 311 | |
---|
| 312 | return ion; |
---|
| 313 | } |
---|
| 314 | |
---|
| 315 | //////////////////// |
---|
| 316 | G4ParticleDefinition* G4IonTable::GetIon(G4int Z, G4int A, G4int L, G4double E, G4int J) |
---|
| 317 | { |
---|
| 318 | if (L==0) return GetIon(Z,A,E,J); |
---|
| 319 | |
---|
| 320 | if (A < 2 || Z < 0 || Z > A-L || L>A || A>999 ) { |
---|
| 321 | #ifdef G4VERBOSE |
---|
| 322 | if (GetVerboseLevel()>0) { |
---|
| 323 | G4cout << "G4IonTable::GetIon() : illegal atomic number/mass" << G4endl; |
---|
| 324 | G4cout << " Z =" << Z << " A = " << A << " L = " << L |
---|
| 325 | <<" E = " << E/keV << G4endl; |
---|
| 326 | } |
---|
| 327 | #endif |
---|
| 328 | return 0; |
---|
| 329 | } else if( A==2 ) { |
---|
| 330 | #ifdef G4VERBOSE |
---|
| 331 | if (GetVerboseLevel()>0) { |
---|
| 332 | G4cout << "G4IonTable::GetIon() : No boud state for " << G4endl; |
---|
| 333 | G4cout << " Z =" << Z << " A = " << A << " L = " << L |
---|
| 334 | << " E = " << E/keV << G4endl; |
---|
| 335 | } |
---|
| 336 | #endif |
---|
| 337 | return 0; |
---|
| 338 | } |
---|
| 339 | |
---|
| 340 | // Search ions with A, Z |
---|
| 341 | G4ParticleDefinition* ion = FindIon(Z,A,L,E,J); |
---|
| 342 | |
---|
| 343 | // create ion |
---|
| 344 | if (ion == 0) { |
---|
| 345 | ion = CreateIon(Z, A, L, E, J); |
---|
| 346 | } |
---|
| 347 | |
---|
| 348 | return ion; |
---|
| 349 | } |
---|
| 350 | |
---|
| 351 | //////////////////// |
---|
| 352 | G4ParticleDefinition* G4IonTable::FindIon(G4int Z, G4int A, G4double E, G4int J) |
---|
| 353 | { |
---|
| 354 | const G4double EnergyTorelance = 0.1 * keV; |
---|
| 355 | |
---|
| 356 | if ( (A<1) || (Z<=0) || (J<0) || (E<0.0) || (A>999) ) { |
---|
| 357 | #ifdef G4VERBOSE |
---|
| 358 | if (GetVerboseLevel()>0) { |
---|
| 359 | G4cout << "G4IonTable::FindIon() : illegal atomic number/mass or excitation level " << G4endl; |
---|
| 360 | G4cout << " Z =" << Z << " A = " << A << " E = " << E/keV << G4endl; |
---|
| 361 | } |
---|
| 362 | #endif |
---|
| 363 | G4Exception( "G4IonTable::FindIon()","Illegal operation", |
---|
| 364 | JustWarning, "illegal atomic number/mass"); |
---|
| 365 | return 0; |
---|
| 366 | } |
---|
| 367 | // Search ions with A, Z ,E |
---|
| 368 | // !! J is omitted now !! |
---|
| 369 | G4ParticleDefinition* ion=0; |
---|
| 370 | G4bool isFound = false; |
---|
| 371 | |
---|
| 372 | // -- loop over all particles in Ion table |
---|
[1196] | 373 | G4int encoding=GetNucleusEncoding(Z, A, 0); |
---|
| 374 | G4IonList::iterator i = fIonList->find(encoding); |
---|
| 375 | for( ;i != fIonList->end() ; i++) { |
---|
| 376 | ion = i->second; |
---|
| 377 | if ( ( ion->GetAtomicNumber() != Z) || (ion->GetAtomicMass()!=A) ) break; |
---|
[824] | 378 | |
---|
| 379 | // excitation level |
---|
| 380 | G4double anExcitaionEnergy = ((const G4Ions*)(ion))->GetExcitationEnergy(); |
---|
[1196] | 381 | if ( ( std::fabs(E - anExcitaionEnergy ) < EnergyTorelance ) ) { |
---|
[824] | 382 | isFound = true; |
---|
| 383 | break; |
---|
| 384 | } |
---|
| 385 | } |
---|
| 386 | |
---|
| 387 | if ( isFound ){ |
---|
| 388 | return ion; |
---|
| 389 | } else { |
---|
| 390 | return 0; |
---|
| 391 | } |
---|
| 392 | } |
---|
| 393 | |
---|
| 394 | |
---|
| 395 | //////////////////// |
---|
| 396 | G4ParticleDefinition* G4IonTable::FindIon(G4int Z, G4int A, G4int L, G4double E, G4int J) |
---|
| 397 | { |
---|
| 398 | if (L==0) return FindIon(Z,A,E,J); |
---|
| 399 | |
---|
| 400 | const G4double EnergyTorelance = 0.1 * keV; |
---|
| 401 | |
---|
| 402 | if (A < 2 || Z < 0 || Z > A-L || L>A || A>999 ) { |
---|
| 403 | #ifdef G4VERBOSE |
---|
| 404 | if (GetVerboseLevel()>0) { |
---|
| 405 | G4cout << "G4IonTable::FindIon() : illegal atomic number/mass or excitation level " << G4endl; |
---|
| 406 | G4cout << " Z =" << Z << " A = " << A << " L = " << L |
---|
| 407 | <<" E = " << E/keV << G4endl; |
---|
| 408 | } |
---|
| 409 | #endif |
---|
| 410 | G4Exception( "G4IonTable::FindIon()","Illegal operation", |
---|
| 411 | JustWarning, "illegal atomic number/mass"); |
---|
| 412 | return 0; |
---|
| 413 | } |
---|
| 414 | // Search ions with A, Z ,E |
---|
| 415 | // !! J is omitted now !! |
---|
| 416 | G4ParticleDefinition* ion=0; |
---|
| 417 | G4bool isFound = false; |
---|
| 418 | |
---|
| 419 | // -- loop over all particles in Ion table |
---|
[1196] | 420 | G4int encoding=GetNucleusEncoding(Z, A, L); |
---|
| 421 | G4IonList::iterator i = fIonList->find(encoding); |
---|
| 422 | for( ;i != fIonList->end() ; i++) { |
---|
| 423 | ion = i->second; |
---|
| 424 | if ( ( ion->GetAtomicNumber() != Z) || (ion->GetAtomicMass()!=A) ) break; |
---|
| 425 | if( ion->GetQuarkContent(3) != L) break; |
---|
[824] | 426 | |
---|
| 427 | // excitation level |
---|
| 428 | G4double anExcitaionEnergy = ((const G4Ions*)(ion))->GetExcitationEnergy(); |
---|
| 429 | |
---|
[1196] | 430 | if ( ( std::fabs(E - anExcitaionEnergy ) < EnergyTorelance ) ) { |
---|
[824] | 431 | isFound = true; |
---|
| 432 | break; |
---|
| 433 | } |
---|
| 434 | } |
---|
| 435 | |
---|
| 436 | if ( isFound ){ |
---|
| 437 | return ion; |
---|
| 438 | } else { |
---|
| 439 | return 0; |
---|
| 440 | } |
---|
| 441 | } |
---|
| 442 | |
---|
| 443 | |
---|
| 444 | ///////////////// |
---|
| 445 | G4int G4IonTable::GetNucleusEncoding(G4int Z, G4int A, G4double E, G4int ) |
---|
| 446 | { |
---|
[1196] | 447 | // PDG code for Ions |
---|
| 448 | // Nuclear codes are given as 10-digit numbers +-100ZZZAAAI. |
---|
| 449 | //For a nucleus consisting of np protons and nn neutrons |
---|
| 450 | // A = np + nn and Z = np. |
---|
| 451 | // I gives the isomer level, with I = 0 corresponding |
---|
| 452 | // to the ground state and I >0 to excitations |
---|
| 453 | |
---|
| 454 | //!!! I = 1 is assigned fo all excitation states !!! |
---|
| 455 | const G4double EnergyTorelance = 0.1 * keV; |
---|
| 456 | if ( Z==1 && A==1 && E< EnergyTorelance ) { |
---|
| 457 | //proton |
---|
| 458 | return 2212; |
---|
| 459 | } |
---|
| 460 | |
---|
[824] | 461 | G4int encoding = 1000000000; |
---|
| 462 | encoding += Z * 10000; |
---|
| 463 | encoding += A *10; |
---|
| 464 | if (E>0.0) encoding += 1; |
---|
| 465 | |
---|
| 466 | return encoding; |
---|
| 467 | } |
---|
| 468 | |
---|
| 469 | ///////////////// |
---|
| 470 | G4int G4IonTable::GetNucleusEncoding(G4int Z, G4int A, G4int L, |
---|
| 471 | G4double E, G4int ) |
---|
| 472 | { |
---|
| 473 | // get PDG code for Hyper-Nucleus Ions |
---|
| 474 | // Nuclear codes are given as 10-digit numbers +-10LZZZAAAI. |
---|
| 475 | //For a nucleus consisting of np protons and nn neutrons |
---|
| 476 | // A = np + nn +nlambda and Z = np. |
---|
| 477 | // L = nlambda |
---|
| 478 | // I gives the isomer level, with I = 0 corresponding |
---|
| 479 | // to the ground state and I >0 to excitations |
---|
| 480 | // |
---|
| 481 | //!!! I = 1 is assigned fo all excitation states in Geant4 |
---|
| 482 | |
---|
| 483 | G4int encoding = 1000000000; |
---|
| 484 | encoding += L* 10000000; |
---|
| 485 | encoding += Z * 10000; |
---|
| 486 | encoding += A *10; |
---|
| 487 | if (E>0.0) encoding += 1; |
---|
| 488 | |
---|
| 489 | return encoding; |
---|
| 490 | } |
---|
| 491 | |
---|
| 492 | /////////////// |
---|
| 493 | G4bool G4IonTable::GetNucleusByEncoding(G4int encoding, |
---|
| 494 | G4int &Z, G4int &A, |
---|
| 495 | G4double &E, G4int &J) |
---|
| 496 | { |
---|
| 497 | if (encoding <= 0) { |
---|
| 498 | // anti particle |
---|
| 499 | return false; |
---|
[1196] | 500 | } |
---|
| 501 | if (encoding == 2212) { |
---|
| 502 | // proton |
---|
| 503 | Z = 1; |
---|
| 504 | A = 1; |
---|
| 505 | E=0.0; |
---|
| 506 | J=0; |
---|
| 507 | return true; |
---|
[824] | 508 | } |
---|
[1196] | 509 | |
---|
[824] | 510 | if (encoding % 10 != 0) { |
---|
| 511 | //!!!not supported for excitation states !!! |
---|
| 512 | return false; |
---|
| 513 | } |
---|
| 514 | |
---|
| 515 | encoding -= 1000000000; |
---|
| 516 | Z = encoding/10000; |
---|
| 517 | encoding -= 10000*Z; |
---|
| 518 | A = encoding/10; |
---|
| 519 | |
---|
| 520 | E=0.0; |
---|
| 521 | J=0; |
---|
| 522 | |
---|
| 523 | return true; |
---|
| 524 | } |
---|
| 525 | /////////////// |
---|
| 526 | G4bool G4IonTable::GetNucleusByEncoding(G4int encoding, |
---|
| 527 | G4int &Z, G4int &A, |
---|
| 528 | G4int &L, |
---|
| 529 | G4double &E, G4int &J) |
---|
| 530 | { |
---|
| 531 | if (encoding <= 0) { |
---|
| 532 | // anti particle |
---|
| 533 | return false; |
---|
| 534 | } |
---|
| 535 | if (encoding % 10 != 0) { |
---|
| 536 | //!!!not supported for excitation states !!! |
---|
| 537 | return false; |
---|
| 538 | } |
---|
| 539 | if (encoding < 1000000000) { |
---|
| 540 | // anti particle |
---|
| 541 | return false; |
---|
| 542 | } |
---|
| 543 | |
---|
| 544 | encoding -= 1000000000; |
---|
| 545 | L = encoding/10000000; |
---|
| 546 | encoding -= 10000000*L; |
---|
| 547 | Z = encoding/10000; |
---|
| 548 | encoding -= 10000*Z; |
---|
| 549 | A = encoding/10; |
---|
| 550 | |
---|
| 551 | E=0.0; |
---|
| 552 | J=0; |
---|
| 553 | |
---|
| 554 | return true; |
---|
| 555 | } |
---|
| 556 | ///////////////// |
---|
| 557 | const G4String& G4IonTable::GetIonName(G4int Z, G4int A, G4double E) const |
---|
| 558 | { |
---|
| 559 | static G4String name; |
---|
| 560 | name =""; |
---|
| 561 | if ( (0< Z) && (Z <=numberOfElements) ) { |
---|
| 562 | name = elementName[Z-1]; |
---|
| 563 | } else if (Z > numberOfElements) { |
---|
| 564 | std::ostringstream os1; |
---|
| 565 | os1.setf(std::ios::fixed); |
---|
| 566 | os1 << Z ; |
---|
| 567 | name = "E" + os1.str() + "-"; |
---|
| 568 | } else { |
---|
| 569 | name = "?"; |
---|
| 570 | return name; |
---|
| 571 | } |
---|
| 572 | std::ostringstream os; |
---|
| 573 | os.setf(std::ios::fixed); |
---|
| 574 | os << A << '[' << std::setprecision(1) << E/keV << ']'; |
---|
| 575 | name += os.str(); |
---|
| 576 | return name; |
---|
| 577 | } |
---|
| 578 | |
---|
| 579 | ///////////////// |
---|
| 580 | const G4String& G4IonTable::GetIonName(G4int Z, G4int A, G4int L, G4double E) const |
---|
| 581 | { |
---|
| 582 | if (L==0) return GetIonName(Z, A, E); |
---|
| 583 | static G4String name; |
---|
| 584 | name =""; |
---|
| 585 | for (int i =0; i<L; i++){ |
---|
| 586 | name +="L"; |
---|
| 587 | } |
---|
| 588 | name += GetIonName(Z, A, E); |
---|
| 589 | return name; |
---|
| 590 | } |
---|
| 591 | |
---|
| 592 | ///////////////// |
---|
[1196] | 593 | G4bool G4IonTable::IsIon(const G4ParticleDefinition* particle) |
---|
[824] | 594 | { |
---|
| 595 | // return true if the particle is ion |
---|
| 596 | |
---|
[992] | 597 | static G4String nucleus("nucleus"); |
---|
| 598 | static G4String proton("proton"); |
---|
| 599 | |
---|
[1196] | 600 | // neutron is not ion |
---|
| 601 | if ((particle->GetAtomicMass() >0) && (particle->GetAtomicNumber()>0)) return true; |
---|
| 602 | |
---|
[824] | 603 | // particles derived from G4VIon and G4Ions |
---|
[1196] | 604 | if (particle->GetParticleType() == nucleus) return true; |
---|
[824] | 605 | |
---|
| 606 | // proton (Hydrogen nucleus) |
---|
[1196] | 607 | if (particle->GetParticleName() == proton) return true; |
---|
[824] | 608 | |
---|
[1196] | 609 | return false; |
---|
[824] | 610 | } |
---|
| 611 | |
---|
| 612 | ///////////////// |
---|
| 613 | #include <algorithm> |
---|
| 614 | |
---|
| 615 | G4bool G4IonTable::IsLightIon(G4ParticleDefinition* particle) const |
---|
| 616 | { |
---|
| 617 | static const std::string names[] = { "proton", "neutron", "alpha", "deuteron", |
---|
| 618 | "triton", "He3", "GenericIon"}; |
---|
| 619 | |
---|
| 620 | // return true if the particle is pre-defined ion |
---|
| 621 | return std::find(names, names+7, particle->GetParticleName())!=names+7; |
---|
| 622 | } |
---|
| 623 | |
---|
| 624 | ///////////////// |
---|
| 625 | G4ParticleDefinition* G4IonTable::GetLightIon(G4int Z, G4int A) const |
---|
| 626 | { |
---|
| 627 | // returns pointer to pre-defined ions |
---|
[890] | 628 | static G4bool isInitialized = false; |
---|
| 629 | static G4ParticleDefinition* p_proton=0; |
---|
| 630 | static G4ParticleDefinition* p_neutron=0; |
---|
| 631 | static G4ParticleDefinition* p_deuteron=0; |
---|
| 632 | static G4ParticleDefinition* p_triton=0; |
---|
| 633 | static G4ParticleDefinition* p_alpha=0; |
---|
| 634 | static G4ParticleDefinition* p_He3=0; |
---|
| 635 | |
---|
| 636 | if (!isInitialized) { |
---|
| 637 | p_proton = G4ParticleTable::GetParticleTable()->FindParticle("proton"); // proton |
---|
| 638 | p_neutron = G4ParticleTable::GetParticleTable()->FindParticle("neutron"); // neutron |
---|
| 639 | p_deuteron = G4ParticleTable::GetParticleTable()->FindParticle("deuteron"); // deuteron |
---|
| 640 | p_triton = G4ParticleTable::GetParticleTable()->FindParticle("triton"); // tritoon |
---|
| 641 | p_alpha = G4ParticleTable::GetParticleTable()->FindParticle("alpha"); // alpha |
---|
| 642 | p_He3 = G4ParticleTable::GetParticleTable()->FindParticle("He3"); // He3 |
---|
| 643 | isInitialized = true; |
---|
| 644 | } |
---|
[824] | 645 | |
---|
| 646 | G4ParticleDefinition* ion=0; |
---|
| 647 | if ( (Z<=2) ) { |
---|
| 648 | if ( (Z==1)&&(A==1) ) { |
---|
[890] | 649 | ion = p_proton; |
---|
[824] | 650 | } else if ( (Z==0)&&(A==1) ) { |
---|
[890] | 651 | ion = p_neutron; |
---|
[824] | 652 | } else if ( (Z==1)&&(A==2) ) { |
---|
[890] | 653 | ion = p_deuteron; |
---|
[824] | 654 | } else if ( (Z==1)&&(A==3) ) { |
---|
[890] | 655 | ion = p_triton; |
---|
[824] | 656 | } else if ( (Z==2)&&(A==4) ) { |
---|
[890] | 657 | ion = p_alpha; |
---|
[824] | 658 | } else if ( (Z==2)&&(A==3) ) { |
---|
[890] | 659 | ion = p_He3; |
---|
[824] | 660 | } |
---|
| 661 | } |
---|
| 662 | return ion; |
---|
| 663 | } |
---|
| 664 | |
---|
| 665 | ///////////////// |
---|
| 666 | // -- GetNucleusMass/GetIonMass --- |
---|
| 667 | ///////////////// |
---|
| 668 | G4double G4IonTable::GetNucleusMass(G4int Z, G4int A, G4int L) const |
---|
| 669 | { |
---|
| 670 | if ( (A<1) || (Z<0) || (L<0) ){ |
---|
| 671 | #ifdef G4VERBOSE |
---|
| 672 | if (GetVerboseLevel()>0) { |
---|
| 673 | G4cout << "G4IonTable::GetNucleusMass() : illegal atomic number/mass " << G4endl; |
---|
| 674 | G4cout << " Z =" << Z << " A = " << A << G4endl; |
---|
| 675 | } |
---|
| 676 | #endif |
---|
| 677 | G4Exception( "G4IonTable::GetNucleusMass()","Illegal operation", |
---|
| 678 | EventMustBeAborted, "illegal atomic number/mass"); |
---|
| 679 | return -1.0; |
---|
| 680 | } |
---|
| 681 | |
---|
| 682 | G4double mass; |
---|
| 683 | if (L == 0) { |
---|
| 684 | // calculate nucleus mass |
---|
| 685 | G4ParticleDefinition* ion=GetLightIon(Z, A); |
---|
| 686 | |
---|
| 687 | if (ion!=0) { |
---|
| 688 | mass = ion->GetPDGMass(); |
---|
| 689 | } else { |
---|
| 690 | // use G4NucleiProperties::GetNuclearMass |
---|
| 691 | mass = G4NucleiProperties::GetNuclearMass(A, Z); |
---|
| 692 | } |
---|
| 693 | |
---|
| 694 | } else { |
---|
| 695 | mass = G4HyperNucleiProperties::GetNuclearMass(A, Z, L); |
---|
| 696 | } |
---|
| 697 | return mass; |
---|
| 698 | } |
---|
| 699 | |
---|
| 700 | ////////////////// |
---|
| 701 | G4double G4IonTable::GetIonMass(G4int Z, G4int A, G4int L) const |
---|
| 702 | { |
---|
| 703 | return GetNucleusMass(Z,A,L); |
---|
| 704 | } |
---|
| 705 | |
---|
| 706 | |
---|
| 707 | ///////////////// |
---|
| 708 | // -- Methods for handling conatiner --- |
---|
| 709 | ///////////////// |
---|
| 710 | void G4IonTable::Insert(G4ParticleDefinition* particle) |
---|
| 711 | { |
---|
[1196] | 712 | if (!IsIon(particle)) return; |
---|
| 713 | if (Contains(particle)) return; |
---|
| 714 | |
---|
| 715 | G4int Z = particle->GetAtomicNumber(); |
---|
| 716 | G4int A = particle->GetAtomicMass(); |
---|
| 717 | G4int L = particle->GetQuarkContent(3); //strangeness |
---|
| 718 | G4int encoding=GetNucleusEncoding(Z, A, L); |
---|
| 719 | |
---|
| 720 | fIonList->insert( std::pair<G4int, G4ParticleDefinition*>(encoding, particle) ); |
---|
| 721 | |
---|
[824] | 722 | } |
---|
| 723 | |
---|
| 724 | ///////////////// |
---|
| 725 | void G4IonTable::Remove(G4ParticleDefinition* particle) |
---|
| 726 | { |
---|
| 727 | if (IsIon(particle)) { |
---|
[1196] | 728 | G4int Z = particle->GetAtomicNumber(); |
---|
| 729 | G4int A = particle->GetAtomicMass(); |
---|
| 730 | G4int L = particle->GetQuarkContent(3); //strangeness |
---|
| 731 | G4int encoding=GetNucleusEncoding(Z, A, L); |
---|
| 732 | if (encoding !=0 ) { |
---|
| 733 | G4IonList::iterator i = fIonList->find(encoding); |
---|
| 734 | for( ;i != fIonList->end() ; i++) { |
---|
| 735 | if (particle == i->second) { |
---|
| 736 | fIonList->erase(i); |
---|
| 737 | break; |
---|
| 738 | } |
---|
[824] | 739 | } |
---|
| 740 | } |
---|
| 741 | } else { |
---|
| 742 | #ifdef G4VERBOSE |
---|
[850] | 743 | if (GetVerboseLevel()>1) { |
---|
[824] | 744 | G4cout << "G4IonTable::Remove :" << particle->GetParticleName() ; |
---|
| 745 | G4cout << " is not ions" << G4endl; |
---|
| 746 | } |
---|
| 747 | #endif |
---|
| 748 | } |
---|
[850] | 749 | |
---|
[824] | 750 | } |
---|
| 751 | |
---|
| 752 | |
---|
| 753 | |
---|
| 754 | ///////////////// |
---|
| 755 | // -- Dump Information |
---|
| 756 | ///////////////// |
---|
| 757 | void G4IonTable::DumpTable(const G4String &particle_name) const |
---|
| 758 | { |
---|
| 759 | G4ParticleDefinition* ion; |
---|
| 760 | G4IonList::iterator idx; |
---|
| 761 | for (idx = fIonList->begin(); idx!= fIonList->end(); ++idx) { |
---|
[1196] | 762 | ion = idx->second; |
---|
[824] | 763 | if (( particle_name == "ALL" ) || (particle_name == "all")){ |
---|
| 764 | ion->DumpTable(); |
---|
| 765 | } else if ( particle_name == ion->GetParticleName() ) { |
---|
| 766 | ion->DumpTable(); |
---|
| 767 | } |
---|
| 768 | } |
---|
| 769 | } |
---|
| 770 | |
---|
| 771 | ///////////////// |
---|
| 772 | const G4String G4IonTable::elementName[] = { |
---|
| 773 | "H", "He", |
---|
| 774 | "Li", "Be", "B", "C", "N", "O", "F", "Ne", |
---|
| 775 | "Na", "Mg", "Al", "Si", "P", "S", "Cl", "Ar", |
---|
| 776 | "K", "Ca", "Sc", "Ti", "V", "Cr", "Mn", "Fe", "Co", "Ni", "Cu", "Zn", "Ga", "Ge", "As", "Se", "Br", "Kr", |
---|
| 777 | "Rb", "Sr", "Y", "Zr", "Nb", "Mo","Tc", "Ru", "Rh", "Pd", "Ag", "Cd", "In", "Sn", "Sb", "Te", "I", "Xe", |
---|
| 778 | "Cs", "Ba", |
---|
| 779 | "La", "Ce", "Pr", "Nd", "Pm", "Sm", "Eu", "Gd", "Tb", "Dy", "Ho", "Er", "Tm", "Yb", "Lu", |
---|
| 780 | "Hf", "Ta", "W", "Re", "Os", "Ir", "Pt", "Au", "Hg", "Tl", "Pb", "Bi", "Po", "At", "Rn", |
---|
| 781 | "Fr", "Ra", |
---|
| 782 | "Ac", "Th", "Pa", "U", "Np", "Pu", "Am", "Cm", "Bk", "Cf", "Es", "Fm", "Md", "No", "Lr", |
---|
| 783 | "Rf", "Db", "Sg", "Bh", "Hs", "Mt", "Ds", "Rg", |
---|
| 784 | "Uub", "Uut", "Uuq","Uup","Uuh","Uus","Uuo" |
---|
| 785 | }; |
---|
| 786 | |
---|
| 787 | |
---|
| 788 | ///////////////// |
---|
| 789 | G4int G4IonTable::GetVerboseLevel() const |
---|
| 790 | { |
---|
| 791 | return G4ParticleTable::GetParticleTable()->GetVerboseLevel(); |
---|
| 792 | } |
---|
| 793 | |
---|
| 794 | ///////////////// |
---|
| 795 | void G4IonTable::AddProcessManager(const G4String& name) |
---|
| 796 | { |
---|
| 797 | // create command string for addProcManager |
---|
| 798 | std::ostringstream osAdd; |
---|
| 799 | osAdd << "/run/particle/addProcManager "<< name; |
---|
| 800 | G4String cmdAdd = osAdd.str(); |
---|
| 801 | |
---|
| 802 | // set /control/verbose 0 |
---|
| 803 | G4int tempVerboseLevel = G4UImanager::GetUIpointer()->GetVerboseLevel(); |
---|
| 804 | G4UImanager::GetUIpointer()->SetVerboseLevel(0); |
---|
| 805 | |
---|
| 806 | // issue /run/particle/addProcManage |
---|
| 807 | G4UImanager::GetUIpointer()->ApplyCommand(cmdAdd); |
---|
| 808 | |
---|
| 809 | // retreive /control/verbose |
---|
| 810 | G4UImanager::GetUIpointer()->SetVerboseLevel(tempVerboseLevel); |
---|
| 811 | } |
---|
| 812 | |
---|
| 813 | #include <vector> |
---|
| 814 | |
---|
| 815 | //////////////////// |
---|
| 816 | void G4IonTable::RegisterIsotopeTable(G4VIsotopeTable* table) |
---|
| 817 | { |
---|
| 818 | fIsotopeTableList->push_back(table); |
---|
| 819 | } |
---|
| 820 | |
---|
| 821 | //////////////////// |
---|
| 822 | G4VIsotopeTable* G4IonTable::GetIsotopeTable(size_t index) const |
---|
| 823 | { |
---|
| 824 | G4VIsotopeTable* fIsotopeTable=0; |
---|
| 825 | if ( index < fIsotopeTableList->size() ) { |
---|
| 826 | fIsotopeTable = (*fIsotopeTableList)[index]; |
---|
| 827 | } |
---|
| 828 | return fIsotopeTable; |
---|
| 829 | } |
---|
| 830 | |
---|
| 831 | |
---|
| 832 | //////////////////// |
---|
| 833 | G4IsotopeProperty* G4IonTable::FindIsotope(G4int Z, G4int A, G4double E, G4int ) |
---|
| 834 | { |
---|
| 835 | if (fIsotopeTableList ==0) return 0; |
---|
| 836 | if (fIsotopeTableList->size()==0) return 0; |
---|
| 837 | |
---|
| 838 | // ask IsotopeTable |
---|
| 839 | G4IsotopeProperty* property =0; |
---|
| 840 | |
---|
| 841 | // iterate |
---|
| 842 | for (size_t i = 0; i< fIsotopeTableList->size(); ++i) { |
---|
| 843 | G4VIsotopeTable* fIsotopeTable= (*fIsotopeTableList)[i]; |
---|
| 844 | G4IsotopeProperty* tmp = fIsotopeTable->GetIsotope(Z,A,E); |
---|
| 845 | if ( tmp !=0) { |
---|
| 846 | |
---|
| 847 | #ifdef G4VERBOSE |
---|
| 848 | if (GetVerboseLevel()>1) { |
---|
| 849 | G4cout << "G4IonTable::FindIsotope:"; |
---|
| 850 | G4cout << " Z: " << Z; |
---|
| 851 | G4cout << " A: " << A; |
---|
| 852 | G4cout << " E: " << E; |
---|
| 853 | G4cout << G4endl; |
---|
| 854 | tmp->DumpInfo(); |
---|
| 855 | } |
---|
| 856 | #endif |
---|
| 857 | if (property !=0) { |
---|
| 858 | // overwrite spin/magnetic moment/decay table if not defined |
---|
| 859 | if( property->GetiSpin() ==0) { |
---|
| 860 | property->SetiSpin( tmp->GetiSpin() ); |
---|
| 861 | } |
---|
| 862 | if( property->GetMagneticMoment() <= 0.0) { |
---|
| 863 | property->SetMagneticMoment( tmp->GetMagneticMoment() ); |
---|
| 864 | } |
---|
| 865 | if( property->GetLifeTime() <= 0.0) { |
---|
| 866 | property->SetLifeTime( tmp->GetLifeTime() ); |
---|
| 867 | if ( (property->GetLifeTime() > 0.0) |
---|
| 868 | && (property->GetDecayTable() ==0 ) ) { |
---|
| 869 | property->SetDecayTable( tmp->GetDecayTable() ); |
---|
| 870 | tmp->SetDecayTable( 0 ); |
---|
| 871 | } |
---|
| 872 | } |
---|
| 873 | } else { |
---|
| 874 | property = tmp; |
---|
| 875 | } |
---|
| 876 | } |
---|
| 877 | } |
---|
| 878 | |
---|
| 879 | return property; |
---|
| 880 | } |
---|
| 881 | |
---|
| 882 | |
---|
[1196] | 883 | //////////////////// |
---|
| 884 | void G4IonTable::CreateAllIon() |
---|
| 885 | { |
---|
| 886 | G4int Z; |
---|
| 887 | G4int A; |
---|
| 888 | G4double E=0.0; |
---|
| 889 | G4int J=0; |
---|
| 890 | |
---|
| 891 | for (Z=1; Z<=120; Z++) { |
---|
| 892 | for (A=Z;A<999 && A<Z*3+10; A++) { |
---|
| 893 | if (G4NucleiProperties::IsInStableTable(A,Z)){ |
---|
| 894 | GetIon(Z,A,E,J); |
---|
| 895 | } |
---|
| 896 | } |
---|
| 897 | } |
---|
| 898 | } |
---|
[824] | 899 | |
---|
[1196] | 900 | //////////////////// |
---|
| 901 | G4ParticleDefinition* G4IonTable::GetParticle(G4int index) const |
---|
| 902 | { |
---|
| 903 | if ( (index >=0) && (index < Entries()) ) { |
---|
| 904 | G4IonList::iterator idx = fIonList->begin(); |
---|
| 905 | G4int counter = 0; |
---|
| 906 | while( idx != fIonList->end() ){ |
---|
| 907 | if ( counter == index ) return idx->second; |
---|
| 908 | counter++; |
---|
| 909 | idx++; |
---|
| 910 | } |
---|
| 911 | } |
---|
| 912 | #ifdef G4VERBOSE |
---|
| 913 | if (GetVerboseLevel()>1){ |
---|
| 914 | G4cout << " G4IonTable::GetParticle"; |
---|
| 915 | G4cout << " invalid index (=" << index << ")" |
---|
| 916 | << " entries = " << Entries() << G4endl; |
---|
| 917 | } |
---|
| 918 | #endif |
---|
| 919 | return 0; |
---|
| 920 | } |
---|
[824] | 921 | |
---|
| 922 | |
---|
| 923 | |
---|
| 924 | |
---|
| 925 | |
---|
| 926 | |
---|
| 927 | |
---|
| 928 | |
---|
| 929 | |
---|
| 930 | |
---|
| 931 | |
---|