Belle II Software development
BParticle Class Reference

The Class for Masterclass particle information This class provides the data structure of the particle that are used by Belle II Masterclass application. More...

#include <BParticle.h>

Inheritance diagram for BParticle:

Public Member Functions

 BParticle ()
 Default constructor.
 
 BParticle (const BParticle &)=default
 Constructor using the particle.
 
BParticleoperator+= (const BParticle &)
 Operator to add particle.
 
 BParticle (float px, float py, float pz, float energy, float charge, SIMPLEPID pid, float logL_e=0, float logL_mu=0, float logL_pi=0, float logL_k=0, float logL_p=0, float logL_d=0)
 Constructor of fthe particle.
 
 ~BParticle ()
 Default destructor.
 
float px () const
 
float py () const
 
float pz () const
 z
 
float e () const
 
float GetMomentum () const
 Get the momentum of the particle.
 
float GetTransverseMomentum () const
 Get the transverse momentum of the particle.
 
float charge () const
 Get the particle charge.
 
SIMPLEPID pid () const
 Get the particle identity.
 
float logL_e () const
 Get the log likelihood for electron hypothesis.
 
float logL_mu () const
 Get the log likelihood for muon hypothesis.
 
float logL_pi () const
 Get the log likelihood for pion hypothesis.
 
float logL_k () const
 Get the log likelihood for kaon hypothesis.
 
float logL_p () const
 Get the log likelihood for proton hypothesis.
 
float logL_d () const
 Get the log likelihood for deuteron hypothesis.
 
float GetLogL (SIMPLEPID pid)
 Get the log likelihood for a particle hypothesis.
 
float GetPID (SIMPLEPID pid)
 Get the log likelihood ratio for a particle hypothesis with respect to all other hypotheses.
 
float GetBinPID (SIMPLEPID pid1, SIMPLEPID pid2)
 Get the binary log likelihood ratio for a particle hypothesis with respect to a second hypothesis.
 
float GetMass (SIMPLEPID pid)
 Get the mass of the particle with the identity.
 
float GetMass ()
 Get the mass of the particle.
 
void SetEnergyFromMass (float mass)
 Recalculate energy from particle mass and momentum.
 
void SetEnergyFromPid ()
 Recalculate energy from particle identity and momentum.
 
void SetPid (SIMPLEPID pid)
 Set particle identity.
 
int InMassRange (float mlower, float mupper)
 Test if the mass is in range.
 
BParticleoperator= (const BParticle &p)
 Assign a particle.
 

Private Attributes

float m_px
 x component of the particle momentum
 
float m_py
 y component of the particle momentum
 
float m_pz
 z component of the particle momentum
 
float m_e
 energy of the particle
 
float m_charge
 charge of the particle
 
SIMPLEPID m_pid
 particle identity
 
float m_logL_e
 log likelihood of the electron hypothesis
 
float m_logL_mu
 log likelihood of the muon hypothesis
 
float m_logL_pi
 log likelihood of the pion hypothesis
 
float m_logL_k
 log likelihood of the kaon hypothesis
 
float m_logL_p
 log likelihood of the proton hypothesis
 
float m_logL_d
 log likelihood of the deuteron hypothesis
 

Detailed Description

The Class for Masterclass particle information This class provides the data structure of the particle that are used by Belle II Masterclass application.

Definition at line 18 of file BParticle.h.

Constructor & Destructor Documentation

◆ BParticle() [1/2]

BParticle ( )
inline

Default constructor.

Definition at line 36 of file BParticle.h.

36{};

◆ BParticle() [2/2]

BParticle ( float  px,
float  py,
float  pz,
float  energy,
float  charge,
SIMPLEPID  pid,
float  logL_e = 0,
float  logL_mu = 0,
float  logL_pi = 0,
float  logL_k = 0,
float  logL_p = 0,
float  logL_d = 0 
)

Constructor of fthe particle.

Parameters
px- x component of the particle momentum
py- y component of the particle momentum
pz- z component of the particle momentum
energy- energy of the particle
charge- unit charge of the particle
pid- particle identity - hypothesis with the highest maximum likelihood
logL_e- log likelihood of the electron hypothesis
logL_mu- log likelihood of the muon hypothesis
logL_pi- log likelihood of the pion hypothesis
logL_k- log likelihood of the kaon hypothesis
logL_p- log likelihood of the proton hypothesis
logL_d- log likelihood of the deuteron hypothesis

Definition at line 13 of file BParticle.cc.

16{
17 m_px = px;
18 m_py = py;
19 m_pz = pz;
20 m_e = e;
22 m_pid = pid;
29}
float m_logL_pi
log likelihood of the pion hypothesis
Definition: BParticle.h:29
SIMPLEPID pid() const
Get the particle identity.
Definition: BParticle.h:101
float m_logL_p
log likelihood of the proton hypothesis
Definition: BParticle.h:31
float logL_pi() const
Get the log likelihood for pion hypothesis.
Definition: BParticle.h:116
float m_e
energy of the particle
Definition: BParticle.h:24
SIMPLEPID m_pid
particle identity
Definition: BParticle.h:26
float m_logL_mu
log likelihood of the muon hypothesis
Definition: BParticle.h:28
float m_py
y component of the particle momentum
Definition: BParticle.h:22
float m_charge
charge of the particle
Definition: BParticle.h:25
float px() const
Definition: BParticle.h:67
float m_logL_e
log likelihood of the electron hypothesis
Definition: BParticle.h:27
float charge() const
Get the particle charge.
Definition: BParticle.h:94
float logL_p() const
Get the log likelihood for proton hypothesis.
Definition: BParticle.h:126
float m_pz
z component of the particle momentum
Definition: BParticle.h:23
float logL_e() const
Get the log likelihood for electron hypothesis.
Definition: BParticle.h:106
float e() const
Definition: BParticle.h:79
float logL_mu() const
Get the log likelihood for muon hypothesis.
Definition: BParticle.h:111
float m_px
x component of the particle momentum
Definition: BParticle.h:21
float logL_k() const
Get the log likelihood for kaon hypothesis.
Definition: BParticle.h:121
float py() const
Definition: BParticle.h:71
float m_logL_k
log likelihood of the kaon hypothesis
Definition: BParticle.h:30
float m_logL_d
log likelihood of the deuteron hypothesis
Definition: BParticle.h:32
float logL_d() const
Get the log likelihood for deuteron hypothesis.
Definition: BParticle.h:131
float pz() const
z
Definition: BParticle.h:75

◆ ~BParticle()

~BParticle ( )
inline

Default destructor.

Definition at line 61 of file BParticle.h.

61{};

Member Function Documentation

◆ charge()

float charge ( ) const
inline

Get the particle charge.

Returns
particle unit charge

Definition at line 94 of file BParticle.h.

94{ return m_charge; };

◆ e()

float e ( ) const
inline
Returns
particle energy GeV

Definition at line 79 of file BParticle.h.

79{ return m_e; };

◆ GetBinPID()

float GetBinPID ( SIMPLEPID  pid1,
SIMPLEPID  pid2 
)

Get the binary log likelihood ratio for a particle hypothesis with respect to a second hypothesis.

Parameters
pid1particle identity
pid2particle identity
Returns
the binary log likelihood ratio for two particle hypotheses

Definition at line 71 of file BParticle.cc.

72{
73 return exp(GetLogL(pid1)) / (exp(GetLogL(pid1)) + exp(GetLogL(pid2)));
74}
float GetLogL(SIMPLEPID pid)
Get the log likelihood for a particle hypothesis.
Definition: BParticle.cc:48

◆ GetLogL()

float GetLogL ( SIMPLEPID  pid)

Get the log likelihood for a particle hypothesis.

Parameters
pidparticle identity
Returns
the log likelihood for a particle hypothesis

Definition at line 48 of file BParticle.cc.

49{
50 switch (pid) {
51 case ELECTRON: return m_logL_e;
52 case PION: return m_logL_pi;
53 case MUON: return m_logL_mu;
54 case KAON: return m_logL_k;
55 case PROTON: return m_logL_p;
56 case DEUTERON: return m_logL_d;
57 default: return 0;
58 }
59}

◆ GetMass() [1/2]

float GetMass ( )

Get the mass of the particle.

Returns
mass of the particle GeV/c2

Definition at line 99 of file BParticle.cc.

100{
101 float m2 = m_e * m_e - m_px * m_px - m_py * m_py - m_pz * m_pz;
102 if (m2 < 0) m2 = 0;
103 return sqrt(m2);
104}
double sqrt(double a)
sqrt for double
Definition: beamHelpers.h:28

◆ GetMass() [2/2]

float GetMass ( SIMPLEPID  pid)

Get the mass of the particle with the identity.

Parameters
pidparticle identity
Returns
mass of the particle GeV/c2

Definition at line 76 of file BParticle.cc.

77{
78
79 switch (pid) {
80 case PHOTON: return 0;
81 case ELECTRON: return 0.00051;
82 case PION: return 0.139;
83 case MUON: return 0.105;
84 case KAON: return 0.497;
85 case PROTON: return 0.938;
86 case JPSI: return 3.1;
87 case D: return 1.86;
88 case DSTAR: return 2.01;
89 case B: return 5.27;
90 case PHI: return 1.02;
91 case LAMBDA0: return 1.115683;
92 case DEUTERON: return 1.8756;
93 case ALL: return -1;
94 default: return 0;
95 }
96
97}

◆ GetMomentum()

float GetMomentum ( ) const
inline

Get the momentum of the particle.

Returns
particle momentum GeV/c

Definition at line 84 of file BParticle.h.

84{ return sqrt(m_px * m_px + m_py * m_py + m_pz * m_pz); };

◆ GetPID()

float GetPID ( SIMPLEPID  pid)

Get the log likelihood ratio for a particle hypothesis with respect to all other hypotheses.

Parameters
pidparticle identity
Returns
the log likelihood ratio for a particle hypothesis

Definition at line 61 of file BParticle.cc.

62{
63 float sum = 0;
64 for (int i = 0; i < 6; i++) {
65 sum += exp(GetLogL(SIMPLEPID(i)));
66 }
67 sum -= exp(GetLogL(pid));
68 return exp(GetLogL(pid)) / sum;
69}

◆ GetTransverseMomentum()

float GetTransverseMomentum ( ) const
inline

Get the transverse momentum of the particle.

Returns
transverse particle momentum GeV/c

Definition at line 89 of file BParticle.h.

89{ return sqrt(m_px * m_px + m_py * m_py); };

◆ InMassRange()

int InMassRange ( float  mlower,
float  mupper 
)
inline

Test if the mass is in range.

Parameters
mlowerlower limit of the range
mupperupper limit of the range

Definition at line 189 of file BParticle.h.

189{ float m = GetMass(); if (m >= mlower && m <= mupper) return 1; else return 0; };
float GetMass()
Get the mass of the particle.
Definition: BParticle.cc:99

◆ logL_d()

float logL_d ( ) const
inline

Get the log likelihood for deuteron hypothesis.

Returns
the log likelihood for deuteron hypothesis

Definition at line 131 of file BParticle.h.

131{ return m_logL_d; };

◆ logL_e()

float logL_e ( ) const
inline

Get the log likelihood for electron hypothesis.

Returns
the log likelihood for electron hypothesis

Definition at line 106 of file BParticle.h.

106{ return m_logL_e; };

◆ logL_k()

float logL_k ( ) const
inline

Get the log likelihood for kaon hypothesis.

Returns
the log likelihood for kaon hypothesis

Definition at line 121 of file BParticle.h.

121{ return m_logL_k; };

◆ logL_mu()

float logL_mu ( ) const
inline

Get the log likelihood for muon hypothesis.

Returns
the log likelihood for muon hypothesis

Definition at line 111 of file BParticle.h.

111{ return m_logL_mu; };

◆ logL_p()

float logL_p ( ) const
inline

Get the log likelihood for proton hypothesis.

Returns
the log likelihood for proton hypothesis

Definition at line 126 of file BParticle.h.

126{ return m_logL_p; };

◆ logL_pi()

float logL_pi ( ) const
inline

Get the log likelihood for pion hypothesis.

Returns
the log likelihood for pion hypothesis

Definition at line 116 of file BParticle.h.

116{ return m_logL_pi; };

◆ operator+=()

BParticle & operator+= ( const BParticle a)

Operator to add particle.

Definition at line 31 of file BParticle.cc.

32{
33 m_px += a.px();
34 m_py += a.py();
35 m_pz += a.pz();
36 m_e += a.e();
37 m_charge += a.charge();
38 m_pid = PHOTON; // wrong
40 return *this;
41}

◆ operator=()

BParticle & operator= ( const BParticle p)
inline

Assign a particle.

Definition at line 192 of file BParticle.h.

193 {
194 m_px = p.px();
195 m_py = p.py();
196 m_pz = p.pz();
197 m_e = p.e();
198 m_charge = p.charge();
199 m_pid = p.pid();
200 m_logL_e = p.logL_e();
201 m_logL_mu = p.logL_mu();
202 m_logL_pi = p.logL_pi();
203 m_logL_k = p.logL_k();
204 m_logL_p = p.logL_p();
205 m_logL_d = p.logL_d();
206 return *this;
207 };

◆ pid()

SIMPLEPID pid ( ) const
inline

Get the particle identity.

Returns
the particle identity

Definition at line 101 of file BParticle.h.

101{ return m_pid; };

◆ px()

float px ( ) const
inline
Returns
x component of the particle momentum GeV/c

Definition at line 67 of file BParticle.h.

67{ return m_px; };

◆ py()

float py ( ) const
inline
Returns
y component of the particle momentum GeV/c

Definition at line 71 of file BParticle.h.

71{ return m_py; };

◆ pz()

float pz ( ) const
inline

z

Returns
z component of the particle momentum GeV/c

Definition at line 75 of file BParticle.h.

75{ return m_pz; };

◆ SetEnergyFromMass()

void SetEnergyFromMass ( float  mass)

Recalculate energy from particle mass and momentum.

Parameters
massof the particle

Definition at line 106 of file BParticle.cc.

107{
108 if (mass < 0) return;
109 m_e = sqrt(mass * mass + m_px * m_px + m_py * m_py + m_pz * m_pz);
110
111}

◆ SetEnergyFromPid()

void SetEnergyFromPid ( )

Recalculate energy from particle identity and momentum.

Definition at line 113 of file BParticle.cc.

114{
116}
void SetEnergyFromMass(float mass)
Recalculate energy from particle mass and momentum.
Definition: BParticle.cc:106

◆ SetPid()

void SetPid ( SIMPLEPID  pid)
inline

Set particle identity.

Parameters
pid- particle identity

Definition at line 181 of file BParticle.h.

181{ m_pid = pid; };

Member Data Documentation

◆ m_charge

float m_charge
private

charge of the particle

Definition at line 25 of file BParticle.h.

◆ m_e

float m_e
private

energy of the particle

Definition at line 24 of file BParticle.h.

◆ m_logL_d

float m_logL_d
private

log likelihood of the deuteron hypothesis

Definition at line 32 of file BParticle.h.

◆ m_logL_e

float m_logL_e
private

log likelihood of the electron hypothesis

Definition at line 27 of file BParticle.h.

◆ m_logL_k

float m_logL_k
private

log likelihood of the kaon hypothesis

Definition at line 30 of file BParticle.h.

◆ m_logL_mu

float m_logL_mu
private

log likelihood of the muon hypothesis

Definition at line 28 of file BParticle.h.

◆ m_logL_p

float m_logL_p
private

log likelihood of the proton hypothesis

Definition at line 31 of file BParticle.h.

◆ m_logL_pi

float m_logL_pi
private

log likelihood of the pion hypothesis

Definition at line 29 of file BParticle.h.

◆ m_pid

SIMPLEPID m_pid
private

particle identity

Definition at line 26 of file BParticle.h.

◆ m_px

float m_px
private

x component of the particle momentum

Definition at line 21 of file BParticle.h.

◆ m_py

float m_py
private

y component of the particle momentum

Definition at line 22 of file BParticle.h.

◆ m_pz

float m_pz
private

z component of the particle momentum

Definition at line 23 of file BParticle.h.


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