19 #include <momemta/ParameterSet.h> 20 #include <momemta/Module.h> 21 #include <momemta/Solution.h> 23 #include <momemta/InputTag.h> 24 #include <momemta/Types.h> 26 #include <Math/GenVector/VectorUtil.h> 81 sqrt_s(parameters.globalParameters().get<
double>(
"energy")) {
82 s12 = get<double>(parameters.get<
InputTag>(
"s12"));
83 s123 = get<double>(parameters.get<
InputTag>(
"s123"));
85 m_p1 = get<LorentzVector>(parameters.get<
InputTag>(
"p1"));
86 m_p2 = get<LorentzVector>(parameters.get<
InputTag>(
"p2"));
87 m_p3 = get<LorentzVector>(parameters.get<
InputTag>(
"p3"));
90 virtual Status
work()
override {
94 const double m1 = m_p1->M();
95 const double m2 = m_p2->M();
96 const double m3 = m_p3->M();
97 const double m1_squared =
SQ(m1);
98 const double m2_squared =
SQ(m2);
99 const double m3_squared =
SQ(m3);
102 if (*s123 >
SQ(sqrt_s) || *s12 > *s123 || m1_squared + m2_squared >= *s12 || *s12 + m3_squared >= *s123)
110 const double E2 = m_p2->E();
111 const double E3 = m_p3->E();
112 const double p2z = m_p2->Pz();
113 const double p3z = m_p3->Pz();
114 const double p2t = m_p2->Pt();
115 const double p3t = m_p3->Pt();
116 const double cosPhi12 = std::cos(ROOT::Math::VectorUtil::DeltaPhi(*m_p1, *m_p2));
117 const double cosPhi13 = std::cos(ROOT::Math::VectorUtil::DeltaPhi(*m_p1, *m_p3));
118 const double cosPhi23 = std::cos(ROOT::Math::VectorUtil::DeltaPhi(*m_p2, *m_p3));
120 const double denominator = cosPhi13 * p2z * p3t - cosPhi12 * p2t * p3z;
121 const double E2E3 = E2 * E3;
122 const double p2zp3z = p2z * p3z;
123 const double p2tp3t = p2t * p3t;
124 const double E3p2z_E2p3z = E3 * p2z - E2 * p3z;
125 const double p1t_linear = E3p2z_E2p3z / denominator;
126 const double p1t_indep = (p2z * (2 * (E2E3 - p2zp3z - cosPhi23 * p2tp3t) + m3_squared - *s123 + *s12) - p3z * (m1_squared + m2_squared - *s12)) / (2. * denominator);
128 const double p1z_linear = (cosPhi12 * E3 * p2t - cosPhi13 * E2 * p3t) / (-denominator);
129 const double p1z_indep = (-(cosPhi13 * p3t * (m1_squared + m2_squared - *s12)) + cosPhi12 * p2t * (2 * (E2E3 - cosPhi23 * p2tp3t - p2zp3z) + m3_squared + *s12 - *s123)) / (2 * (-denominator));
133 const double p1t_linear_squared =
SQ(p1t_linear);
134 const double p1t_indep_squared =
SQ(p1t_indep);
135 const double p1z_linear_squared =
SQ(p1z_linear);
136 const double p1z_indep_squared =
SQ(p1z_indep);
138 const double E1_indep = m1_squared + p1t_indep_squared + p1z_indep_squared;
139 const double E1_linear = 2 * (p1t_indep * p1t_linear + p1z_indep * p1z_linear);
140 const double E1_quadratic = -1 + p1t_linear_squared + p1z_linear_squared;
142 std::vector<double> E1_solutions;
143 bool foundSolution =
solveQuadratic(E1_quadratic, E1_linear, E1_indep, E1_solutions);
148 for (
const double& E1: E1_solutions) {
150 const double p1t = p1t_linear * E1 + p1t_indep;
151 if (E1 <= m1 || p1t < 0)
154 const double p1z = p1z_linear * E1 + p1z_indep;
155 const double phi1 = m_p1->Phi();
156 LorentzVector p1_sol;
158 p1t * std::cos(phi1),
159 p1t * std::sin(phi1),
165 LOG(trace) <<
"[SecondaryBlockB] Throwing solution because of invalid mass. " <<
166 "Expected " << m1 <<
", got " << p1_sol.M();
173 LOG(trace) <<
"[SecondaryBlockB] Throwing solution because of invalid invariant mass. " <<
174 "Expected " << *s123 <<
", got " << (p1_sol + *m_p2 + *m_p3).M2();
181 LOG(trace) <<
"[SecondaryBlockB] Throwing solution because of invalid invariant mass. " <<
182 "Expected " << *s12 <<
", got " << (p1_sol + *m_p2).M2();
188 const double jacobian = p1t / (64 *
CB(M_PI) * std::abs(cosPhi12 * p2t * (E1 * p3z - E3 * p1z) + cosPhi13 * p3t * (E2 * p1z - E1 * p2z) + p1t * E3p2z_E2p3z));
190 Solution solution { {p1_sol}, jacobian,
true };
191 solutions->push_back(solution);
193 return (solutions->size() > 0) ? Status::OK : Status::NEXT;
208 std::shared_ptr<SolutionCollection> solutions = produce<SolutionCollection>(
"solutions");
218 .GlobalAttr(
"energy: double");
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 .
Parent class for all the modules.
A class encapsulating a lua table.
Secondary Block B, describing
Module(PoolPtr pool, const std::string &name)
Constructor.
virtual Status work() override
Main function.