Belle II Software  release-06-02-00
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 #include "TVector3.h"
12 
13 using namespace Belle2;
14 
15 
16 
18 {
19  // Loop over the particles' momenta
20  for (auto& p : m_momenta) {
21  // Gets momentum and costheta of the vector
22  double pMag = p.Mag();
23  double cTheta = p.Dot(m_axis) / pMag;
24 
25  // Fills the momenta.
26  // This part is quite ugly, but hard-coding the Legendre polynomials makes the code
27  // much faster than using the boost libraries, which are implementing the recursive formulas.
28  // This implementation should also be faster than a switch...case one.
29  double cTheta2 = cTheta * cTheta;
30  double cTheta3 = cTheta2 * cTheta;
31  double cTheta4 = cTheta2 * cTheta2;
32 
33  m_moment[0] += pMag;
34  m_moment[1] += pMag * cTheta;
35  m_moment[2] += pMag * 0.5 * (3.*cTheta2 - 1);
36  m_moment[3] += pMag * 0.5 * (5.*cTheta3 - 3.*cTheta);
37  m_moment[4] += pMag * 0.125 * (35.*cTheta4 - 30.*cTheta2 + 3.);
38  }
39  return;
40 }
41 
42 
44 {
45  // Loop over the particles' momenta
46  for (auto& p : m_momenta) {
47  // gets momentum and costheta of the vector
48  double pMag = p.Mag();
49  double cTheta = p.Dot(m_axis) / pMag;
50 
51  // Fills the momenta.
52  // This part is quite ugly, but hard-coding the Legendre polynomials makes the code
53  // much faster than using the boost libraries, which are implementing the recursive formulas.
54  // This implementation should also be faster than a switch...case one.
55  double cTheta2 = cTheta * cTheta;
56  double cTheta3 = cTheta2 * cTheta;
57  double cTheta4 = cTheta2 * cTheta2;
58  double cTheta5 = cTheta4 * cTheta;
59  double cTheta6 = cTheta3 * cTheta3;
60  double cTheta7 = cTheta6 * cTheta;
61  double cTheta8 = cTheta4 * cTheta4;
62 
63  m_moment[0] += pMag;
64  m_moment[1] += pMag * cTheta;
65  m_moment[2] += pMag * 0.5 * (3.*cTheta2 - 1);
66  m_moment[3] += pMag * 0.5 * (5.*cTheta3 - 3.*cTheta);
67  m_moment[4] += pMag * 0.125 * (35.*cTheta4 - 30.*cTheta2 + 3.);
68  m_moment[5] += pMag * 0.125 * (63.*cTheta5 - 70 * cTheta3 + 15.*cTheta);
69  m_moment[6] += pMag * 0.0625 * (231.*cTheta6 - 315 * cTheta4 + 105 * cTheta2 - 5.);
70  m_moment[7] += pMag * 0.0625 * (429.*cTheta7 - 693.*cTheta5 + 315.*cTheta3 - 35.*cTheta);
71  m_moment[8] += pMag * 0.0078125 * (6435.*cTheta8 - 12012.*cTheta6 + 6930.*cTheta4 - 1260.*cTheta2 + 35.);
72  }
73  return;
74 }
double m_moment[9]
The harmonic moments.
void calculateAllMoments()
Calculates the moments up to order 8.
void calculateBasicMoments()
Calculates the moments up to order 4.
TVector3 m_axis
The reference axis.
std::vector< TVector3 > m_momenta
The list of particles.
Abstract base class for different kinds of events.