Belle II Software development
FoxWolfram Class Reference

Class to calculate the Fox-Wolfram moments up to order 8. More...

#include <FoxWolfram.h>

Public Member Functions

 FoxWolfram ()
 Default constructor.
 
 FoxWolfram (const std::vector< ROOT::Math::XYZVector > &momenta)
 Constructor with an array of 3-momenta.
 
 ~FoxWolfram ()
 Default destructor.
 
void calculateBasicMoments ()
 Method to perform the calculation of the moments up to order 4, which are the most relevant ones.
 
void calculateAllMoments ()
 Method to perform the calculation of the moments up to order 8.
 
void setMomenta (const std::vector< ROOT::Math::XYZVector > &momenta)
 Sets the list of momenta used for the FW moment calculation, overwriting whatever list has been set before.
 
double getH (int i) const
 Returns the i-th moment.
 
double getR (int i) const
 Returns the i-th moment normalized to the 0th-order moment.
 

Private Attributes

double m_moment [9] = {0.}
 The moments.
 
std::vector< ROOT::Math::XYZVector > m_momenta
 The particle's momenta.
 

Detailed Description

Class to calculate the Fox-Wolfram moments up to order 8.

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. FoxWolfram::calculateBasicMoments will calculate the moments up to 4, while FoxWolfram::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 FoxWolfram.h.

Constructor & Destructor Documentation

◆ FoxWolfram()

FoxWolfram ( const std::vector< ROOT::Math::XYZVector > &  momenta)
inlineexplicit

Constructor with an array of 3-momenta.

Definition at line 40 of file FoxWolfram.h.

41 {
42 m_momenta.clear();
43 m_momenta = momenta;
44 };
std::vector< ROOT::Math::XYZVector > m_momenta
The particle's momenta.
Definition: FoxWolfram.h:94

◆ ~FoxWolfram()

~FoxWolfram ( )
inline

Default destructor.

Definition at line 50 of file FoxWolfram.h.

50{};

Member Function Documentation

◆ calculateAllMoments()

void calculateAllMoments ( )

Method to perform the calculation of the moments up to order 8.

It adds a significant overhead to the total FW moments calculation time, so it should be used for debugging or development studies.

Definition at line 58 of file FoxWolfram.cc.

59{
60 // clear the momenta, in case someone calls this function twice
61 for (double& i : m_moment)
62 i = 0.;
63
64 const auto begin = m_momenta.begin();
65 const auto end = m_momenta.end();
66
67 // loops over the vector pairs
68 for (auto iter1 = begin; iter1 != end; iter1++) {
69 const XYZVector pVec1 = (*iter1);
70 double pMag1 = pVec1.R();
71
72 // avoids to iterate twice over the same pairs
73 for (auto iter2 = iter1; iter2 != end; iter2++) {
74 const XYZVector pVec2 = (*iter2);
75 double magProd = pMag1 * pVec2.R(); // product of the vector's magnitudes
76 double cTheta = pVec1.Dot(pVec2) / magProd; // costheta_ij
77
78 // Since the FW moment definition requires to double count all the
79 // pairs of different particles, but the smart loop implemented here doesn't,
80 // multiply each entry by 2.
81 if (iter1 != iter2) magProd *= 2;
82
83 // Fills the moments' list.
84 // This part is quite ugly, but hard-coding the Legendre polynomials makes the code
85 // much faster than using the boost libraries, which are implementing the recursive formulas.
86 // This implementation should also be faster than a switch...case one.
87 double cTheta2 = cTheta * cTheta;
88 double cTheta3 = cTheta2 * cTheta;
89 double cTheta4 = cTheta2 * cTheta2;
90 double cTheta5 = cTheta4 * cTheta;
91 double cTheta6 = cTheta3 * cTheta3;
92 double cTheta7 = cTheta6 * cTheta;
93 double cTheta8 = cTheta4 * cTheta4;
94
95 m_moment[0] += magProd;
96 m_moment[1] += magProd * cTheta;
97 m_moment[2] += magProd * 0.5 * (3.*cTheta2 - 1);
98 m_moment[3] += magProd * 0.5 * (5.*cTheta3 - 3.*cTheta);
99 m_moment[4] += magProd * 0.125 * (35.*cTheta4 - 30.*cTheta2 + 3.);
100 m_moment[5] += magProd * 0.125 * (63.*cTheta5 - 70 * cTheta3 + 15.*cTheta);
101 m_moment[6] += magProd * 0.0625 * (231.*cTheta6 - 315 * cTheta4 + 105 * cTheta2 - 5.);
102 m_moment[7] += magProd * 0.0625 * (429.*cTheta7 - 693.*cTheta5 + 315.*cTheta3 - 35.*cTheta);
103 m_moment[8] += magProd * 0.0078125 * (6435.*cTheta8 - 12012.*cTheta6 + 6930.*cTheta4 - 1260.*cTheta2 + 35.);
104 }
105 }
106 return;
107}
double m_moment[9]
The moments.
Definition: FoxWolfram.h:93

◆ calculateBasicMoments()

void calculateBasicMoments ( )

Method to perform the calculation of the moments up to order 4, which are the most relevant ones.

The momenta up to order 8 can be calculated calling FoxWolfram::calculateAllMoments().

Definition at line 14 of file FoxWolfram.cc.

15{
16 // clear the momenta, in case someone calls this function twice
17 for (double& i : m_moment)
18 i = 0.;
19
20 const auto begin = m_momenta.begin();
21 const auto end = m_momenta.end();
22
23 // loops over the vector pairs
24 for (auto iter1 = begin; iter1 != end; iter1++) {
25 const XYZVector pVec1 = (*iter1);
26 double pMag1 = pVec1.R();
27
28 // avoids to iterate twice over the same pairs
29 for (auto iter2 = iter1; iter2 != end; iter2++) {
30 const XYZVector pVec2 = (*iter2);
31 double magProd = pMag1 * pVec2.R(); // product of the vector's magnitudes
32 double cTheta = pVec1.Dot(pVec2) / magProd; // costheta_ij
33
34 // Since the FW moment definition requires to double count all the
35 // pairs of different particles, but the smart loop implemented here doesn't,
36 // multiply each entry by 2.
37 if (iter1 != iter2) magProd *= 2;
38
39 // Fills the moments' list.
40 // This part is quite ugly, but hard-coding the Legendre polynomials makes the code
41 // much faster than using the boost libraries, which are implementing the recursive formulas.
42 // This implementation should also be faster than a switch...case one.
43 double cTheta2 = cTheta * cTheta;
44 double cTheta3 = cTheta2 * cTheta;
45 double cTheta4 = cTheta2 * cTheta2;
46 m_moment[0] += magProd;
47 m_moment[1] += magProd * cTheta;
48 m_moment[2] += magProd * 0.5 * (3.*cTheta2 - 1);
49 m_moment[3] += magProd * 0.5 * (5.*cTheta3 - 3.*cTheta);
50 m_moment[4] += magProd * 0.125 * (35.*cTheta4 - 30.*cTheta2 + 3.);
51 }
52 }
53 return;
54}

◆ getH()

double getH ( int  i) const
inline

Returns the i-th moment.

Definition at line 83 of file FoxWolfram.h.

83{ return (i < 0 || i > 8) ? NAN : m_moment[i]; }

◆ getR()

double getR ( int  i) const
inline

Returns the i-th moment normalized to the 0th-order moment.

These are the quantites normally used for the event shape characterization and the continuum suppression.

Definition at line 89 of file FoxWolfram.h.

89{ return (i < 0 || i > 8 || m_moment[0] == 0) ? NAN : m_moment[i] / m_moment[0]; }

◆ setMomenta()

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

Sets the list of momenta used for the FW moment calculation, overwriting whatever list has been set before.

Definition at line 73 of file FoxWolfram.h.

74 {
75 m_momenta.clear();
76 m_momenta = momenta;
77 return;
78 };

Member Data Documentation

◆ m_moment

double m_moment[9] = {0.}
private

The moments.

Definition at line 93 of file FoxWolfram.h.

◆ m_momenta

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

The particle's momenta.

Definition at line 94 of file FoxWolfram.h.


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