Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-11-09 10:15:02

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/optical/action/detail/StepDiagnosticExecutor.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include "corecel/Assert.hh"
0010 #include "corecel/Macros.hh"
0011 #include "corecel/math/Algorithms.hh"
0012 #include "corecel/math/Atomics.hh"
0013 #include "celeritas/optical/CoreTrackView.hh"
0014 #include "celeritas/user/ParticleTallyData.hh"
0015 
0016 namespace celeritas
0017 {
0018 namespace optical
0019 {
0020 namespace detail
0021 {
0022 //---------------------------------------------------------------------------//
0023 struct StepDiagnosticExecutor
0024 {
0025     NativeCRef<ParticleTallyParamsData> const params;
0026     NativeRef<ParticleTallyStateData> const state;
0027 
0028     inline CELER_FUNCTION void operator()(CoreTrackView const& track);
0029 };
0030 
0031 //---------------------------------------------------------------------------//
0032 /*!
0033  * Collect distribution of steps per track for each particle type.
0034  */
0035 CELER_FUNCTION void StepDiagnosticExecutor::operator()(
0036     CoreTrackView const& track)
0037 {
0038     CELER_EXPECT(params);
0039     CELER_EXPECT(state);
0040 
0041     // Tally the number of steps if the track was killed
0042     auto sim = track.sim();
0043     if (sim.status() == TrackStatus::killed)
0044     {
0045         size_type index = celeritas::min(sim.num_steps(), params.num_bins - 1);
0046         using namespace celeritas::literals;
0047         atomic_add(&state.counts[ItemId<size_type>(index)], 1_sz);
0048     }
0049 }
0050 
0051 //---------------------------------------------------------------------------//
0052 }  // namespace detail
0053 }  // namespace optical
0054 }  // namespace celeritas