Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-22 10:31:32

0001 //----------------------------------*-C++-*----------------------------------//
0002 // Copyright 2022-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 celeritas/user/StepCollector.hh
0007 //---------------------------------------------------------------------------//
0008 #pragma once
0009 
0010 #include <memory>
0011 #include <vector>
0012 
0013 #include "celeritas/Types.hh"
0014 #include "celeritas/geo/GeoFwd.hh"
0015 
0016 #include "StepInterface.hh"
0017 
0018 namespace celeritas
0019 {
0020 //---------------------------------------------------------------------------//
0021 class ActionRegistry;
0022 
0023 namespace detail
0024 {
0025 template<StepPoint P>
0026 class StepGatherAction;
0027 struct StepStorage;
0028 }  // namespace detail
0029 
0030 //---------------------------------------------------------------------------//
0031 /*!
0032  * Gather and transfer track states at each step.
0033  *
0034  * This defines the interface to set up and manage a generic class for
0035  * interfacing with the GPU track states at the beginning and/or end of every
0036  * step.
0037  *
0038  * \todo The step collector serves two purposes: supporting "sensitive
0039  * detectors" (mapping volume IDs to detector IDs and ignoring unmapped
0040  * volumes) and supporting unfiltered output for "MC truth" . Right now only
0041  * one or the other can be used, not both.
0042  *
0043  * \todo Add a "begin run" interface to set up the stream store, rather than
0044  * passing in number of streams at construction time.
0045  */
0046 class StepCollector
0047 {
0048   public:
0049     //!@{
0050     //! \name Type aliases
0051     using SPStepInterface = std::shared_ptr<StepInterface>;
0052     using SPConstGeo = std::shared_ptr<GeoParams const>;
0053     using VecInterface = std::vector<SPStepInterface>;
0054     //!@}
0055 
0056   public:
0057     // Construct with options and register pre/post-step actions
0058     StepCollector(VecInterface callbacks,
0059                   SPConstGeo geo,
0060                   size_type max_streams,
0061                   ActionRegistry* action_registry);
0062 
0063     // Default destructor and move and copy
0064     ~StepCollector();
0065     StepCollector(StepCollector const&);
0066     StepCollector& operator=(StepCollector const&);
0067     StepCollector(StepCollector&&);
0068     StepCollector& operator=(StepCollector&&);
0069 
0070     // See which data are being gathered
0071     StepSelection const& selection() const;
0072 
0073   private:
0074     template<StepPoint P>
0075     using SPStepGatherAction = std::shared_ptr<detail::StepGatherAction<P>>;
0076     using SPStepStorage = std::shared_ptr<detail::StepStorage>;
0077 
0078     SPStepStorage storage_;
0079     SPStepGatherAction<StepPoint::pre> pre_action_;
0080     SPStepGatherAction<StepPoint::post> post_action_;
0081 };
0082 
0083 //---------------------------------------------------------------------------//
0084 }  // namespace celeritas