20 #include <momemta/ParameterSet.h> 21 #include <momemta/Module.h> 22 #include <momemta/Solution.h> 23 #include <momemta/Types.h> 91 sqrt_s = parameters.globalParameters().get<
double>(
"energy");
92 pT_is_met = parameters.get<
bool>(
"pT_is_met",
false);
94 m1 = parameters.get<
double>(
"m1", 0.);
96 s12 = get<double>(parameters.get<
InputTag>(
"s12"));
98 p2 = get<LorentzVector>(parameters.get<
InputTag>(
"p2"));
100 if (parameters.exists(
"branches")) {
101 auto branches_tags = parameters.get<std::vector<InputTag>>(
"branches");
102 for (
auto& t: branches_tags)
103 m_branches.push_back(get<LorentzVector>(t));
109 if (parameters.exists(
"met")) {
110 met_tag = parameters.get<
InputTag>(
"met");
115 m_met = get<LorentzVector>(met_tag);
118 virtual Status
work()
override {
128 const double p11 =
SQ(m1);
129 const double p22 = p2->M2();
132 if (*s12 >=
SQ(sqrt_s) || *s12 <= p11 + p22)
140 for (
size_t i = 0; i < m_branches.size(); i++) {
141 pT += *m_branches[i];
148 const double A = - (*s12 - p11 - p22 - 2 * (pT.Px() * p2->Px() + pT.Py() * p2->Py())) / (2 * p2->Pz());
149 const double B = p2->E() / p2->Pz();
150 const double C = -
SQ(pT.Px()) -
SQ(pT.Py());
153 const double a = 1 -
SQ(B);
154 const double b = - 2 * A * B;
155 const double c = C -
SQ(A) - p11;
157 std::vector<double> E1;
164 for (
unsigned int i = 0; i < E1.size(); i++){
165 const double e1 = E1.at(i);
167 if (e1 <= 0)
continue;
169 LorentzVector p1(-pT.Px(), -pT.Py(), A + B*e1, e1);
172 LorentzVector tot = p1 + *p2;
173 for (
size_t i = 0; i < m_branches.size(); i++)
174 tot += *m_branches[i];
175 double q1Pz = std::abs(tot.Pz() + tot.E()) / 2.;
176 double q2Pz = std::abs(tot.Pz() - tot.E()) / 2.;
177 if (q1Pz > sqrt_s / 2 || q2Pz > sqrt_s / 2)
182 LOG(trace) <<
"[BlockB] Throwing solution because of invalid mass. " <<
183 "Expected " << m1 <<
", got " << p1.M();
190 LOG(trace) <<
"[BlockB] Throwing solution because of invalid invariant mass. " <<
191 "Expected " << *s12 <<
", got " << (p1 + *p2).M2();
196 const double inv_jacobian =
SQ(sqrt_s) * std::abs(p2->Pz() * e1 - p2->E() * p1.Pz());
198 Solution s { {p1}, M_PI / inv_jacobian,
true };
199 solutions->push_back(s);
202 return solutions->size() > 0 ? Status::OK : Status::NEXT;
213 std::vector<Value<LorentzVector>> m_branches;
217 std::shared_ptr<SolutionCollection> solutions = produce<SolutionCollection>(
"solutions");
223 .OptionalInputs(
"branches")
224 .Input(
"met=met::p4")
226 .GlobalAttr(
"energy:double")
227 .Attr(
"pT_is_met:bool=false")
228 .Attr(
"m1:double=0.");
bool ApproxComparison(double value, double expected)
Compare two doubles and return true if they are approximatively equal.
Generic solution structure representing a set of particles, along with its jacobian.
bool solveQuadratic(const double a, const double b, const double c, std::vector< double > &roots, bool verbose=false)
Finds the real solutions to .
virtual Status work() override
Main function.
Parent class for all the modules.
A class encapsulating a lua table.
Module(PoolPtr pool, const std::string &name)
Constructor.
Final (main) Block B, describing