Unverified Commit 0c421b0b authored by Stephan Lachnit's avatar Stephan Lachnit
Browse files

DepositionGeant4: support old ion source definition



This allows using the old ion/Z/A/Q/E source definition again, but emits a
warning pointing to the new definition when using it.

Signed-off-by: default avatarStephan Lachnit <stephanlachnit@debian.org>
parent bfd49541
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -270,6 +270,14 @@ void GeneratorActionG4::GeneratePrimaries(G4Event* event) {
                    particle->SetPDGLifeTime(0.);
                }
                single_source->SetParticleCharge(allpix::from_string<int>(ion[3]));
            } else if(std::regex_match(
                          particle_type_, ion, std::regex("ion/([0-9]+)/([0-9]+)/([-+]?[0-9]+)/([0-9.]+(?:[a-zA-Z]+)?)")) &&
                      ion.ready()) {
                // Parse old declaration with /Z/A/Q/E
                particle = G4IonTable::GetIonTable()->GetIon(
                    allpix::from_string<int>(ion[1]), allpix::from_string<int>(ion[2]), allpix::from_string<double>(ion[4]));
                single_source->SetParticleCharge(allpix::from_string<int>(ion[3]));
                LOG(WARNING) << "Using \"ion/Z/A/Q/E\" is deprecated and superseded by \"ion/Z/A/Q/E/D\".";
            } else {
                throw InvalidValueError(config_, "particle_type", "cannot parse parameters for ion.");
            }