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

Merge branch 'coverity' into 'master'

Fix Some Coverity Findings

See merge request allpix-squared/allpix-squared!562
parents ffc1ce63 bd7fd93c
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
+1 −1
Original line number Diff line number Diff line
@@ -145,7 +145,7 @@ void DetectorHistogrammerModule::initialize() {
    // Create cluster size plots, preventing a zero-bin histogram by scaling with integer ceiling: (x + y - 1) / y
    std::string cluster_size_title = "Cluster size for " + detector_->getName() + ";cluster size [px];clusters";
    cluster_size = CreateHistogram<TH1D>(
        "cluster_size", cluster_size_title.c_str(), (xpixels * ypixels + 9) / 10, 0.5, (xpixels * ypixels + 9) / 10 + 0.5);
        "cluster_size", cluster_size_title.c_str(), (xpixels * ypixels + 9) / 10, 0.5, (xpixels * ypixels + 9.0) / 10 + 0.5);

    std::string cluster_size_x_title = "Cluster size X for " + detector_->getName() + ";cluster size x [px];clusters";
    cluster_size_x = CreateHistogram<TH1D>("cluster_size_x", cluster_size_x_title.c_str(), xpixels, 0.5, xpixels + 0.5);
Loading