cepgen is hosted by Hepforge, IPPP Durham
CepGen N/A
Central exclusive processes event generator
RunParameters.h
Go to the documentation of this file.
1/*
2 * CepGen: a central exclusive processes event generator
3 * Copyright (C) 2013-2025 Laurent Forthomme
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef CepGen_Core_RunParameters_h
20#define CepGen_Core_RunParameters_h
21
23
24namespace cepgen {
25 class EventExporter;
26 class EventModifier;
27 class ParametersList;
28 enum class IntegratorType;
29} // namespace cepgen
30namespace cepgen::proc {
31 class Process;
32} // namespace cepgen::proc
33namespace cepgen::utils {
34 class Functional;
35 class TimeKeeper;
36} // namespace cepgen::utils
37
38namespace cepgen {
39 using EventModifiersSequence = std::vector<std::unique_ptr<EventModifier> >;
40 using EventExportersSequence = std::vector<std::unique_ptr<EventExporter> >;
41 using TamingFunctionsSequence = std::vector<std::unique_ptr<utils::Functional> >;
42} // namespace cepgen
43
44namespace cepgen {
46 class RunParameters : public SteeredObject<RunParameters> {
47 public:
51 ~RunParameters() override; // required for unique_ptr initialisation!
52
54
56
57 friend std::ostream& operator<<(std::ostream&, const RunParameters&);
58
60 utils::TimeKeeper* timeKeeper() { return timer_.get(); }
61 const utils::TimeKeeper* timeKeeper() const { return timer_.get(); }
62
64
65 inline ParametersList& integrator() { return integrator_; }
66 inline const ParametersList& integrator() const { return integrator_; }
67
68 //----- process to compute
69
70 inline bool hasProcess() const { return !!process_; }
72 const proc::Process& process() const;
73 std::string processName() const;
74 void clearProcess();
75 void setProcess(std::unique_ptr<proc::Process>);
77
78 //----- events kinematics
79
81 const Kinematics& kinematics() const;
82
83 //----- events generation
84
86 class Generation : public SteeredObject<Generation> {
87 public:
90
92
93 inline void setTargetLuminosity(double lumi) { target_lumi_ = lumi; }
94 inline double targetLuminosity() const { return target_lumi_; }
95 inline void setMaxGen(size_t max_gen) { max_gen_ = max_gen; }
96 inline size_t maxGen() const { return max_gen_; }
97 inline bool enabled() const { return max_gen_ > 0; }
98 inline void setPrintEvery(size_t every) { gen_print_every_ = every; }
99 inline size_t printEvery() const { return gen_print_every_; }
100 inline void setSymmetrise(bool sym) { symmetrise_ = sym; }
101 inline bool symmetrise() const { return symmetrise_; }
102 inline void setNumThreads(size_t nt) { num_threads_ = nt; }
103 inline size_t numThreads() const { return num_threads_; }
104 inline void setNumPoints(size_t np) { num_points_ = np; }
105 inline size_t numPoints() const { return num_points_; }
106
107 private:
108 int max_gen_;
109 int gen_print_every_;
110 double target_lumi_;
111 bool symmetrise_;
112 int num_threads_;
113 int num_points_;
114 };
115 inline Generation& generation() { return generation_; }
116 inline const Generation& generation() const { return generation_; }
117
118 //----- event modification (e.g. hadronisation, decay) algorithm
119
122 inline EventModifiersSequence& eventModifiersSequence() { return evt_modifiers_; }
124 inline const EventModifiersSequence& eventModifiersSequence() const { return evt_modifiers_; }
126 void addModifier(std::unique_ptr<EventModifier>);
128
129 //----- event output algorithms
130
133 inline EventExportersSequence& eventExportersSequence() { return evt_exporters_; }
135 inline const EventExportersSequence& eventExportersSequence() const { return evt_exporters_; }
137 void addEventExporter(std::unique_ptr<EventExporter>);
139
140 //----- taming functions
141
143 inline const TamingFunctionsSequence& tamingFunctions() const { return taming_functions_; }
144 void addTamingFunction(std::unique_ptr<utils::Functional>);
145
146 //----- run operations
147
148 void prepareRun();
149
152 void addGenerationTime(double generation_time);
153 inline double totalGenerationTime() const { return total_gen_time_; }
154 inline unsigned int numGeneratedEvents() const { return num_gen_events_; }
155
156 private:
157 std::unique_ptr<proc::Process> process_;
158 EventModifiersSequence evt_modifiers_;
159 EventExportersSequence evt_exporters_;
160 TamingFunctionsSequence taming_functions_;
161 double total_gen_time_{0.};
162 unsigned long num_gen_events_{0ul};
163 ParametersList integrator_;
164 Generation generation_;
165 std::unique_ptr<utils::TimeKeeper> timer_;
166 };
167} // namespace cepgen
168
169#endif
Output format handler for events export.
Class template to interface (external/internal) events modification algorithms.
List of kinematic constraints to apply on the process phase space.
Definition Kinematics.h:27
A description object for parameters collection.
Collection of events generation parameters.
void setSymmetrise(bool sym)
Symmetrisation of the z-axis for each event?
size_t numPoints() const
Number of points to "shoot" in each integration bin.
size_t numThreads() const
Number of threads to perform event generation.
size_t printEvery() const
Periodicity of event displays.
void setNumThreads(size_t nt)
Set number of threads for event generation.
void setPrintEvery(size_t every)
Set the events display periodicity.
bool symmetrise() const
Symmetrise events wrt the -axis?
size_t maxGen() const
Maximal number of events to generate.
void setTargetLuminosity(double lumi)
Set target luminosity, in pb^-1.
static ParametersDescription description()
void setNumPoints(size_t np)
Set number of points to probe in each integr.bin.
void setMaxGen(size_t max_gen)
Set the maximal number of events to generate.
double targetLuminosity() const
Target luminosity to reach, in pb^-1.
Generation(const ParametersList &=ParametersList())
Build a generation parameters collection from a user input.
bool enabled() const
Are we generating events?
List of parameters used to start and run the simulation job.
const Kinematics & kinematics() const
Events kinematics for phase space definition.
const EventModifiersSequence & eventModifiersSequence() const
List of event modification algos.
void initialiseModules()
Initialise the event handling modules for an event generation.
~RunParameters() override
proc::Process & process()
Process object for cross-section computation/events generation.
const utils::TimeKeeper * timeKeeper() const
Pointer to a timekeeper instance.
void addGenerationTime(double generation_time)
Add a new timing into the total generation time.
void addEventExporter(EventExporter *)
Set the pointer to an output module.
void clearEventModifiersSequence()
Remove all event modifiers from the sequence.
unsigned int numGeneratedEvents() const
Number of events generated in run.
EventModifier & eventModifier(size_t) const
Event modification algorithm List of event modification algos.
void addModifier(std::unique_ptr< EventModifier >)
Add a new event modification algorithm to the sequence.
void addModifier(EventModifier *)
Add a new event modification algorithm to the sequence.
RunParameters(RunParameters &)
Copy constructor (transfers ownership to process/event modification algorithm)
EventExporter & eventExporter(size_t) const
Output module List of event output modules.
EventExportersSequence & eventExportersSequence()
friend std::ostream & operator<<(std::ostream &, const RunParameters &)
User-readable dump of runtime parameters.
utils::TimeKeeper * timeKeeper()
Pointer to a timekeeper instance.
RunParameters & operator=(RunParameters)
Assignment operator.
const TamingFunctionsSequence & tamingFunctions() const
List of all taming functions definitions.
static ParametersDescription description()
void prepareRun()
Reset total generation time and number of events generated for this run, prepare kinematics.
const Generation & generation() const
Event generation parameters.
void clearEventExportersSequence()
Remove all output modules from sequence.
void setProcess(std::unique_ptr< proc::Process >)
Set a process configuration.
std::string processName() const
Name of the process considered.
bool hasProcess() const
Are we holding any physics process?
void addTamingFunction(std::unique_ptr< utils::Functional >)
Set a new taming function definition.
EventModifiersSequence & eventModifiersSequence()
void clearProcess()
Remove the process pointer.
const ParametersList & integrator() const
Integrator specific user parameters.
const proc::Process & process() const
Process object for cross-section computation/events generation.
ParametersList & integrator()
Integrator specific user parameters.
void addEventExporter(std::unique_ptr< EventExporter >)
Set a new output module definition.
void setTimeKeeper(utils::TimeKeeper *)
Initialise the timekeeper instance.
void setProcess(proc::Process *)
Set a process configuration.
const EventExportersSequence & eventExportersSequence() const
List of event output modules.
Generation & generation()
Event generation parameters.
double totalGenerationTime() const
Total generation time in s for this run.
RunParameters(const RunParameters &)
Const copy constructor (all but process + event handling algorithms)
Base user-steerable object.
Class template to define any process to compute using this MC integrator/events generator.
Definition Process.h:34
A string-to-functional parser.
Definition Functional.h:32
Collection of clocks to benchmark execution blocks.
Definition TimeKeeper.h:34
Location for all physics processes to be generated.
Collection of utilities.
Common namespace for this Monte Carlo generator.
Definition Handler.h:26
std::vector< std::unique_ptr< EventModifier > > EventModifiersSequence
Event modification algos collection.
std::vector< std::unique_ptr< EventExporter > > EventExportersSequence
Event export modules collection.
std::vector< std::unique_ptr< utils::Functional > > TamingFunctionsSequence
Function evaluators collection.