Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions Generators/include/Generators/GeneratorHybrid.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,11 @@ class GeneratorHybrid : public Generator
{

public:
GeneratorHybrid(const std::string& inputgens);
~GeneratorHybrid();
GeneratorHybrid& operator=(const GeneratorHybrid&) = delete;
GeneratorHybrid(const GeneratorHybrid&) = delete;

// Singleton access method
static GeneratorHybrid& Instance(const std::string& inputgens = "");

Bool_t Init() override;
Bool_t generateEvent() override;
Expand All @@ -66,8 +69,11 @@ class GeneratorHybrid : public Generator
Bool_t confSetter(const auto& gen);
template <typename T>
std::string jsonValueToString(const T& value);
std::vector<std::shared_ptr<o2::eventgen::Generator>> const& getGenerators() { return gens; }

private:
GeneratorHybrid(const std::string& inputgens);
~GeneratorHybrid();
o2::eventgen::Generator* currentgen = nullptr;
std::vector<std::shared_ptr<o2::eventgen::Generator>> gens;
const std::vector<std::string> generatorNames = {"extkinO2", "evtpool", "boxgen", "external", "hepmc", "pythia8", "pythia8pp", "pythia8hi", "pythia8hf", "pythia8powheg"};
Expand Down
4 changes: 2 additions & 2 deletions Generators/src/GeneratorFactory.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,8 @@ void GeneratorFactory::setPrimaryGenerator(o2::conf::SimConfig const& conf, Fair
LOG(fatal) << "Configuration file for hybrid generator does not exist";
return;
}
auto hybrid = new o2::eventgen::GeneratorHybrid(config);
primGen->AddGenerator(hybrid);
auto& hybrid = o2::eventgen::GeneratorHybrid::Instance(config);
primGen->AddGenerator(&hybrid);
#endif
} else {
LOG(fatal) << "Invalid generator";
Expand Down
6 changes: 6 additions & 0 deletions Generators/src/GeneratorHybrid.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ namespace o2
namespace eventgen
{

GeneratorHybrid& GeneratorHybrid::Instance(const std::string& inputgens)
{
static GeneratorHybrid instance(inputgens);
return instance;
}

GeneratorHybrid::GeneratorHybrid(const std::string& inputgens)
{
// This generator has trivial unit conversions
Expand Down