Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-11-03 10:18:54

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 celeritas/user/StepCollector.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include <memory>
0010 #include <vector>
0011 
0012 #include "celeritas/Types.hh"
0013 #include "celeritas/geo/GeoFwd.hh"
0014 
0015 #include "StepInterface.hh"
0016 
0017 namespace celeritas
0018 {
0019 //---------------------------------------------------------------------------//
0020 class ActionRegistry;
0021 class AuxParamsRegistry;
0022 class CoreParams;
0023 class VolumeParams;
0024 
0025 namespace detail
0026 {
0027 template<StepPoint P>
0028 class StepGatherAction;
0029 class StepParams;
0030 }  // namespace detail
0031 
0032 //---------------------------------------------------------------------------//
0033 /*!
0034  * Gather and transfer track states at each step.
0035  *
0036  * This defines the interface to set up and manage a generic class for
0037  * interfacing with the GPU track states at the beginning and/or end of every
0038  * step.
0039  *
0040  * During \c Stepper::warm_up, the gather kernels execute but the callbacks
0041  * are skipped: warmup produces no step result with which to consume deferred
0042  * hit data. Ordinary transport steps still invoke the callbacks, including
0043  * when no tracks are active.
0044  *
0045  * \todo The step collector serves two purposes: supporting "sensitive
0046  * detectors" (mapping volume IDs to detector IDs and ignoring unmapped
0047  * volumes) and supporting unfiltered output for "MC truth" . Right now only
0048  * one or the other can be used, not both.
0049  *
0050  * \todo Like the optical collector, this class is not used after it's created:
0051  * it just serves to create helper classes. Perhaps move to the \c setup
0052  * namespace?
0053  */
0054 class StepCollector
0055 {
0056   public:
0057     //!@{
0058     //! \name Type aliases
0059     using SPStepInterface = std::shared_ptr<StepInterface>;
0060     using SPConstCoreGeo = std::shared_ptr<CoreGeoParams const>;
0061     using SPConstVolume = std::shared_ptr<VolumeParams const>;
0062     using VecInterface = std::vector<SPStepInterface>;
0063     //!@}
0064 
0065   public:
0066     // Construct and add to core params
0067     static std::shared_ptr<StepCollector> make_and_insert(
0068         CoreParams const& core, VecInterface callbacks);
0069 
0070     // Construct with options and register pre/post-step actions
0071     StepCollector(SPConstCoreGeo geo,
0072                   SPConstVolume volume,
0073                   VecInterface&& callbacks,
0074                   AuxParamsRegistry* aux_registry,
0075                   ActionRegistry* action_registry);
0076 
0077     // See which data are being gathered
0078     StepSelection const& selection() const;
0079 
0080   private:
0081     template<StepPoint P>
0082     using SPStepGatherAction = std::shared_ptr<detail::StepGatherAction<P>>;
0083 
0084     std::shared_ptr<detail::StepParams> params_;
0085     SPStepGatherAction<StepPoint::pre> pre_action_;
0086     SPStepGatherAction<StepPoint::post> post_action_;
0087 };
0088 
0089 //---------------------------------------------------------------------------//
0090 }  // namespace celeritas