Belle II Software  release-05-01-25
Thrust.cc
1 #include <analysis/ContinuumSuppression/Thrust.h>
2 
3 using namespace Belle2;
4 
5 TVector3 Thrust::calculateThrust(const std::vector<TVector3>& momenta)
6 {
7 
8  decltype(momenta.begin()) p;
9  decltype(momenta.begin()) q;
10  decltype(momenta.begin()) loopcount;
11 
12  const auto begin = momenta.begin();
13  const auto end = momenta.end();
14 
15  double sump = 0;
16  for (p = begin; p != end; p++)
17  sump += (*p).Mag();
18 
19 
20  TVector3 Axis;
21 
22  // Thrust and thrust vectors
23 
24  double Thru = 0;
25  for (p = begin; p != end; p++) {
26  TVector3 rvec(*p);
27  if (rvec.z() <= 0.0) rvec = -rvec;
28 
29  double s = rvec.Mag();
30  if (s != 0.0) rvec *= (1 / s);
31 
32  for (loopcount = begin; loopcount != end; loopcount++) {
33  TVector3 rprev(rvec);
34  rvec = TVector3(); // clear
35 
36  for (q = begin; q != end; q++) {
37  const TVector3 qvec(*q);
38  rvec += (qvec.Dot(rprev) >= 0) ? qvec : - qvec;
39  }
40 
41  for (q = begin; q != end; q++) {
42  const TVector3 qvec(*q);
43  if (qvec.Dot(rvec) * qvec.Dot(rprev) < 0) break;
44  }
45 
46  if (q == end) break;
47  }
48 
49  double ttmp = 0.0;
50  for (q = begin; q != end; q++) {
51  const TVector3 qvec = *q;
52  ttmp += std::fabs(qvec.Dot(rvec));
53  }
54  ttmp /= (sump * rvec.Mag());
55  rvec *= 1 / rvec.Mag();
56  if (ttmp > Thru) {
57  Thru = ttmp;
58  Axis = rvec;
59  }
60  }
61  Axis *= Thru;
62  return Axis;
63 }
Belle2::Thrust::calculateThrust
static TVector3 calculateThrust(const std::vector< TVector3 > &momenta)
calculates the thrust axis
Definition: Thrust.cc:5
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19