src/modules/DepositionGeant4/StepInfoUserHookG4.cpp

Implements a user hook for Geant4 stepping action to catch problematic events and abort them. More…

Detailed Description

Implements a user hook for Geant4 stepping action to catch problematic events and abort them.

Copyright: Copyright (c) 2023-2024 CERN and the Allpix Squared authors. This software is distributed under the terms of the MIT License, copied verbatim in the file “LICENSE.md”. In applying this license, CERN does not waive the privileges and immunities granted to it by virtue of its status as an Intergovernmental Organization or submit itself to any jurisdiction. SPDX-License-Identifier: MIT

Source code


#include "StepInfoUserHookG4.hpp"
#include "DepositionGeant4Module.hpp"

#include "tools/geant4/RunManager.hpp"

using namespace allpix;

void StepInfoUserHookG4::UserSteppingAction(const G4Step* aStep) {
    if(aStep->GetStepLength() < 0) {
        LOG(WARNING) << "Negative step length found; aborting event.";

        // Load the G4 run manager (which is owned by the geometry builder), and call AbortRun() to abort the current event
        G4RunManager::GetRunManager()->AbortRun();
    }
}

Updated on 2024-12-13 at 08:31:37 +0000