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