Geant4 Cross Reference |
1 // ******************************************* 1 // ******************************************************************** 2 // * License and Disclaimer 2 // * License and Disclaimer * 3 // * 3 // * * 4 // * The Geant4 software is copyright of th 4 // * The Geant4 software is copyright of the Copyright Holders of * 5 // * the Geant4 Collaboration. It is provided 5 // * the Geant4 Collaboration. It is provided under the terms and * 6 // * conditions of the Geant4 Software License 6 // * conditions of the Geant4 Software License, included in the file * 7 // * LICENSE and available at http://cern.ch/ 7 // * LICENSE and available at http://cern.ch/geant4/license . These * 8 // * include a list of copyright holders. 8 // * include a list of copyright holders. * 9 // * 9 // * * 10 // * Neither the authors of this software syst 10 // * Neither the authors of this software system, nor their employing * 11 // * institutes,nor the agencies providing fin 11 // * institutes,nor the agencies providing financial support for this * 12 // * work make any representation or warran 12 // * work make any representation or warranty, express or implied, * 13 // * regarding this software system or assum 13 // * regarding this software system or assume any liability for its * 14 // * use. Please see the license in the file 14 // * use. Please see the license in the file LICENSE and URL above * 15 // * for the full disclaimer and the limitatio 15 // * for the full disclaimer and the limitation of liability. * 16 // * 16 // * * 17 // * This code implementation is the result 17 // * This code implementation is the result of the scientific and * 18 // * technical work of the GEANT4 collaboratio 18 // * technical work of the GEANT4 collaboration. * 19 // * By using, copying, modifying or distri 19 // * By using, copying, modifying or distributing the software (or * 20 // * any work based on the software) you ag 20 // * any work based on the software) you agree to acknowledge its * 21 // * use in resulting scientific publicati 21 // * use in resulting scientific publications, and indicate your * 22 // * acceptance of all terms of the Geant4 Sof 22 // * acceptance of all terms of the Geant4 Software license. * 23 // ******************************************* 23 // ******************************************************************** 24 // 24 // 25 // particle_hp -- source file 25 // particle_hp -- source file 26 // J.P. Wellisch, Nov-1996 26 // J.P. Wellisch, Nov-1996 27 // A prototype of the low energy neutron trans 27 // A prototype of the low energy neutron transport model. 28 // 28 // 29 // 080901 Avoiding troubles which caused by G4 << 29 //080901 Avoiding troubles which caused by G4PhysicsVecotor of length 0 by T. Koi 30 // 30 // 31 // P. Arce, June-2014 Conversion neutron_hp to 31 // P. Arce, June-2014 Conversion neutron_hp to particle_hp 32 // 32 // 33 #include "G4ParticleHPIsoData.hh" 33 #include "G4ParticleHPIsoData.hh" 34 << 35 #include "G4Neutron.hh" << 36 #include "G4ParticleHPDataUsed.hh" << 37 #include "G4ParticleHPManager.hh" 34 #include "G4ParticleHPManager.hh" 38 #include "G4Alpha.hh" << 35 #include "G4ParticleHPDataUsed.hh" 39 #include "G4Deuteron.hh" << 36 #include "G4Neutron.hh" 40 #include "G4He3.hh" << 41 #include "G4Proton.hh" << 42 #include "G4Triton.hh" << 43 //#include <stdlib.h> << 44 #include <fstream> << 45 << 46 void G4ParticleHPIsoData::FillChannelData(G4Pa << 47 { << 48 if (theChannelData != nullptr) { << 49 G4Exception("G4ParticleHPIsoData::FillChan << 50 FatalException, "Inconsistency << 51 } << 52 theChannelData = new G4ParticleHPVector; << 53 for (G4int i = 0; i < aBuffer->GetVectorLeng << 54 theChannelData->SetPoint(i, aBuffer->GetPo << 55 } << 56 theChannelData->Hash(); << 57 } << 58 37 59 G4bool G4ParticleHPIsoData::Init(G4int A, G4in << 38 //G4bool G4ParticleHPIsoData::Init(G4int A, G4int Z, G4double abun, G4String dirName, G4String aFSType) 60 const G4Strin << 39 G4bool G4ParticleHPIsoData::Init(G4int A, G4int Z, G4int M, G4double abun, G4String dirName, G4String aFSType) 61 { << 40 { 62 theChannelData = nullptr; << 41 theChannelData = 0; 63 G4double abundance = abun / 100.; << 42 G4double abundance = abun/100.; 64 G4String filename; << 43 G4String filename; 65 G4bool result = true; << 44 G4bool result = true; 66 G4ParticleHPDataUsed aFile = theNames.GetNam << 45 //G4ParticleHPDataUsed aFile = theNames.GetName(A, Z, dirName, aFSType, result); 67 filename = aFile.GetName(); << 46 G4ParticleHPDataUsed aFile = theNames.GetName(A, Z, M, dirName, aFSType, result); 68 << 47 filename = aFile.GetName(); 69 std::istringstream theChannel(filename, std: << 48 // if(filename=="") return false; 70 auto man = G4ParticleHPManager::GetInstance( << 49 //std::ifstream theChannel(filename); 71 man->GetDataStream(filename, theChannel); << 50 std::istringstream theChannel(filename,std::ios::in); >> 51 G4ParticleHPManager::GetInstance()->GetDataStream(filename,theChannel); 72 52 73 #ifdef G4PHPDEBUG 53 #ifdef G4PHPDEBUG 74 if (man->GetDEBUG()) << 54 if(std::getenv("G4ParticleHPDebug")) G4cout << "G4ParticleHPIsoData::Init = "<< filename <<" "<< A << " " << Z <<G4endl; 75 G4cout << "G4ParticleHPIsoData::Init = " < << 76 #endif 55 #endif 77 << 56 78 if (Z == 1 && (aFile.GetZ() != Z || aFile.Ge << 57 if(Z==1 && (aFile.GetZ()!=Z || std::abs(aFile.GetA()-A)>0.0001) ) 79 if (man->GetDEBUG()) << 80 G4cout << "Skipped = " << filename << " << 81 // 080901 TKDB No more necessary below pro << 82 } << 83 if (!theChannel) { /*theChannel.close()*/ << 84 return false; << 85 } << 86 // accommodating deficiencie of some compile << 87 if (theChannel.eof()) { /*theChannel.close() << 88 return false; << 89 } << 90 G4int dummy; << 91 theChannel >> dummy >> dummy; << 92 theChannelData = new G4ParticleHPVector; << 93 G4int nData; << 94 theChannel >> nData; << 95 theChannelData->Init(theChannel, nData, CLHE << 96 return result; << 97 } << 98 << 99 void G4ParticleHPIsoData::Init(G4int A, G4int << 100 G4ParticleDefin << 101 // fill PhysicsVector for this Isotope << 102 { << 103 auto man = G4ParticleHPManager::GetInstance( << 104 << 105 G4String baseName = man->GetParticleHPPath(p << 106 << 107 G4String dirName; << 108 if (projectile == G4Neutron::Neutron()) { << 109 dirName = baseName + "/Fission"; << 110 if (Z > 87) // TK Modifed for ENDF VII.0 << 111 { 58 { 112 Init(A, Z, M, abun, dirName, "/CrossSect << 59 if(std::getenv("G4ParticleHPDebug")) G4cout << "Skipped = "<< filename <<" "<<A<<" "<<Z<<G4endl; >> 60 //080901 TKDB No more necessary below protection, cross sections set to 0 in G4ParticleHPNames >> 61 //And below two lines causes trouble with G4PhysicsVector >> 62 //theChannel.close(); >> 63 //return false; 113 } 64 } 114 else { << 65 if(!theChannel) {/*theChannel.close()*/; return false;} 115 theChannelData = new G4ParticleHPVector; << 66 // accommodating deficiencie of some compilers 116 } << 67 if(theChannel.eof()) {/*theChannel.close()*/; return false;} 117 theFissionData = theChannelData; << 68 if(!theChannel) {/*theChannel.close()*/; return false;} 118 theChannelData = nullptr; // fast fix for << 69 G4int dummy; >> 70 theChannel >> dummy >> dummy; >> 71 theChannelData = new G4ParticleHPVector; >> 72 G4int nData; >> 73 theChannel >> nData; >> 74 theChannelData->Init(theChannel, nData, CLHEP::eV, abundance*CLHEP::barn); >> 75 // G4cout << "Channel Data Statistics: "<<theChannelData->GetVectorLength()<<G4endl; >> 76 // G4cout << "Channel data"<<G4endl; >> 77 // G4int hpw; >> 78 // G4cin >> hpw; >> 79 // theChannelData->Dump(); >> 80 // theChannel.close(); >> 81 return result; >> 82 } >> 83 >> 84 //void G4ParticleHPIsoData::Init(G4int A, G4int Z, G4double abun) //fill PhysicsVector for this Isotope >> 85 #include "G4Proton.hh" >> 86 #include "G4Deuteron.hh" >> 87 #include "G4Triton.hh" >> 88 #include "G4He3.hh" >> 89 #include "G4Alpha.hh" >> 90 void G4ParticleHPIsoData::Init(G4int A, G4int Z, G4int M,G4double abun, G4ParticleDefinition* projectile, const char* dataDirVariable ) //fill PhysicsVector for this Isotope >> 91 { 119 92 120 dirName = baseName + "/Capture"; << 93 G4String particleName; 121 Init(A, Z, M, abun, dirName, "/CrossSectio << 94 if ( projectile == G4Neutron::Neutron() ) { 122 theCaptureData = theChannelData; << 95 ; 123 theChannelData = nullptr; << 96 } else if ( projectile == G4Proton::Proton() ) { >> 97 particleName = "Proton"; >> 98 } else if ( projectile == G4Deuteron::Deuteron() ) { >> 99 particleName = "Deuteron"; >> 100 } else if ( projectile == G4Triton::Triton() ) { >> 101 particleName = "Triton"; >> 102 } else if ( projectile == G4He3::He3() ) { >> 103 particleName = "He3"; >> 104 } else if ( projectile == G4Alpha::Alpha() ) { >> 105 particleName = "Alpha"; >> 106 } else { >> 107 G4String message("G4ParticleHPInelastic may only be called for neutron, proton, deuteron, triton, He3 or alpha, while it is called for " + projectile->GetParticleName()); >> 108 throw G4HadronicException(__FILE__, __LINE__,message.c_str()); >> 109 } >> 110 >> 111 G4String baseName; >> 112 if ( std::getenv( dataDirVariable ) ) { >> 113 baseName = std::getenv( dataDirVariable ); >> 114 } else { >> 115 baseName = std::getenv( "G4PARTICLEHPDATA" ); >> 116 baseName += "/" + particleName; >> 117 } >> 118 >> 119 // G4String baseName = getenv(dataDirVariable); >> 120 G4String dirName; >> 121 if( projectile == G4Neutron::Neutron() ){ >> 122 dirName = baseName+"/Fission"; >> 123 //if(Z>89) >> 124 if(Z>87) //TK Modifed for ENDF VII.0 >> 125 { >> 126 //Init(A, Z, abun, dirName, "/CrossSection/"); >> 127 Init(A, Z, M, abun, dirName, "/CrossSection"); >> 128 } >> 129 else >> 130 { >> 131 theChannelData = new G4ParticleHPVector; >> 132 } >> 133 theFissionData = theChannelData; >> 134 theChannelData = 0; // fast fix for double delete; revisit later. @@@@@@@ >> 135 >> 136 dirName = baseName+"/Capture"; >> 137 //Init(A, Z, abun, dirName, "/CrossSection/"); >> 138 Init(A, Z, M, abun, dirName, "/CrossSection"); >> 139 theCaptureData = theChannelData; >> 140 theChannelData = 0; >> 141 >> 142 dirName = baseName+"/Elastic"; >> 143 //Init(A, Z, abun, dirName, "/CrossSection/"); >> 144 Init(A, Z, M, abun, dirName, "/CrossSection"); >> 145 theElasticData = theChannelData; >> 146 theChannelData = 0; >> 147 } 124 148 125 dirName = baseName + "/Elastic"; << 149 dirName = baseName+"/Inelastic"; >> 150 //Init(A, Z, abun, dirName, "/CrossSection/"); 126 Init(A, Z, M, abun, dirName, "/CrossSectio 151 Init(A, Z, M, abun, dirName, "/CrossSection"); 127 theElasticData = theChannelData; << 152 theInelasticData = theChannelData; 128 theChannelData = nullptr; << 153 theChannelData = 0; >> 154 >> 155 // if(theInelasticData!=0) G4cout << "Inelastic Data Statistics: "<<theInelasticData->GetVectorLength()<<G4endl; >> 156 // if(theElasticData!=0) G4cout << "Elastic Data Statistics: "<<theElasticData->GetVectorLength()<<G4endl; >> 157 // if(theCaptureData!=0) G4cout << "Capture Data Statistics: "<<theCaptureData->GetVectorLength()<<G4endl; >> 158 // if(theFissionData!=0) G4cout << "Fission Data Statistics: "<<theFissionData->GetVectorLength()<<G4endl; >> 159 // G4cout << "Inelastic data"<<G4endl; >> 160 // if(theInelasticData!=0) theInelasticData->Dump(); >> 161 // G4cout << "Elastic data"<<G4endl; >> 162 // if(theElasticData!=0) theElasticData->Dump(); >> 163 // G4cout << "Capture data"<<G4endl; >> 164 // if(theCaptureData!=0) theCaptureData->Dump(); >> 165 // G4cout << "Fission data"<<G4endl; >> 166 // if(theFissionData!=0) theFissionData->Dump(); >> 167 >> 168 } >> 169 >> 170 G4String G4ParticleHPIsoData::GetName(G4int A, G4int Z, G4String base, G4String rest) >> 171 { >> 172 G4bool dbool; >> 173 return (theNames.GetName(A, Z, base, rest, dbool)).GetName(); 129 } 174 } 130 175 131 dirName = baseName + "/Inelastic"; << 132 Init(A, Z, M, abun, dirName, "/CrossSection" << 133 theInelasticData = theChannelData; << 134 theChannelData = nullptr; << 135 } << 136 << 137 G4String G4ParticleHPIsoData::GetName(G4int A, << 138 { << 139 G4bool dbool; << 140 return (theNames.GetName(A, Z, base, rest, d << 141 } << 142 176