forked from sPHENIX-Collaboration/coresoftware
/
ParticleFlowElementv1.cc
74 lines (56 loc) · 1.47 KB
/
ParticleFlowElementv1.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include "ParticleFlowElementv1.h"
#include <cmath>
#include <iostream>
ParticleFlowElementv1::ParticleFlowElementv1()
: _mom() , _e(NAN)
{
for (int i = 0; i < 3; ++i) _mom[i] = NAN;
_id = 0;
_type = ParticleFlowElement::PFLOWTYPE::UNASSIGNED;
}
void ParticleFlowElementv1::identify(std::ostream& os) const
{
os << "-- ParticleFlowElement v1 : ";
os << " id: " << get_id() << ", type: " << get_type() << ",";
os << " (px, py, pz, e) = (" << get_px() << ", " << get_py() << ", ";
os << get_pz() << ", " << get_e() << ") GeV" << std::endl;
return;
}
void ParticleFlowElementv1::Reset()
{
for (int i = 0; i < 3; ++i) _mom[i] = NAN;
_e = NAN;
}
int ParticleFlowElementv1::isValid() const
{
for (int i = 0; i < 3; ++i)
{
if (std::isnan(_mom[i])) return 0;
}
if (std::isnan(_e)) return 0;
return 1;
}
float ParticleFlowElementv1::get_p() const
{
return sqrt(get_px() * get_px() + get_py() * get_py() + get_pz() * get_pz());
}
float ParticleFlowElementv1::get_pt() const
{
return sqrt(get_px() * get_px() + get_py() * get_py());
}
float ParticleFlowElementv1::get_et() const
{
return get_pt() / get_p() * get_e();
}
float ParticleFlowElementv1::get_eta() const
{
return asinh(get_pz() / get_pt());
}
float ParticleFlowElementv1::get_phi() const
{
return atan2(get_py(), get_px());
}
float ParticleFlowElementv1::get_mass() const
{
return sqrt( get_e() * get_e() - get_px() * get_px() + get_py() * get_py() + get_pz() * get_pz() );
}