Belle II Software  release-08-01-10
KsfwMoments.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 
10 // //
11 // KsfwMoments.cc //
12 // //
13 // moment-calculation of the k_sfw //
14 // improved Super-Fox-Wolfram moments //
15 // to be used with rooksfw.{cc,h} //
16 // //
17 // M. Nakao //
18 // //
20 
21 #include <analysis/ContinuumSuppression/KsfwMoments.h>
22 
23 
24 namespace Belle2 {
33  inline double legendre(const double z, const int i)
34  {
35  switch (i) {
36  case 0: return 1.;
37  case 1: return z;
38  case 2: return 1.5 * z * z - 0.5;
39  case 3: return z * (2.5 * z * z - 1.5);
40  case 4: return (4.375 * z * z * z * z - 3.75 * z * z + 0.375);
41  default: return 0;
42  }
43  }
44 // ----------------------------------------------------------------------
45 // Constructor
46 // (copied from k_sfw.cc with minimum modification)
47 // ----------------------------------------------------------------------
48  KsfwMoments::KsfwMoments(double Hso0_max,
49  std::vector<std::pair<ROOT::Math::XYZVector, int>> p3_cms_q_sigA,
50  std::vector<std::pair<ROOT::Math::XYZVector, int>> p3_cms_q_sigB,
51  std::vector<std::pair<ROOT::Math::XYZVector, int>> p3_cms_q_roe,
52  const ROOT::Math::PxPyPzEVector& p_cms_missA,
53  const ROOT::Math::PxPyPzEVector& p_cms_missB,
54  const double et[2]
55  )
56  {
57  // Private member needs to be initialized. Here it is initialized to -1 (illegal value).
58  m_uf = -1;
59 
60  m_et[0] = et[0];
61  m_et[1] = et[1];
62 
63  m_mm2[0] = p_cms_missA.E() > 0
64  ? p_cms_missA.mag2()
65  : -p_cms_missA.E() * p_cms_missA.E() - p_cms_missA.P2();
66  m_mm2[1] = p_cms_missB.E() > 0
67  ? p_cms_missB.mag2()
68  : -p_cms_missB.E() * p_cms_missB.E() - p_cms_missB.P2();
69 
70  //========================
71  // Calculate discriminants
72  //========================
73  std::vector<std::pair<ROOT::Math::XYZVector, int>>::iterator pqi, pqj;
74 
75  // Calculate Hso components
76  for (int i = 0; i < 3; i++) {
77  for (int k = 0; k < 5; k++) {
78  m_Hso[0][i][k] = m_Hso[1][i][k] = 0;
79  }
80  }
81 
82  // Signal A (use_finalstate_for_sig == 0)
83  for (pqi = p3_cms_q_sigA.begin(); pqi != p3_cms_q_sigA.end(); ++pqi) {
84  const double pi_mag((pqi->first).R());
85  for (pqj = p3_cms_q_roe.begin(); pqj != p3_cms_q_roe.end(); ++pqj) {
86  const double pj_mag((pqj->first).R());
87  const double ij_cos((pqi->first).Dot(pqj->first) / pi_mag / pj_mag);
88  const int c_or_n(0 == (pqj->second) ? 1 : 0); // 0: charged 1: neutral
89  for (int k = 0; k < 5; k++) {
90  m_Hso[0][c_or_n][k] += (k % 2)
91  ? (pqi->second) * (pqj->second) * pj_mag * legendre(ij_cos, k)
92  : pj_mag * legendre(ij_cos, k);
93  }
94  }
95  const double p_miss_mag(p_cms_missA.P());
96  const double i_miss_cos((pqi->first).Dot(p_cms_missA.Vect()) / pi_mag / p_miss_mag);
97  for (int k = 0; k < 5; k++) {
98  m_Hso[0][2][k] += (k % 2) ? 0 : p_miss_mag * legendre(i_miss_cos, k);
99  }
100  }
101 
102  // Signal B (use_finalstate_for_sig == 1)
103  for (pqi = p3_cms_q_sigB.begin(); pqi != p3_cms_q_sigB.end(); ++pqi) {
104  const double pi_mag((pqi->first).R());
105  for (pqj = p3_cms_q_roe.begin(); pqj != p3_cms_q_roe.end(); ++pqj) {
106  const double pj_mag((pqj->first).R());
107  const double ij_cos((pqi->first).Dot(pqj->first) / pi_mag / pj_mag);
108  const int c_or_n(0 == (pqj->second) ? 1 : 0); // 0: charged 1: neutral
109  for (int k = 0; k < 5; k++) {
110  m_Hso[1][c_or_n][k] += (k % 2)
111  ? (pqi->second) * (pqj->second) * pj_mag * legendre(ij_cos, k)
112  : pj_mag * legendre(ij_cos, k);
113  }
114  }
115  const double p_miss_mag(p_cms_missB.P());
116  const double i_miss_cos((pqi->first).Dot(p_cms_missB.Vect()) / pi_mag / p_miss_mag);
117  for (int k = 0; k < 5; k++) {
118  m_Hso[1][2][k] += (k % 2) ? 0 : p_miss_mag * legendre(i_miss_cos, k);
119  }
120  }
121 
122  // Add missing to the lists
123  std::vector<std::pair<ROOT::Math::XYZVector, int>> p3_cms_q_roeA(p3_cms_q_roe), p3_cms_q_roeB(p3_cms_q_roe);
124  p3_cms_q_roeA.emplace_back(p_cms_missA.Vect(), 0);
125  p3_cms_q_roeB.emplace_back(p_cms_missB.Vect(), 0);
126 
127  // Calculate Hoo components
128  for (int k = 0; k < 5; k++) {
129  m_Hoo[0][k] = m_Hoo[1][k] = 0;
130  }
131  for (pqi = p3_cms_q_roeA.begin(); pqi != p3_cms_q_roeA.end(); ++pqi) {
132  const double pi_mag((pqi->first).R());
133  for (pqj = p3_cms_q_roeA.begin(); pqj != pqi; ++pqj) {
134  const double pj_mag((pqj->first).R());
135  const double ij_cos((pqi->first).Dot(pqj->first) / pi_mag / pj_mag);
136  for (int k = 0; k < 5; k++) {
137  m_Hoo[0][k] += (k % 2)
138  ? (pqi->second) * (pqj->second) * pi_mag * pj_mag * legendre(ij_cos, k)
139  : pi_mag * pj_mag * legendre(ij_cos, k);
140  }
141  }
142  }
143  for (pqi = p3_cms_q_roeB.begin(); pqi != p3_cms_q_roeB.end(); ++pqi) {
144  const double pi_mag((pqi->first).R());
145  for (pqj = p3_cms_q_roeB.begin(); pqj != pqi; ++pqj) {
146  const double pj_mag((pqj->first).R());
147  const double ij_cos((pqi->first).Dot(pqj->first) / pi_mag / pj_mag);
148  for (int k = 0; k < 5; k++) {
149  m_Hoo[1][k] += (k % 2)
150  ? (pqi->second) * (pqj->second) * pi_mag * pj_mag * legendre(ij_cos, k)
151  : pi_mag * pj_mag * legendre(ij_cos, k);
152  }
153  }
154  }
155 
156  // Normalize so that it does not dependent on delta_e
157  for (int k = 0; k < 5; k++) {
158  for (int j = 0; j < ((k % 2) ? 1 : 3); j++) {
159  m_Hso[0][j][k] /= Hso0_max;
160  m_Hso[1][j][k] /= Hso0_max;
161  }
162  m_Hoo[0][k] /= (Hso0_max * Hso0_max);
163  m_Hoo[1][k] /= (Hso0_max * Hso0_max);
164  }
165 
166  }
167 
169 } // Belle2 namespace
double et(int uf=-1) const
Returns calculated transverse energy.
Definition: KsfwMoments.h:93
double m_et[2]
Transverse energy.
Definition: KsfwMoments.h:127
int m_uf
Flag that specifiies we are using the final state for signal.
Definition: KsfwMoments.h:124
double m_Hso[2][3][5]
KSFW moments.
Definition: KsfwMoments.h:125
KsfwMoments()
Initialize KSFW moments, et, and mm2 to 0.
Definition: KsfwMoments.h:41
double m_mm2[2]
Missing mass squared.
Definition: KsfwMoments.h:128
double m_Hoo[2][5]
KSFW moments.
Definition: KsfwMoments.h:126
double legendre(const double z, const int i)
Legendre polynomials.
Definition: KsfwMoments.cc:33
Abstract base class for different kinds of events.