Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-10-17 08:19:25

0001 #include "PhotonClusterv1.h"
0002 #include <iostream>
0003 #include <limits>
0004 #include <map>
0005 #include <string>
0006 
0007 PhotonClusterv1::PhotonClusterv1(const RawClusterv1& rawcluster)
0008   : RawClusterv1(rawcluster)
0009   , m_conversion_prob(0.0F)
0010   , m_is_converted(false)
0011 
0012 {
0013   // No default shower shape inserted; user/algorithm must set if needed
0014   // Photon energy now same as cluster energy via get_energy()
0015   // Isolation energy sourced from RawClusterv1 get_et_iso()
0016 }
0017 
0018 void PhotonClusterv1::Reset()
0019 {
0020   // @warning: Call base class reset first to avoid issues with virtual dispatch
0021   RawClusterv1::Reset();
0022 
0023   // Reset photon-specific members
0024   reset_photon_properties();
0025 }
0026 
0027 void PhotonClusterv1::reset_photon_properties()
0028 {
0029   // Reset photon-related values (cluster energy left to RawClusterv1 Reset caller if needed)
0030   m_conversion_prob = 0.0F;
0031   m_is_converted = false;
0032   m_shower_shapes.clear();
0033 }
0034 
0035 int PhotonClusterv1::isValid() const
0036 {
0037   // @warning: Multiple inheritance - both base class validations checked
0038   return RawClusterv1::isValid() && is_valid_photon();
0039 }
0040 
0041 bool PhotonClusterv1::is_valid_photon() const
0042 {
0043   // Valid photon if has positive energy
0044   return (get_energy() > 0.0F);
0045 }
0046 
0047 void PhotonClusterv1::identify(std::ostream& os) const
0048 {
0049   // @warning: Call base class identify first to maintain output order
0050   RawClusterv1::identify(os);
0051 
0052   // Add photon-specific information
0053   identify_photon(os);
0054 }
0055 
0056 void PhotonClusterv1::identify_photon(std::ostream& os) const
0057 {
0058   os << "--- PhotonClusterv1 Photon Properties ---" << std::endl;
0059   os << "  Photon Energy: " << get_energy() << " GeV" << std::endl;
0060   os << "  Conversion Probability: " << get_conversion_probability() << std::endl;
0061   os << "  Is Converted: " << (is_converted() ? "Yes" : "No") << std::endl;
0062   os << "  Isolation Energy: " << get_et_iso() << " GeV" << std::endl;
0063   // List all named shower shapes
0064   for (const auto& kv : m_shower_shapes)
0065   {
0066     os << "    shape[" << kv.first << "]: " << kv.second << std::endl;
0067   }
0068   os << "  Passes Photon Cuts: " << (pass_photon_cuts() ? "Yes" : "No") << std::endl;
0069   os << "------------------------------------------" << std::endl;
0070 }
0071 
0072 bool PhotonClusterv1::pass_photon_cuts() const
0073 {
0074   // @warning: These are example cuts - customize based on your analysis needs
0075   std::cout << "this is currently unimplemented" << std::endl;
0076   // Minimum energy cut
0077   if (get_energy() < 0.5F)
0078   {
0079     return false;
0080   }
0081 
0082   // Shower shape cut: if a shape named "core" exists, apply cut
0083   // auto it_core = m_shower_shapes.find("core");
0084   // if (it_core != m_shower_shapes.end()) {
0085   //  if (it_core->second > 0.3f) return false;
0086   //}
0087 
0088   // Isolation cut (photons should be isolated)
0089   if (get_et_iso() > 2.0F)
0090   {
0091     return false;
0092   }
0093 
0094   // @warning: Add more sophisticated photon ID cuts as needed
0095   // Consider using cluster properties like get_ecore(), get_prob(), etc.
0096 
0097   return true;
0098 }
0099 
0100 float PhotonClusterv1::get_shower_shape_parameter(const std::string& name) const
0101 {
0102   auto it = m_shower_shapes.find(name);
0103   if (it != m_shower_shapes.end())
0104   {
0105     return it->second;
0106   }
0107   return std::numeric_limits<float>::quiet_NaN();
0108 }