Belle II Software development
FourVector.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * Forked from https://github.com/iLCSoft/MarlinKinfit *
6 * *
7 * Further information about the fit engine and the user interface *
8 * provided in MarlinKinfit can be found at *
9 * https://www.desy.de/~blist/kinfit/doc/html/ *
10 * and in the LCNotes LC-TOOL-2009-001 and LC-TOOL-2009-004 available *
11 * from http://www-flc.desy.de/lcnotes/ *
12 * *
13 * See git log for contributors and copyright holders. *
14 * This file is licensed under LGPL-3.0, see LICENSE.md. *
15 **************************************************************************/
16
17#ifdef MARLIN_USE_ROOT
18
19#include "analysis/OrcaKInFit/FourVector.h"
20
21#include <cmath>
22
23#undef NDEBUG
24#include <cassert>
25
26#include <TRandom3.h>
27
28namespace Belle2 {
33 namespace OrcaKinFit {
34
35 FourVector& FourVector::boost(const FourVector& P)
36 {
37 // See CERNLIB U101 for a description
38
39 double pP = -(p * P.p);
40 double e = getE();
41 double M = P.getM();
42
43 E = (e * P.getE() - pP) / M;
44 p = p - ((pP / (P.getE() + M) - e) / M) * P.p;
45
46 return *this;
47 }
48
49 void FourVector::decayto(FourVector& d1, FourVector& d2) const
50 {
51 // Let this particle decay isotropically into 4-vectors d1 and d2;
52 // d1 and d2 must have definite mass at beginning
53 using std::abs;
54 using std::sqrt;
55 using std::pow;
56
57 double M2 = getM2();
58 double M = getM();;
59 double m1 = d1.getM();
60 double m2 = d2.getM();
61
62 double randoms[2];
63 gRandom->RndmArray(2, randoms);
64
65 assert(m1 + m2 <= M);
66
67 double pstar = 0.5 * sqrt(abs((M2 - pow(m1 + m2, 2)) * (M2 - pow(m1 - m2, 2)))) / M;
68 double phistar = 2 * M_PI * randoms[0];
69 double costhetastar = 2 * randoms[1] - 1;
70 double sinthetastar = sqrt(abs(1 - costhetastar * costhetastar));
71 double E1 = sqrt(m1 * m1 + pstar * pstar);
72 double E2 = sqrt(m2 * m2 + pstar * pstar);
73
74
75 d1 = FourVector(E1, pstar * sinthetastar * cos(phistar),
76 pstar * sinthetastar * sin(phistar),
77 pstar * costhetastar);
78 d2 = FourVector(E2, -pstar * sinthetastar * cos(phistar),
79 -pstar * sinthetastar * sin(phistar),
80 -pstar * costhetastar);
81
82 d1.boost(*this);
83 d2.boost(*this);
84
85 }
86
87 }// end OrcaKinFit namespace
89} // end Belle2 namespace
90
91#endif // MARLIN_USE_ROOT
Yet another four vector class, with metric +—.
Definition FourVector.h:43
FourVector()
Default constructor.
Definition FourVector.h:111
double E
The energy / 0 component.
Definition FourVector.h:107
double getM2() const
Returns the mass squared / magnitude squared.
Definition FourVector.h:138
double getM() const
Returns the mass / magnitude.
Definition FourVector.h:139
ThreeVector p
The momentum three vector.
Definition FourVector.h:108
double getE() const
Returns the energy / 0 component.
Definition FourVector.h:127
double sqrt(double a)
sqrt for double
Definition beamHelpers.h:28
Abstract base class for different kinds of events.