Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-18 09:09:09

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/TrackingCutExecutor.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include "corecel/Assert.hh"
0010 #include "corecel/Macros.hh"
0011 #include "celeritas/Types.hh"
0012 #include "celeritas/optical/CoreTrackView.hh"
0013 #include "celeritas/optical/ParticleTrackView.hh"
0014 #include "celeritas/optical/SimTrackView.hh"
0015 
0016 namespace celeritas
0017 {
0018 namespace optical
0019 {
0020 namespace detail
0021 {
0022 //---------------------------------------------------------------------------//
0023 /*!
0024  * Kill a malfunctioning photon.
0025  */
0026 struct TrackingCutExecutor
0027 {
0028     inline CELER_FUNCTION void operator()(CoreTrackView& track);
0029 };
0030 
0031 //---------------------------------------------------------------------------//
0032 CELER_FUNCTION void TrackingCutExecutor::operator()(CoreTrackView& track)
0033 {
0034     using Energy = ParticleTrackView::Energy;
0035 
0036     auto deposited = track.particle().energy().value();
0037 
0038     auto&& sim = track.sim();
0039 #if !CELER_DEVICE_COMPILE
0040     {
0041         // Print a debug message if track is just being cut; error message if
0042         // an error occurred
0043         auto msg = self_logger()(CELER_CODE_PROVENANCE,
0044                                  sim.status() == TrackStatus::errored
0045                                      ? LogLevel::error
0046                                      : LogLevel::debug);
0047         msg << "Killing optical photon: lost " << deposited << ' '
0048             << Energy::unit_type::label();
0049     }
0050 #endif
0051 
0052     sim.status(TrackStatus::killed);
0053 }
0054 
0055 //---------------------------------------------------------------------------//
0056 }  // namespace detail
0057 }  // namespace optical
0058 }  // namespace celeritas