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