cepgen
is hosted by
Hepforge
,
IPPP Durham
CepGen
1.2.5
Central exclusive processes event generator
Toggle main menu visibility
Main Page
Related Pages
Packages
Package List
Package Members
All
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
x
y
Functions
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
x
y
Variables
Typedefs
Enumerations
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Variables
a
b
c
d
e
f
g
h
i
k
l
m
n
p
q
r
s
t
u
v
w
x
y
z
Typedefs
Enumerations
Enumerator
b
c
d
e
g
h
i
l
m
n
p
r
t
u
w
x
y
z
Related Symbols
d
g
h
o
u
v
Files
File List
File Members
All
_
a
b
c
d
e
h
o
p
r
s
Functions
Variables
Macros
_
b
c
d
e
p
r
s
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
Loading...
Searching...
No Matches
cepgenScan.cc
Go to the documentation of this file.
1
/*
2
* CepGen: a central exclusive processes event generator
3
* Copyright (C) 2016-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 <fstream>
20
21
#include "
CepGen/Cards/Handler.h
"
22
#include "
CepGen/Core/Exception.h
"
23
#include "
CepGen/Core/RunParameters.h
"
24
#include "
CepGen/EventFilter/EventExporter.h
"
25
#include "
CepGen/Generator.h
"
26
#include "
CepGen/Modules/CardsHandlerFactory.h
"
27
#include "
CepGen/Modules/DrawerFactory.h
"
28
#include "
CepGen/Modules/IntegratorFactory.h
"
29
#include "
CepGen/Physics/PDG.h
"
30
#include "
CepGen/Process/Process.h
"
31
#include "
CepGen/Utils/AbortHandler.h
"
32
#include "
CepGen/Utils/ArgumentsParser.h
"
33
#include "
CepGen/Utils/Drawer.h
"
34
#include "
CepGen/Utils/Graph.h
"
35
#include "
CepGen/Utils/Logger.h
"
36
#include "
CepGen/Utils/String.h
"
37
38
using namespace
std;
39
40
int
main
(
int
argc,
char
* argv[]) {
41
string
input_config, output_file, scan, plotter, integrator;
42
int
npoints;
43
cepgen::Limits
range, yrange;
44
vector<double> points;
45
bool
draw_grid, logx, logy;
46
47
cepgen::ArgumentsParser
parser(argc, argv);
48
parser.
addArgument
(
"config,i"
,
"base configuration"
, &input_config)
49
.
addOptionalArgument
(
"scan,s"
,
"type of scan to perform"
, &scan,
"ptmin"
)
50
.
addOptionalArgument
(
"range,r"
,
"minimum value of scan"
, &range,
cepgen::Limits
{1., 11.})
51
.addOptionalArgument(
"num-points,n"
,
"number of points to consider"
, &npoints, 10)
52
.
addOptionalArgument
(
"points"
,
"list of points to consider"
, &points, vector<double>{})
53
.addOptionalArgument(
"output,o"
,
"output file"
, &output_file,
"xsect.dat"
)
54
.
addOptionalArgument
(
"logx"
,
"logarithmic x-scale"
, &logx,
false
)
55
.
addOptionalArgument
(
"logy,l"
,
"logarithmic y-scale"
, &logy,
false
)
56
.
addOptionalArgument
(
"yrange,y"
,
"y range"
, &yrange)
57
.
addOptionalArgument
(
"draw-grid,g"
,
"draw the x/y grid"
, &draw_grid,
false
)
58
.
addOptionalArgument
(
"plotter,p"
,
"type of plotter to user"
, &plotter,
""
)
59
.
addOptionalArgument
(
"integrator,I"
,
"type of integrator used"
, &integrator,
""
)
60
.
parse
();
61
62
cepgen::Generator
gen;
63
gen.
parseRunParameters
(input_config);
64
65
if
(!parser.
extra_config
().empty()) {
66
auto
args_handler =
cepgen::CardsHandlerFactory::get
().build(
".cmd"
);
67
args_handler->setRunParameters(&gen.
runParameters
());
68
args_handler->parseCommands(parser.
extra_config
());
69
gen.
setRunParameters
(args_handler->runParameters());
70
}
71
if
(!integrator.empty())
72
gen.
runParameters
().
integrator
() = cepgen::IntegratorFactory::get().describeParameters(integrator).parameters();
73
74
CG_LOG
<< gen.
runParameters
();
75
76
ofstream xsect_file(output_file);
77
if
(!xsect_file.is_open())
78
throw
CG_FATAL
(
"main"
) <<
"Output file \""
<< output_file <<
"\" cannot be opened!"
;
79
xsect_file <<
"# "
<< scan <<
"\txsect (pb)\td(xsect) (pb)\n"
;
80
81
auto
& par = gen.
runParameters
();
82
//--- ensure nothing is written in the output sequence
83
par.
eventExportersSequence
().clear();
84
85
if
(points.empty())
86
points = range.
generate
(npoints, logx);
87
88
cepgen::utils::AbortHandler
();
89
90
cepgen::utils::Graph1D
graph(
"comp_sigma_gen"
);
91
auto
& kin = par.process().kinematics();
92
string
scan_str = scan;
93
for
(
const
auto
& value : points) {
94
try
{
95
if
(scan ==
"sqrtS"
) {
96
kin.incomingBeams().setSqrtS(value);
97
scan_str =
"$\\sqrt{s}$ (GeV)"
;
98
}
else
if
(scan ==
"abseta"
) {
99
kin.cuts().central.eta_single.min() = -value;
100
kin.cuts().central.eta_single.max() = +value;
101
scan_str =
"$|\\eta|$"
;
102
}
else
if
(scan ==
"absrap"
) {
103
kin.cuts().central.rapidity_single.min() = -value;
104
kin.cuts().central.rapidity_single.max() = +value;
105
scan_str =
"$|y|$"
;
106
}
else
if
(
cepgen::utils::startsWith
(scan,
"m:"
)) {
107
const
auto
tok =
cepgen::utils::split
(scan,
':'
);
108
if
(tok.size() > 2)
109
throw
CG_FATAL
(
"main"
) <<
"Invalid mass scan defined: should follow the \"m:<pdgid int>\" convention!"
;
110
const
cepgen::pdgid_t
pdg
= abs(stoi(tok.at(1)));
111
cepgen::PDG::get
()[
pdg
].
mass
= value;
112
scan_str =
"$m_{"
+
cepgen::PDG::get
()(
pdg
).name +
"}$ (GeV)"
;
113
}
else
{
114
auto
modif =
cepgen::ParametersList
().
set
<
double
>(scan, value);
115
kin.setParameters(modif);
116
}
117
CG_LOG
<<
"Scan of \""
<< scan <<
"\". Value = "
<< value <<
"."
;
118
const
auto
cross_section = gen.
computeXsection
();
119
string
out_line =
cepgen::utils::format
(
"%.2f\t%.8e\t%.8e\n"
, value, cross_section, cross_section.uncertainty());
120
graph.
addPoint
(value, cross_section, 0., cross_section.uncertainty());
121
xsect_file << out_line;
122
CG_LOG
<< out_line;
123
xsect_file.flush();
124
}
catch
(
const
cepgen::utils::RunAbortedException
&) {
125
CG_LOG
<<
"Run aborted!"
;
126
break
;
127
}
128
}
129
130
if
(!plotter.empty()) {
131
cepgen::utils::Drawer::Mode
dm;
132
if
(logx)
133
dm |=
cepgen::utils::Drawer::Mode::logx
;
134
if
(logy)
135
dm |=
cepgen::utils::Drawer::Mode::logy
;
136
if
(draw_grid)
137
dm |=
cepgen::utils::Drawer::Mode::grid
;
138
graph.
xAxis
().
setLabel
(scan_str);
139
graph.
yAxis
().
setLabel
(
"$\\sigma_{gen}$ (pb)"
);
140
if
(yrange.
valid
())
141
graph.
yAxis
().
setRange
(yrange);
142
auto
plt = cepgen::DrawerFactory::get().build(plotter);
143
plt->draw(graph, dm);
144
}
145
146
return
0;
147
}
AbortHandler.h
ArgumentsParser.h
CardsHandlerFactory.h
DrawerFactory.h
Drawer.h
EventExporter.h
Exception.h
CG_FATAL
#define CG_FATAL(mod)
Definition
Exception.h:61
Generator.h
Graph.h
Handler.h
IntegratorFactory.h
Logger.h
CG_LOG
#define CG_LOG
Definition
Message.h:212
PDG.h
Process.h
RunParameters.h
String.h
cepgen::ArgumentsParser
A generic command line arguments parser.
Definition
ArgumentsParser.h:31
cepgen::ArgumentsParser::extra_config
const std::vector< std::string > & extra_config() const
Definition
ArgumentsParser.h:59
cepgen::ArgumentsParser::addArgument
ArgumentsParser & addArgument(Args &&... args)
Add a parameter required for the parser.
Definition
ArgumentsParser.h:39
cepgen::ArgumentsParser::parse
ArgumentsParser & parse()
Associate command-line arguments to parameters.
Definition
ArgumentsParser.cpp:106
cepgen::ArgumentsParser::addOptionalArgument
ArgumentsParser & addOptionalArgument(Args &&... args)
Add a non-mandatory parameters that can be parsed.
Definition
ArgumentsParser.h:46
cepgen::Generator
Core generator object allowing for process definition, cross section computation, and event generatio...
Definition
Generator.h:48
cepgen::Generator::parseRunParameters
void parseRunParameters(const std::string &)
Read a steering card to populate the run parameters block.
Definition
Generator.cpp:72
cepgen::Generator::setRunParameters
void setRunParameters(std::unique_ptr< RunParameters > &)
Feed the generator with a RunParameters object.
Definition
Generator.cpp:88
cepgen::Generator::runParameters
const RunParameters & runParameters() const
Pointer to the parameters block.
Definition
Generator.cpp:76
cepgen::Generator::computeXsection
Value computeXsection()
Compute the cross section and uncertainty, in pb, for the run parameters Compute the cross section fo...
Definition
Generator.cpp:110
cepgen::Limits
Validity interval for a variable.
Definition
Limits.h:28
cepgen::Limits::valid
bool valid() const
Is there a lower and upper limit?
Definition
Limits.cpp:85
cepgen::Limits::generate
std::vector< double > generate(size_t num_bins, bool log_scale=false) const
Generate a collection of values from a number of bins.
Definition
Limits.cpp:113
cepgen::PDG::mass
double mass(spdgid_t) const
Particle mass (in GeV)
Definition
PDG.cpp:90
cepgen::PDG::get
static PDG & get()
Retrieve a unique instance of this particles info collection.
Definition
PDG.cpp:41
cepgen::ParametersList
Definition
ParametersList.h:52
cepgen::ParametersList::set
ParametersList & set(const std::string &, const T &)
Set a parameter value Set a recast parameter value.
Definition
ParametersList.cpp:401
cepgen::RunParameters::eventExportersSequence
EventExportersSequence & eventExportersSequence()
List of output modules.
Definition
RunParameters.h:124
cepgen::RunParameters::integrator
ParametersList & integrator()
Integrator specific user-defined parameters.
Definition
RunParameters.h:60
cepgen::utils::AbortHandler
Object handling an user-driven process abortion.
Definition
AbortHandler.h:39
cepgen::utils::Drawable::AxisInfo::setLabel
AxisInfo & setLabel(const std::string &label)
Set the axis title.
Definition
Drawable.h:50
cepgen::utils::Drawable::AxisInfo::setRange
AxisInfo & setRange(const Limits &lim)
Set the full axis range.
Definition
Drawable.h:67
cepgen::utils::Drawable::yAxis
AxisInfo & yAxis()
Definition
Drawable.h:81
cepgen::utils::Drawable::xAxis
AxisInfo & xAxis()
Definition
Drawable.h:79
cepgen::utils::Drawer::Mode
Definition
Drawer.h:41
cepgen::utils::Drawer::Mode::grid
@ grid
Definition
Drawer.h:49
cepgen::utils::Drawer::Mode::logx
@ logx
Definition
Drawer.h:45
cepgen::utils::Drawer::Mode::logy
@ logy
Definition
Drawer.h:46
cepgen::utils::Graph1D
A one-dimensional graph object.
Definition
Graph.h:29
cepgen::utils::Graph1D::addPoint
Graph1D & addPoint(double x, double y)
Add one value to the graph.
Definition
Graph.cpp:30
cepgen::utils::format
std::string format(const std::string &fmt, Args... args)
Format a string using a printf style format descriptor.
Definition
String.h:61
cepgen::utils::startsWith
bool startsWith(const std::string &str, const std::string &beg)
Check if a string starts with a given token.
Definition
String.cpp:365
cepgen::utils::split
std::vector< std::string > split(const std::string &str, char delim, bool trim)
Split a string according to a separation character.
Definition
String.cpp:233
cepgen::pdgid_t
unsigned long long pdgid_t
Alias for the integer-like particle PDG id.
Definition
ParticleProperties.h:26
pdg
Definition
MCDFileParser.cpp:28
main
int main()
Definition
pythia6_decay.cc:9
cepgen::CardsHandlerFactory::get
static CardsHandlerFactory & get()
Definition
CardsHandlerFactory.cpp:25
cepgen::utils::RunAbortedException
Exception raised when the user terminates the process.
Definition
AbortHandler.h:31
src
utils
cepgenScan.cc
Generated on Mon Jul 29 2024 for CepGen by
1.9.7