Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-01-07 10:01:47

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/SDParams.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include "corecel/Assert.hh"
0010 #include "corecel/data/Collection.hh"
0011 #include "corecel/data/CollectionMirror.hh"
0012 #include "corecel/data/ParamsDataInterface.hh"
0013 #include "corecel/io/Label.hh"
0014 
0015 #include "SDData.hh"
0016 
0017 namespace celeritas
0018 {
0019 //---------------------------------------------------------------------------//
0020 class GeoParamsInterface;
0021 
0022 //---------------------------------------------------------------------------//
0023 /*!
0024  * Manage params and state data for sensitive detectors.
0025  */
0026 class SDParams final : public ParamsDataInterface<SDParamsData>
0027 {
0028   public:
0029     using VecLabel = std::vector<Label>;
0030 
0031   public:
0032     //! Default Constructor
0033     SDParams() {}
0034 
0035     //! Construct from volume labels
0036     SDParams(VecLabel const& volume_labels, GeoParamsInterface const& geo);
0037 
0038     //! Whether any detectors are present
0039     bool empty() const { return !static_cast<bool>(mirror_); }
0040 
0041     //! Number of detectors
0042     DetectorId::size_type size() const { return volume_ids_.size(); }
0043 
0044     //! Access detector ID based on volume ID
0045     DetectorId volume_to_detector_id(VolumeId vol_id)
0046     {
0047         return host_ref().detector[vol_id];
0048     }
0049 
0050     //! Access volume ID based on detector ID
0051     VolumeId detector_to_volume_id(DetectorId det_id)
0052     {
0053         CELER_EXPECT(det_id < this->size());
0054         return volume_ids_[det_id.get()];
0055     }
0056 
0057     //!@{
0058     //! \name Data interface
0059 
0060     //! Access sensitive detector properties on the host
0061     HostRef const& host_ref() const final { return mirror_.host_ref(); }
0062     //! Access sensitive detector properties on the device
0063     DeviceRef const& device_ref() const final { return mirror_.device_ref(); }
0064     //!@}
0065 
0066   private:
0067     std::vector<VolumeId> volume_ids_;
0068     CollectionMirror<SDParamsData> mirror_;
0069 };
0070 
0071 //---------------------------------------------------------------------------//
0072 }  // namespace celeritas