File indexing completed on 2025-08-06 08:17:57
0001 #include "ParticleFlowElementv1.h"
0002
0003 #include <cmath>
0004 #include <iostream>
0005 #include <limits>
0006
0007 ParticleFlowElementv1::ParticleFlowElementv1()
0008 : _mom()
0009 , _e(std::numeric_limits<float>::quiet_NaN())
0010 {
0011 for (float& i : _mom)
0012 {
0013 i = std::numeric_limits<float>::quiet_NaN();
0014 }
0015
0016 _id = 0;
0017
0018 _type = ParticleFlowElement::PFLOWTYPE::UNASSIGNED;
0019 }
0020
0021 void ParticleFlowElementv1::identify(std::ostream& os) const
0022 {
0023 os << "-- ParticleFlowElement v1 : ";
0024 os << " id: " << get_id() << ", type: " << get_type() << ",";
0025 os << " (px, py, pz, e) = (" << get_px() << ", " << get_py() << ", ";
0026 os << get_pz() << ", " << get_e() << ") GeV" << std::endl;
0027
0028 return;
0029 }
0030
0031 void ParticleFlowElementv1::Reset()
0032 {
0033 for (float& i : _mom)
0034 {
0035 i = std::numeric_limits<float>::quiet_NaN();
0036 }
0037 _e = std::numeric_limits<float>::quiet_NaN();
0038 }
0039
0040 int ParticleFlowElementv1::isValid() const
0041 {
0042 for (float i : _mom)
0043 {
0044 if (std::isnan(i))
0045 {
0046 return 0;
0047 }
0048 }
0049 if (std::isnan(_e))
0050 {
0051 return 0;
0052 }
0053
0054 return 1;
0055 }
0056
0057 float ParticleFlowElementv1::get_p() const
0058 {
0059 return std::sqrt(get_px() * get_px() + get_py() * get_py() + get_pz() * get_pz());
0060 }
0061
0062 float ParticleFlowElementv1::get_pt() const
0063 {
0064 return std::sqrt(get_px() * get_px() + get_py() * get_py());
0065 }
0066
0067 float ParticleFlowElementv1::get_et() const
0068 {
0069 return get_pt() / get_p() * get_e();
0070 }
0071
0072 float ParticleFlowElementv1::get_eta() const
0073 {
0074 return std::asinh(get_pz() / get_pt());
0075 }
0076
0077 float ParticleFlowElementv1::get_phi() const
0078 {
0079 return std::atan2(get_py(), get_px());
0080 }
0081
0082 float ParticleFlowElementv1::get_mass() const
0083 {
0084 return std::sqrt(get_e() * get_e() - get_px() * get_px() + get_py() * get_py() + get_pz() * get_pz());
0085 }