Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-16 08:27:18

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 accel/GeantSimpleCalo.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include <memory>
0010 #include <string>
0011 #include <vector>
0012 
0013 #include "corecel/io/OutputInterface.hh"
0014 #include "celeritas/Quantities.hh"
0015 
0016 class G4LogicalVolume;
0017 class G4VSensitiveDetector;
0018 
0019 namespace celeritas
0020 {
0021 //---------------------------------------------------------------------------//
0022 class SharedParams;
0023 namespace detail
0024 {
0025 struct GeantSimpleCaloStorage;
0026 }
0027 
0028 //---------------------------------------------------------------------------//
0029 /*!
0030  * Manage a simple calorimeter sensitive detector across threads.
0031  *
0032  * The factory should be created in DetectorConstruction or
0033  * DetectorConstruction::Construct and added to the output parameters. Calling
0034  * \c MakeSensitiveDetector will emit a sensitive detector for the local thread
0035  * *and attach it* to the logical volumes on the local thread.
0036  */
0037 class GeantSimpleCalo final : public OutputInterface
0038 {
0039   public:
0040     //!@{
0041     //! \name Type aliases
0042     using SPConstParams = std::shared_ptr<SharedParams const>;
0043     using UPSensitiveDetector = std::unique_ptr<G4VSensitiveDetector>;
0044     using VecLV = std::vector<G4LogicalVolume*>;
0045     using VecReal = std::vector<double>;
0046     using EnergyUnits = units::Mev;
0047     //!@}
0048 
0049   public:
0050     // Construct with SD name and the volumes to attach the SD to
0051     GeantSimpleCalo(std::string name, SPConstParams params, VecLV volumes);
0052 
0053     // Emit a new detector for the local thread and attach to the stored LVs
0054     UPSensitiveDetector MakeSensitiveDetector();
0055 
0056     //! Get the list of volumes with this SD attached
0057     VecLV const& Volumes() const { return volumes_; }
0058 
0059     // Get accumulated energy deposition over all threads
0060     VecReal CalcTotalEnergyDeposition() const;
0061 
0062     //!@{
0063     //! \name Output interface
0064 
0065     //! Category of data to write
0066     Category category() const final { return Category::result; }
0067     // Key for the entry inside the category
0068     std::string_view label() const final;
0069     // Write output to the given JSON object
0070     void output(JsonPimpl*) const final;
0071     //!@}
0072 
0073   private:
0074     using SPStorage = std::shared_ptr<detail::GeantSimpleCaloStorage>;
0075     SPConstParams params_;
0076     VecLV volumes_;
0077     SPStorage storage_;
0078 };
0079 
0080 //---------------------------------------------------------------------------//
0081 }  // namespace celeritas