Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:20:17

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