Belle II Software  release-06-02-00
BParticle.h
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 #pragma once
10 
11 #include "TObject.h"
12 #include "TClonesArray.h"
13 
14 enum SIMPLEPID {PHOTON, ELECTRON, PION, MUON, KAON, PROTON, JPSI, D, DSTAR, B, PHI, LAMBDA0, ALL };
15 
18 class BParticle : public TObject {
19 
20 private:
21  float m_px;
22  float m_py;
23  float m_pz;
24  float m_e;
25  float m_charge;
26  SIMPLEPID m_pid;
28 public:
30  BParticle() {};
32  BParticle(const BParticle&) = default;
33 
43  BParticle(float px, float py, float pz, float energy, float charge, SIMPLEPID pid);
44 
46  ~BParticle() {};
47 
48 
52  float px() const { return m_px; };
56  float py() const { return m_py; };
60  float pz() const { return m_pz; };
64  float e() const { return m_e; };
69  float GetMomentum() const { return sqrt(m_px * m_px + m_py * m_py + m_pz * m_pz); };
74  float GetTransverseMomentum() const { return sqrt(m_px * m_px + m_py * m_py); };
79  float charge() const { return m_charge; };
80 
86  SIMPLEPID pid() const { return m_pid; };
93  float GetMass(SIMPLEPID pid);
99  float GetMass();
100 
106  void SetEnergyFromMass(float mass);
110  void SetEnergyFromPid();
116  void SetPid(SIMPLEPID pid) { m_pid = pid; };
117 
124  int InMassRange(float mlower, float mupper) { float m = GetMass(); if (m >= mlower && m <= mupper) return 1; else return 0; };
125 
128  {
129 
130  BParticle particle(
131  px() + b.px(),
132  py() + b.py(),
133  pz() + b.pz(),
134  e() + b.e(),
135  charge() + b.charge(),
136  PHOTON // wrong
137  );
138 
139  return particle;
140  };
141 
144  {
145  m_px = p.px();
146  m_py = p.py();
147  m_pz = p.pz();
148  m_e = p.e();
149  m_charge = p.charge();
150  m_pid = p.pid();
151  return *this;
152  };
153 
154  ClassDef(BParticle, 1) // Simple particle class
155 };
156 
157 int SelectParticles(TClonesArray* pin , int charge, SIMPLEPID type, TClonesArray* pout);
158 
159 int CombineParticles(TClonesArray* plist1 , TClonesArray* plist2 , int same, float masslow, float massup, SIMPLEPID pid,
160  TClonesArray* pout);
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
void SetPid(SIMPLEPID pid)
Set particle identity.
Definition: BParticle.h:116
BParticle & operator=(const BParticle &p)
Assign a particle.
Definition: BParticle.h:143
float GetMomentum() const
Get the momentum of the particle.
Definition: BParticle.h:69
float m_e
energy of the particle
Definition: BParticle.h:24
SIMPLEPID m_pid
particle identity
Definition: BParticle.h:26
float GetTransverseMomentum() const
Get the transverse momentum of the particle.
Definition: BParticle.h:74
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
~BParticle()
Default destructor.
Definition: BParticle.h:46
BParticle(const BParticle &)=default
Constructor using the particle.
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
int InMassRange(float mlower, float mupper)
Test if the mass is in range.
Definition: BParticle.h:124
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
BParticle operator+(const BParticle &b)
Adds to particles.
Definition: BParticle.h:127