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 #include "G4TextPPRetriever.hh" 26 #include "G4TextPPRetriever.hh" 27 27 28 #include "G4DecayTable.hh" 28 #include "G4DecayTable.hh" 29 #include "G4ParticleDefinition.hh" 29 #include "G4ParticleDefinition.hh" 30 #include "G4ParticleTable.hh" 30 #include "G4ParticleTable.hh" 31 #include "G4SystemOfUnits.hh" 31 #include "G4SystemOfUnits.hh" 32 #include "G4Tokenizer.hh" 32 #include "G4Tokenizer.hh" 33 #include "G4VDecayChannel.hh" 33 #include "G4VDecayChannel.hh" 34 #include "G4ios.hh" 34 #include "G4ios.hh" 35 #include "globals.hh" 35 #include "globals.hh" 36 36 37 #include <fstream> 37 #include <fstream> 38 38 39 void G4TextPPRetriever::Retrieve(const G4Strin 39 void G4TextPPRetriever::Retrieve(const G4String& option) 40 { 40 { 41 SparseOption(option); 41 SparseOption(option); 42 42 43 // pointer to the particle table 43 // pointer to the particle table 44 G4ParticleTable* theParticleTable = G4Partic 44 G4ParticleTable* theParticleTable = G4ParticleTable::GetParticleTable(); 45 G4ParticleTable::G4PTblDicIterator* theParti 45 G4ParticleTable::G4PTblDicIterator* theParticleIterator; 46 theParticleIterator = theParticleTable->GetI 46 theParticleIterator = theParticleTable->GetIterator(); 47 47 48 // loop over all particles in G4ParticleTabl 48 // loop over all particles in G4ParticleTable 49 theParticleIterator->reset(); 49 theParticleIterator->reset(); 50 while ((*theParticleIterator)()) { // Loop 50 while ((*theParticleIterator)()) { // Loop checking, 09.08.2015, K.Kurashige 51 G4ParticleDefinition* particle = thePartic 51 G4ParticleDefinition* particle = theParticleIterator->value(); 52 ModifyPropertyTable(particle); 52 ModifyPropertyTable(particle); 53 } 53 } 54 } 54 } 55 55 56 void G4TextPPRetriever::SparseOption(const G4S 56 void G4TextPPRetriever::SparseOption(const G4String& option) 57 { 57 { 58 G4Tokenizer savedToken(option); 58 G4Tokenizer savedToken(option); 59 59 60 // 1st option : base directory 60 // 1st option : base directory 61 baseDir = savedToken(); 61 baseDir = savedToken(); 62 if (!baseDir.empty()) { 62 if (!baseDir.empty()) { 63 if (baseDir.back() != '/') { 63 if (baseDir.back() != '/') { 64 baseDir += "/"; 64 baseDir += "/"; 65 } 65 } 66 } 66 } 67 } 67 } 68 68 69 G4bool G4TextPPRetriever::ModifyPropertyTable( 69 G4bool G4TextPPRetriever::ModifyPropertyTable(const G4ParticleDefinition* particle) 70 { 70 { 71 G4String name = particle->GetParticleName(); 71 G4String name = particle->GetParticleName(); 72 72 73 //--- open file ----- 73 //--- open file ----- 74 G4String fileName = baseDir + name + ".txt"; 74 G4String fileName = baseDir + name + ".txt"; 75 // exception 75 // exception 76 if (name == "J/psi") fileName = baseDir + "j 76 if (name == "J/psi") fileName = baseDir + "jpsi.txt"; 77 77 78 std::ifstream inFile(fileName, std::ios::in) 78 std::ifstream inFile(fileName, std::ios::in); 79 if (!inFile) return false; 79 if (!inFile) return false; 80 80 81 // GetParticleProperty 81 // GetParticleProperty 82 G4ParticlePropertyData* pData = pPropertyTab 82 G4ParticlePropertyData* pData = pPropertyTable->GetParticleProperty(name); 83 83 84 // particle name encoding 84 // particle name encoding 85 G4String name_t; 85 G4String name_t; 86 G4int encoding; 86 G4int encoding; 87 inFile >> name_t >> encoding; 87 inFile >> name_t >> encoding; 88 if ((name != name_t) || (encoding != pData-> 88 if ((name != name_t) || (encoding != pData->GetPDGEncoding())) { 89 G4cout << "G4TextPPRetriever::ModifyProper 89 G4cout << "G4TextPPRetriever::ModifyPropertyTable: "; 90 G4cout << "particle name or encoding misma 90 G4cout << "particle name or encoding mismatch for " << name; 91 G4cout << G4endl; 91 G4cout << G4endl; 92 return false; 92 return false; 93 } 93 } 94 94 95 // IJPC 95 // IJPC 96 G4int iIsoSpin, iSpin, iParity, iConj; 96 G4int iIsoSpin, iSpin, iParity, iConj; 97 inFile >> iIsoSpin >> iSpin >> iParity >> iC 97 inFile >> iIsoSpin >> iSpin >> iParity >> iConj; 98 if ((iIsoSpin != pData->GetPDGiIsospin()) || 98 if ((iIsoSpin != pData->GetPDGiIsospin()) || (iSpin != pData->GetPDGiSpin()) 99 || (iParity != pData->GetPDGiParity()) | 99 || (iParity != pData->GetPDGiParity()) || (iConj != pData->GetPDGiConjugation())) 100 { 100 { 101 G4cout << "G4TextPPRetriever::ModifyProper 101 G4cout << "G4TextPPRetriever::ModifyPropertyTable: "; 102 G4cout << "IJPC mismatch for " << name; 102 G4cout << "IJPC mismatch for " << name; 103 G4cout << G4endl; 103 G4cout << G4endl; 104 return false; 104 return false; 105 } 105 } 106 106 107 // mass, width, charge 107 // mass, width, charge 108 G4double mass, width, charge; 108 G4double mass, width, charge; 109 inFile >> mass >> width >> charge; 109 inFile >> mass >> width >> charge; 110 mass *= GeV; 110 mass *= GeV; 111 width *= GeV; 111 width *= GeV; 112 charge *= eplus; 112 charge *= eplus; 113 if (mass != pData->GetPDGMass()) { 113 if (mass != pData->GetPDGMass()) { 114 pData->SetPDGMass(mass); 114 pData->SetPDGMass(mass); 115 } 115 } 116 if (width != pData->GetPDGWidth()) { 116 if (width != pData->GetPDGWidth()) { 117 pData->SetPDGWidth(width); 117 pData->SetPDGWidth(width); 118 } 118 } 119 if (charge != pData->GetPDGCharge()) { 119 if (charge != pData->GetPDGCharge()) { 120 pData->SetPDGCharge(charge); 120 pData->SetPDGCharge(charge); 121 } 121 } 122 122 123 // life time 123 // life time 124 G4double tlife; 124 G4double tlife; 125 inFile >> tlife; 125 inFile >> tlife; 126 tlife *= second; 126 tlife *= second; 127 if (tlife != pData->GetPDGLifeTime()) { 127 if (tlife != pData->GetPDGLifeTime()) { 128 pData->SetPDGLifeTime(tlife); 128 pData->SetPDGLifeTime(tlife); 129 } 129 } 130 130 131 pPropertyTable->SetParticleProperty(*pData); 131 pPropertyTable->SetParticleProperty(*pData); 132 132 133 // Decay Table 133 // Decay Table 134 G4DecayTable* dcyTable = particle->GetDecayT 134 G4DecayTable* dcyTable = particle->GetDecayTable(); 135 if (dcyTable == nullptr) return true; 135 if (dcyTable == nullptr) return true; 136 136 137 G4int idx = 0; 137 G4int idx = 0; 138 while (!inFile.eof()) { // Loop checking, 0 138 while (!inFile.eof()) { // Loop checking, 09.08.2015, K.Kurashige 139 G4double br; 139 G4double br; 140 G4int n_daughters; 140 G4int n_daughters; 141 inFile >> br >> n_daughters; 141 inFile >> br >> n_daughters; 142 142 143 G4VDecayChannel* channel = dcyTable->GetDe 143 G4VDecayChannel* channel = dcyTable->GetDecayChannel(idx); 144 144 145 if (n_daughters == channel->GetNumberOfDau 145 if (n_daughters == channel->GetNumberOfDaughters()) { 146 channel->SetBR(br); 146 channel->SetBR(br); 147 } 147 } 148 148 149 idx += 1; 149 idx += 1; 150 if (idx >= dcyTable->entries()) break; 150 if (idx >= dcyTable->entries()) break; 151 } 151 } 152 return true; 152 return true; 153 } 153 } 154 154