Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-10-29 08:22:21

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 #include "ActsPlugins/Geant4/Geant4MaterialStepConverter.hpp"
0014 
0015 #include <memory>
0016 #include <string>
0017 #include <vector>
0018 
0019 #include <G4UserSteppingAction.hh>
0020 
0021 class G4Step;
0022 
0023 namespace ActsExamples::Geant4 {
0024 
0025 /// @class MaterialSteppingAction
0026 ///
0027 /// @brief Collects the RecordedMaterialSlab entities
0028 ///
0029 /// The MaterialSteppingAction class is the implementation of the
0030 /// Geant4 class MaterialSteppingAction. It extracts the weighted material
0031 /// of every step and collects all material steps.
0032 class MaterialSteppingAction final : public G4UserSteppingAction {
0033  public:
0034   /// Nested configuration struct
0035   struct Config {
0036     std::shared_ptr<EventStore> eventStore;
0037 
0038     std::vector<std::string> excludeMaterials = {};
0039     bool recordElementFractions = false;
0040   };
0041 
0042   /// Construct the action
0043   ///
0044   /// @param cfg the configuration struct for this Stepping action
0045   /// @param logger is an Acts::Logger for unique logging
0046   explicit MaterialSteppingAction(
0047       const Config& cfg,
0048       std::unique_ptr<const Acts::Logger> logger = Acts::getDefaultLogger(
0049           "SimParticleTranslation", Acts::Logging::INFO));
0050 
0051   /// @brief Action per step to be performed
0052   ///
0053   /// @param stepPtr is the Geant4 step of the particle
0054   void UserSteppingAction(const G4Step* stepPtr) override;
0055 
0056  private:
0057   /// Config struct
0058   Config m_cfg;
0059 
0060   /// Converts the steps into material interactions
0061   ActsPlugins::Geant4MaterialStepConverter m_stepConverter;
0062 
0063   /// Private access method to the logging instance
0064   const Acts::Logger& logger() const { return *m_logger; }
0065 
0066   /// Private access method to the event store
0067   EventStore& eventStore() const { return *m_cfg.eventStore; }
0068 
0069   /// The looging instance
0070   std::unique_ptr<const Acts::Logger> m_logger;
0071 };
0072 
0073 }  // namespace ActsExamples::Geant4