Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:09:46

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2017-2024 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/PdgParticle.hpp"
0012 #include "Acts/Definitions/Units.hpp"
0013 #include "Acts/Utilities/Logger.hpp"
0014 #include "ActsExamples/EventData/SimParticle.hpp"
0015 #include "ActsExamples/EventData/SimVertex.hpp"
0016 #include "ActsExamples/Framework/RandomNumbers.hpp"
0017 #include "ActsExamples/Generators/EventGenerator.hpp"
0018 
0019 #include <memory>
0020 #include <mutex>
0021 #include <string>
0022 #include <vector>
0023 
0024 namespace Pythia8 {
0025 class Pythia;
0026 }
0027 
0028 namespace ActsExamples {
0029 
0030 class Pythia8Generator : public EventGenerator::ParticlesGenerator {
0031  public:
0032   struct Config {
0033     /// PDG particle number of the first incoming beam.
0034     Acts::PdgParticle pdgBeam0 = Acts::PdgParticle::eProton;
0035     /// PDG particle number of the second incoming beam.
0036     Acts::PdgParticle pdgBeam1 = Acts::PdgParticle::eProton;
0037     /// Center-of-mass energy.
0038     double cmsEnergy = 14 * Acts::UnitConstants::TeV;
0039     /// Additional Pythia8 settings.
0040     std::vector<std::string> settings = {{"HardQCD:all = on"}};
0041     /// Let pythia print summarized event info
0042     bool printShortEventListing = false;
0043     /// Let pythia print detailed event info
0044     bool printLongEventListing = false;
0045     /// Turn on/off the labeling of secondary vertices
0046     /// TODO this is essentially broken as the current code will label any kind
0047     /// of decay as secondary
0048     bool labelSecondaries = true;
0049     /// The spatial threshold to consider a particle originating from a vertex
0050     double spatialVertexThreshold = 1.0 * Acts::UnitConstants::um;
0051   };
0052 
0053   Pythia8Generator(const Config& cfg, Acts::Logging::Level lvl);
0054   ~Pythia8Generator() override;
0055   // try to prevent pythia breakage by forbidding copying
0056   Pythia8Generator() = delete;
0057   Pythia8Generator(const Pythia8Generator&) = delete;
0058   Pythia8Generator(Pythia8Generator&&) = delete;
0059   Pythia8Generator& operator=(const Pythia8Generator&) = delete;
0060   Pythia8Generator& operator=(Pythia8Generator&& other) = delete;
0061 
0062   std::pair<SimVertexContainer, SimParticleContainer> operator()(
0063       RandomEngine& rng) override;
0064 
0065  private:
0066   /// Private access to the logging instance
0067   const Acts::Logger& logger() const { return (*m_logger); }
0068 
0069   Config m_cfg;
0070   std::unique_ptr<const Acts::Logger> m_logger;
0071   std::unique_ptr<::Pythia8::Pythia> m_pythia8;
0072   std::mutex m_pythia8Mutex;
0073 };
0074 
0075 }  // namespace ActsExamples