src/modules/DepositionGeant4/TrackInfoManager.hpp

The TrackInfoManager class, contains a factory method for TrackInfoG4 to be used in AP2 as well as handling and dispatching MCTracks. More…

Namespaces

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

Classes

Name
class allpix::TrackInfoManager
The TrackInfoManager is a factory for TrackInfoG4 objects and manages MCTracks within AP2.

Detailed Description

The TrackInfoManager class, contains a factory method for TrackInfoG4 to be used in AP2 as well as handling and dispatching MCTracks.

Copyright: Copyright (c) 2018-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 TrackInfoManager_H
#define TrackInfoManager_H 1

#include <map>

#include "G4Track.hh"
#include "TrackInfoG4.hpp"

#include "core/module/Event.hpp"
#include "core/module/Module.hpp"
#include "objects/MCTrack.hpp"

namespace allpix {
    class TrackInfoManager {
    public:
        explicit TrackInfoManager(bool record_all);

        std::unique_ptr<TrackInfoG4> makeTrackInfo(const G4Track* const track);

        void storeTrackInfo(std::unique_ptr<TrackInfoG4> the_track_info);

        void setTrackInfoToBeStored(int track_id);

        void resetTrackInfoManager();

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

        void createMCTracks();

        MCTrack const* findMCTrack(int track_id) const;

    private:
        void set_all_track_parents();

        // 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
        std::map<int, int> track_id_to_parent_id_{};
        // List of track ids to be stored if they are provided via #storeTrackInfo
        std::vector<int> to_store_track_ids_;
        // The TrackInfoG4 instances which are handed over to this track manager
        std::vector<std::unique_ptr<TrackInfoG4>> stored_track_infos_;
        // The MCTrack vector which is dispatched via #dispatchMessage
        std::vector<MCTrack> stored_tracks_;
        // Ids ins same order as tracks stored in #stored_tracks_
        std::vector<int> stored_track_ids_;
        // Id to index in #stored_tracks_ for easier handling
        std::map<int, MCTrack const*> id_to_track_;
    };
} // namespace allpix
#endif /* TrackInfoManager_H */

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