cepgen
is hosted by
Hepforge
,
IPPP Durham
CepGen
1.2.5
Central exclusive processes event generator
Loading...
Searching...
No Matches
cepgenPlotAlphaS.cc
Go to the documentation of this file.
1
/*
2
* CepGen: a central exclusive processes event generator
3
* Copyright (C) 2022-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/Generator.h
"
22
#include "
CepGen/Modules/CouplingFactory.h
"
23
#include "
CepGen/Modules/DrawerFactory.h
"
24
#include "
CepGen/Physics/Coupling.h
"
25
#include "
CepGen/Utils/ArgumentsParser.h
"
26
#include "
CepGen/Utils/Drawer.h
"
27
#include "
CepGen/Utils/Graph.h
"
28
#include "
CepGen/Utils/String.h
"
29
30
using namespace
std;
31
32
int
main
(
int
argc,
char
* argv[]) {
33
cepgen::initialise
();
34
35
cepgen::Limits
q_range;
36
int
num_points;
37
string
output_file, plotter;
38
vector<string> models;
39
bool
q2mode, logx, logy, draw_grid, ratio_plot;
40
41
cepgen::ArgumentsParser
(argc, argv)
42
.
addOptionalArgument
(
"models,m"
,
"models to draw"
, &models, cepgen::AlphaSFactory::get().modules())
43
.
addOptionalArgument
(
"qrange,q"
,
"virtuality range (GeV)"
, &q_range,
cepgen::Limits
{1., 101.})
44
.addOptionalArgument(
"q2mode"
,
"plot as a function of Q^2"
, &q2mode,
false
)
45
.
addOptionalArgument
(
"npoints,n"
,
"number of x-points to scan"
, &num_points, 100)
46
.
addOptionalArgument
(
"output,o"
,
"output file name"
, &output_file,
"alphas.scan.output.txt"
)
47
.
addOptionalArgument
(
"logx"
,
"logarithmic x-scale"
, &logx,
false
)
48
.
addOptionalArgument
(
"logy,l"
,
"logarithmic y-scale"
, &logy,
false
)
49
.
addOptionalArgument
(
"draw-grid,g"
,
"draw the x/y grid"
, &draw_grid,
false
)
50
.
addOptionalArgument
(
"ratio,r"
,
"draw the ratio plot"
, &ratio_plot,
false
)
51
.
addOptionalArgument
(
"plotter,p"
,
"type of plotter to user"
, &plotter,
""
)
52
.
parse
();
53
54
struct
alpha_t {
55
string
name;
56
vector<double> vals;
57
cepgen::utils::Graph1D
graph;
58
};
59
vector<alpha_t> alphas;
60
61
const
auto
qvals = q_range.
generate
(num_points, logx);
62
63
{
// alphaS(Q) modellings part
64
size_t
i = 0;
65
for
(
const
auto
& mod : models) {
66
const
auto
& algo = cepgen::AlphaSFactory::get().build(mod);
67
alphas.emplace_back(alpha_t{
68
mod,
69
vector<double>(num_points),
70
cepgen::utils::Graph1D
(
71
mod,
cepgen::utils::replaceAll
(cepgen::AlphaSFactory::get().describe(mod),
"alpha(S)"
,
"\\alpha_{S}"
))});
72
auto
& as = alphas[i++];
73
for
(
size_t
j = 0; j < qvals.size(); ++j) {
74
const
auto
val = (*algo)(qvals[j]);
75
as.vals[j] = val;
76
as.graph.addPoint(q2mode ? qvals[j] * qvals[j] : qvals[j], val);
77
}
78
}
79
}
80
81
// output ascii file
82
ofstream out(output_file);
83
out <<
"#"
;
84
for
(
const
auto
& smp : alphas)
85
out <<
"\t"
<< smp.name;
86
for
(
size_t
i = 0; i < qvals.size(); ++i) {
87
out <<
"\n"
<< (q2mode ? qvals[i] * qvals[i] : qvals[i]);
88
for
(
const
auto
& smp : alphas)
89
out <<
"\t"
<< smp.vals[i];
90
}
91
92
// drawing part
93
94
if
(!plotter.empty()) {
95
auto
plt = cepgen::DrawerFactory::get().build(plotter);
96
cepgen::utils::Drawer::Mode
dm;
97
if
(logx)
98
dm |=
cepgen::utils::Drawer::Mode::logx
;
99
if
(logy)
100
dm |=
cepgen::utils::Drawer::Mode::logy
;
101
if
(draw_grid)
102
dm |=
cepgen::utils::Drawer::Mode::grid
;
103
if
(ratio_plot)
104
dm |=
cepgen::utils::Drawer::Mode::ratio
;
105
string
xlabel = q2mode ?
"Q^{2} (GeV^{2})"
:
"Q (GeV)"
, spectrum = q2mode ?
"Q^{2}"
:
"Q"
;
106
107
{
108
cepgen::utils::DrawableColl
mp;
109
for
(
size_t
i = 0; i < alphas.size(); ++i) {
110
alphas[i].graph.xAxis().setLabel(xlabel);
111
alphas[i].graph.yAxis().setLabel(
"$\\alpha_{S}("
+ spectrum +
")$"
);
112
mp.emplace_back(&alphas[i].graph);
113
}
114
plt->draw(mp,
"comp_alphas"
,
cepgen::utils::s
(
"$\\alpha_{S}$ modelling"
, alphas.size(),
false
), dm);
115
}
116
}
117
return
0;
118
}
ArgumentsParser.h
CouplingFactory.h
Coupling.h
DrawerFactory.h
Drawer.h
Generator.h
Graph.h
String.h
cepgen::ArgumentsParser
A generic command line arguments parser.
Definition
ArgumentsParser.h:31
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::Limits
Validity interval for a variable.
Definition
Limits.h:28
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::utils::Drawer::Mode
Definition
Drawer.h:41
cepgen::utils::Drawer::Mode::grid
@ grid
Definition
Drawer.h:49
cepgen::utils::Drawer::Mode::ratio
@ ratio
Definition
Drawer.h:52
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::s
std::string s(const std::string &word, float num, bool show_number)
Add a trailing "s" when needed.
Definition
String.cpp:228
cepgen::utils::DrawableColl
std::vector< const Drawable * > DrawableColl
A collection of drawable objects.
Definition
Drawer.h:34
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
cepgen::initialise
void initialise(bool safe_mode)
Definition
GlobalFunctions.cpp:91
main
int main()
Definition
pythia6_decay.cc:9
src
utils
cepgenPlotAlphaS.cc
Generated on Mon Jul 29 2024 for CepGen by
1.9.7