Belle II Software light-2406-ragdoll
HarmonicMoments.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9
10#include <analysis/ContinuumSuppression/HarmonicMoments.h>
11
12using namespace Belle2;
13
14
15
17{
18 // Loop over the particles' momenta
19 for (auto& p : m_momenta) {
20 // Gets momentum and costheta of the vector
21 double pMag = p.R();
22 double cTheta = p.Dot(m_axis) / pMag;
23
24 // Fills the momenta.
25 // This part is quite ugly, but hard-coding the Legendre polynomials makes the code
26 // much faster than using the boost libraries, which are implementing the recursive formulas.
27 // This implementation should also be faster than a switch...case one.
28 double cTheta2 = cTheta * cTheta;
29 double cTheta3 = cTheta2 * cTheta;
30 double cTheta4 = cTheta2 * cTheta2;
31
32 m_moment[0] += pMag;
33 m_moment[1] += pMag * cTheta;
34 m_moment[2] += pMag * 0.5 * (3.*cTheta2 - 1);
35 m_moment[3] += pMag * 0.5 * (5.*cTheta3 - 3.*cTheta);
36 m_moment[4] += pMag * 0.125 * (35.*cTheta4 - 30.*cTheta2 + 3.);
37 }
38 return;
39}
40
41
43{
44 // Loop over the particles' momenta
45 for (auto& p : m_momenta) {
46 // gets momentum and costheta of the vector
47 double pMag = p.R();
48 double cTheta = p.Dot(m_axis) / pMag;
49
50 // Fills the momenta.
51 // This part is quite ugly, but hard-coding the Legendre polynomials makes the code
52 // much faster than using the boost libraries, which are implementing the recursive formulas.
53 // This implementation should also be faster than a switch...case one.
54 double cTheta2 = cTheta * cTheta;
55 double cTheta3 = cTheta2 * cTheta;
56 double cTheta4 = cTheta2 * cTheta2;
57 double cTheta5 = cTheta4 * cTheta;
58 double cTheta6 = cTheta3 * cTheta3;
59 double cTheta7 = cTheta6 * cTheta;
60 double cTheta8 = cTheta4 * cTheta4;
61
62 m_moment[0] += pMag;
63 m_moment[1] += pMag * cTheta;
64 m_moment[2] += pMag * 0.5 * (3.*cTheta2 - 1);
65 m_moment[3] += pMag * 0.5 * (5.*cTheta3 - 3.*cTheta);
66 m_moment[4] += pMag * 0.125 * (35.*cTheta4 - 30.*cTheta2 + 3.);
67 m_moment[5] += pMag * 0.125 * (63.*cTheta5 - 70 * cTheta3 + 15.*cTheta);
68 m_moment[6] += pMag * 0.0625 * (231.*cTheta6 - 315 * cTheta4 + 105 * cTheta2 - 5.);
69 m_moment[7] += pMag * 0.0625 * (429.*cTheta7 - 693.*cTheta5 + 315.*cTheta3 - 35.*cTheta);
70 m_moment[8] += pMag * 0.0078125 * (6435.*cTheta8 - 12012.*cTheta6 + 6930.*cTheta4 - 1260.*cTheta2 + 35.);
71 }
72 return;
73}
double m_moment[9]
The harmonic moments.
std::vector< ROOT::Math::XYZVector > m_momenta
The list of particles.
ROOT::Math::XYZVector m_axis
The reference axis.
void calculateAllMoments()
Calculates the moments up to order 8.
void calculateBasicMoments()
Calculates the moments up to order 4.
Abstract base class for different kinds of events.
Definition: ClusterUtils.h:24