Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-21 09:29:26

0001 //----------------------------------*-C++-*----------------------------------//
0002 // Copyright 2023-2024 UT-Battelle, LLC, and other Celeritas developers.
0003 // See the top-level COPYRIGHT file for details.
0004 // SPDX-License-Identifier: (Apache-2.0 OR MIT)
0005 //---------------------------------------------------------------------------//
0006 //! \file accel/FastSimulationOffload.hh
0007 //---------------------------------------------------------------------------//
0008 #pragma once
0009 
0010 #include <G4VFastSimulationModel.hh>
0011 #include <G4Version.hh>
0012 
0013 namespace celeritas
0014 {
0015 class SharedParams;
0016 class LocalTransporter;
0017 
0018 //---------------------------------------------------------------------------//
0019 /*!
0020  * Offload tracks to Celeritas via G4VFastSimulationModel interface
0021  *
0022  * This class must be constructed locally on each worker thread/task, typically
0023  * within the application's concrete implementation of
0024  * `G4VUserDetectorConstruction::ConstructSDandField()`.
0025  */
0026 class FastSimulationOffload final : public G4VFastSimulationModel
0027 {
0028   public:
0029     // Construct with name, shared (across threads) params, and thread-local
0030     // transporter
0031     FastSimulationOffload(G4String const& name,
0032                           SharedParams const* params,
0033                           LocalTransporter* local);
0034 
0035     // Construct with name, region, shared (across threads) params, and
0036     // thread-local transporter
0037     FastSimulationOffload(G4String const& name,
0038                           G4Envelope* region,
0039                           SharedParams const* params,
0040                           LocalTransporter* local);
0041 
0042     // Return true if model is applicable to the `G4ParticleDefinition`
0043     G4bool IsApplicable(G4ParticleDefinition const& particle) final;
0044 
0045     // Return true if model is applicable to dynamic state of `G4FastTrack`
0046     G4bool ModelTrigger(G4FastTrack const& track) final;
0047 
0048     // Apply model
0049     void DoIt(G4FastTrack const& track, G4FastStep& step) final;
0050 
0051 #if G4VERSION_NUMBER >= 1110
0052     //! Complete processing of buffered tracks
0053     void Flush() final;
0054 #endif
0055 
0056   private:
0057     SharedParams const* params_{nullptr};
0058     LocalTransporter* transport_{nullptr};
0059 };
0060 }  // namespace celeritas