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"
25#include "CepGen/Utils/Caller.h"
26#include "CepGen/Utils/Math.h"
29
30using namespace cepgen;
31
33public:
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
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
98private:
99 const std::unique_ptr<CPPProcess> proc_;
100 std::vector<Momentum> momenta_;
101};
103//=============================================================================
#define CG_FATAL(mod)
Definition Exception.h:61
#define REGISTER_MG5AMC_PROCESS(name, obj)
Add a MadGraph process definition to the factory.
#define CG_DEBUG_LOOP(mod)
Definition Message.h:224
#define CG_DEBUG(mod)
Definition Message.h:220
MadGraphProcessImpl(const ParametersList &params)
static ParametersDescription description()
void initialise(const std::string &param_card) override
const std::vector< Momentum > & momenta() override
Wrapper around a generic MadGraph process definition.
std::vector< double * > mom_
const std::vector< int > incoming_pdgids_
static ParametersDescription description()
const std::vector< int > central_pdgids_
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
A description object for parameters collection.
External command piping utility.
Definition Caller.h:29
bool positive(const T &val)
Check if a number is positive and finite.
Definition Math.cpp:26
Common namespace for this Monte Carlo generator.