Back to home page

EIC code displayed by LXR

 
 

    


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

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/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 struct Pythia8RandomEngineWrapper;
0031 
0032 class Pythia8Generator : public EventGenerator::ParticlesGenerator {
0033  public:
0034   struct Config {
0035     /// PDG particle number of the first incoming beam.
0036     Acts::PdgParticle pdgBeam0 = Acts::PdgParticle::eProton;
0037     /// PDG particle number of the second incoming beam.
0038     Acts::PdgParticle pdgBeam1 = Acts::PdgParticle::eProton;
0039     /// Center-of-mass energy.
0040     double cmsEnergy = 14 * Acts::UnitConstants::TeV;
0041     /// Additional Pythia8 settings.
0042     std::vector<std::string> settings = {{"HardQCD:all = on"}};
0043     /// Let pythia print summarized event info
0044     bool printShortEventListing = false;
0045     /// Let pythia print detailed event info
0046     bool printLongEventListing = false;
0047     /// Turn on/off the labeling of secondary vertices
0048     /// TODO this is essentially broken as the current code will label any kind
0049     /// of decay as secondary
0050     bool labelSecondaries = true;
0051     /// The spatial threshold to consider a particle originating from a vertex
0052     double spatialVertexThreshold = 1.0 * Acts::UnitConstants::um;
0053     /// Random seed for the initialization stage of Pythia8
0054     unsigned int initializationSeed = 42;
0055   };
0056 
0057   Pythia8Generator(const Config& cfg, Acts::Logging::Level lvl);
0058   ~Pythia8Generator() override;
0059   // try to prevent pythia breakage by forbidding copying
0060   Pythia8Generator() = delete;
0061   Pythia8Generator(const Pythia8Generator&) = delete;
0062   Pythia8Generator(Pythia8Generator&&) = delete;
0063   Pythia8Generator& operator=(const Pythia8Generator&) = delete;
0064   Pythia8Generator& operator=(Pythia8Generator&& other) = delete;
0065 
0066   std::pair<SimVertexContainer, SimParticleContainer> operator()(
0067       RandomEngine& rng) override;
0068 
0069  private:
0070   /// Private access to the logging instance
0071   const Acts::Logger& logger() const { return (*m_logger); }
0072 
0073   Config m_cfg;
0074   std::unique_ptr<const Acts::Logger> m_logger;
0075   std::unique_ptr<::Pythia8::Pythia> m_pythia8;
0076   std::shared_ptr<Pythia8RandomEngineWrapper> m_pythia8RndmEngine;
0077   std::mutex m_pythia8Mutex;
0078 };
0079 
0080 }  // namespace ActsExamples