src/modules/DepositionGeant4/SensitiveDetectorActionG4.hpp

Defines the handling of the sensitive device. More…

Namespaces

Name
allpix
Helper class to hold support layers for a detector model.

Classes

Name
class allpix::SensitiveDetectorActionG4
Handles the steps of the particles in all sensitive devices.

Detailed Description

Defines the handling of the sensitive device.

Copyright: Copyright (c) 2017-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_SIMPLE_DEPOSITION_MODULE_SENSITIVE_DETECTOR_ACTION_H
#define ALLPIX_SIMPLE_DEPOSITION_MODULE_SENSITIVE_DETECTOR_ACTION_H

#include <memory>

#include <G4VSensitiveDetector.hh>
#include <G4WrapperProcess.hh>

#include "core/geometry/Detector.hpp"
#include "core/messenger/Messenger.hpp"
#include "core/module/Module.hpp"

#include "objects/DepositedCharge.hpp"
#include "objects/MCParticle.hpp"

#include "TrackInfoManager.hpp"

namespace allpix {
    class Event;

    class SensitiveDetectorActionG4 : public G4VSensitiveDetector {
    public:
        SensitiveDetectorActionG4(const std::shared_ptr<Detector>& detector,
                                  TrackInfoManager* track_info_manager,
                                  double charge_creation_energy,
                                  double fano_factor,
                                  double cutoff_time);

        unsigned int getTotalDepositedCharge() const;

        unsigned int getDepositedCharge() const;

        double getTotalDepositedEnergy() const;

        double getDepositedEnergy() const;

        std::vector<ROOT::Math::XYZPoint> getTrackIncidentPositions() const;

        void clearEventInfo();

        std::string getName() const;

        void seed(uint64_t random_seed) { random_generator_.seed(random_seed); }

        G4bool ProcessHits(G4Step* step, G4TouchableHistory* history) override;

        void dispatchMessages(Module* module, Messenger* messenger, Event* event);

    private:
        std::shared_ptr<Detector> detector_;
        // Pointer to track info manager to register tracks which pass through sensitive detectors
        TrackInfoManager* track_info_manager_;

        double charge_creation_energy_;
        double fano_factor_;
        double cutoff_time_;

        RandomNumberGenerator random_generator_;

        // Statistics of total and per-event deposited charge
        unsigned int total_deposited_charge_{};
        unsigned int deposited_charge_{};
        double total_deposited_energy_{};
        double deposited_energy_{};

        // List of positions for deposits
        std::vector<ROOT::Math::XYZPoint> deposit_position_;
        std::vector<ROOT::Math::XYZPoint> incident_track_position_;

        std::vector<unsigned int> deposit_charge_;
        std::vector<double> deposit_energy_;
        std::vector<double> deposit_time_;

        // List of begin points for tracks
        std::map<int, ROOT::Math::XYZPoint> track_begin_;
        // List of end points for tracks
        std::map<int, ROOT::Math::XYZPoint> track_end_;
        // Parent of all mc tracks
        std::map<int, int> track_parents_;
        // PDG code of the tracks
        std::map<int, int> track_pdg_;
        // Arrival timestamp of the tracks
        std::map<int, double> track_time_;
        // Total charge by track
        std::map<int, unsigned int> track_charge_;
        // Total energy by track at start point
        std::map<int, double> track_total_energy_start_;
        // Kinetic energy by track at start point
        std::map<int, double> track_kinetic_energy_start_;

        // Map from deposit index to track id
        std::vector<int> deposit_to_id_;
        // Map from track id to mc particle index
        std::map<int, size_t> id_to_particle_;
    };
} // namespace allpix

#endif /* ALLPIX_SIMPLE_DEPOSITION_MODULE_SENSITIVE_DETECTOR_ACTION_H */

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