src/tools/geant4/G4ExceptionHandler.hpp
Set of Geant4 utilities for framework integration. More…
Namespaces
Name |
---|
allpix Helper class to hold support layers for a detector model. |
Classes
Name | |
---|---|
class | allpix::G4ExceptionHandler Exception handler for Geant4. |
Detailed Description
Set of Geant4 utilities for framework integration.
Copyright: Copyright (c) 2021-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
#ifndef ALLPIX_GEANT4_EXCEPTIONS_H
#define ALLPIX_GEANT4_EXCEPTIONS_H
#include "core/module/exceptions.h"
#include "core/utils/log.h"
#include <G4VExceptionHandler.hh>
namespace allpix {
class G4ExceptionHandler : public G4VExceptionHandler {
public:
G4bool Notify(const char*, const char* code, G4ExceptionSeverity severity, const char* description) override {
std::string message = "Caught Geant4 exception " + std::string(code) + ": " + std::string(description);
if(severity == G4ExceptionSeverity::JustWarning && std::string(code) != "pl0003") {
LOG(WARNING) << message;
} else if(severity == G4ExceptionSeverity::EventMustBeAborted) {
throw AbortEventException(message);
} else if(severity == G4ExceptionSeverity::RunMustBeAborted) {
throw EndOfRunException(message);
} else {
throw ModuleError(message);
}
// Continue program execution:
return false;
};
};
} // namespace allpix
#endif /* ALLPIX_GEANT4_EXCEPTIONS_H */
Updated on 2024-12-13 at 08:31:37 +0000