Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-16 08:27:18

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/FastSimulationModel.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include <G4VFastSimulationModel.hh>
0010 #include <G4Version.hh>
0011 
0012 namespace celeritas
0013 {
0014 class SharedParams;
0015 class LocalTransporter;
0016 
0017 //---------------------------------------------------------------------------//
0018 /*!
0019  * Offload tracks to Celeritas via G4VFastSimulationModel interface.
0020  *
0021  * This class must be constructed locally on each worker thread/task, typically
0022  * within the application's concrete implementation of
0023  * `G4VUserDetectorConstruction::ConstructSDandField()`.
0024  *
0025  * Note that the argument \c G4Envelope is a type alias to \c G4Region.
0026  *
0027  * \todo Maybe need a helper to create a single fast sim model for multiple
0028  * regions?
0029  */
0030 class FastSimulationModel final : public G4VFastSimulationModel
0031 {
0032   public:
0033     // Construct using the FastSimulationIntegration for a region
0034     explicit FastSimulationModel(G4Envelope* region);
0035 
0036     // Construct without attaching to a region
0037     FastSimulationModel(G4String const& name,
0038                         SharedParams const* params,
0039                         LocalTransporter* local);
0040 
0041     // Construct and build a fast sim manager for the given region
0042     FastSimulationModel(G4String const& name,
0043                         G4Envelope* region,
0044                         SharedParams const* params,
0045                         LocalTransporter* local);
0046 
0047     // Return true if model is applicable to the `G4ParticleDefinition`
0048     G4bool IsApplicable(G4ParticleDefinition const& particle) final;
0049 
0050     // Return true if model is applicable to dynamic state of `G4FastTrack`
0051     G4bool ModelTrigger(G4FastTrack const& track) final;
0052 
0053     // Apply model
0054     void DoIt(G4FastTrack const& track, G4FastStep& step) final;
0055 
0056     // Complete processing of buffered tracks
0057     void Flush()
0058 #if G4VERSION_NUMBER >= 1110
0059         final
0060 #endif
0061         ;
0062 
0063   private:
0064     SharedParams const* params_{nullptr};
0065     LocalTransporter* transport_{nullptr};
0066 };
0067 }  // namespace celeritas