Import Geant4 11.2.0 source tree

This commit is contained in:
Gabriele Cosmo
2023-12-08 10:43:34 +01:00
parent dd1f179cda
commit 860a2b92bf
3962 changed files with 139318 additions and 164259 deletions
+198 -175
View File
@@ -22,151 +22,148 @@
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// the GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
//
//
// ---------------------------------------------------------------
#include "G4HtmlPPReporter.hh"
#include "G4DecayTable.hh"
#include "G4ParticleDefinition.hh"
#include "G4ParticleTable.hh"
#include "G4SystemOfUnits.hh"
#include "G4Tokenizer.hh"
#include "G4VDecayChannel.hh"
#include "G4ios.hh"
#include "globals.hh"
#include "G4SystemOfUnits.hh"
#include "G4ParticleDefinition.hh"
#include "G4ParticleTable.hh"
#include "G4DecayTable.hh"
#include "G4VDecayChannel.hh"
#include "G4Tokenizer.hh"
#include <iomanip>
void G4HtmlPPReporter::Print(const G4String& option)
void G4HtmlPPReporter::Print(const G4String& option)
{
SparseOption( option );
SparseOption(option);
GenerateIndex();
for (const auto & i : pList){
G4ParticleDefinition* particle = G4ParticleTable::GetParticleTable()->FindParticle( i->GetParticleName() );
for (const auto& i : pList) {
G4ParticleDefinition* particle =
G4ParticleTable::GetParticleTable()->FindParticle(i->GetParticleName());
GeneratePropertyTable(particle);
}
}
}
void G4HtmlPPReporter::SparseOption(const G4String& option)
{
G4Tokenizer savedToken( option );
G4Tokenizer savedToken(option);
// 1st option : base directory
baseDir = savedToken();
if (!baseDir.empty()) {
if(baseDir.back()!='/') {
if (baseDir.back() != '/') {
baseDir += "/";
}
}
comment = savedToken();
comment = savedToken();
}
void G4HtmlPPReporter::GenerateIndex()
void G4HtmlPPReporter::GenerateIndex()
{
//--- open index file -----
G4String fileName = baseDir + "index.html";
std::ofstream outFile(fileName, std::ios::out );
outFile.setf( std::ios:: scientific, std::ios::floatfield );
std::ofstream outFile(fileName, std::ios::out);
outFile.setf(std::ios::scientific, std::ios::floatfield);
// header
PrintHeader(outFile);
// comment
outFile << "<! -- " << comment << " -- !> " << G4endl;
outFile << G4endl;
outFile << sTABLE << '"' << "80%" << '"' << " > " << G4endl;
// Raw #1
outFile << sTR;
outFile << sTD << sLFONT << "Code" << eLFONT<< eTD;
outFile << sTD << sLFONT << "Name" << eLFONT<< eTD;
outFile << sTD << sLFONT << "Code" << eLFONT << eTD;
outFile << sTD << sLFONT << "Name" << eLFONT << eTD;
outFile << sTD << sLFONT << "Mass" << eLFONT << eTD;
outFile << sTD << sLFONT << "Charge" << eLFONT << eTD;
outFile << sTD << sLFONT << "Life Time" << eLFONT << eTD;
outFile << sTD << sLFONT << "Anti-Particle" << eLFONT<< eTD;
outFile << eTR << G4endl;;
outFile << sTD << sLFONT << "Anti-Particle" << eLFONT << eTD;
outFile << eTR << G4endl;
;
// Raw #2
outFile << sTR;
outFile << sTD << " " << eTD;
outFile << sTD << " " << eTD;
outFile << sTD << " [GeV/c" << sSUP << "2" << eSUP << "]" << eTD;
outFile << sTD << " " << eTD;
outFile << sTD << " [ns]" << eTD;
outFile << sTD << " " << eTD;
outFile << eTR << G4endl;;
outFile << sTD << " " << eTD;
outFile << sTD << " " << eTD;
outFile << sTD << " [GeV/c" << sSUP << "2" << eSUP << "]" << eTD;
outFile << sTD << " " << eTD;
outFile << sTD << " [ns]" << eTD;
outFile << sTD << " " << eTD;
outFile << eTR << G4endl;
;
for (const auto & i : pList){
if (i->GetPDGEncoding()<0) continue;
for (const auto& i : pList) {
if (i->GetPDGEncoding() < 0) continue;
outFile << sTR << G4endl;;
outFile << sTR << G4endl;
;
// column 1 : endcoding
outFile << sTD << i->GetPDGEncoding() << eTD << G4endl;;
// column 2 : name
outFile << sTD << i->GetPDGEncoding() << eTD << G4endl;
;
// column 2 : name
G4String name = i->GetParticleName();
G4String fname = name +".html";
G4String fname = name + ".html";
// exception
if (name == "J/psi") fname = "jpsi.html";
outFile << sTD;
outFile << "<A HREF=" << '"' << fname << '"' << ">";
outFile << name << "</A>" << eTD << G4endl;
// column 3 mass
outFile << sTD << i->GetPDGMass()/GeV << eTD << G4endl;
outFile << sTD << i->GetPDGMass() / GeV << eTD << G4endl;
// column 4 charge
outFile << sTD << i->GetPDGCharge()/eplus << eTD << G4endl;
outFile << sTD << i->GetPDGCharge() / eplus << eTD << G4endl;
// column 5 life time
outFile << sTD << i->GetPDGLifeTime()/ns << eTD << G4endl;
outFile << sTD << i->GetPDGLifeTime() / ns << eTD << G4endl;
// column 6 AntiParticle
if ( (i->GetAntiPDGEncoding()!= 0) &&
(i->GetAntiPDGEncoding() != i->GetPDGEncoding() ) ) {
G4ParticleDefinition* anti_particle = G4ParticleTable::GetParticleTable()->FindParticle( i->GetAntiPDGEncoding() );
outFile << sTD << anti_particle->GetParticleName() << eTD << G4endl;;
if ((i->GetAntiPDGEncoding() != 0) && (i->GetAntiPDGEncoding() != i->GetPDGEncoding())) {
G4ParticleDefinition* anti_particle =
G4ParticleTable::GetParticleTable()->FindParticle(i->GetAntiPDGEncoding());
outFile << sTD << anti_particle->GetParticleName() << eTD << G4endl;
;
}
// end raw
outFile << eTR << G4endl;;
outFile << eTR << G4endl;
;
}
outFile << eTABLE << G4endl;
// footer
PrintFooter(outFile);
PrintFooter(outFile);
}
void G4HtmlPPReporter::GeneratePropertyTable(const G4ParticleDefinition* particle)
void G4HtmlPPReporter::GeneratePropertyTable(const G4ParticleDefinition* particle)
{
if (particle->GetPDGEncoding()<0) return;
if (particle->GetPDGEncoding() < 0) return;
G4String name = particle->GetParticleName();
//--- open index file -----
G4String fileName = baseDir + name + ".html";
// exception
if (name == "J/psi") fileName = baseDir +"jpsi.html";
std::ofstream outFile(fileName, std::ios::out );
outFile.setf( std::ios:: scientific, std::ios::floatfield );
if (name == "J/psi") fileName = baseDir + "jpsi.html";
std::ofstream outFile(fileName, std::ios::out);
outFile.setf(std::ios::scientific, std::ios::floatfield);
outFile << std::setprecision(7) << G4endl;
PrintHeader(outFile);
// particle name
outFile << "<H2>" << name << "</H2>" << G4endl;
outFile << "<HR>" << G4endl;
@@ -174,92 +171,110 @@ void G4HtmlPPReporter::SparseOption(const G4String& option)
// encoding, type
outFile << sTABLE << '"' << "40%" << '"' << " > " << G4endl;
outFile << sTR << sTD << sB << "PDG encoding" << eB << eTD;
outFile << sTD << particle->GetPDGEncoding() << eTD << eTR << G4endl;
outFile << sTD << particle->GetPDGEncoding() << eTD << eTR << G4endl;
outFile << sTR << sTD << sB << "Type" << eB << eTD;
outFile << sTD << particle->GetParticleType() << eTD << eTR << G4endl;
outFile << sTD << particle->GetParticleType() << eTD << eTR << G4endl;
outFile << eTABLE << G4endl;
outFile << "<HR>" << G4endl;
// Properties
// Properties
outFile << sTABLE << '"' << "60%" << '"' << " > " << G4endl;
// mass
outFile << sTR << sTD << sB << "Mass" << eB << eTD;
outFile << sTD << particle->GetPDGMass()/GeV;
outFile << sTD << particle->GetPDGMass() / GeV;
outFile << " [GeV/c" << sSUP << "2" << eSUP << "]" << eTD << eTR << G4endl;
// width
outFile << sTR << sTD << sB << "Width" << eB << eTD;
outFile << sTD << particle->GetPDGWidth()/GeV;
outFile << sTD << particle->GetPDGWidth() / GeV;
outFile << " [GeV/c" << sSUP << "2" << eSUP << "]" << eTD << eTR << G4endl;
// IJPC
outFile << sTR << sTD << sB << "I J" << sSUP << "PC"<< eSUP << eB << eTD;
if ( particle->GetPDGiIsospin() <0 ) {
outFile << sTR << sTD << sB << "I J" << sSUP << "PC" << eSUP << eB << eTD;
if (particle->GetPDGiIsospin() < 0) {
outFile << sTD << " ";
} else if ( particle->GetPDGiIsospin() == 1) {
outFile << sTD << "1/2 ";
} else if ( particle->GetPDGiIsospin() == 3) {
outFile << sTD << "3/2 ";
} else {
outFile << sTD << particle->GetPDGiIsospin()/2 << " ";
}
if ( particle->GetPDGiSpin() == 1) {
else if (particle->GetPDGiIsospin() == 1) {
outFile << sTD << "1/2 ";
}
else if (particle->GetPDGiIsospin() == 3) {
outFile << sTD << "3/2 ";
}
else {
outFile << sTD << particle->GetPDGiIsospin() / 2 << " ";
}
if (particle->GetPDGiSpin() == 1) {
outFile << "1/2";
} else if ( particle->GetPDGiSpin() == 3) {
outFile << "3/2";
} else if ( particle->GetPDGiSpin() == 5) {
outFile << "5/2";
} else if ( particle->GetPDGiSpin() == 7) {
outFile << "7/2";
} else if ( particle->GetPDGiSpin() == 9) {
outFile << "9/2";
} else if ( particle->GetPDGiSpin() == 11) {
outFile << "11/2";
} else if ( particle->GetPDGiSpin() == 13) {
outFile << "13/2";
} else {
outFile << particle->GetPDGiSpin()/2;
}
else if (particle->GetPDGiSpin() == 3) {
outFile << "3/2";
}
else if (particle->GetPDGiSpin() == 5) {
outFile << "5/2";
}
else if (particle->GetPDGiSpin() == 7) {
outFile << "7/2";
}
else if (particle->GetPDGiSpin() == 9) {
outFile << "9/2";
}
else if (particle->GetPDGiSpin() == 11) {
outFile << "11/2";
}
else if (particle->GetPDGiSpin() == 13) {
outFile << "13/2";
}
else {
outFile << particle->GetPDGiSpin() / 2;
}
outFile << sSUP << sSYMBOL;
if (particle->GetPDGiParity() == +1 ){
outFile << "+";
} else if (particle->GetPDGiParity() == -1 ){
outFile << "-";
} else {
if (particle->GetPDGiParity() == +1) {
outFile << "+";
}
else if (particle->GetPDGiParity() == -1) {
outFile << "-";
}
else {
outFile << " ";
}
if (particle->GetPDGiConjugation() == +1 ){
outFile << "+";
} else if (particle->GetPDGiConjugation() == -1 ){
outFile << "-";
} else {
if (particle->GetPDGiConjugation() == +1) {
outFile << "+";
}
else if (particle->GetPDGiConjugation() == -1) {
outFile << "-";
}
else {
outFile << " ";
}
outFile << eSYMBOL << eSUP;
outFile << eTD << eTR << G4endl;
outFile << eTD << eTR << G4endl;
// charge
outFile << sTR << sTD << sB << "Charge" << eB << eTD;
outFile << sTD << particle->GetPDGCharge()/eplus;
outFile << sTD << particle->GetPDGCharge() / eplus;
outFile << eTD << eTR << G4endl;
// Magnetic Moment
outFile << sTR << sTD << sB << "Magnetic Moment" << eB << eTD;
if (particle->GetPDGMagneticMoment() != 0.0){
outFile << sTD << particle->GetPDGMagneticMoment()/MeV*tesla;
if (particle->GetPDGMagneticMoment() != 0.0) {
outFile << sTD << particle->GetPDGMagneticMoment() / MeV * tesla;
outFile << "[MeV/T]" << eTD << eTR << G4endl;
} else {
outFile << sTD << " not defined ";
}
else {
outFile << sTD << " not defined ";
outFile << eTD << eTR << G4endl;
}
// life time
outFile << sTR << sTD << sB << "Life Time" << eB << eTD;
if ( particle->GetPDGLifeTime() >0.0 ) {
outFile << sTD << particle->GetPDGLifeTime()/second;
if (particle->GetPDGLifeTime() > 0.0) {
outFile << sTD << particle->GetPDGLifeTime() / second;
outFile << "[sec]" << eTD << G4endl;
} else {
}
else {
if (particle->GetPDGStable()) {
outFile << sTD << "stable" << eTD;
} else if (particle->IsShortLived()) {
}
else if (particle->IsShortLived()) {
outFile << sTD << "short-lived" << eTD;
} else {
outFile << sTD << "not Defined" << eTD;
}
else {
outFile << sTD << "not Defined" << eTD;
}
}
outFile << eTR << G4endl;
@@ -267,49 +282,54 @@ void G4HtmlPPReporter::SparseOption(const G4String& option)
outFile << eTABLE << G4endl;
outFile << "<HR>" << G4endl;
// Qurak content
outFile << "<H2>" << " Quark Content " << "</H2>" << G4endl;
// Qurak content
outFile << "<H2>"
<< " Quark Content "
<< "</H2>" << G4endl;
outFile << sTABLE << '"' << "60%" << '"' << " > " << G4endl;
outFile << sTR;
outFile << sTD << sB << "flavour " << eB << eTD ;
outFile << sTD << sB << " quark " << eB << eTD;
outFile << sTD << sB << " anti-quark " << eB << eTD;
outFile << sTD << sB << "flavour " << eB << eTD;
outFile << sTD << sB << " quark " << eB << eTD;
outFile << sTD << sB << " anti-quark " << eB << eTD;
outFile << eTR;
static const char* quarkName[6] = { "d", "u", "s", "c", "b", "t" };
for (G4int flv = 0; flv <6 ; flv++ ){
static const char* quarkName[6] = {"d", "u", "s", "c", "b", "t"};
for (G4int flv = 0; flv < 6; flv++) {
outFile << sTR;
outFile << sTD << sB << quarkName[flv] << eB << eTD ;
outFile << sTD << sB << particle->GetQuarkContent(flv+1) << eB << eTD ;
outFile << sTD << sB << particle->GetAntiQuarkContent(flv+1) << eB << eTD ;
outFile << sTD << sB << quarkName[flv] << eB << eTD;
outFile << sTD << sB << particle->GetQuarkContent(flv + 1) << eB << eTD;
outFile << sTD << sB << particle->GetAntiQuarkContent(flv + 1) << eB << eTD;
outFile << eTR;
}
outFile << eTABLE << G4endl;
outFile << "<HR>" << G4endl;
// Decay Table
G4DecayTable* dcyTable = particle->GetDecayTable();
if (dcyTable != nullptr) {
outFile << "<H2>" << " Decay Table " << "</H2>" << G4endl;
// Decay Table
G4DecayTable* dcyTable = particle->GetDecayTable();
if (dcyTable != nullptr) {
outFile << "<H2>"
<< " Decay Table "
<< "</H2>" << G4endl;
outFile << sTABLE << '"' << "80%" << '"' << " > " << G4endl;
outFile << sTR;
outFile << sTD << sB << "BR" << eB << eTD ;
outFile << sTD << sB << "kinematics" << eB << eTD;
outFile << sTD << sB << "BR" << eB << eTD;
outFile << sTD << sB << "kinematics" << eB << eTD;
outFile << eTR;
for (G4int i=0; i< dcyTable->entries(); i++){
G4VDecayChannel * channel = dcyTable->GetDecayChannel(i);
outFile << sTR << G4endl;;
for (G4int i = 0; i < dcyTable->entries(); i++) {
G4VDecayChannel* channel = dcyTable->GetDecayChannel(i);
outFile << sTR << G4endl;
;
// column 1 : BR
outFile << sTD << channel->GetBR() << eTD;
// column 2 : Kinematics
outFile << sTD << channel->GetKinematicsName() << eTD;
// column 3.. : daughters
for (G4int j=0; j< channel->GetNumberOfDaughters(); j++){
for (G4int j = 0; j < channel->GetNumberOfDaughters(); j++) {
outFile << sTD << channel->GetDaughter(j)->GetParticleName() << eTD;
}
outFile << eTR << G4endl;
@@ -317,51 +337,54 @@ void G4HtmlPPReporter::SparseOption(const G4String& option)
outFile << eTABLE << G4endl;
outFile << "<HR>" << G4endl;
}
outFile << sB;
outFile << "<A HREF=" << '"' << "index.html" << '"' << ">back to index</A>";
outFile << "<A HREF=" << '"' << "index.html" << '"' << ">back to index</A>";
outFile << eB << G4endl;
PrintFooter(outFile);
PrintFooter(outFile);
}
void G4HtmlPPReporter::PrintHeader(std::ofstream& outFile)
void G4HtmlPPReporter::PrintHeader(std::ofstream& outFile)
{
outFile << "<HTML>" << G4endl;
outFile << "<HEAD>" << G4endl;
outFile << " <META HTTP-EQUIV=" << "\"" << " Content-Type" << "\"";
outFile << " CONTENT="
<< "\"" << "text/html; charset=iso-8859-1"
<< "\"" << ">" << G4endl;
outFile << " <META HTTP-EQUIV="
<< "\""
<< " Content-Type"
<< "\"";
outFile << " CONTENT="
<< "\""
<< "text/html; charset=iso-8859-1"
<< "\""
<< ">" << G4endl;
outFile << " <TITLE>Geant4 Particle List </TITLE>" << G4endl;
outFile << "</HEAD>" << G4endl;
outFile << "<! -- Generated automatically by Geant4, "
<< " -- !>" << G4endl;
<< " -- !>" << G4endl;
outFile << "<BODY>" << G4endl;
}
void G4HtmlPPReporter::PrintFooter(std::ofstream& outFile)
void G4HtmlPPReporter::PrintFooter(std::ofstream& outFile)
{
outFile << "<HR>" << G4endl;
outFile << "</BODY>" << G4endl;
outFile << "</HTML>" << G4endl;
}
const char* G4HtmlPPReporter::sTABLE = "<TABLE WIDTH=";
const char* G4HtmlPPReporter::eTABLE = "</TABLE>";
const char* G4HtmlPPReporter::sTR = "<TR>";
const char* G4HtmlPPReporter::eTR = "</TR>";
const char* G4HtmlPPReporter::sTD = "<TD>";
const char* G4HtmlPPReporter::eTD = "</TD>";
const char* G4HtmlPPReporter::sB = "<B>";
const char* G4HtmlPPReporter::eB = "</B>";
const char* G4HtmlPPReporter::sLFONT = "<FONT SIZE = +1>";
const char* G4HtmlPPReporter::eLFONT = "</FONT>";
const char* G4HtmlPPReporter::sSYMBOL = "<FONT FACE = \"symbol\" >";
const char* G4HtmlPPReporter::eSYMBOL = "</FONT>";
const char* G4HtmlPPReporter::sSUP = "<SUP>";
const char* G4HtmlPPReporter::eSUP = "</SUP>";
const char* G4HtmlPPReporter::sSUB = "<SUB>";
const char* G4HtmlPPReporter::eSUB = "</SUB>";
const char* G4HtmlPPReporter::sTABLE = "<TABLE WIDTH=";
const char* G4HtmlPPReporter::eTABLE = "</TABLE>";
const char* G4HtmlPPReporter::sTR = "<TR>";
const char* G4HtmlPPReporter::eTR = "</TR>";
const char* G4HtmlPPReporter::sTD = "<TD>";
const char* G4HtmlPPReporter::eTD = "</TD>";
const char* G4HtmlPPReporter::sB = "<B>";
const char* G4HtmlPPReporter::eB = "</B>";
const char* G4HtmlPPReporter::sLFONT = "<FONT SIZE = +1>";
const char* G4HtmlPPReporter::eLFONT = "</FONT>";
const char* G4HtmlPPReporter::sSYMBOL = "<FONT FACE = \"symbol\" >";
const char* G4HtmlPPReporter::eSYMBOL = "</FONT>";
const char* G4HtmlPPReporter::sSUP = "<SUP>";
const char* G4HtmlPPReporter::eSUP = "</SUP>";
const char* G4HtmlPPReporter::sSUB = "<SUB>";
const char* G4HtmlPPReporter::eSUB = "</SUB>";
@@ -33,229 +33,203 @@
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//
// HISTORY
////////////////////////////////////////////////////////////////////////////////// IsomerLevel is added 30 Apr. 2013 H.Kurashige
////////////////////////////////////////////////////////////////////////////////// IsomerLevel is
/// added 30 Apr. 2013 H.Kurashige
//
#include "G4IsotopeMagneticMomentTable.hh"
#include "G4ios.hh"
#include "globals.hh"
#include "G4PhysicalConstants.hh"
#include "G4SystemOfUnits.hh"
#include <iomanip>
#include <fstream>
#include <sstream>
#include "G4ios.hh"
#include "globals.hh"
#include <fstream>
const G4double G4IsotopeMagneticMomentTable::levelTolerance = 2.0*keV;
// 0.1% torelance for excitation energy
const G4double G4IsotopeMagneticMomentTable::nuclearMagneton = eplus*hbar_Planck/2./(proton_mass_c2 /c_squared);
const G4double G4IsotopeMagneticMomentTable::levelTolerance = 2.0 * keV;
// Nuclear Magneton
///////////////////////////////////////////////////////////////////////////////
G4IsotopeMagneticMomentTable::G4IsotopeMagneticMomentTable()
:G4VIsotopeTable("MagneticMoment")
const G4double G4IsotopeMagneticMomentTable::nuclearMagneton =
eplus * hbar_Planck / 2. / (proton_mass_c2 / c_squared);
G4IsotopeMagneticMomentTable::G4IsotopeMagneticMomentTable() : G4VIsotopeTable("MagneticMoment")
{
if ( std::getenv("G4IONMAGNETICMOMENT") == nullptr) {
if (std::getenv("G4IONMAGNETICMOMENT") == nullptr) {
#ifdef G4VERBOSE
if (GetVerboseLevel()>1) {
G4cout << "G4IsotopeMagneticMomentTable::G4IsotopeMagneticMomentTable(): "
<< "Please setenv G4IONMAGNETICMOMENT for the magnetic moment data."
<< G4endl;
G4Exception( "G4IsotopeMagneticMomentTable",
"File Not Found",
JustWarning,
"Please setenv G4IONMAGNETICMOMENT");
if (GetVerboseLevel() > 1) {
G4cout << "G4IsotopeMagneticMomentTable::G4IsotopeMagneticMomentTable(): "
<< "Please setenv G4IONMAGNETICMOMENT for the magnetic moment data." << G4endl;
G4Exception("G4IsotopeMagneticMomentTable", "File Not Found", JustWarning,
"Please setenv G4IONMAGNETICMOMENT");
}
#endif
G4Exception( "G4IsotopeMagneticMomentTable",
"File Not Found",
JustWarning,
"Please setenv G4IONMAGNETICMOMENT");
G4Exception("G4IsotopeMagneticMomentTable", "File Not Found", JustWarning,
"Please setenv G4IONMAGNETICMOMENT");
return;
}
G4String file = std::getenv("G4IONMAGNETICMOMENT");
std::ifstream DataFile(file);
if (!DataFile ) {
if (!DataFile) {
#ifdef G4VERBOSE
if (GetVerboseLevel()>0) {
G4cout << "G4IsotopeMagneticMomentTable::G4IsotopeMagneticMomentTable(): "
<< file << " is not found " << G4endl;
if (GetVerboseLevel() > 0) {
G4cout << "G4IsotopeMagneticMomentTable::G4IsotopeMagneticMomentTable(): " << file
<< " is not found " << G4endl;
}
#endif
G4Exception( "G4IsotopeMagneticMomentTable",
"File Not Found",
JustWarning,
"Can not open G4IONMAGNETICMOMENT file");
G4Exception("G4IsotopeMagneticMomentTable", "File Not Found", JustWarning,
"Can not open G4IONMAGNETICMOMENT file");
return;
}
char inputChars[80]={' '};
while ( !DataFile.eof() ) { // Loop checking, 09.08.2015, K.Kurashige
char inputChars[80] = {' '};
while (!DataFile.eof()) { // Loop checking, 09.08.2015, K.Kurashige
DataFile.getline(inputChars, 80);
G4String inputLine = inputChars;
G4int ionA, ionZ, ionJ, isomer;
G4double ionE, ionMu, ionLife;
G4String ionName, ionLifeUnit;
if (inputChars[0] != '#' && inputLine.length() != 0) {
std::istringstream tmpstream(inputLine);
tmpstream >> ionZ >> ionName >> ionA
>> isomer >> ionE
>> ionLife >> ionLifeUnit
>> ionJ >> ionMu;
auto fProperty = new G4IsotopeProperty();
tmpstream >> ionZ >> ionName >> ionA >> isomer >> ionE >> ionLife >> ionLifeUnit >> ionJ
>> ionMu;
auto fProperty = new G4IsotopeProperty();
// Set Isotope Property
fProperty->SetAtomicNumber(ionZ);
fProperty->SetAtomicMass(ionA);
fProperty->SetIsomerLevel(isomer);
fProperty->SetEnergy(ionE * MeV);
fProperty->SetiSpin(ionJ);
fProperty->SetMagneticMoment(ionMu*nuclearMagneton);
fProperty->SetMagneticMoment(ionMu * nuclearMagneton);
fIsotopeList.push_back(fProperty);
//if (GetVerboseLevel()>2) {
// fProperty->DumpInfo();
//}
// if (GetVerboseLevel()>2) {
// fProperty->DumpInfo();
// }
}
}
DataFile.close();
}
///////////////////////////////////////////////////////////////////////////////
G4IsotopeMagneticMomentTable::~G4IsotopeMagneticMomentTable()
{
for (const auto & i : fIsotopeList) {
for (const auto& i : fIsotopeList) {
delete i;
}
fIsotopeList.clear();
}
///////////////////////////////////////////////////////////////////////////////
G4IsotopeMagneticMomentTable::G4IsotopeMagneticMomentTable(const G4IsotopeMagneticMomentTable & right)
:G4VIsotopeTable(right),
fIsotopeList(0)
{
}
G4IsotopeMagneticMomentTable::G4IsotopeMagneticMomentTable(
const G4IsotopeMagneticMomentTable& right)
: G4VIsotopeTable(right), fIsotopeList(0)
{}
///////////////////////////////////////////////////////////////////////////////
G4IsotopeMagneticMomentTable & G4IsotopeMagneticMomentTable::operator= (const G4IsotopeMagneticMomentTable &)
G4IsotopeMagneticMomentTable&
G4IsotopeMagneticMomentTable::operator=(const G4IsotopeMagneticMomentTable&)
{
return *this;
}
///////////////////////////////////////////////////////////////////////////////
G4bool G4IsotopeMagneticMomentTable::FindIsotope(G4IsotopeProperty* pP)
{
for (const auto fP : fIsotopeList) {
// check Z
if ( fP->GetAtomicNumber() > pP->GetAtomicNumber()) {
if (fP->GetAtomicNumber() > pP->GetAtomicNumber()) {
// Not Found
break;
}
if ( fP->GetAtomicNumber() < pP->GetAtomicNumber()) {
if (fP->GetAtomicNumber() < pP->GetAtomicNumber()) {
// next
continue;
}
// check A
if ( fP->GetAtomicMass() != pP->GetAtomicMass()) {
// next
continue;
}
//check isomerLevel
if (fP->GetIsomerLevel() != pP->GetIsomerLevel()) {
// next
continue;
}
//check E
// check A
if (fP->GetAtomicMass() != pP->GetAtomicMass()) {
// next
continue;
}
// check isomerLevel
if (fP->GetIsomerLevel() != pP->GetIsomerLevel()) {
// next
continue;
}
// check E
if (std::fabs(fP->GetEnergy() - pP->GetEnergy()) < levelTolerance) {
// Found
return true;
return true;
}
}
return false;
}
///////////////////////////////////////////////////////////////////////////////
//
G4IsotopeProperty*
G4IsotopeMagneticMomentTable::GetIsotope(G4int Z, G4int A, G4double E,
G4Ions::G4FloatLevelBase /*flb*/)
G4IsotopeProperty* G4IsotopeMagneticMomentTable::GetIsotope(G4int Z, G4int A, G4double E,
G4Ions::G4FloatLevelBase /*flb*/)
{
G4IsotopeProperty* fProperty = nullptr;
for (const auto fP : fIsotopeList) {
// check Z
if ( fP->GetAtomicNumber() > Z) {
if (fP->GetAtomicNumber() > Z) {
// Not Found
break;
}
if ( fP->GetAtomicNumber() < Z) {
if (fP->GetAtomicNumber() < Z) {
// next
continue;
}
// check A
if ( fP->GetAtomicMass() != A ) {
if (fP->GetAtomicMass() != A) {
// next
continue;
}
//check E
// check E
if (std::fabs(fP->GetEnergy() - E) < levelTolerance) {
// Found
fProperty = fP;
// fP->DumpInfo();
break;
break;
}
}
return fProperty;
}
///////////////////////////////////////////////////////////////////////
G4IsotopeProperty*
G4IsotopeMagneticMomentTable::GetIsotopeByIsoLvl(G4int Z, G4int A, G4int lvl)
G4IsotopeProperty* G4IsotopeMagneticMomentTable::GetIsotopeByIsoLvl(G4int Z, G4int A, G4int lvl)
{
G4IsotopeProperty* fProperty = nullptr;
for (const auto fP : fIsotopeList) {
// check Z
if ( fP->GetAtomicNumber() > Z) {
if (fP->GetAtomicNumber() > Z) {
// Not Found
break;
}
if ( fP->GetAtomicNumber() < Z) {
if (fP->GetAtomicNumber() < Z) {
// next
continue;
}
// check A
if ( fP->GetAtomicMass() != A ) {
if (fP->GetAtomicMass() != A) {
// next
continue;
}
//check isomerLevel
// check isomerLevel
if (fP->GetIsomerLevel() == lvl) {
// Found
fProperty = fP;
//fP->DumpInfo();
break;
// fP->DumpInfo();
break;
}
}
return fProperty;
}
@@ -22,25 +22,16 @@
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// the GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
//
//
// ---------------------------------------------------------------
#include "G4SimplePPReporter.hh"
#include "G4ios.hh"
#include "globals.hh"
/////////////////////
void G4SimplePPReporter::Print(const G4String& )
void G4SimplePPReporter::Print(const G4String&)
{
for (const auto ptr : pList){
ptr->Print();
for (const auto ptr : pList) {
ptr->Print();
G4cout << G4endl;
}
}
}
+37 -56
View File
@@ -22,92 +22,78 @@
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// the GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
//
//
// ---------------------------------------------------------------
#include "G4TextPPReporter.hh"
#include "G4DecayTable.hh"
#include "G4ParticleDefinition.hh"
#include "G4ParticleTable.hh"
#include "G4SystemOfUnits.hh"
#include "G4Tokenizer.hh"
#include "G4VDecayChannel.hh"
#include "G4ios.hh"
#include "globals.hh"
#include "G4SystemOfUnits.hh"
#include "G4ParticleTable.hh"
#include "G4ParticleDefinition.hh"
#include "G4DecayTable.hh"
#include "G4VDecayChannel.hh"
#include "G4Tokenizer.hh"
#include <iomanip>
#include <fstream>
/////////////////////
#include <fstream>
#include <iomanip>
void G4TextPPReporter::Print(const G4String& option)
{
SparseOption( option );
SparseOption(option);
for (const auto & i : pList){
G4ParticleDefinition* particle = G4ParticleTable::GetParticleTable()->FindParticle( i->GetParticleName() );
for (const auto& i : pList) {
G4ParticleDefinition* particle =
G4ParticleTable::GetParticleTable()->FindParticle(i->GetParticleName());
GeneratePropertyTable(particle);
}
}
}
void G4TextPPReporter::SparseOption(const G4String& option)
{
G4Tokenizer savedToken( option );
G4Tokenizer savedToken(option);
// 1st option : base directory
baseDir = savedToken();
if (!baseDir.empty()) {
if(baseDir.back()!='/') {
if (baseDir.back() != '/') {
baseDir += "/";
}
}
}
void G4TextPPReporter::GeneratePropertyTable(const G4ParticleDefinition* particle)
void G4TextPPReporter::GeneratePropertyTable(const G4ParticleDefinition* particle)
{
G4String name = particle->GetParticleName();
//--- open file -----
G4String fileName = baseDir + name + ".txt";
// exception
if (name == "J/psi") fileName = baseDir +"jpsi.txt";
if (name == "J/psi") fileName = baseDir + "jpsi.txt";
std::ofstream outFile(fileName, std::ios::out );
outFile.setf( std::ios:: scientific, std::ios::floatfield );
std::ofstream outFile(fileName, std::ios::out);
outFile.setf(std::ios::scientific, std::ios::floatfield);
outFile << std::setprecision(7) << G4endl;
// particle name encoding
outFile << name << " "
<< particle->GetPDGEncoding() << G4endl;
outFile << name << " " << particle->GetPDGEncoding() << G4endl;
// IJPC
outFile << particle->GetPDGiIsospin() << " "
<< particle->GetPDGiSpin() << " "
<< particle->GetPDGiParity() << " "
<< particle->GetPDGiConjugation() << G4endl;
outFile << particle->GetPDGiIsospin() << " " << particle->GetPDGiSpin() << " "
<< particle->GetPDGiParity() << " " << particle->GetPDGiConjugation() << G4endl;
// mass, width, charge
outFile << particle->GetPDGMass()/GeV << " "
<< particle->GetPDGWidth()/GeV << " "
<< particle->GetPDGCharge()/eplus << G4endl;
// mass, width, charge
outFile << particle->GetPDGMass() / GeV << " " << particle->GetPDGWidth() / GeV << " "
<< particle->GetPDGCharge() / eplus << G4endl;
// life time
outFile << particle->GetPDGLifeTime()/second << G4endl;
outFile << particle->GetPDGLifeTime() / second << G4endl;
// Decay Table
G4DecayTable* dcyTable = particle->GetDecayTable();
if (dcyTable != nullptr) {
for (G4int i=0; i< dcyTable->entries(); i++){
G4VDecayChannel * channel = dcyTable->GetDecayChannel(i);
// Decay Table
G4DecayTable* dcyTable = particle->GetDecayTable();
if (dcyTable != nullptr) {
for (G4int i = 0; i < dcyTable->entries(); i++) {
G4VDecayChannel* channel = dcyTable->GetDecayChannel(i);
// column 1 : BR
outFile << channel->GetBR() << " ";
// column 2. : daughters
@@ -115,15 +101,10 @@ void G4TextPPReporter::GeneratePropertyTable(const G4ParticleDefinition* partic
// column 3 : Kinematics
outFile << channel->GetKinematicsName() << " ";
// daughters
for (G4int j=0; j< channel->GetNumberOfDaughters(); j++){
for (G4int j = 0; j < channel->GetNumberOfDaughters(); j++) {
outFile << channel->GetDaughter(j)->GetParticleName() << " ";
}
outFile << G4endl;
}
}
}
+57 -67
View File
@@ -22,142 +22,132 @@
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// the GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
//
//
// ---------------------------------------------------------------
#include "G4TextPPRetriever.hh"
#include "G4DecayTable.hh"
#include "G4ParticleDefinition.hh"
#include "G4ParticleTable.hh"
#include "G4SystemOfUnits.hh"
#include "G4Tokenizer.hh"
#include "G4VDecayChannel.hh"
#include "G4ios.hh"
#include "globals.hh"
#include "G4SystemOfUnits.hh"
#include "G4ParticleTable.hh"
#include "G4ParticleDefinition.hh"
#include "G4DecayTable.hh"
#include "G4VDecayChannel.hh"
#include "G4Tokenizer.hh"
#include <iomanip>
#include <fstream>
/////////////////////
#include <fstream>
void G4TextPPRetriever::Retrieve(const G4String& option)
{
SparseOption( option );
// pointer to the particle table
SparseOption(option);
// pointer to the particle table
G4ParticleTable* theParticleTable = G4ParticleTable::GetParticleTable();
G4ParticleTable::G4PTblDicIterator* theParticleIterator;
theParticleIterator = theParticleTable->GetIterator();
// loop over all particles in G4ParticleTable
// loop over all particles in G4ParticleTable
theParticleIterator->reset();
while( (*theParticleIterator)() ){ // Loop checking, 09.08.2015, K.Kurashige
while ((*theParticleIterator)()) { // Loop checking, 09.08.2015, K.Kurashige
G4ParticleDefinition* particle = theParticleIterator->value();
ModifyPropertyTable(particle);
}
}
}
void G4TextPPRetriever::SparseOption(const G4String& option)
{
G4Tokenizer savedToken( option );
G4Tokenizer savedToken(option);
// 1st option : base directory
baseDir = savedToken();
if (!baseDir.empty()) {
if(baseDir.back()!='/') {
if (baseDir.back() != '/') {
baseDir += "/";
}
}
}
G4bool G4TextPPRetriever::ModifyPropertyTable(const G4ParticleDefinition* particle)
G4bool G4TextPPRetriever::ModifyPropertyTable(const G4ParticleDefinition* particle)
{
G4String name = particle->GetParticleName();
//--- open file -----
G4String fileName = baseDir + name + ".txt";
// exception
if (name == "J/psi") fileName = baseDir +"jpsi.txt";
if (name == "J/psi") fileName = baseDir + "jpsi.txt";
std::ifstream inFile(fileName, std::ios::in );
std::ifstream inFile(fileName, std::ios::in);
if (!inFile) return false;
// GetParticleProperty
G4ParticlePropertyData* pData = pPropertyTable->GetParticleProperty(name);
// particle name encoding
G4String name_t;
G4int encoding;
G4int encoding;
inFile >> name_t >> encoding;
if ( (name != name_t) || (encoding != pData->GetPDGEncoding()) ){
if ((name != name_t) || (encoding != pData->GetPDGEncoding())) {
G4cout << "G4TextPPRetriever::ModifyPropertyTable: ";
G4cout << "particle name or encoding mismatch for " << name ;
G4cout << "particle name or encoding mismatch for " << name;
G4cout << G4endl;
return false;
}
// IJPC
G4int iIsoSpin, iSpin, iParity, iConj;
inFile >> iIsoSpin >> iSpin >> iParity >> iConj;
if ( ( iIsoSpin != pData->GetPDGiIsospin()) ||
( iSpin != pData->GetPDGiSpin()) ||
( iParity != pData->GetPDGiParity()) ||
( iConj != pData->GetPDGiConjugation()) ){
G4int iIsoSpin, iSpin, iParity, iConj;
inFile >> iIsoSpin >> iSpin >> iParity >> iConj;
if ((iIsoSpin != pData->GetPDGiIsospin()) || (iSpin != pData->GetPDGiSpin())
|| (iParity != pData->GetPDGiParity()) || (iConj != pData->GetPDGiConjugation()))
{
G4cout << "G4TextPPRetriever::ModifyPropertyTable: ";
G4cout << "IJPC mismatch for " << name ;
G4cout << "IJPC mismatch for " << name;
G4cout << G4endl;
return false;
}
// mass, width, charge
// mass, width, charge
G4double mass, width, charge;
inFile >> mass >> width >> charge;
inFile >> mass >> width >> charge;
mass *= GeV;
width *= GeV;
charge *= eplus;
if (mass != pData->GetPDGMass()){ pData->SetPDGMass(mass);}
if (width != pData->GetPDGWidth()){ pData->SetPDGWidth(width);}
if (charge != pData->GetPDGCharge()){ pData->SetPDGCharge(charge);}
if (mass != pData->GetPDGMass()) {
pData->SetPDGMass(mass);
}
if (width != pData->GetPDGWidth()) {
pData->SetPDGWidth(width);
}
if (charge != pData->GetPDGCharge()) {
pData->SetPDGCharge(charge);
}
// life time
G4double tlife;
inFile >> tlife;
tlife *= second;
if (tlife != pData->GetPDGLifeTime()){ pData->SetPDGLifeTime(tlife);}
if (tlife != pData->GetPDGLifeTime()) {
pData->SetPDGLifeTime(tlife);
}
pPropertyTable->SetParticleProperty(*pData);
// Decay Table
G4DecayTable* dcyTable = particle->GetDecayTable();
// Decay Table
G4DecayTable* dcyTable = particle->GetDecayTable();
if (dcyTable == nullptr) return true;
G4int idx =0;
while (!inFile.eof() ) { // Loop checking, 09.08.2015, K.Kurashige
G4int idx = 0;
while (!inFile.eof()) { // Loop checking, 09.08.2015, K.Kurashige
G4double br;
G4int n_daughters;
G4int n_daughters;
inFile >> br >> n_daughters;
G4VDecayChannel * channel = dcyTable->GetDecayChannel(idx);
G4VDecayChannel* channel = dcyTable->GetDecayChannel(idx);
if ( n_daughters == channel->GetNumberOfDaughters()) {
if (n_daughters == channel->GetNumberOfDaughters()) {
channel->SetBR(br);
}
idx += 1;
if (idx>= dcyTable->entries()) break;
if (idx >= dcyTable->entries()) break;
}
return true;
}
@@ -22,61 +22,52 @@
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// the GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
//
//
// ---------------------------------------------------------------
#include "G4VParticlePropertyReporter.hh"
#include "G4ParticleDefinition.hh"
#include "G4ParticleTable.hh"
////////////////////////////
G4VParticlePropertyReporter::G4VParticlePropertyReporter()
{
pPropertyTable = G4ParticlePropertyTable::GetParticlePropertyTable();
pPropertyTable = G4ParticlePropertyTable::GetParticlePropertyTable();
}
/////////////////////////////
G4VParticlePropertyReporter::~G4VParticlePropertyReporter()
{
pList.clear();
pPropertyTable->Clear();
}
}
///////////////////////////
G4bool G4VParticlePropertyReporter::FillList(G4String name)
{
G4ParticlePropertyData* pData = pPropertyTable->GetParticleProperty(name);
G4bool result = false;
if (pData != nullptr) {
//the particle exists
// the particle exists
pList.push_back(pData);
result = true;
} else {
}
else {
// pointer to the particle table
G4ParticleTable* theParticleTable = G4ParticleTable::GetParticleTable();
G4ParticleTable::G4PTblDicIterator* theParticleIterator;
theParticleIterator = theParticleTable->GetIterator();
// loop over all particles in G4ParticleTable
// loop over all particles in G4ParticleTable
theParticleIterator->reset();
while( (*theParticleIterator)() ){ // Loop checking, 09.08.2015, K.Kurashige
while ((*theParticleIterator)()) { // Loop checking, 09.08.2015, K.Kurashige
G4ParticleDefinition* particle = theParticleIterator->value();
G4String type = particle->GetParticleType();
pData =pPropertyTable->GetParticleProperty(particle);
if ( name == "all" ) {
pList.push_back(pData);
pData = pPropertyTable->GetParticleProperty(particle);
if (name == "all") {
pList.push_back(pData);
result = true;
} else if ( name == type ) {
pList.push_back(pData);
}
else if (name == type) {
pList.push_back(pData);
result = true;
}
}
}
}
return result;
@@ -86,11 +77,3 @@ void G4VParticlePropertyReporter::Clear()
{
pList.clear();
}