Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-11-07 09:43:35

0001 //------------------------------- -*- C++ -*- -------------------------------//
0002 // Copyright Celeritas contributors: see top-level COPYRIGHT file for details
0003 // SPDX-License-Identifier: (Apache-2.0 OR MIT)
0004 //---------------------------------------------------------------------------//
0005 //! \file accel/PGPrimaryGeneratorAction.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include <G4Event.hh>
0010 #include <G4ParticleDefinition.hh>
0011 #include <G4ParticleGun.hh>
0012 #include <G4VUserPrimaryGeneratorAction.hh>
0013 
0014 #include "corecel/Types.hh"
0015 #include "corecel/cont/Array.hh"
0016 #include "celeritas/phys/PrimaryGenerator.hh"
0017 
0018 namespace celeritas
0019 {
0020 //---------------------------------------------------------------------------//
0021 /*!
0022  * Generate events from a particle gun.
0023  *
0024  * This generates primary particles with energy, position, and direction
0025  * sampled from distributions specified by the user in \c
0026  * PrimaryGeneratorOptions.
0027  *
0028  * \sa PrimaryGenerator
0029  */
0030 class PGPrimaryGeneratorAction final : public G4VUserPrimaryGeneratorAction
0031 {
0032   public:
0033     //!@{
0034     //! \name Type aliases
0035     using Input = inp::CorePrimaryGenerator;
0036     //!@}
0037 
0038   public:
0039     // Construct primary action
0040     explicit PGPrimaryGeneratorAction(Input const& opts);
0041 
0042     // Generate events
0043     void GeneratePrimaries(G4Event* event) final;
0044 
0045   private:
0046     using GeneratorImpl = celeritas::PrimaryGenerator;
0047 
0048     std::vector<PDGNumber> pdg_;
0049     GeneratorImpl generate_primaries_;
0050     G4ParticleGun gun_;
0051 };
0052 
0053 //---------------------------------------------------------------------------//
0054 }  // namespace celeritas