Commit 8e8819ea authored by Simon Spannagel's avatar Simon Spannagel
Browse files

DepositionG4: TrackInfoManager is now able to also store all tracks from the event

(cherry picked from commit a81d5298)
parent 8de4db0a
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -11,7 +11,7 @@

using namespace allpix;

TrackInfoManager::TrackInfoManager() : counter_(1) {}
TrackInfoManager::TrackInfoManager(bool record_all) : counter_(1), record_all_(record_all) {}

std::unique_ptr<TrackInfoG4> TrackInfoManager::makeTrackInfo(const G4Track* const track) {
    auto custom_id = counter_++;
@@ -33,8 +33,15 @@ void TrackInfoManager::setTrackInfoToBeStored(int track_id) {
void TrackInfoManager::storeTrackInfo(std::unique_ptr<TrackInfoG4> the_track_info) {
    auto track_id = the_track_info->getID();
    auto element = std::find(to_store_track_ids_.begin(), to_store_track_ids_.end(), track_id);
    if(element != to_store_track_ids_.end()) {

    if(record_all_ || element != to_store_track_ids_.end()) {
        LOG(TRACE) << "Storing MCTrack with ID " << track_id;
        stored_track_infos_.push_back(std::move(the_track_info));
    } else {
        LOG(TRACE) << "Not storing MCTrack with ID " << track_id;
    }

    if(element != to_store_track_ids_.end()) {
        to_store_track_ids_.erase(element);
    }
}
+5 −1
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@ namespace allpix {
        /**
         * @brief Default constructor
         */
        TrackInfoManager();
        explicit TrackInfoManager(bool record_all);

        /**
         * @brief Factory method for TrackInfoG4 instances
@@ -99,6 +99,10 @@ namespace allpix {

        // Counter to store highest assigned track id
        int counter_{};

        // Store configuration whether all tracks or only those connected to sensor should be stored
        bool record_all_{};

        // Geant4 id to custom id translation
        std::map<int, int> g4_to_custom_id_{};
        // Custom id to custom parent id tracking