cepgen
is hosted by
Hepforge
,
IPPP Durham
CepGen
1.2.5
Central exclusive processes event generator
Loading...
Searching...
No Matches
SpringGeneratorWorker.cpp
Go to the documentation of this file.
1
/*
2
* CepGen: a central exclusive processes event generator
3
* Copyright (C) 2024 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
#include "
CepGen/Core/Exception.h
"
20
#include "
CepGen/Core/GeneratorWorker.h
"
21
#include "
CepGen/Core/RunParameters.h
"
22
#include "
CepGen/Integration/Integrator.h
"
23
#include "
CepGen/Integration/ProcessIntegrand.h
"
24
#include "
CepGen/Modules/GeneratorWorkerFactory.h
"
25
#include "
CepGen/Process/Process.h
"
26
#include "
CepGen/Utils/String.h
"
27
#include "
CepGen/Utils/TimeKeeper.h
"
28
#include "
CepGenAddOns/BasesWrapper/BasesCommonBlocks.h
"
29
30
namespace
cepgen
{
31
class
SpringGeneratorWorker
final :
public
GeneratorWorker
{
32
public
:
33
explicit
SpringGeneratorWorker
(
const
ParametersList
& params)
34
:
GeneratorWorker
(params), max_trials_(
steer
<int>(
"maxTrials"
)) {
35
bscntl_
.ipnt = steer<int>(
"verbose"
);
36
}
37
virtual
~SpringGeneratorWorker
() {
38
int
lu = 6;
39
spinfo_
(lu);
40
}
41
42
void
initialise
()
override
{
43
gIntegrand =
dynamic_cast<
Integrand
*
>
(
integrand_
.get());
44
sprng2_
.mxtryp = max_trials_;
45
sprng2_
.nevent = 0;
46
}
47
bool
next
()
override
{
48
if
(!
integrator_
)
49
throw
CG_FATAL
(
"SpringGeneratorWorker:next"
) <<
"No integrator object handled!"
;
50
if
(
integrator_
->
name
() !=
"bases"
)
51
throw
CG_FATAL
(
"SpringGeneratorWorker:next"
) <<
"Spring generator is only compatible with Bases integrator."
;
52
53
CG_TICKER
(
const_cast<
RunParameters
*
>
(
params_
)->timeKeeper());
54
55
sprng2_
.ntrial = 0;
56
sprng2_
.miss = 0;
57
int
mxtry = max_trials_;
58
spring_
(integrand_call, mxtry);
59
if
(
sprng2_
.miss)
60
return
false
;
61
62
// return with an accepted event
63
return
storeEvent
();
64
}
65
66
static
ParametersDescription
description
() {
67
auto
desc =
GeneratorWorker::description
();
68
desc.setDescription(
"Spring/Bases worker"
);
69
desc.add<
int
>(
"maxTrials"
, 50).setDescription(
"maximum number of trials per generation"
);
70
desc.add<
int
>(
"verbose"
, 0);
71
return
desc;
72
}
73
74
private
:
75
static
Integrand
* gIntegrand;
76
static
double
integrand_call(
double
in[]) {
77
if
(!gIntegrand)
78
throw
CG_FATAL
(
"SpringGeneratorWorker"
) <<
"Integrand was not specified before event generation."
;
79
return
gIntegrand->
eval
(std::vector<double>(in, in + gIntegrand->
size
()));
80
}
81
82
const
int
max_trials_;
83
};
84
Integrand* SpringGeneratorWorker::gIntegrand =
nullptr
;
85
}
// namespace cepgen
86
REGISTER_GENERATOR_WORKER
(
"spring"
, SpringGeneratorWorker);
BasesCommonBlocks.h
spinfo_
void spinfo_(int &)
spring_
void spring_(double(*func)(double *), int &mxtry)
bscntl_
struct @4 bscntl_
sprng2_
struct @5 sprng2_
Exception.h
CG_FATAL
#define CG_FATAL(mod)
Definition
Exception.h:61
GeneratorWorkerFactory.h
REGISTER_GENERATOR_WORKER
#define REGISTER_GENERATOR_WORKER(name, obj)
Add a generator worker to the list of handled modules.
Definition
GeneratorWorkerFactory.h:25
GeneratorWorker.h
Integrator.h
ProcessIntegrand.h
Process.h
RunParameters.h
String.h
TimeKeeper.h
CG_TICKER
#define CG_TICKER(tmr)
Definition
TimeKeeper.h:30
cepgen::GeneratorWorker
Event generator worker instance.
Definition
GeneratorWorker.h:32
cepgen::GeneratorWorker::integrand_
std::unique_ptr< ProcessIntegrand > integrand_
Local event weight evaluator.
Definition
GeneratorWorker.h:61
cepgen::GeneratorWorker::params_
const RunParameters * params_
Steering parameters for the event generation.
Definition
GeneratorWorker.h:59
cepgen::GeneratorWorker::storeEvent
bool storeEvent()
Store the event in the output file.
Definition
GeneratorWorker.cpp:58
cepgen::GeneratorWorker::description
static ParametersDescription description()
Definition
GeneratorWorker.cpp:76
cepgen::GeneratorWorker::integrator_
const Integrator * integrator_
Pointer to the mother-handled integrator instance.
Definition
GeneratorWorker.h:58
cepgen::Integrand
An integrand wrapper placeholder.
Definition
Integrand.h:27
cepgen::Integrand::eval
virtual double eval(const std::vector< double > &)=0
Compute the integrand for a given coordinates set.
cepgen::Integrand::size
virtual size_t size() const =0
Phase space dimension.
cepgen::NamedModule::name
const std::string & name() const
Module unique indexing name.
Definition
NamedModule.h:42
cepgen::ParametersDescription
A description object for parameters collection.
Definition
ParametersDescription.h:26
cepgen::ParametersList
Definition
ParametersList.h:52
cepgen::RunParameters
List of parameters used to start and run the simulation job.
Definition
RunParameters.h:41
cepgen::SpringGeneratorWorker
Definition
SpringGeneratorWorker.cpp:31
cepgen::SpringGeneratorWorker::~SpringGeneratorWorker
virtual ~SpringGeneratorWorker()
Definition
SpringGeneratorWorker.cpp:37
cepgen::SpringGeneratorWorker::SpringGeneratorWorker
SpringGeneratorWorker(const ParametersList ¶ms)
Definition
SpringGeneratorWorker.cpp:33
cepgen::SpringGeneratorWorker::description
static ParametersDescription description()
Definition
SpringGeneratorWorker.cpp:66
cepgen::SpringGeneratorWorker::initialise
void initialise() override
Initialise the generation parameters.
Definition
SpringGeneratorWorker.cpp:42
cepgen::SpringGeneratorWorker::next
bool next() override
Generate a single event.
Definition
SpringGeneratorWorker.cpp:47
cepgen::Steerable::steer
T steer(const std::string &key) const
Retrieve a parameters as previously steered.
Definition
Steerable.h:39
cepgen
Common namespace for this Monte Carlo generator.
Definition
CommandLineHandler.cpp:36
CepGenAddOns
BasesWrapper
SpringGeneratorWorker.cpp
Generated on Mon Jul 29 2024 for CepGen by
1.9.7