File indexing completed on 2025-08-05 08:17:42
0001 #include "PHG4Cell.h"
0002
0003 #include <g4main/PHG4HitDefs.h> // for keytype
0004
0005 #include <phool/PHObject.h> // for PHObject
0006
0007 #include <cassert>
0008 #include <cstdlib>
0009
0010 void PHG4Cell::CopyFrom(const PHObject* phobj)
0011 {
0012 const PHG4Cell* g4cell = dynamic_cast<const PHG4Cell*>(phobj);
0013 assert(g4cell);
0014 set_cellid(g4cell->get_cellid());
0015 for (unsigned char ic = 0; ic < std::numeric_limits<unsigned char>::max(); ic++)
0016 {
0017 PROPERTY prop_id = static_cast<PHG4Cell::PROPERTY>(ic);
0018 if (g4cell->has_property(prop_id))
0019 {
0020 set_property_nocheck(prop_id, g4cell->get_property_nocheck(prop_id));
0021 }
0022 }
0023 }
0024
0025 void PHG4Cell::identify(std::ostream& os) const
0026 {
0027 os << "Class " << this->ClassName() << std::endl;
0028 return;
0029 }
0030
0031 std::ostream& operator<<(std::ostream& stream, const PHG4Cell* )
0032 {
0033 stream << "PHG4Cell" << std::endl;
0034 return stream;
0035 }
0036
0037 PHG4Cell::EdepConstRange PHG4Cell::get_g4hits()
0038 {
0039 static std::map<PHG4HitDefs::keytype, float> dummy;
0040 return std::make_pair(dummy.begin(), dummy.end());
0041 }
0042
0043 PHG4Cell::ShowerEdepConstRange PHG4Cell::get_g4showers()
0044 {
0045 static std::map<int, float> dummy;
0046 return std::make_pair(dummy.begin(), dummy.end());
0047 }
0048
0049 void PHG4Cell::Reset()
0050 {
0051 std::cout << "Reset not implemented by daughter class" << std::endl;
0052 return;
0053 }
0054
0055 std::pair<const std::string, PHG4Cell::PROPERTY_TYPE>
0056 PHG4Cell::get_property_info(const PROPERTY prop_id)
0057 {
0058 switch (prop_id)
0059 {
0060 case prop_stave_index:
0061 return std::make_pair("stave index", PHG4Cell::type_int);
0062 case prop_half_stave_index:
0063 return std::make_pair("half stave index", PHG4Cell::type_int);
0064 case prop_module_index:
0065 return std::make_pair("module index", PHG4Cell::type_int);
0066 case prop_chip_index:
0067 return std::make_pair("chip index", PHG4Cell::type_int);
0068 case prop_pixel_index:
0069 return std::make_pair("pixel index", PHG4Cell::type_int);
0070 case prop_phibin:
0071 return std::make_pair("phibin", PHG4Cell::type_int);
0072 case prop_zbin:
0073 return std::make_pair("zbin", PHG4Cell::type_int);
0074 case prop_ladder_z_index:
0075 return std::make_pair("ladder z index", PHG4Cell::type_int);
0076 case prop_ladder_phi_index:
0077 return std::make_pair("ladder phi index", PHG4Cell::type_int);
0078 case prop_edep:
0079 return std::make_pair("energy deposition", PHG4Cell::type_float);
0080 case prop_eion:
0081 return std::make_pair("ionizing energy loss", PHG4Cell::type_float);
0082 case prop_light_yield:
0083 return std::make_pair("light yield", PHG4Cell::type_float);
0084 case prop_raw_light_yield:
0085 return std::make_pair("raw light yield", PHG4Cell::type_float);
0086 default:
0087 std::cout << "PHG4Cell::get_property_info - Fatal Error - unknown index " << prop_id << std::endl;
0088 exit(1);
0089 }
0090 }
0091
0092 bool PHG4Cell::check_property(const PROPERTY prop_id, const PROPERTY_TYPE prop_type)
0093 {
0094 std::pair<const std::string, PROPERTY_TYPE> property_info = get_property_info(prop_id);
0095 if (property_info.second != prop_type)
0096 {
0097 return false;
0098 }
0099 return true;
0100 }
0101
0102 std::string PHG4Cell::get_property_type(const PROPERTY_TYPE prop_type)
0103 {
0104 switch (prop_type)
0105 {
0106 case type_int:
0107 return "int";
0108 case type_uint:
0109 return "unsigned int";
0110 case type_float:
0111 return "float";
0112 default:
0113 return "unkown";
0114 }
0115 }