Belle II Software  release-06-02-00
BParticle.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 
9 #include "masterclass/dataobjects/BParticle.h"
10 
11 
12 BParticle::BParticle(float px, float py, float pz, float e,
13  float charge, SIMPLEPID pid)
14 {
15  m_px = px;
16  m_py = py;
17  m_pz = pz;
18  m_e = e;
19  m_charge = charge;
20  m_pid = pid;
21 }
22 
23 
24 float BParticle::GetMass(SIMPLEPID pid)
25 {
26 
27  switch (pid) {
28  case PHOTON: return 0;
29  case ELECTRON: return 0.51;
30  case PION: return 0.139;
31  case MUON: return 0.105;
32  case KAON: return 0.497;
33  case PROTON: return 0.938;
34  case JPSI: return 3.1;
35  case D: return 1.86;
36  case DSTAR: return 2.01;
37  case B: return 5.27;
38  case PHI: return 1.02;
39  case LAMBDA0: return 1.115683;
40  case ALL: return -1;
41  default: return 0;
42  }
43 
44 }
45 
47 {
48  float m2 = m_e * m_e - m_px * m_px - m_py * m_py - m_pz * m_pz;
49  if (m2 < 0) m2 = 0;
50  return sqrt(m2);
51 }
52 
54 {
55  if (mass < 0) return;
56  m_e = sqrt(mass * mass + m_px * m_px + m_py * m_py + m_pz * m_pz);
57 
58 }
59 
61 {
63 }
64 
65 int SelectParticles(TClonesArray* pin , int charge, SIMPLEPID type, TClonesArray* pout)
66 {
67  pout->Clear();
68  int nprt = 0;
69 
70  for (TIter next(pin); BParticle* p = dynamic_cast<BParticle*>(next());) {
71  if (p->charge() == charge && p->pid() == type) {
72  TClonesArray& list = *pout;
73  new(list[nprt++]) BParticle(*p);
74  }
75  }
76  return nprt;
77 }
78 
79 int CombineParticles(TClonesArray* plist1 , TClonesArray* plist2 , int same, float masslow, float massup, SIMPLEPID pid,
80  TClonesArray* pout)
81 {
82 // Loop over all the particles in both lists.
83  pout->Clear();
84  int nprt = 0;
85 
86  for (TIter next1(plist1); BParticle* p1 = dynamic_cast<BParticle*>(next1());) {
87  // the second loop
88  for (TIter next2 = (plist1 != plist2
89  && same == 0) ? TIter(plist2) : TIter(next1) ; BParticle* p2 = dynamic_cast<BParticle*>(next2());) {
90  BParticle p = *p1 + *p2; // Combine two particles into a new particle
91  if (p.InMassRange(masslow, massup)) {
92  p.SetPid(pid);
93  TClonesArray& list = *pout;
94  new(list[nprt++]) BParticle(p); // create a new entry in kslist list of particles
95  }
96 
97  }
98 
99  }
100  return nprt;
101 }
102 
103 
104 
The Class for Masterclass particle information This class provides the data structure of the particle...
Definition: BParticle.h:18
void SetEnergyFromMass(float mass)
Recalculate energy from particle mass and momentum.
Definition: BParticle.cc:53
SIMPLEPID pid() const
Get the particle identity.
Definition: BParticle.h:86
float m_e
energy of the particle
Definition: BParticle.h:24
SIMPLEPID m_pid
particle identity
Definition: BParticle.h:26
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:52
void SetEnergyFromPid()
Recalculate energy from particle identity and momentum.
Definition: BParticle.cc:60
float charge() const
Get the particle charge.
Definition: BParticle.h:79
float m_pz
z component of the particle momentum
Definition: BParticle.h:23
float e() const
Definition: BParticle.h:64
float m_px
x component of the particle momentum
Definition: BParticle.h:21
BParticle()
Default constructor.
Definition: BParticle.h:30
float py() const
Definition: BParticle.h:56
float GetMass()
Get the mass of the particle.
Definition: BParticle.cc:46
float pz() const
z
Definition: BParticle.h:60