Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:11:35

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 #pragma once
0010 
0011 #include "Acts/Utilities/Logger.hpp"
0012 #include "ActsExamples/Geant4/EventStore.hpp"
0013 
0014 #include <memory>
0015 #include <string>
0016 #include <vector>
0017 
0018 #include <G4UserSteppingAction.hh>
0019 
0020 class G4Step;
0021 
0022 namespace ActsExamples::Geant4 {
0023 
0024 /// @class MaterialSteppingAction
0025 ///
0026 /// @brief Collects the RecordedMaterialSlab entities
0027 ///
0028 /// The MaterialSteppingAction class is the implementation of the
0029 /// Geant4 class MaterialSteppingAction. It extracts the weighted material
0030 /// of every step and collects all material steps.
0031 class MaterialSteppingAction final : public G4UserSteppingAction {
0032  public:
0033   /// Nested configuration struct
0034   struct Config {
0035     std::shared_ptr<EventStore> eventStore;
0036 
0037     std::vector<std::string> excludeMaterials = {};
0038   };
0039 
0040   /// Construct the action
0041   ///
0042   /// @param cfg the configuration struct for this Stepping action
0043   /// @param logger is an Acts::Logger for unique logging
0044   MaterialSteppingAction(const Config& cfg,
0045                          std::unique_ptr<const Acts::Logger> logger =
0046                              Acts::getDefaultLogger("SimParticleTranslation",
0047                                                     Acts::Logging::INFO));
0048   ~MaterialSteppingAction() override;
0049 
0050   /// @brief Action per step to be performed
0051   ///
0052   /// @param step is the Geant4 step of the particle
0053   void UserSteppingAction(const G4Step* step) override;
0054 
0055  private:
0056   /// Config struct
0057   Config m_cfg;
0058 
0059   /// Private access method to the logging instance
0060   const Acts::Logger& logger() const { return *m_logger; }
0061 
0062   /// Private access method to the event store
0063   EventStore& eventStore() const { return *m_cfg.eventStore; }
0064 
0065   /// The looging instance
0066   std::unique_ptr<const Acts::Logger> m_logger;
0067 };
0068 
0069 }  // namespace ActsExamples::Geant4