22 #include <LHAPDF/LHAPDF.h> 24 #include <momemta/Logging.h> 25 #include <momemta/MatrixElement.h> 26 #include <momemta/MatrixElementFactory.h> 27 #include <momemta/ParameterSet.h> 29 #include <momemta/Module.h> 30 #include <momemta/Types.h> 31 #include <momemta/Utils.h> 160 sqrt_s = parameters.globalParameters().get<
double>(
"energy");
162 use_pdf = parameters.get<
bool>(
"use_pdf",
true);
164 m_partons = get<std::vector<LorentzVector>>(parameters.get<
InputTag>(
"initialState"));
166 const auto& particles_set = parameters.get<
ParameterSet>(
"particles");
168 auto particle_tags = particles_set.get<std::vector<InputTag>>(
"inputs");
169 for (
auto& tag: particle_tags)
170 m_particles.push_back(get<LorentzVector>(tag));
172 const auto& particles_ids_set = particles_set.get<std::vector<ParameterSet>>(
"ids");
173 for (
const auto& s: particles_ids_set) {
175 id.pdg_id = s.get<int64_t>(
"pdg_id");
176 id.me_index = s.get<int64_t>(
"me_index");
177 m_particles_ids.push_back(
id);
180 if (m_particles.size() != m_particles_ids.size()) {
181 LOG(fatal) <<
"The number of particles ids is not consistent with the number of particles. Did you" 187 const auto& jacobians_tags = parameters.get<std::vector<InputTag>>(
"jacobians", std::vector<InputTag>());
188 for (
const auto& tag: jacobians_tags) {
189 m_jacobians.push_back(get<double>(tag));
192 std::string matrix_element = parameters.get<std::string>(
"matrix_element");
194 m_ME = MatrixElementFactory::get().
create(matrix_element, matrix_element_configuration);
196 if (parameters.exists(
"override_parameters")) {
198 auto p = m_ME->getParameters();
200 for (
const auto& name: matrix_element_params.getNames()) {
201 double value = matrix_element_params.get<
double>(name);
202 p->setParameter(name, value);
205 p->cacheParameters();
212 LHAPDF::setVerbosity(0);
214 std::string pdf = parameters.get<std::string>(
"pdf");
215 m_pdf.reset(LHAPDF::mkPDF(pdf, 0));
217 double pdf_scale = parameters.get<
double>(
"pdf_scale");
218 pdf_scale_squared =
SQ(pdf_scale);
222 for (
size_t i = 0; i < m_particles_ids.size(); i++) {
223 indexing.push_back(m_particles_ids[i].me_index - 1);
227 finalState.resize(m_particles_ids.size());
230 std::vector<int64_t> suite(indexing.size());
231 std::iota(suite.begin(), suite.end(), 0);
233 permutations = get_permutations(suite, indexing);
239 m_ME->resetHelicities();
242 virtual Status
work()
override {
243 static std::vector<LorentzVector> empty_vector;
246 const std::vector<LorentzVector>& partons = *m_partons;
248 LorentzVectorRefCollection particles;
249 for (
const auto& p: m_particles)
250 particles.push_back(std::ref(*p));
252 for (
size_t i = 0; i < m_particles_ids.size(); i++) {
253 finalState[i] = std::make_pair(m_particles_ids[i].pdg_id, toVector(particles[i].
get()));
257 apply_permutations(finalState, permutations);
259 std::pair<std::vector<double>, std::vector<double>> initialState { toVector(partons[0]),
260 toVector(partons[1]) };
262 auto result = m_ME->compute(initialState, finalState);
264 double x1 = std::abs(partons[0].Pz() / (sqrt_s / 2.));
265 double x2 = std::abs(partons[1].Pz() / (sqrt_s / 2.));
268 double phaseSpaceIn = 1. / (2. * x1 * x2 *
SQ(sqrt_s));
270 double integrand = phaseSpaceIn;
271 for (
const auto& jacobian: m_jacobians) {
272 integrand *= (*jacobian);
276 double final_integrand = 0;
277 for (
const auto& me: result) {
278 double pdf1 = use_pdf ? m_pdf->xfxQ2(me.first.first, x1, pdf_scale_squared) / x1 : 1;
279 double pdf2 = use_pdf ? m_pdf->xfxQ2(me.first.second, x2, pdf_scale_squared) / x2 : 1;
281 final_integrand += me.second * pdf1 * pdf2;
284 final_integrand *= integrand;
285 *m_integrand = final_integrand;
293 double pdf_scale_squared = 0;
294 std::shared_ptr<momemta::MatrixElement> m_ME;
295 std::shared_ptr<LHAPDF::PDF> m_pdf;
297 std::vector<int64_t> indexing;
298 std::vector<size_t> permutations;
299 std::vector<std::pair<int, std::vector<double>>> finalState;
304 std::vector<Value<LorentzVector>> m_particles;
305 std::vector<ParticleId> m_particles_ids;
307 std::vector<Value<double>> m_jacobians;
310 std::shared_ptr<double> m_integrand = produce<double>(
"output");
314 .Input(
"initialState")
315 .OptionalInputs(
"jacobians")
316 .Inputs(
"particles/inputs")
318 .GlobalAttr(
"energy:double")
319 .Attr(
"matrix_element:string")
320 .Attr(
"matrix_element_parameters:pset")
321 .OptionalAttr(
"override_parameters:pset")
322 .Attr(
"particles:pset")
323 .Attr(
"use_pdf:bool=true")
324 .OptionalAttr(
"pdf:string")
325 .OptionalAttr(
"pdf_scale:double");
virtual Status work() override
Main function.
virtual void beginIntegration()
Called once at the beginning of the integration.
virtual void create(const std::string &name, const momemta::any &value)
Add a new element to the ParameterSet.
Parent class for all the modules.
A class encapsulating a lua table.
A class representing a value produced by a module.
Module(PoolPtr pool, const std::string &name)
Constructor.
Compute the integrand: matrix element, PDFs, jacobians.