cepgen
is hosted by
Hepforge
,
IPPP Durham
CepGen
1.2.5
Central exclusive processes event generator
Loading...
Searching...
No Matches
MadGraphProcessImpl.cpp
Go to the documentation of this file.
1
/*
2
* CepGen: a central exclusive processes event generator
3
* Copyright (C) 2020-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
//=============================================================================
20
// NOLI SE TANGERE
21
#include <iostream>
22
23
#include "CPPProcess.h"
24
#include "
CepGen/Core/Exception.h
"
25
#include "
CepGen/Utils/Caller.h
"
26
#include "
CepGen/Utils/Math.h
"
27
#include "
CepGenAddOns/MadGraphWrapper/MadGraphProcess.h
"
28
#include "
CepGenAddOns/MadGraphWrapper/MadGraphProcessFactory.h
"
29
30
using namespace
cepgen
;
31
32
class
MadGraphProcessImpl
:
public
MadGraphProcess
{
33
public
:
34
explicit
MadGraphProcessImpl
(
const
ParametersList
& params) :
MadGraphProcess
(params), proc_(new CPPProcess) {
35
CG_DEBUG
(
"MadGraphProcessImpl"
) <<
"Process considered: "
<< proc_->name() <<
". "
36
<<
"Incoming particles: "
<<
incoming_pdgids_
37
<<
", outgoing system: "
<<
central_pdgids_
<<
"."
;
38
}
39
40
static
ParametersDescription
description
() {
41
auto
desc =
MadGraphProcess::description
();
42
desc.setDescription(
"XXX_PROC_DESCRIPTION_XXX"
);
43
desc.add<std::vector<int> >(
"incomingSystem"
, {XXX_PART1_XXX, XXX_PART2_XXX});
44
desc.add<std::vector<int> >(
"outgoingSystem"
, {XXX_OUT_PART_XXX});
45
return
desc;
46
}
47
48
void
initialise
(
const
std::string& param_card)
override
{
49
try
{
50
utils::Caller
caller;
51
proc_->initProc(param_card);
52
}
catch
(
const
char
* chr) {
53
throw
CG_FATAL
(
"MadGraphProcessImpl:init"
)
54
<<
"Failed to initialise parameters card at \""
<< param_card <<
"\":\n\t"
<< chr;
55
}
56
if
(proc_->nprocesses > 1)
57
throw
CG_FATAL
(
"MadGraphProcessImpl:init"
) <<
"Multi-processes matrix elements are not (yet) supported!"
;
58
if
(proc_->ninitial != 2)
59
throw
CG_FATAL
(
"MadGraphProcessImpl:init"
) <<
"Currently only 2->N processes are supported!"
;
60
61
CG_DEBUG
(
"MadGraphProcessImpl:init"
) <<
"External particles masses (partons + central system): "
62
<< proc_->getMasses() <<
"."
;
63
64
mom_
.clear();
65
for
(
size_t
i = 0; i < proc_->nexternal; ++i)
66
mom_
.emplace_back(
new
double
[4]{proc_->getMasses().at(i), 0., 0., 0.});
67
momenta_.resize(proc_->nexternal);
68
}
69
70
double
eval
()
override
{
71
proc_->setMomenta(
mom_
);
72
proc_->sigmaKin();
73
const
double
* me = proc_->getMatrixElements();
74
if
(!
utils::positive
(me[0]))
75
return
0.;
76
77
CG_DEBUG_LOOP
(
"MadGraphProcessImpl:eval"
).log([&](
auto
& log) {
78
log <<
"Dump of event kinematics\n\t"
79
<<
"Incoming partons 4-momenta: "
<< std::vector<double>(
mom_
[0],
mom_
[0] + 4) <<
", "
80
<< std::vector<double>(
mom_
[1],
mom_
[1] + 4) <<
"\n\t"
81
<<
"Outgoing particles 4-momenta: "
;
82
std::string sep;
83
for
(
size_t
i = 0; i < proc_->nexternal - 2; ++i)
84
log << sep << std::vector<double>(
mom_
[i + 2],
mom_
[i + 2] + 4), sep =
", "
;
85
log <<
"\n\tResulting matrix element: "
<< me[0] <<
"."
;
86
});
87
return
me[0];
88
}
89
90
const
std::vector<Momentum>&
momenta
()
override
{
91
const
auto
& p4 = proc_->getMomenta();
92
// cast it to the member attribute and return it
93
for
(
size_t
i = 0; i < p4.size(); ++i)
94
momenta_[i] =
Momentum::fromPxPyPzE
(p4[i][1], p4[i][2], p4[i][3], p4[i][0]);
95
return
momenta_;
96
}
97
98
private
:
99
const
std::unique_ptr<CPPProcess> proc_;
100
std::vector<Momentum> momenta_;
101
};
102
REGISTER_MG5AMC_PROCESS
(
"XXX_PROC_NAME_XXX"
,
MadGraphProcessImpl
);
103
//=============================================================================
Caller.h
Exception.h
CG_FATAL
#define CG_FATAL(mod)
Definition
Exception.h:61
MadGraphProcessFactory.h
REGISTER_MG5AMC_PROCESS
#define REGISTER_MG5AMC_PROCESS(name, obj)
Add a MadGraph process definition to the factory.
Definition
MadGraphProcessFactory.h:25
MadGraphProcess.h
Math.h
CG_DEBUG_LOOP
#define CG_DEBUG_LOOP(mod)
Definition
Message.h:224
CG_DEBUG
#define CG_DEBUG(mod)
Definition
Message.h:220
MadGraphProcessImpl
Definition
MadGraphProcessImpl.cpp:32
MadGraphProcessImpl::eval
double eval() override
Definition
MadGraphProcessImpl.cpp:70
MadGraphProcessImpl::MadGraphProcessImpl
MadGraphProcessImpl(const ParametersList ¶ms)
Definition
MadGraphProcessImpl.cpp:34
MadGraphProcessImpl::description
static ParametersDescription description()
Definition
MadGraphProcessImpl.cpp:40
MadGraphProcessImpl::initialise
void initialise(const std::string ¶m_card) override
Definition
MadGraphProcessImpl.cpp:48
MadGraphProcessImpl::momenta
const std::vector< Momentum > & momenta() override
Definition
MadGraphProcessImpl.cpp:90
cepgen::MadGraphProcess
Wrapper around a generic MadGraph process definition.
Definition
MadGraphProcess.h:28
cepgen::MadGraphProcess::mom_
std::vector< double * > mom_
Definition
MadGraphProcess.h:46
cepgen::MadGraphProcess::incoming_pdgids_
const std::vector< int > incoming_pdgids_
Definition
MadGraphProcess.h:45
cepgen::MadGraphProcess::description
static ParametersDescription description()
Definition
MadGraphProcess.cpp:39
cepgen::MadGraphProcess::central_pdgids_
const std::vector< int > central_pdgids_
Definition
MadGraphProcess.h:45
cepgen::Momentum::fromPxPyPzE
static Momentum fromPxPyPzE(double px, double py, double pz, double e)
Build a 4-momentum from its four momentum and energy coordinates.
Definition
Momentum.cpp:82
cepgen::ParametersDescription
A description object for parameters collection.
Definition
ParametersDescription.h:26
cepgen::ParametersList
Definition
ParametersList.h:52
cepgen::utils::Caller
External command piping utility.
Definition
Caller.h:29
cepgen::utils::positive
bool positive(const T &val)
Check if a number is positive and finite.
Definition
Math.cpp:26
cepgen
Common namespace for this Monte Carlo generator.
Definition
CommandLineHandler.cpp:36
CepGenAddOns
MadGraphWrapper
template
MadGraphProcessImpl.cpp
Generated on Mon Jul 29 2024 for CepGen by
1.9.7