src/modules/DepositionGenerator/PrimariesReader.hpp

Defines a generic and purely virtual particle reader interface class. More…

Namespaces

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

Classes

Name
class allpix::PrimariesReader
Interface class to read primary particles from input data in different file formats.
class allpix::PrimariesReader::Particle
Particle class to hold information for primary particles before dispatching them to Geant4.

Detailed Description

Defines a generic and purely virtual particle reader interface class.

Copyright: Copyright (c) 2022-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_GENERATOR_DEPOSITION_MODULE_READER_H
#define ALLPIX_GENERATOR_DEPOSITION_MODULE_READER_H

#include <memory>

#include <G4ThreeVector.hh>

#include "core/config/Configuration.hpp"

namespace allpix {
    class PrimariesReader {
        friend class DepositionGeneratorModule;

    public:
        enum class FileModel {
            GENIE,      
            HEPMC,      
            HEPMC2,     
            HEPMCROOT,  
            HEPMCTTREE, 
        };

        class Particle {
        public:
            Particle(int id, double e, G4ThreeVector dir, G4ThreeVector pos, double t)
                : id_(id), energy_(e), direction_(std::move(dir)), position_(std::move(pos)), time_(t) {}

            int pdg() const { return id_; }

            double energy() const { return energy_; }

            G4ThreeVector direction() const { return direction_; }

            G4ThreeVector position() const { return position_; }

            double time() const { return time_; }

        private:
            int id_;
            double energy_;
            G4ThreeVector direction_;
            G4ThreeVector position_;
            double time_;
        };

        PrimariesReader() = default;
        virtual ~PrimariesReader() = default;

        virtual std::vector<Particle> getParticles() = 0;

        uint64_t eventNum() const { return event_num_; }

    private:
        void set_event_num(uint64_t event_num) { event_num_ = event_num; }
        uint64_t event_num_;
    };
} // namespace allpix

#endif /* ALLPIX_GENERATOR_DEPOSITION_MODULE_READER_H */

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