Belle II Software development
HarmonicMoments Class Reference

Class to calculate the Harmonic moments up to order 8 with respect to a given axis. More...

#include <HarmonicMoments.h>

Public Member Functions

 HarmonicMoments ()
 Default constructor.
 
 HarmonicMoments (const std::vector< ROOT::Math::XYZVector > &momenta, const ROOT::Math::XYZVector &axis)
 Constructor.
 
 ~HarmonicMoments ()
 Default destructor.
 
void setMomenta (const std::vector< ROOT::Math::XYZVector > &momenta)
 Sets the list of momenta, overwriting whatever list has been set before.
 
void setAxis (ROOT::Math::XYZVector axis)
 Sets the reference axis.
 
void calculateBasicMoments ()
 Calculates the moments up to order 4.
 
void calculateAllMoments ()
 Calculates the moments up to order 8.
 
double getMoment (short i, double sqrts) const
 Returns the moment of order i.
 

Private Attributes

double m_moment [9] = {0.}
 The harmonic moments.
 
std::vector< ROOT::Math::XYZVector > m_momenta
 The list of particles.
 
ROOT::Math::XYZVector m_axis
 The reference axis.
 

Detailed Description

Class to calculate the Harmonic moments up to order 8 with respect to a given axis.

Since the most common user case is the calculation of the moments up to order 4, and the calculation of the momenta 5-8 takes much longer, two methods have been implemented. HarmonicMoments::calculateBasicMoments will calculate the moments up to 4, while HarmonicMoments::calculateAllMoments will perform the calculation up to order 8. The two options have been implemented in two separate methods instead of using an if condition simply to minimize the computing time.

Definition at line 28 of file HarmonicMoments.h.

Constructor & Destructor Documentation

◆ HarmonicMoments() [1/2]

HarmonicMoments ( )
inline

Default constructor.

Definition at line 34 of file HarmonicMoments.h.

35 {
36 m_axis.SetXYZ(0., 0., 0.);
37 };
ROOT::Math::XYZVector m_axis
The reference axis.

◆ HarmonicMoments() [2/2]

HarmonicMoments ( const std::vector< ROOT::Math::XYZVector > &  momenta,
const ROOT::Math::XYZVector &  axis 
)
inline

Constructor.

Parameters
momentaA vector of XYZVectors containing the 3-momenta to be used to the moments' calculation
axisThe reference axis

Definition at line 44 of file HarmonicMoments.h.

45 {
46 m_momenta.clear();
47 m_momenta = momenta;
48 m_axis = axis;
49 };
std::vector< ROOT::Math::XYZVector > m_momenta
The list of particles.

◆ ~HarmonicMoments()

~HarmonicMoments ( )
inline

Default destructor.

Definition at line 54 of file HarmonicMoments.h.

54{};

Member Function Documentation

◆ calculateAllMoments()

void calculateAllMoments ( )

Calculates the moments up to order 8.

The execution time of this function is significantly longer than calculateBasicMoments().

Definition at line 42 of file HarmonicMoments.cc.

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.

◆ calculateBasicMoments()

void calculateBasicMoments ( )

Calculates the moments up to order 4.

Definition at line 16 of file HarmonicMoments.cc.

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}

◆ getMoment()

double getMoment ( short  i,
double  sqrts 
) const
inline

Returns the moment of order i.

Parameters
ithe order (0-8)
sqrtsthe center of mass energy
Returns
the harmonic moment, not normalized to sqrt(s)

Definition at line 94 of file HarmonicMoments.h.

95 {
96 if (i < 0 || i > 8)
97 return NAN;
98 else
99 return m_moment[i] / sqrts;
100 }

◆ setAxis()

void setAxis ( ROOT::Math::XYZVector  axis)
inline

Sets the reference axis.

Parameters
axisThe reference axis

Definition at line 71 of file HarmonicMoments.h.

72 {
73 m_axis = axis;
74 return;
75 };

◆ setMomenta()

void setMomenta ( const std::vector< ROOT::Math::XYZVector > &  momenta)
inline

Sets the list of momenta, overwriting whatever list has been set before.

Parameters
momentaA vector of XYZVectors containing the 3-momenta to be used to the moments' calculation

Definition at line 60 of file HarmonicMoments.h.

61 {
62 m_momenta.clear();
63 m_momenta = momenta;
64 return;
65 };

Member Data Documentation

◆ m_axis

ROOT::Math::XYZVector m_axis
private

The reference axis.

Definition at line 105 of file HarmonicMoments.h.

◆ m_moment

double m_moment[9] = {0.}
private

The harmonic moments.

Definition at line 103 of file HarmonicMoments.h.

◆ m_momenta

std::vector<ROOT::Math::XYZVector> m_momenta
private

The list of particles.

Definition at line 104 of file HarmonicMoments.h.


The documentation for this class was generated from the following files: