Belle II Software  release-05-01-25
BParticle.cc
1 //+
2 // File : BParticle.cc
3 // Description : Implementation of BTrack class //
4 //-
5 
6 #include "masterclass/dataobjects/BParticle.h"
7 
8 
9 BParticle::BParticle(float px, float py, float pz, float e,
10  float charge, SIMPLEPID pid)
11 {
12  m_px = px;
13  m_py = py;
14  m_pz = pz;
15  m_e = e;
16  m_charge = charge;
17  m_pid = pid;
18 }
19 
20 
21 float BParticle::GetMass(SIMPLEPID pid)
22 {
23 
24  switch (pid) {
25  case PHOTON: return 0;
26  case ELECTRON: return 0.51;
27  case PION: return 0.139;
28  case MUON: return 0.105;
29  case KAON: return 0.497;
30  case PROTON: return 0.938;
31  case JPSI: return 3.1;
32  case D: return 1.86;
33  case DSTAR: return 2.01;
34  case B: return 5.27;
35  case PHI: return 1.02;
36  case LAMBDA0: return 1.115683;
37  case ALL: return -1;
38  default: return 0;
39  }
40 
41 }
42 
43 float BParticle::GetMass()
44 {
45  float m2 = m_e * m_e - m_px * m_px - m_py * m_py - m_pz * m_pz;
46  if (m2 < 0) m2 = 0;
47  return sqrt(m2);
48 }
49 
50 void BParticle::SetEnergyFromMass(float mass)
51 {
52  if (mass < 0) return;
53  m_e = sqrt(mass * mass + m_px * m_px + m_py * m_py + m_pz * m_pz);
54 
55 }
56 
57 void BParticle::SetEnergyFromPid()
58 {
59  SetEnergyFromMass(GetMass(m_pid));
60 }
61 
62 int SelectParticles(TClonesArray* pin , int charge, SIMPLEPID type, TClonesArray* pout)
63 {
64  pout->Clear();
65  int nprt = 0;
66 
67  for (TIter next(pin); BParticle* p = (BParticle*) next();) {
68  if (p->charge() == charge && p->pid() == type) {
69  TClonesArray& list = *pout;
70  new(list[nprt++]) BParticle(*p);
71  }
72  }
73  return nprt;
74 }
75 
76 int CombineParticles(TClonesArray* plist1 , TClonesArray* plist2 , int same, float masslow, float massup, SIMPLEPID pid,
77  TClonesArray* pout)
78 {
79 // Loop over all the particles in both lists.
80  pout->Clear();
81  int nprt = 0;
82 
83  for (TIter next1(plist1); BParticle* p1 = (BParticle*) next1();) {
84  // the second loop
85  for (TIter next2 = (plist1 != plist2 && same == 0) ? TIter(plist2) : TIter(next1) ; BParticle* p2 = (BParticle*) next2();) {
86  BParticle p = *p1 + *p2; // Combine two particles into a new particle
87  if (p.InMassRange(masslow, massup)) {
88  p.SetPid(pid);
89  TClonesArray& list = *pout;
90  new(list[nprt++]) BParticle(p); // create a new entry in kslist list of particles
91  }
92 
93  }
94 
95  }
96  return nprt;
97 }
98 
99 
100 
Belle2::EvtPDLUtil::charge
double charge(int pdgCode)
Returns electric charge of a particle with given pdg code.
Definition: EvtPDLUtil.cc:46
prepareAsicCrosstalkSimDB.e
e
aux.
Definition: prepareAsicCrosstalkSimDB.py:53
BParticle
Definition: BParticle.h:16