Commit 412c8de4 authored by Simon Spannagel's avatar Simon Spannagel
Browse files

DepositionGeant4: TrackInfoManager is static thread_local, we don't need a...

DepositionGeant4: TrackInfoManager is static thread_local, we don't need a pointer to the module anymore
parent c4922dc9
Loading
Loading
Loading
Loading
+2 −5
Original line number Diff line number Diff line
@@ -18,14 +18,12 @@
#include "SetTrackInfoUserHookG4.hpp"

namespace allpix {
    class DepositionGeant4Module;
    /**
     * @brief Initializer for the tracker and generator actions, required for \ref RunManager
     */
    class ActionInitializationG4 : public G4VUserActionInitialization {
    public:
        explicit ActionInitializationG4(const Configuration& config, DepositionGeant4Module* module)
            : config_(config), module_(module){};
        explicit ActionInitializationG4(const Configuration& config) : config_(config){};

        /**
         * @brief Build the user action to be executed by the worker
@@ -36,7 +34,7 @@ namespace allpix {
            SetUserAction(new GeneratorActionG4(config_));

            // tracker hook
            SetUserAction(new SetTrackInfoUserHookG4(module_));
            SetUserAction(new SetTrackInfoUserHookG4());
        };

        /**
@@ -57,7 +55,6 @@ namespace allpix {

    private:
        const Configuration& config_;
        DepositionGeant4Module* module_;
    };
} // namespace allpix

+1 −1
Original line number Diff line number Diff line
@@ -245,7 +245,7 @@ void DepositionGeant4Module::initialize() {
    // User hook to store additional information at track initialization and termination as well as custom track ids
    LOG(TRACE) << "Constructing particle source";

    auto* action_initialization = new ActionInitializationG4(config_, this);
    auto* action_initialization = new ActionInitializationG4(config_);
    run_manager_g4_->SetUserInitialization(action_initialization);

    // Get the creation energy for charge (default is silicon electron hole pair energy)
+2 −2
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@ using namespace allpix;
void SetTrackInfoUserHookG4::PreUserTrackingAction(const G4Track* aTrack) {
    auto theTrack = const_cast<G4Track*>(aTrack); // NOLINT
    if(aTrack->GetUserInformation() == nullptr) {
        auto trackInfo = module_->track_info_manager_->makeTrackInfo(aTrack);
        auto trackInfo = DepositionGeant4Module::track_info_manager_->makeTrackInfo(aTrack);
        // Release ownership of the TrackInfoG4 instance
        theTrack->SetUserInformation(trackInfo.release());
    }
@@ -30,5 +30,5 @@ void SetTrackInfoUserHookG4::PostUserTrackingAction(const G4Track* aTrack) {
    auto userInfoOwningPtr = std::unique_ptr<TrackInfoG4>(userInfo);
    auto theTrack = const_cast<G4Track*>(aTrack); // NOLINT
    theTrack->SetUserInformation(nullptr);
    module_->track_info_manager_->storeTrackInfo(std::move(userInfoOwningPtr));
    DepositionGeant4Module::track_info_manager_->storeTrackInfo(std::move(userInfoOwningPtr));
}
+1 −6
Original line number Diff line number Diff line
@@ -18,7 +18,6 @@
#include "TrackInfoManager.hpp"

namespace allpix {
    class DepositionGeant4Module;
    /**
     * @brief Assigns every G4Track a TrackInfoG4 which carries various information, including the custom track id
     */
@@ -28,7 +27,7 @@ namespace allpix {
         * @brief Constructor taking a TrackInfoManager*
         * @param module Pointer to the DepositionGeant4 module, required to create the TrackInfoG4 instances
         */
        explicit SetTrackInfoUserHookG4(DepositionGeant4Module* module) : module_(module){};
        explicit SetTrackInfoUserHookG4() = default;

        /**
         * @brief Default destructor
@@ -46,10 +45,6 @@ namespace allpix {
         * @param aTrack The pointer to the G4Track for which this routine is called
         */
        void PostUserTrackingAction(const G4Track* aTrack) override;

    private:
        // Raw ptr to module holding track info manager to create instances of TrackInfoG4
        DepositionGeant4Module* module_;
    };

} // namespace allpix