Back to home page

sPhenix code displayed by LXR

 
 

    


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

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2019 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/Definitions/Units.hpp"
0012 #include "Acts/EventData/ParticleHypothesis.hpp"
0013 #include "Acts/Utilities/Logger.hpp"
0014 #include "ActsExamples/EventData/SimParticle.hpp"
0015 #include "ActsExamples/EventData/Track.hpp"
0016 #include "ActsExamples/Framework/DataHandle.hpp"
0017 #include "ActsExamples/Framework/IAlgorithm.hpp"
0018 #include "ActsExamples/Framework/ProcessCode.hpp"
0019 #include "ActsExamples/Framework/RandomNumbers.hpp"
0020 
0021 #include <array>
0022 #include <limits>
0023 #include <memory>
0024 #include <optional>
0025 #include <string>
0026 
0027 namespace ActsExamples {
0028 class RandomNumbers;
0029 struct AlgorithmContext;
0030 
0031 /// Create track states by smearing truth particle information.
0032 ///
0033 /// Particles are smeared in the perigee frame anchored at their true vertex
0034 /// position. The `d0` and `z0` parameters are always defined within that
0035 /// perigee frame and not globally. The generated bound parameters are stored in
0036 /// the same order as the input particles.
0037 class ParticleSmearing final : public IAlgorithm {
0038  public:
0039   struct Config {
0040     /// Input truth particles collection.
0041     std::string inputParticles;
0042     /// Output smeared tracks parameters collection.
0043     std::string outputTrackParameters;
0044     /// Constant term of the d0 resolution.
0045     double sigmaD0 = 20 * Acts::UnitConstants::um;
0046     /// Pt-dependent d0 resolution of the form sigma_d0 = A*exp(-1.*abs(B)*pt).
0047     double sigmaD0PtA = 30 * Acts::UnitConstants::um;
0048     double sigmaD0PtB = 0.3 / Acts::UnitConstants::GeV;
0049     /// Constant term of the z0 resolution.
0050     double sigmaZ0 = 20 * Acts::UnitConstants::um;
0051     /// Pt-dependent z0 resolution of the form sigma_z0 = A*exp(-1.*abs(B)*pt).
0052     double sigmaZ0PtA = 30 * Acts::UnitConstants::um;
0053     double sigmaZ0PtB = 0.3 / Acts::UnitConstants::GeV;
0054     /// Time resolution.
0055     double sigmaT0 = 1 * Acts::UnitConstants::ns;
0056     /// Phi angular resolution.
0057     double sigmaPhi = 1 * Acts::UnitConstants::degree;
0058     /// Theta angular resolution.
0059     double sigmaTheta = 1 * Acts::UnitConstants::degree;
0060     /// Relative momentum resolution.
0061     double sigmaPRel = 0.05;
0062     /// Optional. Initial covariance matrix diagonal. Overwrites the default if
0063     /// set.
0064     std::optional<std::array<double, 6>> initialSigmas = std::array<double, 6>{
0065         1 * Acts::UnitConstants::mm,     1 * Acts::UnitConstants::mm,
0066         1 * Acts::UnitConstants::degree, 1 * Acts::UnitConstants::degree,
0067         0.1 / Acts::UnitConstants::GeV,  1 * Acts::UnitConstants::ns};
0068     /// Inflate the initial covariance matrix
0069     std::array<double, 6> initialVarInflation = {1., 1., 1., 1., 1., 1.};
0070     /// Random numbers service.
0071     std::shared_ptr<const RandomNumbers> randomNumbers = nullptr;
0072     /// Optional particle hypothesis override.
0073     std::optional<Acts::ParticleHypothesis> particleHypothesis = std::nullopt;
0074   };
0075 
0076   ParticleSmearing(const Config& config, Acts::Logging::Level level);
0077 
0078   ProcessCode execute(const AlgorithmContext& ctx) const override;
0079 
0080   /// Get readonly access to the config parameters
0081   const Config& config() const { return m_cfg; }
0082 
0083  private:
0084   Config m_cfg;
0085 
0086   ReadDataHandle<SimParticleContainer> m_inputParticles{this, "InputParticles"};
0087 
0088   WriteDataHandle<TrackParametersContainer> m_outputTrackParameters{
0089       this, "OutputTrackParameters"};
0090 };
0091 
0092 }  // namespace ActsExamples