Belle II Software  release-08-01-10
FoxWolfram Class Reference

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

#include <FoxWolfram.h>

Collaboration diagram for FoxWolfram:

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. More...
 
void calculateAllMoments ()
 Method to perform the calculation of the moments up to order 8. More...
 
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. More...
 

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.

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
std::vector< ROOT::Math::XYZVector > m_momenta
The particle's momenta.
Definition: FoxWolfram.h:94

◆ 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.

◆ 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]; }

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