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
cepgenDistributionDrawer.cc
Go to the documentation of this file.
1
/*
2
* CepGen: a central exclusive processes event generator
3
* Copyright (C) 2013-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/RunParameters.h
"
20
#include "
CepGen/Event/Event.h
"
21
#include "
CepGen/EventFilter/EventBrowser.h
"
22
#include "
CepGen/Generator.h
"
23
#include "
CepGen/Modules/DrawerFactory.h
"
24
#include "
CepGen/Utils/ArgumentsParser.h
"
25
#include "
CepGen/Utils/Drawer.h
"
26
#include "
CepGen/Utils/Histogram.h
"
27
#include "
CepGen/Utils/Message.h
"
28
#include "
CepGen/Utils/String.h
"
29
30
using namespace
std;
31
32
int
main
(
int
argc,
char
* argv[]) {
33
cepgen::Generator
mg;
34
35
vector<string> vars;
36
string
input_card, plotter;
37
int
num_events;
38
bool
draw_grid, log;
39
40
cepgen::ArgumentsParser
(argc, argv)
41
.
addArgument
(
"input,i"
,
"input card"
, &input_card)
42
.
addArgument
(
"vars"
,
"variables to plot"
, &vars)
43
.
addOptionalArgument
(
"num-events,n"
,
"number of events to generate"
, &num_events, 100)
44
.
addOptionalArgument
(
"draw-grid,g"
,
"draw the x/y grid"
, &draw_grid,
false
)
45
.
addOptionalArgument
(
"log,l"
,
"logarithmic axis"
, &log,
false
)
46
.
addOptionalArgument
(
"plotter,p"
,
"type of plotter to user"
, &plotter,
""
)
47
.
parse
();
48
49
mg.
parseRunParameters
(input_card);
50
mg.
runParameters
().
clearEventExportersSequence
();
51
52
// book all histograms
53
map<string, unique_ptr<cepgen::utils::Hist1D> > h_var_hist;
54
for
(
const
auto
& var : vars) {
55
cepgen::Limits
lim{0., 250.};
56
if
(var ==
"eta"
)
57
lim = {-3., 3.};
58
const
auto
parsed_var =
cepgen::utils::replaceAll
(var,
":"
,
","
);
59
h_var_hist[parsed_var].reset(
new
cepgen::utils::Hist1D
(100, lim,
cepgen::utils::sanitise
(var)));
60
h_var_hist[parsed_var]->xAxis().setLabel(parsed_var);
61
h_var_hist[parsed_var]->yAxis().setLabel(
"d$\\sigma$/d"
+ parsed_var);
62
}
63
CG_DEBUG
(
"main"
) <<
"Variables to be plotted: "
<< vars <<
"."
;
64
65
CG_LOG
<<
"Process name: "
<< mg.
runParameters
().
processName
() <<
"."
;
66
67
cepgen::utils::EventBrowser
browser;
68
69
// generate the events and feed to the histogram(s)
70
mg.
generate
(num_events, [&browser, &h_var_hist](
const
cepgen::Event
& ev,
unsigned
long
) {
71
for
(
auto
& var : h_var_hist)
72
var.second->fill(browser.
get
(ev, var.first));
73
});
74
75
// normalise to cross section
76
for
(
auto
& var : h_var_hist)
77
var.second->normalise(mg.
crossSection
() / num_events);
78
79
// if a plotter is specified, draw histograms
80
if
(!plotter.empty()) {
81
auto
plt = cepgen::DrawerFactory::get().build(plotter);
82
cepgen::utils::Drawer::Mode
dm;
83
if
(log)
84
dm |=
cepgen::utils::Drawer::Mode::logy
;
85
if
(draw_grid)
86
dm |=
cepgen::utils::Drawer::Mode::grid
;
87
88
for
(
const
auto
& var : h_var_hist)
89
plt->draw(*var.second, dm);
90
}
91
92
return
0;
93
}
ArgumentsParser.h
DrawerFactory.h
Drawer.h
EventBrowser.h
Event.h
Generator.h
Histogram.h
Message.h
CG_LOG
#define CG_LOG
Definition
Message.h:212
CG_DEBUG
#define CG_DEBUG(mod)
Definition
Message.h:220
RunParameters.h
String.h
cepgen::ArgumentsParser
A generic command line arguments parser.
Definition
ArgumentsParser.h:31
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::Event
Container for the information on the in- and outgoing particles' kinematics.
Definition
Event.h:28
cepgen::Generator
Core generator object allowing for process definition, cross section computation, and event generatio...
Definition
Generator.h:48
cepgen::Generator::generate
void generate(size_t num_events, const std::function< void(const Event &, size_t)> &)
Generate events.
Definition
Generator.cpp:235
cepgen::Generator::parseRunParameters
void parseRunParameters(const std::string &)
Read a steering card to populate the run parameters block.
Definition
Generator.cpp:72
cepgen::Generator::crossSection
double crossSection() const
Last cross section computed by the generator.
Definition
Generator.h:69
cepgen::Generator::runParameters
const RunParameters & runParameters() const
Pointer to the parameters block.
Definition
Generator.cpp:76
cepgen::Limits
Validity interval for a variable.
Definition
Limits.h:28
cepgen::RunParameters::clearEventExportersSequence
void clearEventExportersSequence()
Remove all output modules from sequence.
Definition
RunParameters.cpp:143
cepgen::RunParameters::processName
std::string processName() const
Name of the process considered.
Definition
RunParameters.cpp:109
cepgen::utils::Drawer::Mode
Definition
Drawer.h:41
cepgen::utils::Drawer::Mode::grid
@ grid
Definition
Drawer.h:49
cepgen::utils::Drawer::Mode::logy
@ logy
Definition
Drawer.h:46
cepgen::utils::EventBrowser
A user-friendly browser for the Event content.
Definition
EventBrowser.h:34
cepgen::utils::EventBrowser::get
double get(const Event &ev, const std::string &var) const
Get/compute a variable value.
Definition
EventBrowser.cpp:34
cepgen::utils::Hist1D
1D histogram container
Definition
Histogram.h:72
cepgen::utils::sanitise
std::string sanitise(const std::string &str)
Replace all unsafe characters to build a computer-readable (and filename-safe) string.
Definition
String.cpp:105
cepgen::utils::replaceAll
size_t replaceAll(std::string &str, const std::string &from, const std::string &to)
Replace all occurrences of a text by another.
Definition
String.cpp:118
main
int main()
Definition
pythia6_decay.cc:9
src
utils
cepgenDistributionDrawer.cc
Generated on Mon Jul 29 2024 for CepGen by
1.9.7