Commit e3851ecf authored by Paul Schütze's avatar Paul Schütze
Browse files

Merge branch 'p-physlist-uppercase' into 'master'

DepositionGeant4: Fix PhysicsList Check ignoring non-uppercase names

See merge request allpix-squared/allpix-squared!1131
parents a6519d17 be0bb4c1
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -12,6 +12,8 @@
#ifndef ALLPIX_ADDITIONAL_PHYSICS_LISTS_H
#define ALLPIX_ADDITIONAL_PHYSICS_LISTS_H

#include "core/utils/text.h"

#include <G4VModularPhysicsList.hh>

#ifdef ALLPIX_PHYSICSLIST_MICROELEC
@@ -27,12 +29,15 @@ namespace allpix::physicslists {
    /**
     * @brief Function to obtain
     * @param  list_name    Name of the additional physics list
     *
     * @note Name check is performed with provided case and upper-case list names
     *
     * @return              Pointer to the G4VModularPhysicsList of the found physics list, or a nullptr if not found.
     */
    inline G4VModularPhysicsList* getList(const std::string& list_name) {

#ifdef ALLPIX_PHYSICSLIST_MICROELEC
        if(list_name == "MICROELEC-SIONLY") {
        if(list_name == "MICROELEC-SIONLY" || allpix::transform(list_name, ::toupper) == "MICROELEC-SIONLY") {
            // Downcasting from a G4VUserPhysicsList* to a G4VModularPhysicsList
            return dynamic_cast<G4VModularPhysicsList*>(new MicroElecSiPhysics());
        }
+13 −7
Original line number Diff line number Diff line
@@ -169,7 +169,8 @@ void DepositionGeant4Module::initialize() {
    }

    // Find the physics list
    auto physics_list = allpix::transform(config_.get<std::string>("physics_list"), ::toupper);
    auto physics_list_up = allpix::transform(config_.get<std::string>("physics_list"), ::toupper);
    auto physics_list = config_.get<std::string>("physics_list");
    G4PhysListFactory physListFactory;
    G4VModularPhysicsList* physicsList{nullptr};

@@ -181,10 +182,15 @@ void DepositionGeant4Module::initialize() {
        if(physicsList == nullptr) {
            // Geant4 throws an exception if the list is not found
            physicsList = physListFactory.GetReferencePhysList(physics_list);
            // ...but older versions of it don't, so let's do this ourselves:
        }

        // Upper-case version of config
        if(physicsList == nullptr) {
                throw ModuleError("");
            physicsList = physListFactory.GetReferencePhysList(physics_list_up);
        }

        if(physicsList == nullptr) {
            throw ModuleError("");
        }
    } catch(ModuleError&) {
        std::string message = "specified physics list does not exists";
@@ -214,8 +220,8 @@ void DepositionGeant4Module::initialize() {
    LOG(DEBUG) << "Registering Geant4 step limiter physics list";
    physicsList->RegisterPhysics(new G4StepLimiterPhysics());

    // Register radioactive decay physics lists unless we are using a _HP list which include this already:
    if(physics_list.find("_HP") == std::string::npos) {
    // Register radioactive decay physics lists unless the list already has it registered:
    if(physics_list_up.find("HP") == std::string::npos && physics_list.find("Shielding") == std::string::npos) {
        LOG(DEBUG) << "Registering Geant4 radioactive decay physics list";
        physicsList->RegisterPhysics(new G4RadioactiveDecayPhysics());
    }