Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-12-20 09:11:26

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2017 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 http://mozilla.org/MPL/2.0/.
0008 
0009 #pragma once
0010 
0011 #include "Acts/Digitization/DigitizationSourceLink.hpp"
0012 #include "Acts/Digitization/PlanarModuleCluster.hpp"
0013 #include "Acts/Geometry/GeometryIdentifier.hpp"
0014 #include "Acts/Utilities/Logger.hpp"
0015 #include "ActsExamples/EventData/GeometryContainers.hpp"
0016 #include "ActsExamples/EventData/Index.hpp"
0017 #include "ActsExamples/EventData/IndexSourceLink.hpp"
0018 #include "ActsExamples/EventData/Measurement.hpp"
0019 #include "ActsExamples/EventData/SimHit.hpp"
0020 #include "ActsExamples/Framework/DataHandle.hpp"
0021 #include "ActsExamples/Framework/IAlgorithm.hpp"
0022 #include "ActsExamples/Framework/ProcessCode.hpp"
0023 #include "ActsExamples/Framework/RandomNumbers.hpp"
0024 
0025 #include <memory>
0026 #include <string>
0027 #include <unordered_map>
0028 #include <vector>
0029 
0030 namespace ActsFatras {
0031 class Barcode;
0032 }  // namespace ActsFatras
0033 
0034 namespace Acts {
0035 class DigitizationModule;
0036 class IdentifiedDetectorElement;
0037 class PlanarModuleStepper;
0038 class Surface;
0039 class TrackingGeometry;
0040 class PlanarModuleCluster;
0041 }  // namespace Acts
0042 
0043 namespace ActsExamples {
0044 class IndexSourceLink;
0045 class RandomNumbers;
0046 struct AlgorithmContext;
0047 
0048 /// Create planar clusters from simulation hits.
0049 class PlanarSteppingAlgorithm final : public IAlgorithm {
0050  public:
0051   using ClusterContainer =
0052       ActsExamples::GeometryIdMultimap<Acts::PlanarModuleCluster>;
0053 
0054   struct Config {
0055     /// Input collection of simulated hits.
0056     std::string inputSimHits;
0057     /// Output collection of clusters.
0058     std::string outputClusters;
0059     /// Output source links collection.
0060     std::string outputSourceLinks;
0061     /// Output digitization source links collection
0062     std::string outputDigiSourceLinks;
0063     /// Output measurements collection.
0064     std::string outputMeasurements;
0065     /// Output collection to map measured hits to contributing particles.
0066     std::string outputMeasurementParticlesMap;
0067     /// Output collection to map measured hits to simulated hits.
0068     std::string outputMeasurementSimHitsMap;
0069     /// Tracking geometry required to access global-to-local transforms.
0070     std::shared_ptr<const Acts::TrackingGeometry> trackingGeometry;
0071     /// Module stepper for geometric clustering.
0072     std::shared_ptr<const Acts::PlanarModuleStepper> planarModuleStepper;
0073     /// Random numbers tool.
0074     std::shared_ptr<const RandomNumbers> randomNumbers;
0075   };
0076 
0077   /// Construct the digitization algorithm.
0078   ///
0079   /// @param config is the algorithm configuration
0080   /// @param level is the logging level
0081   PlanarSteppingAlgorithm(Config config, Acts::Logging::Level level);
0082 
0083   /// Build clusters from input simulation hits.
0084   ///
0085   /// @param txt is the algorithm context with event information
0086   /// @return a process code indication success or failure
0087   ProcessCode execute(const AlgorithmContext& ctx) const override;
0088 
0089   /// Readonly access to the config
0090   const Config& config() const { return m_cfg; }
0091 
0092  private:
0093   struct Digitizable {
0094     const Acts::Surface* surface = nullptr;
0095     const Acts::IdentifiedDetectorElement* detectorElement = nullptr;
0096     const Acts::DigitizationModule* digitizer = nullptr;
0097   };
0098 
0099   Config m_cfg;
0100   /// Lookup container for all digitizable surfaces
0101   std::unordered_map<Acts::GeometryIdentifier, Digitizable> m_digitizables;
0102 
0103   ReadDataHandle<SimHitContainer> m_inputSimHits{this, "InputSimHits"};
0104 
0105   WriteDataHandle<ClusterContainer> m_outputClusters{this, "OutputClusters"};
0106 
0107   WriteDataHandle<GeometryIdMultiset<IndexSourceLink>> m_outputSourceLinks{
0108       this, "OutputSourceLinks"};
0109 
0110   WriteDataHandle<std::vector<Acts::DigitizationSourceLink>>
0111       m_outputDigiSourceLinks{this, "OutputDigiSourceLinks"};
0112 
0113   WriteDataHandle<MeasurementContainer> m_outputMeasurements{
0114       this, "OutputMeasurements"};
0115 
0116   WriteDataHandle<IndexMultimap<ActsFatras::Barcode>>
0117       m_outputMeasurementParticlesMap{this, "OutputMeasurementParticlesMap"};
0118 
0119   WriteDataHandle<IndexMultimap<Index>> m_outputMeasurementSimHitsMap{
0120       this, "OutputMeasurementSimHitsMap"};
0121 };
0122 
0123 }  // namespace ActsExamples