Skip to content

Commit

Permalink
Add function to convert PDG type code to string
Browse files Browse the repository at this point in the history
  • Loading branch information
sfegan committed Jul 9, 2024
1 parent 607a2f5 commit 7fb9451
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/simulation/geant4_shower_generator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ class Geant4ShowerGenerator: public calin::simulation::tracker::ShowerGenerator
static double get_material_density(const std::string& material_name);
static config_type default_config();

std::string pdg_type_to_string(int pdg_type);

protected:
void construct(unsigned num_atm_layers, VerbosityLevel verbose_level,
double default_cut_value_cm, double detector_size, const std::string& material_name);
Expand Down
13 changes: 13 additions & 0 deletions src/simulation/geant4_shower_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,19 @@ get_material_density(const std::string& material_name)
return material->GetDensity() / (CLHEP::g/CLHEP::cm3);
}

std::string Geant4ShowerGenerator::pdg_type_to_string(int pdg_type)
{
G4ParticleTable* table = G4ParticleTable::GetParticleTable();
if(table) {
const G4ParticleDefinition* particle = table->FindParticle(pdg_type);
if(particle) {
return particle->GetParticleType();
}
}
return std::to_string(pdg_type);
}


Geant4ShowerGenerator::config_type Geant4ShowerGenerator::default_config()
{
config_type config;
Expand Down

0 comments on commit 7fb9451

Please sign in to comment.