Search Results
SecondaryBlockA.cc
/*
* MoMEMta: a modular implementation of the Matrix Element Method
* Copyright (C) 2017 Universite catholique de Louvain (UCL), Belgium
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <momemta/ParameterSet.h>
#include <momemta/Module.h>
#include <momemta/Solution.h>
#include <momemta/Math.h>
#include <momemta/InputTag.h>
#include <momemta/Types.h>
#include <Math/GenVector/VectorUtil.h>
class SecondaryBlockA: public Module {
public:
SecondaryBlockA(PoolPtr pool, const ParameterSet& parameters): Module(pool, parameters.getModuleName()),
sqrt_s(parameters.globalParameters().get<double>("energy")) {
s12 = get<double>(parameters.get<InputTag>("s12"));
s123 = get<double>(parameters.get<InputTag>("s123"));
s1234 = get<double>(parameters.get<InputTag>("s1234"));
m1 = parameters.get<double>("m1", 0.);
m_p2 = get<LorentzVector>(parameters.get<InputTag>("p2"));
m_p3 = get<LorentzVector>(parameters.get<InputTag>("p3"));
m_p4 = get<LorentzVector>(parameters.get<InputTag>("p4"));
};
virtual Status work() override {
solutions->clear();
const double sq_m1 = SQ(m1);
const double m2 = m_p2->M();
const double sq_m2 = SQ(m2);
const double m3 = m_p3->M();
const double sq_m3 = SQ(m3);
const double m4 = m_p4->M();
const double sq_m4 = SQ(m4);
// Don't spend time on unphysical part of phase-space
if (*s1234 >= SQ(sqrt_s) || *s12 + sq_m3 >= *s123 || *s123 + sq_m4 >= *s1234 || sq_m1 + sq_m2 >= *s12)
return Status::NEXT;
const double p2x = m_p2->Px();
const double p2y = m_p2->Py();
const double p2z = m_p2->Pz();
const double E2 = m_p2->E();
const double p3x = m_p3->Px();
const double p3y = m_p3->Py();
const double p3z = m_p3->Pz();
const double E3 = m_p3->E();
const double p4x = m_p4->Px();
const double p4y = m_p4->Py();
const double p4z = m_p4->Pz();
const double E4 = m_p4->E();
const double p2p3 = m_p2->Dot(*m_p3);
const double p2p4 = m_p2->Dot(*m_p4);
const double p3p4 = m_p3->Dot(*m_p4);
/* Analytically solve the system:
* ai1 p1x + ai2 p1y + ai3 p1z = bi E1 + ci, with i = 1...3
*
* This gives p1 as a function of E1:
* p1x = Ax E1 + Bx
* p1y = Ay E1 + By
* p1z = Az E1 + Bz
*/
const double a11 = p2x;
const double a12 = p2y;
const double a13 = p2z;
const double a21 = p2x + p3x;
const double a22 = p2y + p3y;
const double a23 = p2z + p3z;
const double a31 = p2x + p3x + p4x;
const double a32 = p2y + p3y + p4y;
const double a33 = p2z + p3z + p4z;
const double b1 = E2;
const double c1 = 0.5 * (sq_m1 + sq_m2 - *s12);
const double b2 = E2 + E3;
const double c2 = 0.5 * (sq_m1 + sq_m2 + sq_m3 - *s123) + p2p3;
const double b3 = E2 + E3 + E4;
const double c3 = 0.5 * (sq_m1 + sq_m2 + sq_m3 + sq_m4 - *s1234) + p2p3 + p3p4 + p2p4;
const double inv_det = 1 / ((a13 * a22 - a12 * a23) * a31 - (a13 * a21 - a11 * a23) * a32 + (a12 * a21 - a11 * a22) * a33);
const double Ax = ((a13 * a22 - a12 * a23) * b3 - (a13 * a32 - a12 * a33) * b2 + (a23 * a32 - a22 * a33) * b1) * inv_det;
const double Bx = ((a13 * a22 - a12 * a23) * c3 - (a13 * a32 - a12 * a33) * c2 + (a23 * a32 - a22 * a33) * c1) * inv_det;
const double Ay = - ((a13 * a21 - a11 * a23) * b3 - (a13 * a31 - a11 * a33) * b2 + (a23 * a31 - a21 * a33) * b1) * inv_det;
const double By = - ((a13 * a21 - a11 * a23) * c3 - (a13 * a31 - a11 * a33) * c2 + (a23 * a31 - a21 * a33) * c1) * inv_det;
const double Az = ((a12 * a21 - a11 * a22) * b3 - (a12 * a31 - a11 * a32) * b2 + (a22 * a31 - a21 * a32) * b1) * inv_det;
const double Bz = ((a12 * a21 - a11 * a22) * c3 - (a12 * a31 - a11 * a32) * c2 + (a22 * a31 - a21 * a32) * c1) * inv_det;
// Now the mass-shell condition for p1 gives a quadratic equation in E1 with up to two solutions
std::vector<double> E1_sol;
bool foundSolution = solveQuadratic(SQ(Ax) + SQ(Ay) + SQ(Az) - 1, 2 * (Ax * Bx + Ay * By + Az * Bz), SQ(Bx) + SQ(By) + SQ(Bz) + sq_m1, E1_sol);
if (!foundSolution)
return Status::NEXT;
// Use now the obtained solutions of E1 to build the full p1
for (const double E1: E1_sol) {
// Skip unphysical solutions
if (E1 <= 0)
continue;
const double p1x = Ax * E1 + Bx;
const double p1y = Ay * E1 + By;
const double p1z = Az * E1 + Bz;
LorentzVector p1(p1x, p1y, p1z, E1);
if (!ApproxComparison(p1.M() / p1.E(), m1 / p1.E())) {
#ifndef NDEBUG
LOG(trace) << "[SecondaryBlockA] Throwing solution because of invalid mass. " <<
"Expected " << m1 << ", got " << p1.M();
#endif
continue;
}
if (!ApproxComparison((p1 + *m_p2 + *m_p3 + *m_p4).M2(), *s1234)) {
#ifndef NDEBUG
LOG(trace) << "[SecondaryBlockA] Throwing solution because of invalid invariant mass. " <<
"Expected " << *s1234 << ", got " << (p1 + *m_p2 + *m_p3 + *m_p4).M2();
#endif
continue;
}
if (!ApproxComparison((p1 + *m_p2 + *m_p3).M2(), *s123)) {
#ifndef NDEBUG
LOG(trace) << "[SecondaryBlockA] Throwing solution because of invalid invariant mass. " <<
"Expected " << *s123 << ", got " << (p1 + *m_p2 + *m_p3).M2();
#endif
continue;
}
if (!ApproxComparison((p1 + *m_p2).M2(), *s12)) {
#ifndef NDEBUG
LOG(trace) << "[SecondaryBlockA] Throwing solution because of invalid invariant mass. " <<
"Expected " << *s12 << ", got " << (p1 + *m_p2).M2();
#endif
continue;
}
// Compute jacobian
const double jacobian = 1. / (128 * std::pow(M_PI, 3) * std::abs(
E4 * (p1z*p2y*p3x - p1y*p2z*p3x - p1z*p2x*p3y + p1x*p2z*p3y + p1y*p2x*p3z - p1x*p2y*p3z)
+ E2 * (p1z*p3y*p4x - p1y*p3z*p4x - p1z*p3x*p4y + p1x*p3z*p4y + p1y*p3x*p4z - p1x*p3y*p4z)
+ E1 * (- p2z*p3y*p4x + p2y*p3z*p4x + p2z*p3x*p4y - p2x*p3z*p4y - p2y*p3x*p4z + p2x*p3y*p4z)
+ E3 * (- p1z*p2y*p4x + p1y*p2z*p4x + p1z*p2x*p4y - p1x*p2z*p4y - p1y*p2x*p4z + p1x*p2y*p4z)
));
Solution solution { { p1 }, jacobian, true };
solutions->push_back(solution);
}
return (solutions->size() > 0) ? Status::OK : Status::NEXT;
}
private:
double sqrt_s;
double m1;
// Inputs
Value<double> s12;
Value<double> s123;
Value<double> s1234;
Value<LorentzVector> m_p2;
Value<LorentzVector> m_p3;
Value<LorentzVector> m_p4;
// Output
std::shared_ptr<SolutionCollection> solutions = produce<SolutionCollection>("solutions");
};
REGISTER_MODULE(SecondaryBlockA)
.Input("s12")
.Input("s123")
.Input("s1234")
.Input("p1")
.Input("p2")
.Input("p3")
.Input("p4")
.Output("solutions")
.GlobalAttr("energy: double")
.Attr("m1: double=0");