diff --git a/CepGen/Cards/CommandLineHandler.cpp b/CepGen/Cards/CommandLineHandler.cpp index ab4232a4b..1f7465856 100644 --- a/CepGen/Cards/CommandLineHandler.cpp +++ b/CepGen/Cards/CommandLineHandler.cpp @@ -20,6 +20,7 @@ #include "CepGen/Cards/Handler.h" #include "CepGen/Core/Exception.h" +#include "CepGen/Core/RunParameters.h" #include "CepGen/Event/Event.h" #include "CepGen/EventFilter/EventExporter.h" #include "CepGen/EventFilter/EventModifier.h" @@ -27,7 +28,6 @@ #include "CepGen/Modules/EventExporterFactory.h" #include "CepGen/Modules/EventModifierFactory.h" #include "CepGen/Modules/ProcessFactory.h" -#include "CepGen/Parameters.h" #include "CepGen/Physics/PDG.h" #include "CepGen/Process/Process.h" #include "CepGen/Utils/TimeKeeper.h" @@ -53,14 +53,14 @@ namespace cepgen { return desc; } - Parameters* parseString(const std::string&, Parameters*) override; - Parameters* parseFile(const std::string&, Parameters*) override; + RunParameters* parseString(const std::string&, RunParameters*) override; + RunParameters* parseFile(const std::string&, RunParameters*) override; private: std::vector argv_; }; - Parameters* CommandLineHandler::parseFile(const std::string& filename, Parameters* params) { + RunParameters* CommandLineHandler::parseFile(const std::string& filename, RunParameters* params) { rt_params_ = params; if (filename.empty()) throw CG_FATAL("CommandLineHandler") << "Empty filename to be parsed! Aborting."; @@ -72,7 +72,7 @@ namespace cepgen { return rt_params_; } - Parameters* CommandLineHandler::parseString(const std::string& arg, Parameters* params) { + RunParameters* CommandLineHandler::parseString(const std::string& arg, RunParameters* params) { ParametersList pars; pars.feed(arg); CG_INFO("CommandLineHandler") << "Arguments list: " << arg << " unpacked to:\n\t" << pars << "."; diff --git a/CepGen/Cards/Handler.cpp b/CepGen/Cards/Handler.cpp index d49a1d3c6..2e18d303b 100644 --- a/CepGen/Cards/Handler.cpp +++ b/CepGen/Cards/Handler.cpp @@ -1,6 +1,6 @@ /* * CepGen: a central exclusive processes event generator - * Copyright (C) 2013-2021 Laurent Forthomme + * Copyright (C) 2013-2024 Laurent Forthomme * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,39 +19,39 @@ #include "CepGen/Cards/Handler.h" #include "CepGen/Core/Exception.h" #include "CepGen/Core/ParametersList.h" +#include "CepGen/Core/RunParameters.h" #include "CepGen/Modules/CardsHandlerFactory.h" -#include "CepGen/Parameters.h" #include "CepGen/Utils/Filesystem.h" namespace cepgen { namespace card { Handler::Handler(const ParametersList& params) - : NamedModule(params), filename_(steer("filename")), rt_params_(new Parameters) { + : NamedModule(params), filename_(steer("filename")), rt_params_(new RunParameters) { if (!filename_.empty()) parseFile(filename_, rt_params_); } - Parameters* Handler::parseString(const std::string& filename) { + RunParameters* Handler::parseString(const std::string& filename) { try { auto parser = CardsHandlerFactory::get().build(utils::fileExtension(filename)); - return parser->parseString(filename, new Parameters); + return parser->parseString(filename, new RunParameters); } catch (const std::invalid_argument& err) { throw CG_FATAL("Cards:handler") << "Failed to parse the steering card at \"" << filename << "\"! " << err.what(); } } - Parameters* Handler::parseFile(const std::string& filename) { + RunParameters* Handler::parseFile(const std::string& filename) { try { auto parser = CardsHandlerFactory::get().build(utils::fileExtension(filename)); - return parser->parseFile(filename, new Parameters); + return parser->parseFile(filename, new RunParameters); } catch (const std::invalid_argument& err) { throw CG_FATAL("Cards:handler") << "Failed to parse the steering card at \"" << filename << "\"! " << err.what(); } } - void Handler::write(const Parameters* params, const std::string& filename) { + void Handler::write(const RunParameters* params, const std::string& filename) { try { auto writer = CardsHandlerFactory::get().build(utils::fileExtension(filename)); writer->pack(params); diff --git a/CepGen/Cards/Handler.h b/CepGen/Cards/Handler.h index b3e2a39a9..dae87fd89 100644 --- a/CepGen/Cards/Handler.h +++ b/CepGen/Cards/Handler.h @@ -1,6 +1,6 @@ /* * CepGen: a central exclusive processes event generator - * Copyright (C) 2013-2023 Laurent Forthomme + * Copyright (C) 2013-2024 Laurent Forthomme * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,41 +22,34 @@ #include "CepGen/Modules/NamedModule.h" namespace cepgen { - class Parameters; + class RunParameters; /// Location for all steering card parsers/writers namespace card { /// Base steering card module class Handler : public NamedModule { public: - /// Build a configuration from an external steering card - explicit Handler(const ParametersList&); + explicit Handler(const ParametersList&); ///< Build a configuration from an external steering card virtual ~Handler() = default; static ParametersDescription description(); - /// Get the list of runtime parameters as parsed - const Parameters* runtimeParameters() const { return rt_params_; } - /// Get the list of runtime parameters as parsed - Parameters* runtimeParameters() { return rt_params_; } - /// Specify runtime parameters to the handler - virtual void pack(const Parameters*){}; - virtual Parameters* parseString(const std::string&, Parameters* params) { return params; } + const RunParameters* runParameters() const { return rt_params_; } ///< Parsed list of runtime parameters + RunParameters* runParameters() { return rt_params_; } ///< Parsed list of runtime parameters + + virtual void pack(const RunParameters*) {} ///< Specify runtime parameters to the handler + + virtual RunParameters* parseString(const std::string&, RunParameters* params) { return params; } /// Retrieve a configuration from a parsed steering card - virtual Parameters* parseFile(const std::string&, Parameters* params) { return params; } - /// Build a configuration from a steering card - static Parameters* parseString(const std::string&); - /// Build a configuration from a steering card - static Parameters* parseFile(const std::string&); - /// Write the current configuration into a steering card - virtual void write(const std::string&) const {} - /// Write a steering card from a configuration - static void write(const Parameters*, const std::string&); + virtual RunParameters* parseFile(const std::string&, RunParameters* params) { return params; } + static RunParameters* parseString(const std::string&); ///< Build a configuration from a steering card + static RunParameters* parseFile(const std::string&); ///< Build a configuration from a steering card + + virtual void write(const std::string&) const {} ///< Write the current configuration into a steering card + static void write(const RunParameters*, const std::string&); ///< Write a steering card from a configuration protected: - /// Input filename - const std::string filename_; - /// List of parameters parsed from a card handler - Parameters* rt_params_; + const std::string filename_; ///< Input filename + RunParameters* rt_params_; ///< List of parameters parsed from a card handler }; } // namespace card } // namespace cepgen diff --git a/CepGen/Cards/LpairHandler.cpp b/CepGen/Cards/LpairHandler.cpp index f1ee96de1..a672d1e5d 100644 --- a/CepGen/Cards/LpairHandler.cpp +++ b/CepGen/Cards/LpairHandler.cpp @@ -1,6 +1,6 @@ /* * CepGen: a central exclusive processes event generator - * Copyright (C) 2013-2023 Laurent Forthomme + * Copyright (C) 2013-2024 Laurent Forthomme * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,6 +21,7 @@ #include "CepGen/Cards/LpairHandler.h" #include "CepGen/Core/Exception.h" #include "CepGen/Core/ParametersList.h" +#include "CepGen/Core/RunParameters.h" #include "CepGen/EventFilter/EventExporter.h" #include "CepGen/EventFilter/EventModifier.h" #include "CepGen/Generator.h" // for library loading @@ -29,7 +30,6 @@ #include "CepGen/Modules/EventModifierFactory.h" #include "CepGen/Modules/ProcessFactory.h" #include "CepGen/Modules/StructureFunctionsFactory.h" -#include "CepGen/Parameters.h" #include "CepGen/Physics/GluonGrid.h" #include "CepGen/Physics/MCDFileParser.h" #include "CepGen/Process/Process.h" @@ -152,7 +152,7 @@ namespace cepgen { registerKinematicsParameter("MXMAX", "Maximal invariant mass of proton remnants", "mxmax"); } - Parameters* LpairHandler::parseFile(const std::string& filename, Parameters* params) { + RunParameters* LpairHandler::parseFile(const std::string& filename, RunParameters* params) { if (!utils::fileExists(filename)) throw CG_FATAL("LpairHandler") << "Unable to locate steering card \"" << filename << "\"."; rt_params_ = params; @@ -265,8 +265,8 @@ namespace cepgen { f.close(); } - void LpairHandler::pack(const Parameters* params) { - rt_params_ = const_cast(params); + void LpairHandler::pack(const RunParameters* params) { + rt_params_ = const_cast(params); str_fun_ = rt_params_->kinematics().incomingBeams().structureFunctions().name(); sr_type_ = rt_params_->kinematics().incomingBeams().structureFunctions().get("sigmaRatio"); //kmr_grid_path_ = kmr::GluonGrid::get().path(); diff --git a/CepGen/Cards/LpairHandler.h b/CepGen/Cards/LpairHandler.h index 2f31206ac..078f654fe 100644 --- a/CepGen/Cards/LpairHandler.h +++ b/CepGen/Cards/LpairHandler.h @@ -1,6 +1,6 @@ /* * CepGen: a central exclusive processes event generator - * Copyright (C) 2013-2021 Laurent Forthomme + * Copyright (C) 2013-2024 Laurent Forthomme * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -37,8 +37,8 @@ namespace cepgen { static ParametersDescription description(); - void pack(const Parameters*) override; - Parameters* parseFile(const std::string&, Parameters*) override; + void pack(const RunParameters*) override; + RunParameters* parseFile(const std::string&, RunParameters*) override; /// Store a configuration into a LPAIR steering card void write(const std::string& file) const override; diff --git a/CepGen/Core/Generator.cpp b/CepGen/Core/Generator.cpp index a494c637a..eb4dff4f2 100644 --- a/CepGen/Core/Generator.cpp +++ b/CepGen/Core/Generator.cpp @@ -1,6 +1,6 @@ /* * CepGen: a central exclusive processes event generator - * Copyright (C) 2013-2023 Laurent Forthomme + * Copyright (C) 2013-2024 Laurent Forthomme * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,6 +20,7 @@ #include "CepGen/Core/Exception.h" #include "CepGen/Core/GeneratorWorker.h" +#include "CepGen/Core/RunParameters.h" #include "CepGen/EventFilter/EventExporter.h" #include "CepGen/EventFilter/EventModifier.h" #include "CepGen/Generator.h" @@ -27,13 +28,12 @@ #include "CepGen/Integration/ProcessIntegrand.h" #include "CepGen/Modules/GeneratorWorkerFactory.h" #include "CepGen/Modules/IntegratorFactory.h" -#include "CepGen/Parameters.h" #include "CepGen/Process/Process.h" #include "CepGen/Utils/String.h" #include "CepGen/Utils/TimeKeeper.h" namespace cepgen { - Generator::Generator(bool safe_mode) : parameters_(new Parameters) { + Generator::Generator(bool safe_mode) : parameters_(new RunParameters) { static bool init = false; if (!init) { cepgen::initialise(safe_mode); @@ -45,7 +45,7 @@ namespace cepgen { srandom(time.time_since_epoch().count()); } - Generator::Generator(Parameters* ip) : parameters_(ip) {} + Generator::Generator(RunParameters* ip) : parameters_(ip) {} Generator::~Generator() { if (parameters_->timeKeeper()) @@ -61,15 +61,25 @@ namespace cepgen { if (!integrator_) resetIntegrator(); - worker_->setRuntimeParameters(const_cast(parameters_.get())); + worker_->setRunParameters(const_cast(parameters_.get())); worker_->setIntegrator(integrator_.get()); xsect_ = Value{-1., -1.}; parameters_->prepareRun(); } - Parameters& Generator::parametersRef() { return *parameters_; } + const RunParameters& Generator::runParameters() const { + if (!parameters_) + throw CG_FATAL("Generator:runParameters") << "Run parameters object is not yet initialised."; + return *parameters_; + } + + RunParameters& Generator::runParameters() { + if (!parameters_) + throw CG_FATAL("Generator:runParameters") << "Run parameters object is not yet initialised."; + return *parameters_; + } - void Generator::setParameters(Parameters* ip) { parameters_.reset(ip); } + void Generator::setRunParameters(RunParameters* ip) { parameters_.reset(ip); } double Generator::computePoint(const std::vector& coord) { if (!worker_) @@ -168,7 +178,7 @@ namespace cepgen { integrate(); // prepare the run parameters for event generation - parameters_->initialise(); + parameters_->initialiseModules(); worker_->initialise(); initialised_ = true; diff --git a/CepGen/Core/GeneratorWorker.cpp b/CepGen/Core/GeneratorWorker.cpp index d2f1dfd58..0094280e6 100644 --- a/CepGen/Core/GeneratorWorker.cpp +++ b/CepGen/Core/GeneratorWorker.cpp @@ -1,6 +1,6 @@ /* * CepGen: a central exclusive processes event generator - * Copyright (C) 2013-2023 Laurent Forthomme + * Copyright (C) 2013-2024 Laurent Forthomme * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,11 +18,11 @@ #include "CepGen/Core/Exception.h" #include "CepGen/Core/GeneratorWorker.h" +#include "CepGen/Core/RunParameters.h" #include "CepGen/Event/Event.h" #include "CepGen/EventFilter/EventExporter.h" #include "CepGen/Integration/Integrator.h" #include "CepGen/Integration/ProcessIntegrand.h" -#include "CepGen/Parameters.h" #include "CepGen/Process/Process.h" #include "CepGen/Utils/String.h" #include "CepGen/Utils/TimeKeeper.h" @@ -30,11 +30,11 @@ namespace cepgen { GeneratorWorker::GeneratorWorker(const ParametersList& params) : SteeredObject(params) {} - void GeneratorWorker::setRuntimeParameters(const Parameters* params) { + void GeneratorWorker::setRunParameters(const RunParameters* params) { params_ = params; integrand_.reset(new ProcessIntegrand(params)); CG_DEBUG("GeneratorWorker") << "New generator worker initialised for integration/event generation.\n\t" - << "Parameters at " << (void*)params_ << "."; + << "Run parameters at " << (void*)params_ << "."; } GeneratorWorker::~GeneratorWorker() { @@ -56,7 +56,7 @@ namespace cepgen { } bool GeneratorWorker::storeEvent() { - CG_TICKER(const_cast(params_)->timeKeeper()); + CG_TICKER(const_cast(params_)->timeKeeper()); if (!integrand_->process().hasEvent()) return true; @@ -69,7 +69,7 @@ namespace cepgen { callback_proc_(integrand_->process()); for (const auto& mod : params_->eventExportersSequence()) *mod << event; - const_cast(params_)->addGenerationTime(event.metadata.at("time:total")); + const_cast(params_)->addGenerationTime(event.metadata.at("time:total")); return true; } diff --git a/CepGen/Core/GeneratorWorker.h b/CepGen/Core/GeneratorWorker.h index 5b65951a7..2d00215fc 100644 --- a/CepGen/Core/GeneratorWorker.h +++ b/CepGen/Core/GeneratorWorker.h @@ -27,7 +27,7 @@ namespace cepgen { class Integrator; - class Parameters; + class RunParameters; class ProcessIntegrand; namespace proc { class Process; @@ -42,7 +42,7 @@ namespace cepgen { static ParametersDescription description(); /// Specify the runtime parameters - void setRuntimeParameters(const Parameters*); + void setRunParameters(const RunParameters*); /// Specify the integrator instance handled by the mother generator void setIntegrator(const Integrator* integ); /// Launch the event generation @@ -68,7 +68,7 @@ namespace cepgen { const Integrator* integrator_{nullptr}; /// Steering parameters for the event generation /// \note NOT owning - const Parameters* params_{nullptr}; + const RunParameters* params_{nullptr}; /// Local event weight evaluator std::unique_ptr integrand_; /// Callback function on process for each new event diff --git a/CepGen/Core/Parameters.cpp b/CepGen/Core/RunParameters.cpp similarity index 70% rename from CepGen/Core/Parameters.cpp rename to CepGen/Core/RunParameters.cpp index 5594f91ef..561563013 100644 --- a/CepGen/Core/Parameters.cpp +++ b/CepGen/Core/RunParameters.cpp @@ -1,6 +1,6 @@ /* * CepGen: a central exclusive processes event generator - * Copyright (C) 2013-2023 Laurent Forthomme + * Copyright (C) 2013-2024 Laurent Forthomme * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,6 +20,7 @@ #include "CepGen/Core/Exception.h" #include "CepGen/Core/ParametersList.h" +#include "CepGen/Core/RunParameters.h" #include "CepGen/Event/Event.h" #include "CepGen/EventFilter/EventExporter.h" #include "CepGen/EventFilter/EventModifier.h" @@ -27,7 +28,6 @@ #include "CepGen/Modules/FormFactorsFactory.h" #include "CepGen/Modules/ProcessFactory.h" #include "CepGen/Modules/StructureFunctionsFactory.h" -#include "CepGen/Parameters.h" #include "CepGen/Physics/PDG.h" #include "CepGen/Process/Process.h" #include "CepGen/Utils/Functional.h" @@ -35,9 +35,9 @@ #include "CepGen/Utils/TimeKeeper.h" namespace cepgen { - Parameters::Parameters() : par_integrator(ParametersList().setName("Vegas")) {} + RunParameters::RunParameters() : par_integrator(ParametersList().setName("Vegas")) {} - Parameters::Parameters(Parameters& param) + RunParameters::RunParameters(RunParameters& param) : par_integrator(param.par_integrator), process_(std::move(param.process_)), evt_modifiers_(std::move(param.evt_modifiers_)), @@ -48,15 +48,15 @@ namespace cepgen { generation_(param.generation_), tmr_(std::move(param.tmr_)) {} - Parameters::Parameters(const Parameters& param) + RunParameters::RunParameters(const RunParameters& param) : par_integrator(param.par_integrator), total_gen_time_(param.total_gen_time_), num_gen_events_(param.num_gen_events_), generation_(param.generation_) {} - Parameters::~Parameters() {} // required for unique_ptr initialisation! + RunParameters::~RunParameters() {} // required for unique_ptr initialisation! - Parameters& Parameters::operator=(Parameters param) { + RunParameters& RunParameters::operator=(RunParameters param) { par_integrator = param.par_integrator; process_ = std::move(param.process_); evt_modifiers_ = std::move(param.evt_modifiers_); @@ -69,7 +69,7 @@ namespace cepgen { return *this; } - void Parameters::initialise() { + void RunParameters::initialiseModules() { // prepare the event modifications algorithms for event generation for (auto& mod : evt_modifiers_) mod->initialise(*this); @@ -78,7 +78,7 @@ namespace cepgen { mod->initialise(*this); } - void Parameters::prepareRun() { + void RunParameters::prepareRun() { if (tmr_) tmr_->clear(); CG_TICKER(tmr_.get()); @@ -88,70 +88,72 @@ namespace cepgen { num_gen_events_ = 0ul; } - void Parameters::setTimeKeeper(utils::TimeKeeper* kpr) { tmr_.reset(kpr); } + void RunParameters::setTimeKeeper(utils::TimeKeeper* kpr) { tmr_.reset(kpr); } - void Parameters::addGenerationTime(double gen_time) { + void RunParameters::addGenerationTime(double gen_time) { total_gen_time_ += gen_time; num_gen_events_++; } - proc::Process& Parameters::process() { return *process_.get(); } + proc::Process& RunParameters::process() { return *process_.get(); } - const proc::Process& Parameters::process() const { return *process_.get(); } + const proc::Process& RunParameters::process() const { return *process_.get(); } - std::string Parameters::processName() const { + std::string RunParameters::processName() const { if (!process_) return "no process"; return process_->name(); } - void Parameters::clearProcess() { process_.release(); } + void RunParameters::clearProcess() { process_.release(); } - void Parameters::setProcess(std::unique_ptr proc) { process_ = std::move(proc); } + void RunParameters::setProcess(std::unique_ptr proc) { process_ = std::move(proc); } - void Parameters::setProcess(proc::Process* proc) { + void RunParameters::setProcess(proc::Process* proc) { if (!proc) - throw CG_FATAL("Parameters") << "Trying to clone an invalid process!"; + throw CG_FATAL("RunParameters") << "Trying to clone an invalid process!"; process_.reset(proc); } - const Kinematics& Parameters::kinematics() const { + const Kinematics& RunParameters::kinematics() const { if (!process_) - throw CG_FATAL("Parameters") << "Process must be defined before its kinematics is retrieved!"; + throw CG_FATAL("RunParameters") << "Process must be defined before its kinematics is retrieved!"; return process_->kinematics(); } - EventModifier& Parameters::eventModifier(size_t i) { return *evt_modifiers_.at(i); } + EventModifier& RunParameters::eventModifier(size_t i) { return *evt_modifiers_.at(i); } - void Parameters::clearEventModifiersSequence() { evt_modifiers_.clear(); } + void RunParameters::clearEventModifiersSequence() { evt_modifiers_.clear(); } - void Parameters::addModifier(std::unique_ptr mod) { evt_modifiers_.emplace_back(std::move(mod)); } + void RunParameters::addModifier(std::unique_ptr mod) { evt_modifiers_.emplace_back(std::move(mod)); } - void Parameters::addModifier(EventModifier* mod) { + void RunParameters::addModifier(EventModifier* mod) { evt_modifiers_.emplace_back(std::move(std::unique_ptr(mod))); } - EventExporter& Parameters::eventExporter(size_t i) { return *evt_exporters_.at(i); } + EventExporter& RunParameters::eventExporter(size_t i) { return *evt_exporters_.at(i); } - void Parameters::clearEventExportersSequence() { evt_exporters_.clear(); } + void RunParameters::clearEventExportersSequence() { evt_exporters_.clear(); } - void Parameters::addEventExporter(std::unique_ptr mod) { evt_exporters_.emplace_back(std::move(mod)); } + void RunParameters::addEventExporter(std::unique_ptr mod) { + evt_exporters_.emplace_back(std::move(mod)); + } - void Parameters::addEventExporter(EventExporter* mod) { + void RunParameters::addEventExporter(EventExporter* mod) { evt_exporters_.emplace_back(std::unique_ptr(mod)); } - void Parameters::addTamingFunction(std::unique_ptr fct) { + void RunParameters::addTamingFunction(std::unique_ptr fct) { taming_functions_.emplace_back(std::move(fct)); } - std::ostream& operator<<(std::ostream& os, const Parameters* param) { + std::ostream& operator<<(std::ostream& os, const RunParameters& param) { const int wb = 90, wt = 33; os << std::left << "\n" << std::setfill('_') << std::setw(wb + 3) << "_/¯ RUN INFORMATION ¯\\_" << std::setfill(' ') << "\n\n"; - if (param->process_) { - const auto& proc_params = param->process().parameters(); + if (param.process_) { + const auto& proc_params = param.process().parameters(); os << std::setw(wt) << "Process to generate:" << utils::boldify(ProcessFactory::get().describeParameters(proc_params).description()) << "\n"; for (const auto& key : proc_params.keys(false)) { @@ -163,40 +165,40 @@ namespace cepgen { os << std::setw(wt) << "" << key << ": " << proc_params.getString(key) << "\n"; } } - if (!param->evt_modifiers_.empty() || param->evt_exporters_.empty() || !param->taming_functions_.empty()) + if (!param.evt_modifiers_.empty() || param.evt_exporters_.empty() || !param.taming_functions_.empty()) os << "\n" << std::setfill('-') << std::setw(wb + 6) << utils::boldify(" Event treatment ") << std::setfill(' ') << "\n\n"; - if (!param->evt_modifiers_.empty()) { - std::string mod_name = utils::s("Event modifier", param->evt_modifiers_.size(), false), sep; - for (const auto& mod : param->evt_modifiers_) + if (!param.evt_modifiers_.empty()) { + std::string mod_name = utils::s("Event modifier", param.evt_modifiers_.size(), false), sep; + for (const auto& mod : param.evt_modifiers_) os << std::setw(wt) << mod_name << sep << utils::boldify(mod->name()) << "\n", sep = "+ ", mod_name.clear(); os << "\n"; } - if (!param->evt_exporters_.empty()) { - os << utils::s("Output module", param->evt_exporters_.size(), false); - for (const auto& mod : param->evt_exporters_) + if (!param.evt_exporters_.empty()) { + os << utils::s("Output module", param.evt_exporters_.size(), false); + for (const auto& mod : param.evt_exporters_) os << "\n\t*) " << EventExporterFactory::get().describeParameters(mod->name(), mod->parameters()).describe(1); } - if (!param->taming_functions_.empty()) { - os << std::setw(wt) << utils::s("Taming function", param->taming_functions_.size(), false) << "\n"; - for (const auto& tf : param->taming_functions_) + if (!param.taming_functions_.empty()) { + os << std::setw(wt) << utils::s("Taming function", param.taming_functions_.size(), false) << "\n"; + for (const auto& tf : param.taming_functions_) os << std::setw(wt) << "" << tf->variables().at(0) << ": " << tf->expression() << "\n"; } os << "\n\n" << std::setfill('-') << std::setw(wb + 6) << utils::boldify(" Integration/generation parameters ") << std::setfill(' ') << "\n\n" - << std::setw(wt) << "Integration" << utils::boldify(param->par_integrator.name("N/A")) << "\n"; - for (const auto& key : param->par_integrator.keys(false)) - os << std::setw(wt) << "" << key << ": " << param->par_integrator.getString(key) << "\n"; - os << std::setw(wt) << "Event generation? " << utils::yesno(param->generation_.enabled()) << "\n" - << std::setw(wt) << "Number of events to generate" << utils::boldify(param->generation_.maxGen()) << "\n" - << std::setw(wt) << "Generator worker" << param->generation_.parameters().get("worker") << "\n"; - if (param->generation_.numThreads() > 1) - os << std::setw(wt) << "Number of threads" << param->generation_.numThreads() << "\n"; - os << std::setw(wt) << "Number of points to try per bin" << param->generation_.numPoints() << "\n" + << std::setw(wt) << "Integration" << utils::boldify(param.par_integrator.name("N/A")) << "\n"; + for (const auto& key : param.par_integrator.keys(false)) + os << std::setw(wt) << "" << key << ": " << param.par_integrator.getString(key) << "\n"; + os << std::setw(wt) << "Event generation? " << utils::yesno(param.generation_.enabled()) << "\n" + << std::setw(wt) << "Number of events to generate" << utils::boldify(param.generation_.maxGen()) << "\n" + << std::setw(wt) << "Generator worker" << param.generation_.parameters().get("worker") << "\n"; + if (param.generation_.numThreads() > 1) + os << std::setw(wt) << "Number of threads" << param.generation_.numThreads() << "\n"; + os << std::setw(wt) << "Number of points to try per bin" << param.generation_.numPoints() << "\n" << std::setw(wt) << "Verbosity level " << utils::Logger::get().level() << "\n"; - const auto& kin = param->process().kinematics(); + const auto& kin = param.process().kinematics(); const auto& beams = kin.incomingBeams(); os << "\n" << std::setfill('_') << std::setw(wb + 3) << "_/¯ EVENTS KINEMATICS ¯\\_" << std::setfill(' ') << "\n\n" @@ -255,7 +257,7 @@ namespace cepgen { //----------------------------------------------------------------------------------------------- - Parameters::Generation::Generation(const ParametersList& params) : SteeredObject(params) { + RunParameters::Generation::Generation(const ParametersList& params) : SteeredObject(params) { (*this) .add("maxgen", max_gen_) .add("printEvery", gen_print_every_) @@ -265,7 +267,7 @@ namespace cepgen { .add("numPoints", num_points_); } - ParametersDescription Parameters::Generation::description() { + ParametersDescription RunParameters::Generation::description() { auto desc = ParametersDescription(); desc.add("worker", ParametersDescription().setName("grid_optimised")) .setDescription("type of generator worker to use for event generation"); diff --git a/CepGen/Core/RunParameters.h b/CepGen/Core/RunParameters.h new file mode 100644 index 000000000..288d0a725 --- /dev/null +++ b/CepGen/Core/RunParameters.h @@ -0,0 +1,157 @@ +/* + * CepGen: a central exclusive processes event generator + * Copyright (C) 2013-2024 Laurent Forthomme + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef CepGen_Core_RunParameters_h +#define CepGen_Core_RunParameters_h + +#include + +#include "CepGen/Physics/Kinematics.h" + +namespace cepgen { + class EventExporter; + class EventModifier; + class ParametersList; + namespace proc { + class Process; + } + namespace utils { + class Functional; + class TimeKeeper; + } // namespace utils + enum class IntegratorType; + typedef std::vector > EventModifiersSequence; ///< Event modification algos ordered set + typedef std::vector > EventExportersSequence; ///< Event export modules ordered set + typedef std::vector > TamingFunctionsSequence; ///< Taming functions evaluators set + + /// List of parameters used to start and run the simulation job + class RunParameters { + public: + RunParameters(); + RunParameters(RunParameters&); ///< Copy constructor (transfers ownership to process/event modification algorithm!) + RunParameters(const RunParameters&); ///< Const copy constructor (all but process + event handling algorithms) + ~RunParameters(); // required for unique_ptr initialisation! + + RunParameters& operator=(RunParameters); ///< Assignment operator + + friend std::ostream& operator<<(std::ostream&, const RunParameters&); ///< User-readable dump of runtime parameters + + void setTimeKeeper(utils::TimeKeeper*); ///< Initialise the timekeeper instance + utils::TimeKeeper* timeKeeper() { return tmr_.get(); } ///< Pointer to a timekeeper instance + const utils::TimeKeeper* timeKeeper() const { return tmr_.get(); } ///< Pointer to a timekeeper instance + + void initialiseModules(); ///< Initialise the event handling modules for an event generation + + ParametersList par_integrator; ///< Integrator specific user-defined parameters + + //----- process to compute + + bool hasProcess() const { return !(!process_); } ///< Is this parameters collection holding any physics process? + proc::Process& process(); ///< Process object for cross-section computation/events generation + const proc::Process& process() const; ///< Process object for cross-section computation/events generation + std::string processName() const; ///< Name of the process considered + void clearProcess(); ///< Remove the process pointer + void setProcess(std::unique_ptr); ///< Set a process configuration + void setProcess(proc::Process*); ///< Set a process configuration + + //----- events kinematics + + /// Events kinematics for phase space definition + const Kinematics& kinematics() const; + + //----- events generation + + /// Collection of events generation parameters + class Generation : public SteeredObject { + public: + /// Build a generation parameters collection from a user input + explicit Generation(const ParametersList& = ParametersList()); + + static ParametersDescription description(); + + void setTargetLuminosity(double lumi_invpb) { target_lumi_ = lumi_invpb; } ///< Set target luminosity, in pb^-1 + double targetLuminosity() const { return target_lumi_; } ///< Target luminosity to reach, in pb^-1 + void setMaxGen(size_t max_gen) { max_gen_ = max_gen; } ///< Set the maximal number of events to generate + size_t maxGen() const { return max_gen_; } ///< Maximal number of events to generate + bool enabled() const { return max_gen_ > 0; } ///< Are we generating events? + void setPrintEvery(size_t print_every) { gen_print_every_ = print_every; } ///< Set the events display frequency + size_t printEvery() const { return gen_print_every_; } ///< Frequency at which events are displayed to the user + void setSymmetrise(bool sym) { symmetrise_ = sym; } ///< Switch the symmetrisation of the z-axis for each event + bool symmetrise() const { return symmetrise_; } ///< Symmetrise events wrt the \f$z\f$-axis ? + void setNumThreads(size_t nt) { num_threads_ = nt; } ///< Set the number of threads for the events generation + size_t numThreads() const { return num_threads_; } ///< Number of threads to perform the events generation + void setNumPoints(size_t np) { num_points_ = np; } ///< Set the number of points to probe in each integration bin + size_t numPoints() const { return num_points_; } ///< Number of points to "shoot" in each integration bin + + private: + int max_gen_, gen_print_every_; + double target_lumi_; + bool symmetrise_; + int num_threads_, num_points_; + }; + Generation& generation() { return generation_; } ///< Event generation parameters + const Generation& generation() const { return generation_; } ///< Event generation parameters + + //----- event modification (e.g. hadronisation, decay) algorithm + + EventModifier& eventModifier(size_t); ///< Event modification algorithm + EventModifiersSequence& eventModifiersSequence() { return evt_modifiers_; } ///< List of event modification algos + /// List of event modification algos + const EventModifiersSequence& eventModifiersSequence() const { return evt_modifiers_; } + void clearEventModifiersSequence(); ///< Remove all event modifiers from sequence + void addModifier(std::unique_ptr); ///< Add a new event modification algorithm to the sequence + void addModifier(EventModifier*); ///< Add a new event modification algorithm to the sequence + + //----- event output algorithms + + EventExporter& eventExporter(size_t); ///< Output module + EventExportersSequence& eventExportersSequence() { return evt_exporters_; } ///< List of output modules + const EventExportersSequence& eventExportersSequence() const { return evt_exporters_; } ///< List of output modules + void clearEventExportersSequence(); ///< Remove all output modules from sequence + void addEventExporter(std::unique_ptr); ///< Set a new output module definition + void addEventExporter(EventExporter*); ///< Set the pointer to a output module + + //----- taming functions + + /// List of all taming functions definitions + const TamingFunctionsSequence& tamingFunctions() const { return taming_functions_; } + void addTamingFunction(std::unique_ptr); ///< Set a new taming function definition + + //----- run operations + + void prepareRun(); ///< Reset total generation time and number of events generated for this run, prepare kinematics + + /// Add a new timing into the total generation time + /// \param[in] gen_time Time to add (in seconds) + void addGenerationTime(double gen_time); + inline double totalGenerationTime() const { return total_gen_time_; } ///< Total generation time in s for this run + inline unsigned int numGeneratedEvents() const { return num_gen_events_; } ///< Number of events generated in run + + private: + std::unique_ptr process_; ///< Physics process held by these parameters + EventModifiersSequence evt_modifiers_; ///< Collection of event modification algorithms to be applied + EventExportersSequence evt_exporters_; ///< Collection of event output modules to be applied + TamingFunctionsSequence taming_functions_; ///< Functions to be used to account for rescattering corrections + double total_gen_time_{0.}; ///< Total generation time (in seconds) + unsigned long num_gen_events_{0ul}; ///< Number of events already generated + Generation generation_; ///< Events generation parameters + std::unique_ptr tmr_; ///< Collection of stopwatches for timing + }; +} // namespace cepgen + +#endif diff --git a/CepGen/EventFilter/EventExporter.cpp b/CepGen/EventFilter/EventExporter.cpp index 62ec142a1..c13c15342 100644 --- a/CepGen/EventFilter/EventExporter.cpp +++ b/CepGen/EventFilter/EventExporter.cpp @@ -1,6 +1,6 @@ /* * CepGen: a central exclusive processes event generator - * Copyright (C) 2016-2023 Laurent Forthomme + * Copyright (C) 2016-2024 Laurent Forthomme * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,9 +20,9 @@ #include #include "CepGen/Core/ParametersList.h" +#include "CepGen/Core/RunParameters.h" #include "CepGen/EventFilter/EventExporter.h" #include "CepGen/EventFilter/EventModifier.h" -#include "CepGen/Parameters.h" #include "CepGen/Utils/String.h" #include "CepGen/Version.h" diff --git a/CepGen/EventFilter/EventHandler.cpp b/CepGen/EventFilter/EventHandler.cpp index 02b509be5..573fdd4be 100644 --- a/CepGen/EventFilter/EventHandler.cpp +++ b/CepGen/EventFilter/EventHandler.cpp @@ -1,6 +1,6 @@ /* * CepGen: a central exclusive processes event generator - * Copyright (C) 2023 Laurent Forthomme + * Copyright (C) 2023-2024 Laurent Forthomme * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,8 +17,8 @@ */ #include "CepGen/Core/Exception.h" +#include "CepGen/Core/RunParameters.h" #include "CepGen/EventFilter/EventHandler.h" -#include "CepGen/Parameters.h" namespace cepgen { EventHandler::EventHandler(const ParametersList& params) : NamedModule(params) {} @@ -33,7 +33,7 @@ namespace cepgen { return desc; } - void EventHandler::initialise(const Parameters& params) { + void EventHandler::initialise(const RunParameters& params) { if (initialised_) CG_WARNING("EventHandler:initialise") << "Event handler '" << name_ << "' was already initialised."; run_params_ = ¶ms; @@ -41,7 +41,7 @@ namespace cepgen { initialised_ = true; } - const Parameters& EventHandler::runParameters() const { + const RunParameters& EventHandler::runParameters() const { if (!run_params_) throw CG_FATAL("EventHandler:runParameters") << "Run parameters not yet initialised."; return *run_params_; diff --git a/CepGen/EventFilter/EventHandler.h b/CepGen/EventFilter/EventHandler.h index fd6220bca..83e2d2bc5 100644 --- a/CepGen/EventFilter/EventHandler.h +++ b/CepGen/EventFilter/EventHandler.h @@ -1,6 +1,6 @@ /* * CepGen: a central exclusive processes event generator - * Copyright (C) 2023 Laurent Forthomme + * Copyright (C) 2023-2024 Laurent Forthomme * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,7 +26,7 @@ namespace cepgen { class Event; - class Parameters; + class RunParameters; /// Class template for modules interacting with events /// \author Laurent Forthomme /// \date Jan 2023 @@ -38,9 +38,9 @@ namespace cepgen { static ParametersDescription description(); /// Initialise the handler and its inner parameterisation - void initialise(const Parameters&); + void initialise(const RunParameters&); /// List of run parameters - const Parameters& runParameters() const; + const RunParameters& runParameters() const; /// Retrieve the engine object template @@ -54,7 +54,7 @@ namespace cepgen { virtual void* enginePtr(); private: - const Parameters* run_params_{nullptr}; // NOT owning + const RunParameters* run_params_{nullptr}; // NOT owning bool initialised_{false}; }; } // namespace cepgen diff --git a/CepGen/EventFilter/EventHarvester.cpp b/CepGen/EventFilter/EventHarvester.cpp index 20db50cc6..02b123ee8 100644 --- a/CepGen/EventFilter/EventHarvester.cpp +++ b/CepGen/EventFilter/EventHarvester.cpp @@ -1,6 +1,6 @@ /* * CepGen: a central exclusive processes event generator - * Copyright (C) 2019-2023 Laurent Forthomme + * Copyright (C) 2019-2024 Laurent Forthomme * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,12 +17,12 @@ */ #include "CepGen/Core/Exception.h" +#include "CepGen/Core/RunParameters.h" #include "CepGen/Event/Event.h" #include "CepGen/EventFilter/EventBrowser.h" #include "CepGen/EventFilter/EventHarvester.h" #include "CepGen/Modules/DrawerFactory.h" #include "CepGen/Modules/ProcessFactory.h" -#include "CepGen/Parameters.h" #include "CepGen/Utils/Drawer.h" #include "CepGen/Utils/String.h" diff --git a/CepGen/Generator.h b/CepGen/Generator.h index 2f0f99159..07f7dd746 100644 --- a/CepGen/Generator.h +++ b/CepGen/Generator.h @@ -1,6 +1,6 @@ /* * CepGen: a central exclusive processes event generator - * Copyright (C) 2013-2023 Laurent Forthomme + * Copyright (C) 2013-2024 Laurent Forthomme * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -43,28 +43,22 @@ namespace cepgen { class Integrator; class GeneratorWorker; - class Parameters; + class RunParameters; namespace proc { class Process; } - /// Collection of libraries loaded in the runtime environment - static std::vector loaded_libraries; - /// Collection of libraries tested not to work in the runtime environment - static std::vector invalid_libraries; - /// Collection of search paths to build the runtime environment - static std::vector search_paths; + static std::vector loaded_libraries; ///< Collection of libraries loaded in RTE + static std::vector invalid_libraries; ///< Collection of libraries tested not to work with RTE + static std::vector search_paths; ///< Collection of search paths to build RTE /// Execute an action on a path if found in search paths collection bool callPath(const std::string&, bool (*callback)(const std::string&)); - /// Import a shared library in the runtime environment - bool loadLibrary(const std::string&, bool match = false); + bool loadLibrary(const std::string&, bool match = false); ///< Import a shared library in RTE /// Launch the initialisation procedure /// \param[in] safe_mode Drop libraries initialisation? void initialise(bool safe_mode = false); - /// Dump this program's header into the standard output stream - void printHeader(); - /// List the modules registered in the runtime database - void dumpModules(); + void printHeader(); ///< Dump this program's header into the standard output stream + void dumpModules(); ///< List the modules registered in RTE database //////////////////////////////////////////////////////////////////////////////// @@ -75,7 +69,7 @@ namespace cepgen { * while scanning the various parameters (point \f${\bf x}\f$ in the * multi-dimensional phase space). * - * The phase space is constrained using the Parameters object given as an + * The phase space is constrained using the RunParameters object given as an * argument to the constructor, and the differential cross-sections for each * value of the array \f${\bf x}\f$ are computed in the \a f-function defined * outside (but populated inside) this object. @@ -94,27 +88,20 @@ namespace cepgen { /// Core of the Monte Carlo integrator and events generator /// \param[in] safe_mode Load the generator without external libraries? explicit Generator(bool safe_mode = false); - /// Core of the Monte Carlo integrator and events generator - /// \param[in] ip List of input parameters defining the phase space on which to perform the integration - explicit Generator(Parameters* ip); + explicit Generator(RunParameters*); ///< Build a MC generator object ~Generator(); - /// Pointer to the parameters block - const Parameters* parameters() const { return parameters_.get(); } - /// Extracted pointer to the parameters block - Parameters* parametersPtr() { return parameters_.release(); } - /// Getter to the run parameters block - Parameters& parametersRef(); - /// Feed the generator with a Parameters object - void setParameters(Parameters* ip); - /// Reset integrator algorithm from the user-specified configuration - void resetIntegrator(); - /// Specify an integrator algorithm configuration - void setIntegrator(std::unique_ptr); - /// Remove all references to a previous generation/run - void clearRun(); - /// Integrate the functional over the whole phase space - void integrate(); + const RunParameters& runParameters() const; ///< Pointer to the parameters block + RunParameters& runParameters(); ///< Run parameters block + void setRunParameters(RunParameters* ip); ///< Feed the generator with a RunParameters object + + void resetIntegrator(); ///< Reset integrator algorithm from the user-specified configuration + void setIntegrator(std::unique_ptr); ///< Specify an integrator algorithm configuration + + void clearRun(); ///< Remove all references to a previous generation/run + + void integrate(); ///< Integrate the functional over the phase space of interest + /// Compute the cross section for the run parameters /// \return The computed cross-section and uncertainty, in pb Value computeXsection(); @@ -122,35 +109,26 @@ namespace cepgen { /// \param[out] xsec The computed cross-section, in pb /// \param[out] err The absolute integration error on the computed cross-section, in pb [[deprecated("Please use the parameters-less version")]] void computeXsection(double& cross_section, double& err); - /// Last cross section computed by the generator - double crossSection() const { return xsect_; } - /// Last error on the cross section computed by the generator - double crossSectionError() const { return xsect_.uncertainty(); } - - /// Launch the generation of events - void generate(size_t num_events, const std::function&); - /// Launch the generation of events + double crossSection() const { return xsect_; } ///< Last cross section computed by the generator + double crossSectionError() const { return xsect_.uncertainty(); } ///< Last error on the cross section computed + + void generate(size_t num_events, const std::function&); ///< Launch event generation + /// Launch event generation void generate(size_t num_events, const std::function& = nullptr); - /// Generate one event - const Event& next(); + const Event& next(); //& x); private: - /// Initialise the generation of events - void initialise(); - /// Physical Parameters used in the events generation and cross-section computation - std::unique_ptr parameters_; - /// Generator worker instance - std::unique_ptr worker_; - /// Integration algorithm - std::unique_ptr integrator_; - /// Has the event generator already been initialised? - bool initialised_{false}; - /// Cross section value computed at the last integration - Value xsect_{-1., -1.}; + void initialise(); ///< Initialise event generation + std::unique_ptr parameters_; ///< Run parameters for event generation and cross-section computation + std::unique_ptr worker_; ///< Generator worker instance + std::unique_ptr integrator_; ///< Integration algorithm + bool initialised_{false}; ///< Has the event generator already been initialised? + Value xsect_{-1., -1.}; ///< Cross section value computed at the last integration }; } // namespace cepgen diff --git a/CepGen/Integration/ProcessIntegrand.cpp b/CepGen/Integration/ProcessIntegrand.cpp index 410f8d92b..bf86a0383 100644 --- a/CepGen/Integration/ProcessIntegrand.cpp +++ b/CepGen/Integration/ProcessIntegrand.cpp @@ -1,6 +1,6 @@ /* * CepGen: a central exclusive processes event generator - * Copyright (C) 2013-2023 Laurent Forthomme + * Copyright (C) 2013-2024 Laurent Forthomme * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,22 +19,22 @@ #include #include "CepGen/Core/Exception.h" +#include "CepGen/Core/RunParameters.h" #include "CepGen/Event/Event.h" #include "CepGen/EventFilter/EventBrowser.h" #include "CepGen/EventFilter/EventModifier.h" #include "CepGen/Integration/ProcessIntegrand.h" -#include "CepGen/Parameters.h" #include "CepGen/Process/Process.h" #include "CepGen/Utils/Functional.h" #include "CepGen/Utils/Math.h" #include "CepGen/Utils/TimeKeeper.h" namespace cepgen { - ProcessIntegrand::ProcessIntegrand(const proc::Process& proc) : params_(new Parameters), tmr_(new utils::Timer) { + ProcessIntegrand::ProcessIntegrand(const proc::Process& proc) : params_(new RunParameters), tmr_(new utils::Timer) { setProcess(proc); } - ProcessIntegrand::ProcessIntegrand(const Parameters* params) : params_(params), tmr_(new utils::Timer) { + ProcessIntegrand::ProcessIntegrand(const RunParameters* params) : params_(params), tmr_(new utils::Timer) { if (!params_) throw CG_FATAL("ProcessIntegrand") << "Invalid runtime parameters specified."; if (!params_->hasProcess()) @@ -83,7 +83,7 @@ namespace cepgen { } double ProcessIntegrand::eval(const std::vector& x) { - CG_TICKER(const_cast(params_)->timeKeeper()); + CG_TICKER(const_cast(params_)->timeKeeper()); //--- start the timer tmr_->reset(); diff --git a/CepGen/Integration/ProcessIntegrand.h b/CepGen/Integration/ProcessIntegrand.h index b7bf439c0..fa8f5e795 100644 --- a/CepGen/Integration/ProcessIntegrand.h +++ b/CepGen/Integration/ProcessIntegrand.h @@ -1,6 +1,6 @@ /* * CepGen: a central exclusive processes event generator - * Copyright (C) 2013-2021 Laurent Forthomme + * Copyright (C) 2013-2024 Laurent Forthomme * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,7 +26,7 @@ #include "CepGen/Integration/Integrand.h" namespace cepgen { - class Parameters; + class RunParameters; namespace proc { class Process; } @@ -37,7 +37,7 @@ namespace cepgen { class ProcessIntegrand : public Integrand { public: explicit ProcessIntegrand(const proc::Process&); - explicit ProcessIntegrand(const Parameters*); + explicit ProcessIntegrand(const RunParameters*); /// Compute the integrand for a given phase space point (or "event") /// \param[in] x Phase space point coordinates @@ -61,7 +61,7 @@ namespace cepgen { void setProcess(const proc::Process&); std::unique_ptr process_; ///< Local instance of the physics process - const Parameters* params_{nullptr}; ///< Generator-owned runtime parameters + const RunParameters* params_{nullptr}; ///< Generator-owned runtime parameters const std::unique_ptr tmr_; ///< Timekeeper for event generation utils::EventBrowser bws_; ///< Event browser bool storage_{false}; ///< Is the next event to be generated to be stored? diff --git a/CepGen/Parameters.h b/CepGen/Parameters.h deleted file mode 100644 index b8dcb0b3b..000000000 --- a/CepGen/Parameters.h +++ /dev/null @@ -1,211 +0,0 @@ -/* - * CepGen: a central exclusive processes event generator - * Copyright (C) 2013-2021 Laurent Forthomme - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef CepGen_Parameters_h -#define CepGen_Parameters_h - -#include - -#include "CepGen/Physics/Kinematics.h" - -namespace cepgen { - class EventExporter; - class EventModifier; - class ParametersList; - namespace proc { - class Process; - } - namespace utils { - class Functional; - class TimeKeeper; - } // namespace utils - enum class IntegratorType; - /// An ordered collection of event modification algorithms - typedef std::vector > EventModifiersSequence; - /// An ordered collection of event export modules - typedef std::vector > EventExportersSequence; - /// An ordered collection of taming functions evaluators - typedef std::vector > TamingFunctionsSequence; - /// List of parameters used to start and run the simulation job - class Parameters { - public: - Parameters(); - /// Copy constructor (transfers ownership to the process/event modification algorithm!) - Parameters(Parameters&); - /// Const copy constructor (all but the process and the event modification algorithm) - Parameters(const Parameters&); - ~Parameters(); // required for unique_ptr initialisation! - - /// Assignment operator - Parameters& operator=(Parameters); - /// Dump the input parameters in the terminal - friend std::ostream& operator<<(std::ostream&, const Parameters*); - - /// Initialise the timekeeper instance - void setTimeKeeper(utils::TimeKeeper*); - /// Pointer to a timekeeper instance - utils::TimeKeeper* timeKeeper() { return tmr_.get(); } - /// Pointer to a timekeeper instance - const utils::TimeKeeper* timeKeeper() const { return tmr_.get(); } - - /// Initialise the parameters for an event generation - void initialise(); - - /// Integrator specific user-defined parameters - ParametersList par_integrator; - - //----- process to compute - - /// Is this parameters collection holding any physics process? - bool hasProcess() const { return !(!process_); } - /// Process for which the cross-section will be computed and the events will be generated - proc::Process& process(); - /// Process for which the cross-section will be computed and the events will be generated - const proc::Process& process() const; - /// Name of the process considered - std::string processName() const; - /// Remove the process pointer - void clearProcess(); - /// Copy a process configuration - void setProcess(std::unique_ptr proc); - /// Set a process configuration - void setProcess(proc::Process* proc); - - //----- events kinematics - - /// Events kinematics for phase space definition - const Kinematics& kinematics() const; - - //----- events generation - - /// Collection of events generation parameters - class Generation : public SteeredObject { - public: - /// Build a generation parameters collection from a user input - explicit Generation(const ParametersList& = ParametersList()); - - static ParametersDescription description(); - - /// Set the target luminosity to reach (in pb^-1) - void setTargetLuminosity(double lumi_invpb) { target_lumi_ = lumi_invpb; } - /// Target luminosity to reach (in pb^-1) - double targetLuminosity() const { return target_lumi_; } - /// Set the maximal number of events to generate - void setMaxGen(size_t max_gen) { max_gen_ = max_gen; } - /// Maximal number of events to generate - size_t maxGen() const { return max_gen_; } - /// Are we generating events? (true) or only computing the cross-section? (false) - bool enabled() const { return max_gen_ > 0; } - /// Set the frequency at which events are displayed to the end-user - void setPrintEvery(size_t print_every) { gen_print_every_ = print_every; } - /// Frequency at which events are displayed to the end-user - size_t printEvery() const { return gen_print_every_; } - /// Switch on/off the symmetrisation of the z-axis for each event - void setSymmetrise(bool sym) { symmetrise_ = sym; } - /// Do we want the events to be symmetric with respect to the \f$z\f$-axis ? - bool symmetrise() const { return symmetrise_; } - /// Set the number of threads for the events generation - void setNumThreads(size_t nt) { num_threads_ = nt; } - /// Number of threads to perform the events generation - size_t numThreads() const { return num_threads_; } - /// Set the number of points to probe in each integration bin - void setNumPoints(size_t np) { num_points_ = np; } - /// Number of points to "shoot" in each integration bin by the algorithm - size_t numPoints() const { return num_points_; } - - private: - int max_gen_, gen_print_every_; - double target_lumi_; - bool symmetrise_; - int num_threads_, num_points_; - }; - /// Get the events generation parameters - Generation& generation() { return generation_; } - /// Get the events generation parameters - const Generation& generation() const { return generation_; } - - //----- event modification (e.g. hadronisation, decay) algorithm - - /// Event modification algorithm to use - EventModifier& eventModifier(size_t); - /// Retrieve the list of event modification algorithms to run - EventModifiersSequence& eventModifiersSequence() { return evt_modifiers_; } - /// Retrieve the list of event modification algorithms to run - const EventModifiersSequence& eventModifiersSequence() const { return evt_modifiers_; } - /// Remove all event modifiers from sequence - void clearEventModifiersSequence(); - /// Add a new event modification algorithm to the sequence - void addModifier(std::unique_ptr); - /// Add a new event modification algorithm to the sequence - void addModifier(EventModifier*); - - //----- event output algorithms - - /// Output module - EventExporter& eventExporter(size_t); - /// Retrieve the list of output modules to run - EventExportersSequence& eventExportersSequence() { return evt_exporters_; } - /// Retrieve the list of output modules to run - const EventExportersSequence& eventExportersSequence() const { return evt_exporters_; } - /// Remove all output modules from sequence - void clearEventExportersSequence(); - /// Set a new output module definition - void addEventExporter(std::unique_ptr mod); - /// Set the pointer to a output module - void addEventExporter(EventExporter* mod); - - //----- taming functions - - /// List of all taming functions definitions - const TamingFunctionsSequence& tamingFunctions() const { return taming_functions_; } - /// Set a new taming function definition - void addTamingFunction(std::unique_ptr); - - //----- run operations - - /// Reset the total generation time and the number of events generated for this run, prepare kinematics - void prepareRun(); - /// Add a new timing into the total generation time - /// \param[in] gen_time Time to add (in seconds) - void addGenerationTime(double gen_time); - /// Return the total generation time for this run (in seconds) - inline double totalGenerationTime() const { return total_gen_time_; } - /// Total number of events already generated in this run - inline unsigned int numGeneratedEvents() const { return num_gen_events_; } - - private: - /// Physics process held by these parameters - std::unique_ptr process_; - /// Collection of event modification algorithms to be applied - EventModifiersSequence evt_modifiers_; - /// Collection of event output modules to be applied - EventExportersSequence evt_exporters_; - /// Functions to be used to account for rescattering corrections - TamingFunctionsSequence taming_functions_; - /// Total generation time (in seconds) - double total_gen_time_{0.}; - /// Number of events already generated - unsigned long num_gen_events_{0ul}; - /// Events generation parameters - Generation generation_; - /// A collection of stopwatches for timing - std::unique_ptr tmr_; - }; -} // namespace cepgen - -#endif diff --git a/CepGen/Physics/Beam.h b/CepGen/Physics/Beam.h index 2f9879ffc..da35b5e0d 100644 --- a/CepGen/Physics/Beam.h +++ b/CepGen/Physics/Beam.h @@ -42,17 +42,19 @@ namespace cepgen { /// Initialise the fluxes evaluator object void initialise(); - /// Does the beam remain on-shell after parton emission? - bool elastic() const { return elastic_; } - /// Beam particle PDG id - pdgid_t pdgId() const { return pdg_id_; } + bool elastic() const { return elastic_; } ///< Does the beam remain on-shell after parton emission? + /// Specify if the beam remains on-shell after parton emission + Beam& setElastic(bool el) { + elastic_ = el; + return *this; + } + pdgid_t pdgId() const { return pdg_id_; } ///< Beam particle PDG id /// Set the beam particle PDG id Beam& setPdgId(pdgid_t pdg) { pdg_id_ = pdg; return *this; } - /// Beam particle 4-momentum - const Momentum& momentum() const { return momentum_; } + const Momentum& momentum() const { return momentum_; } ///< Beam particle 4-momentum /// Set the beam particle 4-momentum Beam& setMomentum(const Momentum& mom) { momentum_ = mom; diff --git a/CepGen/Physics/IncomingBeams.cpp b/CepGen/Physics/IncomingBeams.cpp index 7c7a06346..cef5bbaa5 100644 --- a/CepGen/Physics/IncomingBeams.cpp +++ b/CepGen/Physics/IncomingBeams.cpp @@ -77,19 +77,21 @@ namespace cepgen { // fill from beam energies p1z = utils::fastSqrtSqDiff(beams_ene.at(0), PDG::get().mass(pos_pdg)); p2z = utils::fastSqrtSqDiff(beams_ene.at(1), PDG::get().mass(neg_pdg)); - } else if (pos_pdg == neg_pdg) { - // fill from centre-of-mass energy (symmetric beams) - const auto sqrts = params_.has("sqrtS") && steer("sqrtS") > 0. ? steer("sqrtS") - : params_.has("cmEnergy") && steer("cmEnergy") > 0. ? steer("cmEnergy") - : 0.; - if (sqrts > 0.) { // compute momenta from energy - const auto pz_abs = utils::fastSqrtSqDiff(0.5 * sqrts, PDG::get().mass(pos_pdg)); - p1z = +pz_abs; - p2z = -pz_abs; - } - } else { // when everything failed, retrieve "beamNpz" attributes + } else { + // when everything failed, retrieve "beamNpz" attributes params_.fill("beam1pz", p1z); params_.fill("beam2pz", p2z); + if (pos_pdg == neg_pdg) { // special case: symmetric beams -> fill from centre-of-mass energy + if (const auto sqrts = params_.has("sqrtS") && steer("sqrtS") > 0. ? steer("sqrtS") + : params_.has("cmEnergy") && steer("cmEnergy") > 0. + ? steer("cmEnergy") + : 0.; + sqrts > 0.) { // compute momenta from energy + const auto pz_abs = utils::fastSqrtSqDiff(0.5 * sqrts, PDG::get().mass(pos_pdg)); + p1z = +pz_abs; + p2z = -pz_abs; + } + } } //--- check the sign of both beams' pz if (p1z * p2z < 0. && p1z < 0.) diff --git a/CepGen/Utils/GridOptimisedGeneratorWorker.cpp b/CepGen/Utils/GridOptimisedGeneratorWorker.cpp index 5e88a74ef..a04e9f620 100644 --- a/CepGen/Utils/GridOptimisedGeneratorWorker.cpp +++ b/CepGen/Utils/GridOptimisedGeneratorWorker.cpp @@ -1,6 +1,6 @@ /* * CepGen: a central exclusive processes event generator - * Copyright (C) 2013-2023 Laurent Forthomme + * Copyright (C) 2013-2024 Laurent Forthomme * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,11 +18,11 @@ #include "CepGen/Core/Exception.h" #include "CepGen/Core/GeneratorWorker.h" +#include "CepGen/Core/RunParameters.h" #include "CepGen/Integration/GridParameters.h" #include "CepGen/Integration/Integrator.h" #include "CepGen/Integration/ProcessIntegrand.h" #include "CepGen/Modules/GeneratorWorkerFactory.h" -#include "CepGen/Parameters.h" #include "CepGen/Process/Process.h" #include "CepGen/Utils/ProgressBar.h" #include "CepGen/Utils/String.h" @@ -80,7 +80,7 @@ namespace cepgen { if (!grid_) throw CG_FATAL("GridOptimisedGeneratorWorker:next") << "Grid object was not initialised."; - CG_TICKER(const_cast(params_)->timeKeeper()); + CG_TICKER(const_cast(params_)->timeKeeper()); // apply correction cycles if required from previous event if (ps_bin_ != UNASSIGNED_BIN) { @@ -123,7 +123,7 @@ namespace cepgen { } bool GridOptimisedGeneratorWorker::correctionCycle(bool& store) { - CG_TICKER(const_cast(params_)->timeKeeper()); + CG_TICKER(const_cast(params_)->timeKeeper()); CG_DEBUG_LOOP("GridOptimisedGeneratorWorker:correction") << "Correction cycles are started.\n\t" diff --git a/CepGen/Utils/String.cpp b/CepGen/Utils/String.cpp index 76c849405..4798bb18b 100644 --- a/CepGen/Utils/String.cpp +++ b/CepGen/Utils/String.cpp @@ -164,6 +164,11 @@ namespace cepgen { return out.str(); } + std::string s(const std::string& word, float num, bool show_number) { + return show_number ? (num == 0 ? "no" : format("%g", num)) + format(" %s%s", word.c_str(), num > 1. ? "s" : "") + : format("%s%s", word.c_str(), num > 1. ? "s" : ""); + } + std::vector split(const std::string& str, char delim, bool trim) { std::vector out; if (str.empty()) diff --git a/CepGen/Utils/String.h b/CepGen/Utils/String.h index 8bffe5899..34e72d612 100644 --- a/CepGen/Utils/String.h +++ b/CepGen/Utils/String.h @@ -148,12 +148,7 @@ namespace cepgen { /// \param[in] end End delimiter of the substring(s) std::vector between(const std::string& str, const std::string& beg, const std::string& end); /// Add a trailing "s" when needed - inline const char* s(size_t num) { return (num > 1) ? "s" : ""; } - /// Add a trailing "s" when needed - inline std::string s(const std::string& word, float num, bool show_number = true) { - return show_number ? format("%g %s%s", num, word.c_str(), (num > 1.) ? "s" : "") - : format("%s%s", word.c_str(), (num > 1.) ? "s" : ""); - } + std::string s(const std::string&, float, bool = true); /// Helper to print a vector template inline std::string repr(const std::vector& vec, diff --git a/CepGenAddOns/BoostWrapper/BoostTreeHandler.cpp b/CepGenAddOns/BoostWrapper/BoostTreeHandler.cpp index 3cd745d4e..5985ceddd 100644 --- a/CepGenAddOns/BoostWrapper/BoostTreeHandler.cpp +++ b/CepGenAddOns/BoostWrapper/BoostTreeHandler.cpp @@ -1,6 +1,6 @@ /* * CepGen: a central exclusive processes event generator - * Copyright (C) 2020-2023 Laurent Forthomme + * Copyright (C) 2020-2024 Laurent Forthomme * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,6 +24,7 @@ #include "CepGen/Cards/Handler.h" #include "CepGen/Core/Exception.h" #include "CepGen/Core/ParametersList.h" +#include "CepGen/Core/RunParameters.h" #include "CepGen/EventFilter/EventExporter.h" #include "CepGen/EventFilter/EventModifier.h" #include "CepGen/Generator.h" // for library loading @@ -31,7 +32,6 @@ #include "CepGen/Modules/EventExporterFactory.h" #include "CepGen/Modules/EventModifierFactory.h" #include "CepGen/Modules/ProcessFactory.h" -#include "CepGen/Parameters.h" #include "CepGen/Process/Process.h" #include "CepGen/Utils/TimeKeeper.h" #include "CepGenAddOns/BoostWrapper/BoostTreeUtils.h" @@ -49,8 +49,8 @@ namespace cepgen { static ParametersDescription description(); - Parameters* parseFile(const std::string&, Parameters*) override; - void pack(const Parameters* params) override; + RunParameters* parseFile(const std::string&, RunParameters*) override; + void pack(const RunParameters* params) override; protected: /// Read and cast a file into the property tree @@ -76,7 +76,7 @@ namespace cepgen { BoostTreeHandler::BoostTreeHandler(const ParametersList& params) : Handler(params) {} - Parameters* BoostTreeHandler::parseFile(const std::string& filename, Parameters* params) { + RunParameters* BoostTreeHandler::parseFile(const std::string& filename, RunParameters* params) { rt_params_ = params; read(filename); @@ -134,8 +134,8 @@ namespace cepgen { return rt_params_; } - void BoostTreeHandler::pack(const Parameters* params) { - rt_params_ = const_cast(params); + void BoostTreeHandler::pack(const RunParameters* params) { + rt_params_ = const_cast(params); tree_.add_child(PROCESS_NAME, bc::pack(rt_params_->process().parameters())); if (!rt_params_->par_integrator.empty()) tree_.add_child(INTEGR_NAME, bc::pack(rt_params_->par_integrator)); diff --git a/CepGenAddOns/BoostWrapper/BoostTreeUtils.cpp b/CepGenAddOns/BoostWrapper/BoostTreeUtils.cpp index 90a8750cb..040fa7dbe 100644 --- a/CepGenAddOns/BoostWrapper/BoostTreeUtils.cpp +++ b/CepGenAddOns/BoostWrapper/BoostTreeUtils.cpp @@ -1,6 +1,6 @@ /* * CepGen: a central exclusive processes event generator - * Copyright (C) 2020-2022 Laurent Forthomme + * Copyright (C) 2020-2024 Laurent Forthomme * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,12 +20,12 @@ #include "CepGen/Core/Exception.h" #include "CepGen/Core/ParametersDescription.h" -#include "CepGen/Parameters.h" +#include "CepGen/Core/RunParameters.h" #include "CepGenAddOns/BoostWrapper/BoostTreeUtils.h" namespace boost { namespace cepgen { - pt::ptree pack(const ::cepgen::Parameters&) { + pt::ptree pack(const ::cepgen::RunParameters&) { pt::ptree out; return out; } diff --git a/CepGenAddOns/BoostWrapper/BoostTreeUtils.h b/CepGenAddOns/BoostWrapper/BoostTreeUtils.h index 25eb11fa5..5da3f6e22 100644 --- a/CepGenAddOns/BoostWrapper/BoostTreeUtils.h +++ b/CepGenAddOns/BoostWrapper/BoostTreeUtils.h @@ -1,6 +1,6 @@ /* * CepGen: a central exclusive processes event generator - * Copyright (C) 2020-2021 Laurent Forthomme + * Copyright (C) 2020-2024 Laurent Forthomme * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,7 +22,7 @@ #include namespace cepgen { - class Parameters; + class RunParameters; class ParametersDescription; } // namespace cepgen @@ -35,7 +35,7 @@ namespace boost { void add(::cepgen::ParametersList&, const std::string&, const pt::ptree&); - pt::ptree pack(const ::cepgen::Parameters&); + pt::ptree pack(const ::cepgen::RunParameters&); pt::ptree pack(const ::cepgen::ParametersDescription&); pt::ptree pack(const ::cepgen::ParametersList&); template diff --git a/CepGenAddOns/DelphesWrapper/DelphesHandler.cpp b/CepGenAddOns/DelphesWrapper/DelphesHandler.cpp index 7162adef3..ea83f23f5 100644 --- a/CepGenAddOns/DelphesWrapper/DelphesHandler.cpp +++ b/CepGenAddOns/DelphesWrapper/DelphesHandler.cpp @@ -1,6 +1,6 @@ /* * CepGen: a central exclusive processes event generator - * Copyright (C) 2019-2023 Laurent Forthomme + * Copyright (C) 2019-2024 Laurent Forthomme * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,10 +24,10 @@ #include #include "CepGen/Core/Exception.h" +#include "CepGen/Core/RunParameters.h" #include "CepGen/Event/Event.h" #include "CepGen/EventFilter/EventExporter.h" #include "CepGen/Modules/EventExporterFactory.h" -#include "CepGen/Parameters.h" #include "CepGen/Utils/Timer.h" #include "CepGen/Utils/Value.h" diff --git a/CepGenAddOns/HepMC3Wrapper/LHEFHepMCHandler.cpp b/CepGenAddOns/HepMC3Wrapper/LHEFHepMCHandler.cpp index da7c978fd..3feb0d8b5 100644 --- a/CepGenAddOns/HepMC3Wrapper/LHEFHepMCHandler.cpp +++ b/CepGenAddOns/HepMC3Wrapper/LHEFHepMCHandler.cpp @@ -1,6 +1,6 @@ /* * CepGen: a central exclusive processes event generator - * Copyright (C) 2013-2023 Laurent Forthomme + * Copyright (C) 2013-2024 Laurent Forthomme * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,10 +18,10 @@ #include +#include "CepGen/Core/RunParameters.h" #include "CepGen/Event/Event.h" #include "CepGen/EventFilter/EventExporter.h" #include "CepGen/Modules/EventExporterFactory.h" -#include "CepGen/Parameters.h" #include "CepGen/Utils/Value.h" using namespace std; // account for improper scoping in following includes diff --git a/CepGenAddOns/PhotosTauolaWrapper/test/simple_tau_decay.cc b/CepGenAddOns/PhotosTauolaWrapper/test/simple_tau_decay.cc index cad7fae5f..753a89a0f 100644 --- a/CepGenAddOns/PhotosTauolaWrapper/test/simple_tau_decay.cc +++ b/CepGenAddOns/PhotosTauolaWrapper/test/simple_tau_decay.cc @@ -1,6 +1,6 @@ /* * CepGen: a central exclusive processes event generator - * Copyright (C) 2022-2023 Laurent Forthomme + * Copyright (C) 2022-2024 Laurent Forthomme * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,11 +16,11 @@ * along with this program. If not, see . */ +#include "CepGen/Core/RunParameters.h" #include "CepGen/Event/Event.h" #include "CepGen/EventFilter/EventModifier.h" #include "CepGen/Generator.h" #include "CepGen/Modules/EventModifierFactory.h" -#include "CepGen/Parameters.h" #include "CepGen/Physics/PDG.h" #include "CepGen/Utils/ArgumentsParser.h" #include "CepGen/Utils/Test.h" @@ -34,7 +34,7 @@ int main(int argc, char* argv[]) { CG_LOG << "Failed to retrieve the Tauola interface!"; return -1; } - tauola->initialise(cepgen::Parameters()); + tauola->initialise(cepgen::RunParameters()); cepgen::Event ev; cepgen::Particle pho(cepgen::Particle::Role::CentralSystem, cepgen::PDG::photon, cepgen::Particle::Status::Resonance); diff --git a/CepGenAddOns/ProMCWrapper/ProMCHandler.cpp b/CepGenAddOns/ProMCWrapper/ProMCHandler.cpp index c88b8d3b6..b959289a3 100644 --- a/CepGenAddOns/ProMCWrapper/ProMCHandler.cpp +++ b/CepGenAddOns/ProMCWrapper/ProMCHandler.cpp @@ -1,6 +1,6 @@ /* * CepGen: a central exclusive processes event generator - * Copyright (C) 2013-2023 Laurent Forthomme + * Copyright (C) 2020-2024 Laurent Forthomme * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,10 +23,10 @@ #include +#include "CepGen/Core/RunParameters.h" #include "CepGen/Event/Event.h" #include "CepGen/EventFilter/EventExporter.h" #include "CepGen/Modules/EventExporterFactory.h" -#include "CepGen/Parameters.h" #include "CepGen/Physics/PDG.h" #include "CepGen/Utils/Filesystem.h" #include "CepGen/Utils/Message.h" diff --git a/CepGenAddOns/Pythia6Wrapper/Pythia6Hadroniser.cpp b/CepGenAddOns/Pythia6Wrapper/Pythia6Hadroniser.cpp index 681a5817e..eff70ee2d 100644 --- a/CepGenAddOns/Pythia6Wrapper/Pythia6Hadroniser.cpp +++ b/CepGenAddOns/Pythia6Wrapper/Pythia6Hadroniser.cpp @@ -1,6 +1,6 @@ /* * CepGen: a central exclusive processes event generator - * Copyright (C) 2013-2023 Laurent Forthomme + * Copyright (C) 2013-2024 Laurent Forthomme * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,10 +17,10 @@ */ #include "CepGen/Core/Exception.h" +#include "CepGen/Core/RunParameters.h" #include "CepGen/Event/Event.h" #include "CepGen/Modules/EventModifierFactory.h" #include "CepGen/Modules/RandomGeneratorFactory.h" -#include "CepGen/Parameters.h" #include "CepGen/Physics/Hadroniser.h" #include "CepGen/Utils/RandomGenerator.h" #include "CepGen/Utils/String.h" diff --git a/CepGenAddOns/Pythia6Wrapper/test/pythia6_kt_hadr.cc b/CepGenAddOns/Pythia6Wrapper/test/pythia6_kt_hadr.cc index c4c21620d..681e7833f 100644 --- a/CepGenAddOns/Pythia6Wrapper/test/pythia6_kt_hadr.cc +++ b/CepGenAddOns/Pythia6Wrapper/test/pythia6_kt_hadr.cc @@ -1,8 +1,8 @@ +#include "CepGen/Core/RunParameters.h" #include "CepGen/EventFilter/EventModifier.h" #include "CepGen/Generator.h" #include "CepGen/Modules/EventModifierFactory.h" #include "CepGen/Modules/ProcessFactory.h" -#include "CepGen/Parameters.h" #include "CepGen/Physics/Beam.h" #include "CepGen/Process/Process.h" #include "CepGen/Utils/ArgumentsParser.h" @@ -18,7 +18,7 @@ int main(int argc, char* argv[]) { auto evt = cepgen::utils::generateLPAIREvent(); evt.dump(); - gen.parametersRef().setProcess(cepgen::ProcessFactory::get().build( + gen.runParameters().setProcess(cepgen::ProcessFactory::get().build( "lpair", cepgen::ParametersList().set( "kinematics", @@ -28,7 +28,7 @@ int main(int argc, char* argv[]) { auto cg_pythia = cepgen::EventModifierFactory::get().build("pythia6"); cg_pythia->setCrossSection(cepgen::Value{1.46161e-1, 1.25691e-3}); - cg_pythia->initialise(gen.parametersRef()); + cg_pythia->initialise(gen.runParameters()); double evt_weight = 1.; const auto evt_before_particles = evt.particles().size(); diff --git a/CepGenAddOns/Pythia8Wrapper/Pythia8Hadroniser.cpp b/CepGenAddOns/Pythia8Wrapper/Pythia8Hadroniser.cpp index 327fef3af..49a9f2b31 100644 --- a/CepGenAddOns/Pythia8Wrapper/Pythia8Hadroniser.cpp +++ b/CepGenAddOns/Pythia8Wrapper/Pythia8Hadroniser.cpp @@ -1,6 +1,6 @@ /* * CepGen: a central exclusive processes event generator - * Copyright (C) 2013-2023 Laurent Forthomme + * Copyright (C) 2016-2024 Laurent Forthomme * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,9 +19,9 @@ #include #include "CepGen/Core/Exception.h" +#include "CepGen/Core/RunParameters.h" #include "CepGen/Event/Event.h" #include "CepGen/Modules/EventModifierFactory.h" -#include "CepGen/Parameters.h" #include "CepGen/Physics/Hadroniser.h" #include "CepGen/Physics/Kinematics.h" #include "CepGen/Physics/PDG.h" diff --git a/CepGenAddOns/Pythia8Wrapper/PythiaEventInterface.cpp b/CepGenAddOns/Pythia8Wrapper/PythiaEventInterface.cpp index 3fb70540f..7b8abd195 100644 --- a/CepGenAddOns/Pythia8Wrapper/PythiaEventInterface.cpp +++ b/CepGenAddOns/Pythia8Wrapper/PythiaEventInterface.cpp @@ -1,6 +1,6 @@ /* * CepGen: a central exclusive processes event generator - * Copyright (C) 2013-2021 Laurent Forthomme + * Copyright (C) 2016-2023 Laurent Forthomme * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,9 +17,9 @@ */ #include "CepGen/Core/Exception.h" +#include "CepGen/Core/RunParameters.h" #include "CepGen/Event/Event.h" #include "CepGen/Event/Particle.h" -#include "CepGen/Parameters.h" #include "CepGen/Physics/PDG.h" #include "CepGenAddOns/Pythia8Wrapper/PythiaEventInterface.h" @@ -29,7 +29,7 @@ namespace Pythia8 { CepGenEvent::CepGenEvent() : LHAup(3), mp_(cepgen::PDG::get().mass(cepgen::PDG::proton)), mp2_(mp_ * mp_) {} - void CepGenEvent::initialise(const cepgen::Parameters& params) { + void CepGenEvent::initialise(const cepgen::RunParameters& params) { params_ = ¶ms; inel1_ = !params_->kinematics().incomingBeams().positive().elastic(); inel2_ = !params_->kinematics().incomingBeams().negative().elastic(); diff --git a/CepGenAddOns/Pythia8Wrapper/PythiaEventInterface.h b/CepGenAddOns/Pythia8Wrapper/PythiaEventInterface.h index 9b334fc56..e0f5a9e5d 100644 --- a/CepGenAddOns/Pythia8Wrapper/PythiaEventInterface.h +++ b/CepGenAddOns/Pythia8Wrapper/PythiaEventInterface.h @@ -1,6 +1,6 @@ /* * CepGen: a central exclusive processes event generator - * Copyright (C) 2013-2021 Laurent Forthomme + * Copyright (C) 2016-2023 Laurent Forthomme * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,7 +24,7 @@ #include namespace cepgen { - class Parameters; + class RunParameters; class Event; class Particle; } // namespace cepgen @@ -41,7 +41,7 @@ namespace Pythia8 { }; explicit CepGenEvent(); /// Initialise this conversion object with CepGen parameters - void initialise(const cepgen::Parameters&); + void initialise(const cepgen::RunParameters&); /// Feed a new CepGen event to this conversion object /// \param[in] ev CepGen event to be fed /// \param[in] type Type of storage @@ -97,7 +97,7 @@ namespace Pythia8 { const double mp_, mp2_; bool inel1_{false}, inel2_{false}; std::unordered_map py_cg_corresp_; - const cepgen::Parameters* params_{nullptr}; // borrowed + const cepgen::RunParameters* params_{nullptr}; // borrowed }; } // namespace Pythia8 #endif diff --git a/CepGenAddOns/PythonWrapper/PythonCardHandler.cpp b/CepGenAddOns/PythonWrapper/PythonCardHandler.cpp index f4de5de43..99a964547 100644 --- a/CepGenAddOns/PythonWrapper/PythonCardHandler.cpp +++ b/CepGenAddOns/PythonWrapper/PythonCardHandler.cpp @@ -1,6 +1,6 @@ /* * CepGen: a central exclusive processes event generator - * Copyright (C) 2013-2023 Laurent Forthomme + * Copyright (C) 2018-2024 Laurent Forthomme * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,6 +27,7 @@ #include "CepGen/Cards/Handler.h" #include "CepGen/Core/Exception.h" #include "CepGen/Core/ParametersList.h" +#include "CepGen/Core/RunParameters.h" #include "CepGen/EventFilter/EventExporter.h" #include "CepGen/EventFilter/EventModifier.h" #include "CepGen/Generator.h" // for library loading @@ -35,7 +36,6 @@ #include "CepGen/Modules/EventModifierFactory.h" #include "CepGen/Modules/FunctionalFactory.h" #include "CepGen/Modules/ProcessFactory.h" -#include "CepGen/Parameters.h" #include "CepGen/Physics/HeavyIon.h" #include "CepGen/Physics/MCDFileParser.h" #include "CepGen/Physics/PDG.h" @@ -52,8 +52,8 @@ namespace cepgen { public: /// Read a standard configuration card explicit PythonHandler(const ParametersList&); - Parameters* parseFile(const std::string&, Parameters*) override; - Parameters* parseString(const std::string&, Parameters*) override; + RunParameters* parseFile(const std::string&, RunParameters*) override; + RunParameters* parseString(const std::string&, RunParameters*) override; static ParametersDescription description(); @@ -71,7 +71,7 @@ namespace cepgen { static constexpr const char* PDGLIST_NAME = "PDG"; static constexpr const char* MCD_NAME = "mcdFile"; - Parameters* parse(Parameters*); + RunParameters* parse(RunParameters*); void parseLogging(PyObject*); void parseIntegrator(PyObject*); void parseGenerator(PyObject*); @@ -88,7 +88,7 @@ namespace cepgen { PythonHandler::PythonHandler(const ParametersList& params) : Handler(params), env_(new python::Environment(params)) {} - Parameters* PythonHandler::parseFile(const std::string& file, Parameters* params) { + RunParameters* PythonHandler::parseFile(const std::string& file, RunParameters* params) { std::string filename = python::pythonPath(file); env_->setProgramName(filename); cfg_ = python::importModule(filename); // new @@ -98,7 +98,7 @@ namespace cepgen { return parse(params); } - Parameters* PythonHandler::parseString(const std::string& str, Parameters* params) { + RunParameters* PythonHandler::parseString(const std::string& str, RunParameters* params) { env_->setProgramName("Cards.Core"); cfg_ = python::defineModule("Cards.Core", str); // new if (!cfg_) @@ -109,7 +109,7 @@ namespace cepgen { return parse(params); } - Parameters* PythonHandler::parse(Parameters* params) { + RunParameters* PythonHandler::parse(RunParameters* params) { if (!cfg_) throw PY_ERROR << "Python configuration card was not defined."; diff --git a/CepGenAddOns/PythonWrapper/PythonConfigWriter.cpp b/CepGenAddOns/PythonWrapper/PythonConfigWriter.cpp index 9bb1db225..5193d4d5d 100644 --- a/CepGenAddOns/PythonWrapper/PythonConfigWriter.cpp +++ b/CepGenAddOns/PythonWrapper/PythonConfigWriter.cpp @@ -1,6 +1,6 @@ /* * CepGen: a central exclusive processes event generator - * Copyright (C) 2013-2023 Laurent Forthomme + * Copyright (C) 2021-2024 Laurent Forthomme * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,9 +19,9 @@ #include #include "CepGen/Core/ParametersDescription.h" +#include "CepGen/Core/RunParameters.h" #include "CepGen/EventFilter/EventExporter.h" #include "CepGen/EventFilter/EventModifier.h" -#include "CepGen/Parameters.h" #include "CepGen/Process/Process.h" #include "CepGen/Utils/Message.h" #include "CepGenAddOns/PythonWrapper/PythonConfigWriter.h" @@ -36,7 +36,7 @@ namespace cepgen { PythonConfigWriter::~PythonConfigWriter() { file_.close(); } - PythonConfigWriter& PythonConfigWriter::operator<<(const Parameters& params) { + PythonConfigWriter& PythonConfigWriter::operator<<(const RunParameters& params) { if (params.timeKeeper()) (*this) << ParametersDescription("timer"); if (params.hasProcess()) diff --git a/CepGenAddOns/PythonWrapper/PythonConfigWriter.h b/CepGenAddOns/PythonWrapper/PythonConfigWriter.h index 710e99158..84f983c4e 100644 --- a/CepGenAddOns/PythonWrapper/PythonConfigWriter.h +++ b/CepGenAddOns/PythonWrapper/PythonConfigWriter.h @@ -1,6 +1,6 @@ /* * CepGen: a central exclusive processes event generator - * Copyright (C) 2013-2022 Laurent Forthomme + * Copyright (C) 2021-2024 Laurent Forthomme * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,7 +22,7 @@ #include namespace cepgen { - class Parameters; + class RunParameters; class ParametersDescription; namespace utils { class PythonConfigWriter final { @@ -30,7 +30,7 @@ namespace cepgen { PythonConfigWriter(const std::string&); ~PythonConfigWriter(); - PythonConfigWriter& operator<<(const Parameters&); + PythonConfigWriter& operator<<(const RunParameters&); PythonConfigWriter& operator<<(const ParametersDescription&); private: diff --git a/CepGenAddOns/PythonWrapper/test/python_output.cc b/CepGenAddOns/PythonWrapper/test/python_output.cc index 0c10fa1a9..356ebb143 100644 --- a/CepGenAddOns/PythonWrapper/test/python_output.cc +++ b/CepGenAddOns/PythonWrapper/test/python_output.cc @@ -1,6 +1,6 @@ /* * CepGen: a central exclusive processes event generator - * Copyright (C) 2022-2023 Laurent Forthomme + * Copyright (C) 2022-2024 Laurent Forthomme * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,9 +21,9 @@ #include "CepGenAddOns/PythonWrapper/Error.h" #include "CepGenAddOns/PythonWrapper/PythonUtils.h" // clang-format on +#include "CepGen/Core/RunParameters.h" #include "CepGen/Generator.h" #include "CepGen/Modules/ProcessFactory.h" -#include "CepGen/Parameters.h" #include "CepGen/Process/Process.h" #include "CepGen/Utils/ArgumentsParser.h" #include "CepGen/Utils/Test.h" @@ -43,9 +43,9 @@ int main(int argc, char* argv[]) { process = *cepgen::ProcessFactory::get().modules().begin(); { - gen.parametersRef().setProcess(cepgen::ProcessFactory::get().build(process)); + gen.runParameters().setProcess(cepgen::ProcessFactory::get().build(process)); cepgen::utils::PythonConfigWriter py(output_file); - py << gen.parametersRef(); + py << gen.runParameters(); } try { diff --git a/CepGenAddOns/PythonWrapper/test/python_particle_mod.cc b/CepGenAddOns/PythonWrapper/test/python_particle_mod.cc index 17e5956d4..e2fb97e59 100644 --- a/CepGenAddOns/PythonWrapper/test/python_particle_mod.cc +++ b/CepGenAddOns/PythonWrapper/test/python_particle_mod.cc @@ -1,6 +1,6 @@ /* * CepGen: a central exclusive processes event generator - * Copyright (C) 2023 Laurent Forthomme + * Copyright (C) 2023-2024 Laurent Forthomme * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,8 +17,8 @@ */ #include "CepGen/Cards/Handler.h" +#include "CepGen/Core/RunParameters.h" #include "CepGen/Modules/CardsHandlerFactory.h" -#include "CepGen/Parameters.h" #include "CepGen/Physics/PDG.h" #include "CepGen/Utils/ArgumentsParser.h" #include "CepGen/Utils/Test.h" diff --git a/CepGenAddOns/ROOTWrapper/ROOTTreeHandler.cpp b/CepGenAddOns/ROOTWrapper/ROOTTreeHandler.cpp index d2ce976b7..dab932097 100644 --- a/CepGenAddOns/ROOTWrapper/ROOTTreeHandler.cpp +++ b/CepGenAddOns/ROOTWrapper/ROOTTreeHandler.cpp @@ -1,6 +1,6 @@ /* * CepGen: a central exclusive processes event generator - * Copyright (C) 2013-2023 Laurent Forthomme + * Copyright (C) 2013-2024 Laurent Forthomme * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,11 +21,11 @@ #include #include "CepGen/Core/Exception.h" +#include "CepGen/Core/RunParameters.h" #include "CepGen/Event/Event.h" #include "CepGen/EventFilter/EventExporter.h" #include "CepGen/EventFilter/EventModifier.h" #include "CepGen/Modules/EventExporterFactory.h" -#include "CepGen/Parameters.h" #include "CepGen/Process/Process.h" #include "CepGen/Utils/String.h" #include "CepGen/Utils/Value.h" diff --git a/CepGenAddOns/ROOTWrapper/test/root_ttree_process.cc b/CepGenAddOns/ROOTWrapper/test/root_ttree_process.cc index 68a2af45c..ebc0b2f22 100644 --- a/CepGenAddOns/ROOTWrapper/test/root_ttree_process.cc +++ b/CepGenAddOns/ROOTWrapper/test/root_ttree_process.cc @@ -1,6 +1,6 @@ /* * CepGen: a central exclusive processes event generator - * Copyright (C) 2022-2023 Laurent Forthomme + * Copyright (C) 2022-2024 Laurent Forthomme * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,11 +16,11 @@ * along with this program. If not, see . */ +#include "CepGen/Core/RunParameters.h" #include "CepGen/EventFilter/EventExporter.h" #include "CepGen/Generator.h" #include "CepGen/Modules/EventExporterFactory.h" #include "CepGen/Modules/ProcessFactory.h" -#include "CepGen/Parameters.h" #include "CepGen/Process/Process.h" #include "CepGen/Utils/ArgumentsParser.h" #include "CepGen/Utils/Filesystem.h" @@ -44,7 +44,7 @@ int main(int argc, char* argv[]) { double cross_sec, cross_sec_unc; { // generation + tree building part cepgen::Generator gen; - auto& pars = gen.parametersRef(); + auto& pars = gen.runParameters(); pars.setProcess(cepgen::ProcessFactory::get().build(proc_name)); pars.process().kinematics().setParameters(cepgen::ParametersList() .set >("pdgIds", {2212, 2212}) diff --git a/src/cepgen.cc b/src/cepgen.cc index dd3924aef..a145595b6 100644 --- a/src/cepgen.cc +++ b/src/cepgen.cc @@ -1,6 +1,6 @@ /* * CepGen: a central exclusive processes event generator - * Copyright (C) 2013-2023 Laurent Forthomme + * Copyright (C) 2013-2024 Laurent Forthomme * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,11 +18,11 @@ #include "CepGen/Cards/Handler.h" #include "CepGen/Core/Exception.h" +#include "CepGen/Core/RunParameters.h" #include "CepGen/EventFilter/EventExporter.h" #include "CepGen/Generator.h" #include "CepGen/Modules/CardsHandlerFactory.h" #include "CepGen/Modules/EventExporterFactory.h" -#include "CepGen/Parameters.h" #include "CepGen/Utils/AbortHandler.h" #include "CepGen/Utils/ArgumentsParser.h" @@ -71,26 +71,27 @@ int main(int argc, char* argv[]) { } //--- parse the steering card if (!input_card.empty()) - gen.setParameters(cepgen::card::Handler::parseFile(input_card)); + gen.setRunParameters(cepgen::card::Handler::parseFile(input_card)); //--- parse the additional flags if (!parser.extra_config().empty()) - gen.setParameters(cepgen::CardsHandlerFactory::get() - .build(".cmd", cepgen::ParametersList().set >("args", parser.extra_config())) - ->parseString(string(), gen.parametersPtr())); + gen.setRunParameters( + cepgen::CardsHandlerFactory::get() + .build(".cmd", cepgen::ParametersList().set >("args", parser.extra_config())) + ->parseString(string(), &gen.runParameters())); cepgen::utils::AbortHandler(); try { - auto& params = gen.parametersRef(); + auto& params = gen.runParameters(); if (num_events >= 0) // user specified a number of events to generate params.generation().setMaxGen(num_events); if (params.generation().enabled() && !outputs.empty()) for (const auto& output : outputs) - gen.parametersRef().addEventExporter(cepgen::EventExporterFactory::get().build(output)); + gen.runParameters().addEventExporter(cepgen::EventExporterFactory::get().build(output)); //--- list all parameters - CG_LOG << gen.parameters(); + CG_LOG << gen.runParameters(); //--- let there be a cross-section... gen.computeXsection(); diff --git a/src/cepgenScan.cc b/src/cepgenScan.cc index c23157ddd..5c6a131fe 100644 --- a/src/cepgenScan.cc +++ b/src/cepgenScan.cc @@ -20,11 +20,11 @@ #include "CepGen/Cards/Handler.h" #include "CepGen/Core/Exception.h" +#include "CepGen/Core/RunParameters.h" #include "CepGen/EventFilter/EventExporter.h" #include "CepGen/Generator.h" #include "CepGen/Modules/CardsHandlerFactory.h" #include "CepGen/Modules/DrawerFactory.h" -#include "CepGen/Parameters.h" #include "CepGen/Physics/PDG.h" #include "CepGen/Process/Process.h" #include "CepGen/Utils/AbortHandler.h" @@ -57,21 +57,21 @@ int main(int argc, char* argv[]) { .parse(); cepgen::Generator mg; - mg.setParameters(cepgen::card::Handler::parse(input_config)); + mg.setRunParameters(cepgen::card::Handler::parseFile(input_config)); if (!parser.extra_config().empty()) - mg.setParameters(cepgen::CardsHandlerFactory::get() - .build(".cmd", cepgen::ParametersList().set >("args", parser.extra_config())) - ->parse("", mg.parametersPtr())); + mg.setRunParameters(cepgen::CardsHandlerFactory::get() + .build(".cmd", cepgen::ParametersList().set >("args", parser.extra_config())) + ->parseString("", &mg.runParameters())); - CG_LOG << mg.parameters(); + CG_LOG << mg.runParameters(); ofstream xsect_file(output_file); if (!xsect_file.is_open()) throw CG_FATAL("main") << "Output file \"" << output_file << "\" cannot be opened!"; xsect_file << "# " << scan << "\txsect (pb)\td(xsect) (pb)\n"; - auto& par = mg.parametersRef(); + auto& par = mg.runParameters(); //--- ensure nothing is written in the output sequence par.eventExportersSequence().clear(); @@ -84,7 +84,6 @@ int main(int argc, char* argv[]) { cepgen::utils::Graph1D graph("comp_sigma_gen"); auto& kin = par.process().kinematics(); - double cross_section, err_cross_section; string scan_str = scan; for (const auto& value : points) { try { @@ -111,9 +110,9 @@ int main(int argc, char* argv[]) { kin.setParameters(modif); } CG_LOG << "Scan of \"" << scan << "\". Value = " << value << "."; - mg.computeXsection(cross_section, err_cross_section); - string out_line = cepgen::utils::format("%.2f\t%.8e\t%.8e\n", value, cross_section, err_cross_section); - graph.addPoint(value, cross_section, 0., err_cross_section); + const auto cross_section = mg.computeXsection(); + string out_line = cepgen::utils::format("%.2f\t%.8e\t%.8e\n", value, cross_section, cross_section.uncertainty()); + graph.addPoint(value, cross_section, 0., cross_section.uncertainty()); xsect_file << out_line; CG_LOG << out_line; xsect_file.flush(); diff --git a/src/utils/cepgenCardsConverter.cc b/src/utils/cepgenCardsConverter.cc index 6408e8d4a..f531221e9 100644 --- a/src/utils/cepgenCardsConverter.cc +++ b/src/utils/cepgenCardsConverter.cc @@ -19,7 +19,6 @@ #include "CepGen/Cards/Handler.h" #include "CepGen/Core/Exception.h" #include "CepGen/Generator.h" -#include "CepGen/Parameters.h" #include "CepGen/Utils/ArgumentsParser.h" #include "CepGen/Utils/Filesystem.h" @@ -36,7 +35,7 @@ int main(int argc, char* argv[]) { cepgen::initialise(); try { - auto params = cepgen::card::Handler::parse(input_config); + auto* params = cepgen::card::Handler::parseFile(input_config); cepgen::card::Handler::write(params, output_config); CG_LOG << "Successfully converted the \"" << cepgen::utils::fileExtension(input_config) << "\" card into a \"" << cepgen::utils::fileExtension(output_config) << "\" card.\n\t" diff --git a/src/utils/cepgenDistributionDrawer.cc b/src/utils/cepgenDistributionDrawer.cc index df0d6af8c..b3568560d 100644 --- a/src/utils/cepgenDistributionDrawer.cc +++ b/src/utils/cepgenDistributionDrawer.cc @@ -17,11 +17,11 @@ */ #include "CepGen/Cards/Handler.h" +#include "CepGen/Core/RunParameters.h" #include "CepGen/Event/Event.h" #include "CepGen/EventFilter/EventBrowser.h" #include "CepGen/Generator.h" #include "CepGen/Modules/DrawerFactory.h" -#include "CepGen/Parameters.h" #include "CepGen/Utils/ArgumentsParser.h" #include "CepGen/Utils/Drawer.h" #include "CepGen/Utils/Histogram.h" @@ -47,8 +47,8 @@ int main(int argc, char* argv[]) { .addOptionalArgument("plotter,p", "type of plotter to user", &plotter, "") .parse(); - mg.setParameters(cepgen::card::Handler::parseFile(input_card)); - mg.parametersRef().clearEventExportersSequence(); + mg.setRunParameters(cepgen::card::Handler::parseFile(input_card)); + mg.runParameters().clearEventExportersSequence(); // book all histograms map > h_var_hist; @@ -63,7 +63,7 @@ int main(int argc, char* argv[]) { } CG_DEBUG("main") << "Variables to be plotted: " << vars << "."; - CG_LOG << "Process name: " << mg.parameters()->processName() << "."; + CG_LOG << "Process name: " << mg.runParameters().processName() << "."; cepgen::utils::EventBrowser browser; diff --git a/test/steeringcard_parser.cc b/src/utils/cepgenPrintSteeringCard.cc similarity index 85% rename from test/steeringcard_parser.cc rename to src/utils/cepgenPrintSteeringCard.cc index 04f11a798..5b221bd73 100644 --- a/test/steeringcard_parser.cc +++ b/src/utils/cepgenPrintSteeringCard.cc @@ -1,6 +1,6 @@ /* * CepGen: a central exclusive processes event generator - * Copyright (C) 2021 Laurent Forthomme + * Copyright (C) 2021-2024 Laurent Forthomme * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,8 +20,8 @@ #include "CepGen/Cards/Handler.h" #include "CepGen/Core/Exception.h" +#include "CepGen/Core/RunParameters.h" #include "CepGen/Generator.h" -#include "CepGen/Parameters.h" #include "CepGen/Utils/ArgumentsParser.h" using namespace std; @@ -31,12 +31,12 @@ int main(int argc, char* argv[]) { cepgen::initialise(); - cepgen::ArgumentsParser(argc, argv).addOptionalArgument("card,i", "input card", &card, "Cards/lpair_cfg.py").parse(); + cepgen::ArgumentsParser(argc, argv).addArgument("card,i", "input card", &card, "Cards/lpair_cfg.py").parse(); try { CG_LOG << "Parsing configuration from '" << card << "."; const auto* params = cepgen::card::Handler::parseFile(card); - CG_LOG << "Configuration parsed from '" << card << "':\n" << params; + CG_LOG << "Configuration parsed from '" << card << "':\n" << *params; } catch (const cepgen::Exception& e) { e.dump(); return -1; diff --git a/src/utils/cepgenProbeOnePoint.cc b/src/utils/cepgenProbeOnePoint.cc index 3e38a6291..9d14aa7ff 100644 --- a/src/utils/cepgenProbeOnePoint.cc +++ b/src/utils/cepgenProbeOnePoint.cc @@ -17,8 +17,8 @@ */ #include "CepGen/Cards/Handler.h" +#include "CepGen/Core/RunParameters.h" #include "CepGen/Generator.h" -#include "CepGen/Parameters.h" #include "CepGen/Process/Process.h" #include "CepGen/Utils/ArgumentsParser.h" #include "CepGen/Utils/Message.h" @@ -41,11 +41,11 @@ int main(int argc, char* argv[]) { CG_LOG_LEVEL(debugInsideLoop); cepgen::Generator gen; - gen.setParameters(cepgen::card::Handler::parseFile(input_card)); - gen.parametersRef().process().initialise(); - CG_DEBUG("main") << gen.parameters(); + gen.setRunParameters(cepgen::card::Handler::parseFile(input_card)); + gen.runParameters().process().initialise(); + CG_DEBUG("main") << gen.runParameters(); - const auto ndim = gen.parameters()->process().ndim(); + const auto ndim = gen.runParameters().process().ndim(); vector points; if (num_scans > 0) { for (const auto& range : cepgen::Limits{0., 1.}.generate(num_scans)) diff --git a/src/utils/cepgenScanPhaseSpace.cc b/src/utils/cepgenScanPhaseSpace.cc index f2073a244..4146c3de7 100644 --- a/src/utils/cepgenScanPhaseSpace.cc +++ b/src/utils/cepgenScanPhaseSpace.cc @@ -18,9 +18,9 @@ #include "CepGen/Cards/Handler.h" #include "CepGen/Core/Exception.h" +#include "CepGen/Core/RunParameters.h" #include "CepGen/Generator.h" #include "CepGen/Modules/DrawerFactory.h" -#include "CepGen/Parameters.h" #include "CepGen/Process/Process.h" #include "CepGen/Utils/ArgumentsParser.h" #include "CepGen/Utils/Drawer.h" @@ -52,9 +52,9 @@ int main(int argc, char* argv[]) { throw CG_FATAL("main") << "Number of dimensions to probe (" << dim.size() << ") is too high"; cepgen::Generator gen; - gen.setParameters(cepgen::card::Handler::parseFile(input_card)); - CG_LOG << gen.parameters(); - const size_t ndim = gen.parametersPtr()->process().ndim(); + gen.setRunParameters(cepgen::card::Handler::parseFile(input_card)); + CG_LOG << gen.runParameters(); + const size_t ndim = gen.runParameters().process().ndim(); vector coord(ndim, def); diff --git a/test/benchmarks/generator.cc b/test/benchmarks/generator.cc index 9b543dfa1..7c82cb49d 100644 --- a/test/benchmarks/generator.cc +++ b/test/benchmarks/generator.cc @@ -1,6 +1,6 @@ /* * CepGen: a central exclusive processes event generator - * Copyright (C) 2023 Laurent Forthomme + * Copyright (C) 2023-2024 Laurent Forthomme * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,11 +16,11 @@ * along with this program. If not, see . */ +#include "CepGen/Core/RunParameters.h" #include "CepGen/Generator.h" #include "CepGen/Integration/Integrator.h" #include "CepGen/Modules/IntegratorFactory.h" #include "CepGen/Modules/ProcessFactory.h" -#include "CepGen/Parameters.h" #include "CepGen/Process/Process.h" #include "CepGen/Utils/ArgumentsParser.h" #include "CepGen/Version.h" @@ -49,8 +49,8 @@ int main(int argc, char* argv[]) { .epochs(num_epochs) .context("process", process); - gen.parametersRef().setProcess(cepgen::ProcessFactory::get().build(process)); - auto& kin = gen.parametersRef().process().kinematics(); + gen.runParameters().setProcess(cepgen::ProcessFactory::get().build(process)); + auto& kin = gen.runParameters().process().kinematics(); kin.incomingBeams().positive().setPdgId(2212); kin.incomingBeams().negative().setPdgId(2212); kin.incomingBeams().setSqrtS(13.e3); diff --git a/test/generator/generate_events.cc b/test/generator/generate_events.cc index 6bc49aae5..bc7474ad7 100644 --- a/test/generator/generate_events.cc +++ b/test/generator/generate_events.cc @@ -17,9 +17,9 @@ */ #include "CepGen/Cards/Handler.h" +#include "CepGen/Core/RunParameters.h" #include "CepGen/EventFilter/EventExporter.h" #include "CepGen/Generator.h" -#include "CepGen/Parameters.h" #include "CepGen/Utils/ArgumentsParser.h" #include "CepGen/Utils/Test.h" @@ -35,12 +35,12 @@ int main(int argc, char* argv[]) { .parse(); cepgen::Generator gen; - gen.setParameters(cepgen::card::Handler::parseFile(input_card)); - gen.parametersRef().eventExportersSequence().clear(); + gen.setRunParameters(cepgen::card::Handler::parseFile(input_card)); + gen.runParameters().eventExportersSequence().clear(); for (auto iev = 0; iev < num_events; ++iev) gen.next(); - CG_TEST_EQUAL(gen.parametersRef().numGeneratedEvents(), (size_t)num_events, "number of events generated"); + CG_TEST_EQUAL(gen.runParameters().numGeneratedEvents(), (size_t)num_events, "number of events generated"); CG_TEST_SUMMARY; } diff --git a/test/physics/processes_cross_sections.cc b/test/physics/processes_cross_sections.cc index 0c399ec8b..5913bbacc 100644 --- a/test/physics/processes_cross_sections.cc +++ b/test/physics/processes_cross_sections.cc @@ -20,9 +20,9 @@ #include #include "CepGen/Cards/Handler.h" +#include "CepGen/Core/RunParameters.h" #include "CepGen/Generator.h" #include "CepGen/Modules/IntegratorFactory.h" -#include "CepGen/Parameters.h" #include "CepGen/Utils/AbortHandler.h" #include "CepGen/Utils/ArgumentsParser.h" #include "CepGen/Utils/Test.h" @@ -88,11 +88,11 @@ int main(int argc, char* argv[]) { for (const auto& test : tests) { const std::string filename = "TestProcesses/" + test.filename + "_cfg.py"; try { - gen.parametersRef().clearProcess(); - gen.setParameters(cepgen::card::Handler::parseFile(filename)); - gen.parametersRef().par_integrator = cepgen::IntegratorFactory::get().describeParameters(integrator).parameters(); + gen.runParameters().clearProcess(); + gen.setRunParameters(cepgen::card::Handler::parseFile(filename)); + gen.runParameters().par_integrator = cepgen::IntegratorFactory::get().describeParameters(integrator).parameters(); - CG_DEBUG("main") << "Process: " << gen.parameters()->processName() << "\n\t" + CG_DEBUG("main") << "Process: " << gen.runParameters().processName() << "\n\t" << "File: " << filename << "\n\t" << "Configuration time: " << tmr.elapsed() * 1.e3 << " ms.";