Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-23 09:13:58

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  * \deprecated This class should be replaced by a more advanced scoring
0038  * mechanism.
0039  */
0040 class GeantSimpleCalo final : public OutputInterface
0041 {
0042   public:
0043     //!@{
0044     //! \name Type aliases
0045     using SPConstParams = std::shared_ptr<SharedParams const>;
0046     using UPSensitiveDetector = std::unique_ptr<G4VSensitiveDetector>;
0047     using VecLV = std::vector<G4LogicalVolume*>;
0048     using VecReal = std::vector<double>;
0049     using EnergyUnits = units::Mev;
0050     //!@}
0051 
0052   public:
0053     // Construct with SD name and the volumes to attach the SD to
0054     GeantSimpleCalo(std::string name, SPConstParams params, VecLV volumes);
0055 
0056     // Emit a new detector for the local thread and attach to the stored LVs
0057     UPSensitiveDetector MakeSensitiveDetector();
0058 
0059     //! Get the list of volumes with this SD attached
0060     VecLV const& Volumes() const { return volumes_; }
0061 
0062     // Get accumulated energy deposition over all threads
0063     VecReal CalcTotalEnergyDeposition() const;
0064 
0065     //!@{
0066     //! \name Output interface
0067 
0068     //! Category of data to write
0069     Category category() const final { return Category::result; }
0070     // Key for the entry inside the category
0071     std::string_view label() const final;
0072     // Write output to the given JSON object
0073     void output(JsonPimpl*) const final;
0074     //!@}
0075 
0076   private:
0077     using SPStorage = std::shared_ptr<detail::GeantSimpleCaloStorage>;
0078     SPConstParams params_;
0079     VecLV volumes_;
0080     SPStorage storage_;
0081 };
0082 
0083 //---------------------------------------------------------------------------//
0084 }  // namespace celeritas