30int main(
int argc,
char** argv)
32 if (argc != 3 || std::string(argv[1]) !=
"--output") {
33 std::cerr <<
"Usage: " << argv[0] <<
" --output <file>\n";
37 std::ofstream os{argv[2]};
39 std::cerr <<
"Cannot open " << argv[2] <<
"\n";
47 auto vmc =
new TGeant4(
"TGeant4",
"The Geant4 Monte Carlo", runConfiguration);
51 os <<
"# Geant4 particle table, Geant4 version " << G4VERSION_NUMBER <<
"\n";
52 os <<
"# physics setup: " << physicsSetup <<
"\n";
53 os <<
"# pdg g4name ctau_mm shortlived hasDecayTable\n";
55 auto table = G4ParticleTable::GetParticleTable();
56 auto it = table->GetIterator();
60 auto particle = it->value();
61 int pdg = particle->GetPDGEncoding();
65 double lifetime = particle->GetPDGLifeTime();
67 double ctau = lifetime > 0. ? lifetime * CLHEP::c_light : 0.;
69 std::snprintf(
buf,
sizeof(
buf),
"%.6g", ctau);
70 os << pdg <<
" " << particle->GetParticleName() <<
" " <<
buf <<
" "
71 << (particle->IsShortLived() ? 1 : 0) <<
" "
72 << (particle->GetDecayTable() ? 1 : 0) <<
"\n";
75 std::cout <<
"Wrote " << nParticles <<
" particles to " << argv[2] <<
"\n";