cepgen is hosted by Hepforge, IPPP Durham
CepGen 1.2.5
Central exclusive processes event generator
Loading...
Searching...
No Matches
Cuts.cpp
Go to the documentation of this file.
1/*
2 * CepGen: a central exclusive processes event generator
3 * Copyright (C) 2017-2023 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 <algorithm>
20
21#include "CepGen/Event/Event.h"
22#include "CepGen/Physics/Cuts.h"
24#include "CepGen/Utils/String.h"
25
26namespace cepgen {
27 namespace cuts {
28 //--------------------------------------------------------------------
29 // physics system kinematic properties
30 //--------------------------------------------------------------------
31
33
35 (*this)
36 .add("pt", pt_single)
37 .add("eta", eta_single)
38 .add("rapidity", rapidity_single)
39 .add("energy", energy_single)
40 .add("mass", mass_single)
41 .add("ptsum", pt_sum)
42 .add("etasum", eta_sum)
43 .add("energysum", energy_sum)
44 .add("invmass", mass_sum)
45 .add("ptdiff", pt_diff)
46 .add("dphi", phi_diff)
47 .add("rapiditydiff", rapidity_diff);
48 if (params.has<Limits>("phiptdiff")) {
49 CG_WARNING("Central") << "\"phiptdiff\" parameter is deprecated! "
50 << "Please use \"phidiff\" instead.";
51 params.fill("phiptdiff", phi_diff); // legacy
52 }
53 }
54
55 bool Central::contain(const Particles& parts, const Event*) const {
56 Momentum mom_sum;
57 for (const auto& part : parts) {
58 const auto& mom = part.momentum();
59 if (!pt_single.contains(mom.pt()) || !eta_single.contains(mom.eta()) ||
60 !rapidity_single.contains(mom.rapidity()) || !energy_single.contains(mom.energy()) ||
61 !mass_single.contains(mom.mass()))
62 return false;
63 mom_sum += mom;
64 }
65 if (!pt_sum.contains(mom_sum.pt()) || !eta_sum.contains(mom_sum.eta()) ||
66 !energy_sum.contains(mom_sum.energy()) || !mass_sum.contains(mom_sum.mass()))
67 return false;
68 if (parts.size() > 1) { // look at correlations
69 const auto &mom1 = parts.at(0).momentum(), &mom2 = parts.at(1).momentum();
70 if (!pt_diff.contains(fabs(mom1.pt() - mom2.pt())) || !phi_diff.contains(mom1.deltaPhi(mom2)) ||
71 !rapidity_diff.contains(fabs(mom1.rapidity() - mom2.rapidity())))
72 return false;
73 }
74 return true;
75 }
76
78 auto desc = ParametersDescription();
79 desc.add<Limits>("pt", Limits{0.}).setDescription("Single particle pt (GeV/c)");
80 desc.add<Limits>("eta", Limits{}).setDescription("Single particle eta");
81 desc.add<Limits>("rapidity", Limits{}).setDescription("Single particle rapidity");
82 desc.add<Limits>("energy", Limits{}).setDescription("Single particle energy (GeV)");
83 desc.add<Limits>("mass", Limits{}).setDescription("Single particle mass (GeV/c^2)");
84 desc.add<Limits>("ptsum", Limits{}).setDescription("System pt (GeV/c)");
85 desc.add<Limits>("etasum", Limits{}).setDescription("System eta");
86 desc.add<Limits>("energysum", Limits{}).setDescription("System energy (GeV)");
87 desc.add<Limits>("invmass", Limits{}).setDescription("System mass (GeV/c^2)");
88 desc.add<Limits>("ptdiff", Limits{}).setDescription("System D(pt) (GeV/c)");
89 desc.add<Limits>("dphi", Limits{}).setDescription("System D(phi) (rad)");
90 desc.add<Limits>("rapiditydiff", Limits{}).setDescription("System D(Y)");
91 return desc;
92 }
93
94 //------------------------------------------------------------------
95
97 (*this).add("q2", q2).add("qt", qt).add("phi", phi);
98 }
99
101 if (params.empty())
102 return;
104 if (const auto q2lim = params.get<Limits>("q2"); q2lim.valid()) // symmetric Q^2 cut specified
105 q2 = {q2lim, q2lim};
106 for (auto& q2lim : q2)
107 if (q2lim.max() <= 0.) {
108 CG_WARNING("Initial:setParameters") << "Maximum parton virtuality (" << q2lim << ") is invalid. "
109 << "It is now set to " << 1.e4 << " GeV^2.";
110 q2lim.max() = 1.e4;
111 }
112 }
113
114 bool Initial::contain(const Particles& parts, const Event*) const {
115 for (const auto& part : parts) {
116 const auto& mom = part.momentum();
117 if (!qt.contains(mom.pt()))
118 return false;
119 }
120 if (parts.size() == 2) {
121 for (size_t i = 0; i < 2; ++i)
122 if (!q2.at(i).contains(parts.at(i).momentum().mass2()))
123 return false;
124 if (phi.valid() && !phi.contains(parts.at(0).momentum().deltaPhi(parts.at(1).momentum())))
125 return false;
126 }
127 return true;
128 }
129
131 auto desc = ParametersDescription();
132 desc.add("q2", std::vector<Limits>(2, {0., 1.e5})).setDescription("Parton virtuality(ies) (GeV^2)");
133 desc.add("qt", Limits{}).setDescription("Transverse virtuality (GeV)");
134 desc.add("phi", Limits{}).setDescription("Partons D(phi) (rad)");
135 return desc;
136 }
137
138 //------------------------------------------------------------------
139
141 (*this).add("mx", mx).add("yj", yj).add("xi", xi);
142 }
143
145 if (params.empty())
146 return;
148 if (mx.min() < MX_MIN) {
149 CG_WARNING("CutsList:setParameters") << "Minimum diffractive mass range (" << mx << ") is invalid. "
150 << "It is now set to " << MX_MIN << " GeV/c^2.";
151 mx.min() = MX_MIN;
152 }
153 }
154
155 bool Remnants::contain(const Particles& parts, const Event* evt) const {
156 for (const auto& part : parts) {
157 if (part.status() != Particle::Status::FinalState)
158 continue;
159 if (evt && xi.valid() &&
160 !xi.contains(1. - part.momentum().pz() / (*evt)(*part.mothers().begin()).momentum().pz()))
161 return false;
162 if (!yj.contains(fabs(part.momentum().rapidity())))
163 return false;
164 }
165 return true;
166 }
167
169 auto desc = ParametersDescription();
170 desc.add<Limits>("mx", Limits{Remnants::MX_MIN, 1.e3}).setDescription("Diffractive mass (GeV/c^2)");
171 desc.add<Limits>("yj", Limits{}).setDescription("Diffractive jet rapidity");
172 desc.add<Limits>("xi", Limits{}).setDescription("Longit.fract.mom. loss (\"xi\")");
173 return desc;
174 }
175 } // namespace cuts
176
177 //--------------------------------------------------------------------
178 // List of kinematics limits
179 //--------------------------------------------------------------------
180
182 : SteeredObject(params),
183 initial(steer<ParametersList>("initial")),
184 central(steer<ParametersList>("central")),
185 remnants(steer<ParametersList>("remnants")) {}
186
188 if (params.empty())
189 return;
193 if (params.has<ParametersList>("cuts")) { // per-particle cuts
194 const auto per_part_cuts = params.get<ParametersList>("cuts");
195 for (const auto& part : per_part_cuts.keys())
196 central_particles[(pdgid_t)std::stoi(part)].setDescribedParameters(per_part_cuts.get<ParametersList>(part));
197 }
198
199 // override the parameters from sub-parameters content
200 params_.set("initial", initial.parameters())
201 .set("central", central.parameters())
202 .set("remnants", remnants.parameters());
203 for (const auto& cuts_vs_part : central_particles) // per-PDGid selection
204 params_.operator[]<ParametersList>("cuts").set<ParametersList>(std::to_string(cuts_vs_part.first),
205 cuts_vs_part.second.parameters());
206 CG_DEBUG("CutsList:setParameters") << "User specified the following cuts list:\n" << *this << ".";
207 for (const auto& key : params_.keys()) {
208 if (key == "initial" || key == "central" || key == "remnants" || key == "cuts") {
209 auto& cuts = params_.operator[]<ParametersList>(key);
210 for (const auto& lim_key : cuts.keysOf<Limits>())
211 if (auto& lim = cuts.operator[]<Limits>(lim_key); lim.min() == 0. && lim.max() == 0.) {
212 CG_WARNING("CutsList:setParameters")
213 << "Unset the range for '" << key << "/" << lim_key << "' from " << lim << ".";
214 lim = Limits{};
215 }
216 } else
217 params_.erase(key);
218 }
219 initial.setParameters(steer<ParametersList>("initial"));
220 central.setParameters(steer<ParametersList>("central"));
221 remnants.setParameters(steer<ParametersList>("remnants"));
222 }
223
225 auto desc = ParametersDescription();
226 desc.add("initial", cuts::Initial::description());
227 desc.add("central", cuts::Central::description());
228 desc.add("remnants", cuts::Remnants::description());
229 return desc;
230 }
231
232 std::ostream& operator<<(std::ostream& os, const CutsList& cl) {
233 auto dump_cuts = [&os](const auto& obj) {
234 std::string sep;
235 for (const auto& lim : obj.parameters().template keysOf<Limits>()) {
236 const auto& limit = obj.parameters().template get<Limits>(lim);
237 if (limit.valid() && obj.description().has(lim))
238 os << sep << obj.description().get(lim).description() << ": " << limit, sep = ";";
239 }
240 };
241 os << "init.system{";
242 dump_cuts(cl.initial);
243 os << "}, cent.system{";
244 dump_cuts(cl.central);
245 os << "}, remnants{";
246 dump_cuts(cl.remnants);
247 return os << "}";
248 }
249} // namespace cepgen
#define CG_WARNING(mod)
Definition Message.h:228
#define CG_DEBUG(mod)
Definition Message.h:220
Container for the information on the in- and outgoing particles' kinematics.
Definition Event.h:28
Validity interval for a variable.
Definition Limits.h:28
bool valid() const
Is there a lower and upper limit?
Definition Limits.cpp:85
double min() const
Lower limit to apply on the variable.
Definition Limits.h:52
bool contains(double val, bool exclude_boundaries=false) const
Check if value is inside limits' boundaries.
Definition Limits.cpp:77
Container for a particle's 4-momentum, along with useful methods to ease the development of any matri...
Definition Momentum.h:33
double eta() const
Pseudo-rapidity.
Definition Momentum.cpp:240
double pt() const
Transverse momentum (in GeV)
Definition Momentum.cpp:232
double mass() const
Mass (in GeV) as computed from its energy and momentum.
Definition Momentum.cpp:222
double energy() const
Energy (in GeV)
Definition Momentum.h:136
A description object for parameters collection.
bool has(const std::string &key) const
Check if a given parameter is handled in this list.
std::vector< std::string > keys(bool name_key=true) const
bool empty() const
Is the list empty?
size_t erase(const std::string &)
Erase a parameter with key.
T get(const std::string &key, const T &def=default_arg< T >::get()) const
Get a parameter value.
ParametersList & set(const std::string &, const T &)
Set a parameter value Set a recast parameter value.
const ParametersList & fill(const std::string &key, T &value) const
Fill a variable with the key content if exists.
@ FinalState
Stable, final state particle.
ParametersList params_
Module parameters.
Definition Steerable.h:50
Base user-steerable object.
void setDescribedParameters(const ParametersList &params_orig)
Set (documented) module parameters.
virtual void setParameters(const ParametersList &params) override
Set module parameters.
const ParametersList & parameters() const override
Module user-defined parameters.
Common namespace for this Monte Carlo generator.
unsigned long long pdgid_t
Alias for the integer-like particle PDG id.
std::ostream & operator<<(std::ostream &os, const Exception::Type &type)
Definition Exception.cpp:59
std::vector< Particle > Particles
List of Particle objects.
Definition Particle.h:169
A collection of cuts to apply on the physical phase space.
Definition Cuts.h:85
void setParameters(const ParametersList &) override
Set module parameters.
Definition Cuts.cpp:187
cuts::Initial initial
Cuts on the initial particles kinematics.
Definition Cuts.h:94
CutsList(const ParametersList &)
Definition Cuts.cpp:181
cuts::Remnants remnants
Cuts on the beam remnants system.
Definition Cuts.h:97
cuts::Central central
Cuts on the central system produced.
Definition Cuts.h:95
static ParametersDescription description()
Definition Cuts.cpp:224
PerIdCuts central_particles
Cuts on the central individual particles.
Definition Cuts.h:96
Limits energy_sum
multiparticle system energy
Definition Cuts.h:45
Limits eta_single
single particle pseudo-rapidity
Definition Cuts.h:39
Limits energy_single
single particle energy
Definition Cuts.h:41
Limits mass_single
single particle mass
Definition Cuts.h:42
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 pt_sum
multiparticle system transverse momentum
Definition Cuts.h:43
Limits phi_diff
azimuthal angles difference between the central particles
Definition Cuts.h:48
Limits mass_sum
multiparticle system invariant mass
Definition Cuts.h:46
bool contain(const Particles &, const Event *evt=nullptr) const
Definition Cuts.cpp:55
Limits eta_sum
multiparticle system pseudo-rapidity
Definition Cuts.h:44
Limits pt_single
single particle transverse momentum
Definition Cuts.h:38
static ParametersDescription description()
Definition Cuts.cpp:77
Limits rapidity_diff
rapidity balance between the central particles
Definition Cuts.h:49
Limits phi
parton azimuthal angle
Definition Cuts.h:63
void setParameters(const ParametersList &) override
Set module parameters.
Definition Cuts.cpp:100
bool contain(const Particles &, const Event *evt=nullptr) const
Definition Cuts.cpp:114
std::vector< Limits > q2
parton virtualities
Definition Cuts.h:61
static ParametersDescription description()
Definition Cuts.cpp:130
Initial(const ParametersList &)
Definition Cuts.cpp:96
Limits qt
parton transverse virtuality
Definition Cuts.h:62
Limits mx
diffractive mass
Definition Cuts.h:75
void setParameters(const ParametersList &) override
Set module parameters.
Definition Cuts.cpp:144
bool contain(const Particles &, const Event *evt=nullptr) const
Definition Cuts.cpp:155
Remnants(const ParametersList &)
Definition Cuts.cpp:140
Limits xi
longitudinal momentum fraction
Definition Cuts.h:77
static ParametersDescription description()
Definition Cuts.cpp:168
Limits yj
diffractive jet rapidity
Definition Cuts.h:76
static constexpr double MX_MIN
Minimal diffractive mass for dissociative proton treatment.
Definition Cuts.h:79