cepgen
is hosted by
Hepforge
,
IPPP Durham
CepGen
1.2.5
Central exclusive processes event generator
Loading...
Searching...
No Matches
cepgenPlotSigmaRatios.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/Core/Exception.h
"
22
#include "
CepGen/Generator.h
"
23
#include "
CepGen/Modules/DrawerFactory.h
"
24
#include "
CepGen/Modules/StructureFunctionsFactory.h
"
25
#include "
CepGen/Physics/PDG.h
"
26
#include "
CepGen/Physics/Utils.h
"
27
#include "
CepGen/StructureFunctions/SigmaRatio.h
"
28
#include "
CepGen/Utils/ArgumentsParser.h
"
29
#include "
CepGen/Utils/Drawer.h
"
30
#include "
CepGen/Utils/Graph.h
"
31
#include "
CepGen/Utils/String.h
"
32
33
using namespace
std;
34
35
int
main
(
int
argc,
char
* argv[]) {
36
int
var, num_points;
37
double
q2, w2;
38
string
output_file, plotter;
39
vector<string> sigrat_types;
40
cepgen::Limits
x_range;
41
bool
logx, logy, draw_grid, ratio_plot;
42
43
cepgen::ArgumentsParser
(argc, argv)
44
.
addOptionalArgument
(
"sr,s"
,
45
"longitud./transv. cross section ratio modelling"
,
46
&sigrat_types,
47
cepgen::SigmaRatiosFactory::get().modules())
48
.
addOptionalArgument
(
"q2,q"
,
"parton virtuality (GeV^2)"
, &q2, -1.)
49
.
addOptionalArgument
(
"w2,w"
,
"scattered particle squared mass (GeV^2/c^4)"
, &w2, -1.)
50
.
addOptionalArgument
(
"var,t"
,
"variable to study (0=xBj, 1=w)"
, &var, 0)
51
.
addOptionalArgument
(
"xrange,x"
,
"Bjorken x range"
, &x_range,
cepgen::Limits
{1.e-7, 1.})
52
.addOptionalArgument(
"npoints,n"
,
"number of x-points to scan"
, &num_points, 500)
53
.
addOptionalArgument
(
"output,o"
,
"output file name"
, &output_file,
"strfuns.scan.output.txt"
)
54
.
addOptionalArgument
(
"plotter,p"
,
"type of plotter to user"
, &plotter,
""
)
55
.
addOptionalArgument
(
"logx"
,
"logarithmic x-axis"
, &logx,
false
)
56
.
addOptionalArgument
(
"logy,l"
,
"logarithmic y-axis"
, &logy,
false
)
57
.
addOptionalArgument
(
"draw-grid,g"
,
"draw the x/y grid"
, &draw_grid,
false
)
58
.
addOptionalArgument
(
"ratio,r"
,
"draw the ratio plot"
, &ratio_plot,
false
)
59
.
parse
();
60
61
if
(q2 < 0. && w2 < 0.)
62
throw
CG_FATAL
(
"main"
) <<
"Either a Q^2 or a w^2 must be provided!"
;
63
64
cepgen::initialise
();
65
66
string
var_name, var_unit;
67
switch
(var) {
68
case
0:
69
var_name =
"x_{Bj}"
;
70
break
;
71
case
1:
72
var_name =
"w"
;
73
var_unit =
"GeV"
;
74
break
;
75
case
2:
76
var_name =
"w^{2}"
;
77
var_unit =
"GeV$^{2}$"
;
78
break
;
79
default
:
80
throw
CG_FATAL
(
"main"
) <<
"Unsupported variable to be plotted!"
;
81
}
82
83
string
fixed_var;
84
if
(q2 > 0.)
85
fixed_var =
"$Q^{2}$"
;
86
else
if
(w2 > 0.)
87
fixed_var =
"$w^{2}$"
;
88
89
ofstream out(output_file);
90
out <<
"# sigma ratios: "
<<
cepgen::utils::repr
(sigrat_types) <<
"\n"
91
<<
"# x in ["
<< x_range <<
"]\n"
;
92
93
const
float
mp =
cepgen::PDG::get
().
mass
(2212), mp2 = mp * mp;
94
95
vector<unique_ptr<cepgen::sigrat::Parameterisation> > sigrats;
96
vector<cepgen::utils::Graph1D> g_sigrats;
97
for
(
const
auto
& sr_type : sigrat_types) {
98
auto
sr = cepgen::SigmaRatiosFactory::get().build(sr_type);
99
const
auto
sr_name = cepgen::SigmaRatiosFactory::get().describe(sr_type);
100
g_sigrats.emplace_back(sr_type, sr_name);
101
sigrats.emplace_back(move(sr));
102
}
103
for
(
const
auto
& x : x_range.
generate
(num_points, logx)) {
104
out << x <<
"\t"
;
105
size_t
j = 0;
106
for
(
const
auto
& sr : sigrats) {
107
double
xbj;
108
switch
(var) {
109
case
0:
110
xbj = x;
111
break
;
112
case
1:
113
xbj =
cepgen::utils::xBj
(q2, mp2, x * x);
114
break
;
115
case
2:
116
xbj =
cepgen::utils::xBj
(q2, mp2, x);
117
break
;
118
default
:
119
xbj = 0.;
120
break
;
121
}
122
double
err;
123
const
auto
sigrat = (*sr)(xbj, q2, err);
124
out <<
"\t"
<< sigrat;
125
g_sigrats.at(j).addPoint(x, sigrat);
126
++j;
127
}
128
out <<
"\n"
;
129
}
130
CG_LOG
<<
"Scan written in \""
<< output_file <<
"\"."
;
131
out.close();
132
133
if
(!plotter.empty()) {
134
auto
plt = cepgen::DrawerFactory::get().build(plotter);
135
cepgen::utils::Drawer::Mode
dm;
136
if
(logx)
137
dm |=
cepgen::utils::Drawer::Mode::logx
;
138
if
(logy)
139
dm |=
cepgen::utils::Drawer::Mode::logy
;
140
if
(draw_grid)
141
dm |=
cepgen::utils::Drawer::Mode::grid
;
142
if
(ratio_plot)
143
dm |=
cepgen::utils::Drawer::Mode::ratio
;
144
145
cepgen::utils::DrawableColl
mg;
146
for
(
auto
& gr : g_sigrats) {
147
gr.xAxis().setLabel(
"$"
+ var_name +
"$"
+ (!var_unit.empty() ?
" ("
+ var_unit +
")"
:
""
));
148
gr.yAxis().setLabel(
"$\\sigma_{L}/\\sigma_{T} = R("
+ var_name +
", Q^{2})$"
);
149
mg.emplace_back(&gr);
150
}
151
plt->draw(mg,
"comp_sigrat"
, fixed_var +
cepgen::utils::format
(
" = %g GeV$^{2}$"
, q2 > 0. ? q2 : w2), dm);
152
}
153
154
return
0;
155
}
ArgumentsParser.h
DrawerFactory.h
Drawer.h
Exception.h
CG_FATAL
#define CG_FATAL(mod)
Definition
Exception.h:61
Generator.h
Graph.h
CG_LOG
#define CG_LOG
Definition
Message.h:212
PDG.h
Utils.h
SigmaRatio.h
String.h
StructureFunctionsFactory.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::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::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::xBj
double xBj(double q2, double mp2, double mx2)
Compute Bjorken x from virtuality/diffractive mass.
Definition
Utils.cpp:41
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::repr
std::string repr(const std::vector< T > &vec, const std::function< std::string(const T &)> &printer, const std::string &sep=",")
Helper to print a vector.
Definition
String.h:156
cepgen::utils::DrawableColl
std::vector< const Drawable * > DrawableColl
A collection of drawable objects.
Definition
Drawer.h:34
cepgen::initialise
void initialise(bool safe_mode)
Definition
GlobalFunctions.cpp:91
main
int main()
Definition
pythia6_decay.cc:9
src
utils
cepgenPlotSigmaRatios.cc
Generated on Mon Jul 29 2024 for CepGen by
1.9.7