cepgen is hosted by Hepforge, IPPP Durham
CepGen 1.2.5
Central exclusive processes event generator
Loading...
Searching...
No Matches
FortranFactorisedProcess.cpp
Go to the documentation of this file.
1/*
2 * CepGen: a central exclusive processes event generator
3 * Copyright (C) 2018-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
20#include "CepGen/Event/Event.h"
24#include "CepGen/Physics/PDG.h"
28
29namespace {
30 extern "C" {
31 extern cepgen::ktblock::Constants constants_;
32 extern cepgen::ktblock::GenParameters genparams_;
34 extern cepgen::ktblock::KinCuts kincuts_;
36 }
37} // namespace
38
39extern "C" {
43}
44
48int cepgen_param_int_(char* pname, int& def) {
49 //--- first check if the "integer" is a particle id
50 if (cepgen::proc::FortranFactorisedProcess::kProcParameters.has<cepgen::ParticleProperties>(pname))
52 if (cepgen::proc::FortranFactorisedProcess::kProcParameters.has<unsigned long long>(pname)) {
53 unsigned long long ulong_def = def;
54 return cepgen::proc::FortranFactorisedProcess::kProcParameters.get<unsigned long long>(pname, ulong_def);
55 }
56 //--- if not, proceed with retrieving the integer value
58}
59
63double cepgen_param_real_(char* pname, double& def) {
65}
66}
67
68namespace cepgen {
69 namespace proc {
71
73 const std::function<double(void)>& func)
74 : FactorisedProcess(params, {PDG::muon, PDG::muon}), func_(func) {
75 constants_.m_p = Process::mp_;
76 constants_.units = constants::GEVM2_TO_PB;
77 constants_.pi = M_PI;
78 }
79
80 void FortranFactorisedProcess::prepareFactorisedPhaseSpace() {
81 const auto lim_rap = kinematics().cuts().central.rapidity_single.truncate(Limits{-6., 6.});
82 defineVariable(m_y1_, Mapping::linear, lim_rap, "y1", "First central particle rapidity");
83 defineVariable(m_y2_, Mapping::linear, lim_rap, "y2", "Second central particle rapidity");
84
85 const auto lim_pt_diff = kinematics().cuts().central.pt_diff.truncate(Limits{0., 50.});
87 m_pt_diff_, Mapping::linear, lim_pt_diff, "pt_diff", "Central particles transverse momentum difference");
88
89 const auto lim_phi_diff = kinematics().cuts().central.phi_diff.truncate(Limits{0., 2. * M_PI});
91 m_phi_pt_diff_, Mapping::linear, lim_phi_diff, "phi_diff", "Central particles azimuthal angle difference");
92
93 //===========================================================================================
94 // feed phase space cuts to the common block
95 //===========================================================================================
96
97 // export the limits into external variables
98 auto save_lim = [](const Limits& lim, int& on, double& min, double& max) {
99 on = lim.valid();
100 min = lim.hasMin() ? lim.min() : -9999.999;
101 max = lim.hasMax() ? lim.max() : +9999.999;
102 };
103
104 save_lim(kinematics().cuts().central.pt_single, kincuts_.ipt, kincuts_.pt_min, kincuts_.pt_max);
105 save_lim(kinematics().cuts().central.energy_single, kincuts_.iene, kincuts_.ene_min, kincuts_.ene_max);
106 save_lim(kinematics().cuts().central.eta_single, kincuts_.ieta, kincuts_.eta_min, kincuts_.eta_max);
107 save_lim(kinematics().cuts().central.mass_sum, kincuts_.iinvm, kincuts_.invm_min, kincuts_.invm_max);
108 save_lim(kinematics().cuts().central.pt_sum, kincuts_.iptsum, kincuts_.ptsum_min, kincuts_.ptsum_max);
109 save_lim(kinematics().cuts().central.rapidity_diff, kincuts_.idely, kincuts_.dely_min, kincuts_.dely_max);
110
111 //===========================================================================================
112 // feed run parameters to the common block
113 //===========================================================================================
114
115 genparams_.icontri = (int)kinematics().incomingBeams().mode();
116
117 //-------------------------------------------------------------------------------------------
118 // incoming beams information
119 //-------------------------------------------------------------------------------------------
120
121 //--- positive-z incoming beam
122 genparams_.inp1 = kinematics().incomingBeams().positive().momentum().pz();
123 //--- check if first incoming beam is a heavy ion
124 if (HeavyIon::isHI(kinematics().incomingBeams().positive().integerPdgId())) {
125 const auto in1 = HeavyIon::fromPdgId(kinematics().incomingBeams().positive().integerPdgId());
126 genparams_.a_nuc1 = in1.A;
127 genparams_.z_nuc1 = (unsigned short)in1.Z;
128 if (genparams_.z_nuc1 > 1) {
131 }
132 } else
133 genparams_.a_nuc1 = genparams_.z_nuc1 = 1;
134
135 //--- negative-z incoming beam
136 genparams_.inp2 = kinematics().incomingBeams().negative().momentum().pz();
137 //--- check if second incoming beam is a heavy ion
138 if (HeavyIon::isHI(kinematics().incomingBeams().negative().integerPdgId())) {
139 const auto in2 = HeavyIon::fromPdgId(kinematics().incomingBeams().negative().integerPdgId());
140 genparams_.a_nuc2 = in2.A;
141 genparams_.z_nuc2 = (unsigned short)in2.Z;
142 if (genparams_.z_nuc2 > 1) {
145 }
146 } else
147 genparams_.a_nuc2 = genparams_.z_nuc2 = 1;
148
149 // intermediate partons information
150 genparams_.iflux1 = (int)psgen_->partons().at(0);
151 genparams_.iflux2 = (int)psgen_->partons().at(1);
152 }
153
154 double FortranFactorisedProcess::computeFactorisedMatrixElement() {
155 //===========================================================================================
156 // outgoing beam remnants
157 //===========================================================================================
158
159 pX() = Momentum(evtkin_.px);
160 pY() = Momentum(evtkin_.py);
161 // express these momenta per nucleon
162 pX() *= 1. / genparams_.a_nuc1;
163 pY() *= 1. / genparams_.a_nuc2;
164
165 //===========================================================================================
166 // intermediate partons
167 //===========================================================================================
168
169 q1() = pA() - pX();
170 q2() = pB() - pY();
172
173 //===========================================================================================
174 // central system
175 //===========================================================================================
176
177 auto oc = event()[Particle::CentralSystem]; // retrieve all references
178 // to central system particles
179 for (int i = 0; i < evtkin_.nout; ++i) {
180 auto& p = oc[i].get(); // retrieve a reference to the specific particle
181 p.setPdgId((long)evtkin_.pdg[i]);
182 p.setStatus(Particle::Status::FinalState);
183 p.setMomentum(Momentum(evtkin_.pc[i]));
184 }
185 // set all kinematics variables for this phase space point
186 ktkin_.q1t = q1().p();
187 ktkin_.q2t = q2().p();
188 ktkin_.phiq1t = q1().phi();
189 ktkin_.phiq2t = q2().phi();
190 ktkin_.y1 = m_y1_;
191 ktkin_.y2 = m_y2_;
192 ktkin_.ptdiff = m_pt_diff_;
193 ktkin_.phiptdiff = m_phi_pt_diff_;
194 ktkin_.m_x = mX();
195 ktkin_.m_y = mY();
196
197 // compute the event weight
198 return func_();
199 }
200 } // namespace proc
201} // namespace cepgen
void cepgen_list_params_()
Print the full list of parameters in the runtime process parameters collection.
double cepgen_param_real_(char *pname, double &def)
Retrieve a double precision floating point process parameter from runtime parameters collection.
int cepgen_param_int_(char *pname, int &def)
Retrieve an integer process parameter from runtime parameters collection.
#define CG_LOG
Definition Message.h:212
const Momentum & momentum() const
Beam particle 4-momentum Set the beam particle 4-momentum.
Definition Beam.h:54
Particle & oneWithRole(Particle::Role role)
First Particle object with a given role in the event.
Definition Event.cpp:190
const Beam & positive() const
Reference to the positive-z beam information.
const Beam & negative() const
Reference to the negative-z beam information.
mode::Kinematics mode() const
Type of kinematics to consider for the phase space.
CutsList & cuts()
Phase space cuts.
Definition Kinematics.h:41
IncomingBeams & incomingBeams()
Beam/primary particle kinematics.
Definition Kinematics.h:36
Validity interval for a variable.
Definition Limits.h:28
Limits truncate(const Limits &) const
Truncate limits to minimal/maximal values.
Definition Limits.cpp:130
double pz() const
Longitudinal momentum (in GeV)
Definition Momentum.h:120
double phi() const
Azimuthal angle (angle in the transverse plane)
Definition Momentum.cpp:230
double p() const
3-momentum norm (in GeV)
Definition Momentum.h:130
@ muon
Definition PDG.h:38
A description object for parameters collection.
std::string describe(size_t offset=0) const
Human-readable description of parameters and their default value.
T get(const std::string &key, const T &def=default_arg< T >::get()) const
Get a parameter value.
Particle & setMomentum(const Momentum &, bool offshell=false)
Associate a momentum object to this particle.
Definition Particle.cpp:77
@ FinalState
Stable, final state particle.
@ IncomingBeam2
incoming beam particle
Definition Particle.h:53
@ OutgoingBeam1
outgoing beam state/particle
Definition Particle.h:54
@ IncomingBeam1
incoming beam particle
Definition Particle.h:52
@ OutgoingBeam2
outgoing beam state/particle
Definition Particle.h:55
@ CentralSystem
Central particles system.
Definition Particle.h:56
@ Intermediate
Intermediate two-parton system.
Definition Particle.h:57
Particle & setPdgId(pdgid_t pdg, short ch=0)
Set the PDG identifier (along with the particle's electric charge)
Definition Particle.cpp:93
Generic parton emission-factorised process.
const std::unique_ptr< PhaseSpaceGenerator > psgen_
Kinematic variables generator for the phase space coverage.
FortranFactorisedProcess(const ParametersList &, const std::function< double(void)> &func)
Construct a Fortran-CepGen interface object using a double precision argument-less F77 function.
static ParametersList kProcParameters
List of parameters to steer the process.
const Kinematics & kinematics() const
Constant reference to the process kinematics.
Definition Process.h:50
const Momentum & pA() const
Positive-z incoming beam particle's 4-momentum.
Definition Process.cpp:91
const Momentum & pX() const
Positive-z outgoing beam particle's 4-momentum.
Definition Process.cpp:99
double mp_
Proton mass, in GeV/c .
Definition Process.h:121
double mX() const
Positive-z outgoing beam particle's mass.
Definition Process.h:75
const Momentum & q2() const
Negative-z incoming parton's 4-momentum.
Definition Process.cpp:111
Process & defineVariable(double &out, const Mapping &type, const Limits &lim, const std::string &name, const std::string &description="")
Register a variable to be handled and populated whenever a new phase space point weight is to be calc...
Definition Process.cpp:149
const Momentum & pB() const
Negative-z incoming beam particle's 4-momentum.
Definition Process.cpp:95
double mY() const
Negative-z outgoing beam particle's mass.
Definition Process.h:78
const Momentum & pY() const
Negative-z outgoing beam particle's 4-momentum.
Definition Process.cpp:103
const Event & event() const
Handled particles objects and their relationships.
Definition Process.cpp:267
const Momentum & q1() const
Positive-z incoming parton's 4-momentum.
Definition Process.cpp:107
constexpr double GEVM2_TO_PB
Conversion factor between GeV and barn i.e. in GeV .
Definition Constants.h:37
General physics constants.
Generic run parameters.
Kinematics properties of the -factorised process.
Phase space cuts for event kinematics.
bool positive(const T &val)
Check if a number is positive and finite.
Definition Math.cpp:26
Common namespace for this Monte Carlo generator.
unsigned long long pdgid_t
Alias for the integer-like particle PDG id.
cuts::Central central
Cuts on the central system produced.
Definition Cuts.h:95
static HeavyIon fromPdgId(pdgid_t)
Build from a custom PDG id.
Definition HeavyIon.cpp:34
static bool isHI(const spdgid_t &)
Check if the PDG id is compatible with a HI.
Definition HeavyIon.cpp:54
A collection of physics constants associated to a single particle.
Limits pt_diff
transverse momentum balance between the central particles
Definition Cuts.h:47
Limits rapidity_single
single particle rapidity
Definition Cuts.h:40
Limits phi_diff
azimuthal angles difference between the central particles
Definition Cuts.h:48
Single event kinematics.