File indexing completed on 2025-08-05 08:18:07
0001 #include "EicEventHeaderv1.h"
0002
0003 #include <phool/phool.h>
0004
0005 #include <iostream> // for operator<<, basic_ostream, basic_ostream::o...
0006 #include <limits>
0007 #include <string> // for operator<<, string, char_traits
0008 #include <utility> // for pair
0009
0010 using namespace std;
0011
0012 EicEventHeaderv1::EicEventHeaderv1(const EicEventHeader *eicevt)
0013 {
0014 CopyFrom(eicevt);
0015 }
0016
0017 void EicEventHeaderv1::Reset()
0018 {
0019 prop_map.clear();
0020 }
0021
0022 bool EicEventHeaderv1::has_property(const PROPERTY prop_id) const
0023 {
0024 prop_map_t::const_iterator i = prop_map.find(prop_id);
0025 return i != prop_map.end();
0026 }
0027
0028 float EicEventHeaderv1::get_property_float(const PROPERTY prop_id) const
0029 {
0030 if (!check_property(prop_id, type_float))
0031 {
0032 pair<const string, PROPERTY_TYPE> property_info = get_property_info(prop_id);
0033 cout << PHWHERE << " Property " << property_info.first << " with id "
0034 << prop_id << " is of type " << get_property_type(property_info.second)
0035 << " not " << get_property_type(type_float) << endl;
0036 exit(1);
0037 }
0038 prop_map_t::const_iterator i = prop_map.find(prop_id);
0039
0040 if (i != prop_map.end())
0041 {
0042 return u_property(i->second).fdata;
0043 }
0044
0045 return std::numeric_limits<float>::quiet_NaN();
0046 }
0047
0048 int EicEventHeaderv1::get_property_int(const PROPERTY prop_id) const
0049 {
0050 if (!check_property(prop_id, type_int))
0051 {
0052 pair<const string, PROPERTY_TYPE> property_info = get_property_info(prop_id);
0053 cout << PHWHERE << " Property " << property_info.first << " with id "
0054 << prop_id << " is of type " << get_property_type(property_info.second)
0055 << " not " << get_property_type(type_int) << endl;
0056 exit(1);
0057 }
0058 prop_map_t::const_iterator i = prop_map.find(prop_id);
0059
0060 if (i != prop_map.end())
0061 {
0062 return u_property(i->second).idata;
0063 }
0064
0065 return std::numeric_limits<int>::min();
0066 }
0067
0068 unsigned int
0069 EicEventHeaderv1::get_property_uint(const PROPERTY prop_id) const
0070 {
0071 if (!check_property(prop_id, type_uint))
0072 {
0073 pair<const string, PROPERTY_TYPE> property_info = get_property_info(prop_id);
0074 cout << PHWHERE << " Property " << property_info.first << " with id "
0075 << prop_id << " is of type " << get_property_type(property_info.second)
0076 << " not " << get_property_type(type_uint) << endl;
0077 exit(1);
0078 }
0079 prop_map_t::const_iterator i = prop_map.find(prop_id);
0080
0081 if (i != prop_map.end())
0082 {
0083 return u_property(i->second).uidata;
0084 }
0085
0086 return std::numeric_limits<unsigned int>::max();
0087 }
0088
0089 void EicEventHeaderv1::set_property(const PROPERTY prop_id, const float value)
0090 {
0091 if (!check_property(prop_id, type_float))
0092 {
0093 pair<const string, PROPERTY_TYPE> property_info = get_property_info(prop_id);
0094 cout << PHWHERE << " Property " << property_info.first << " with id "
0095 << prop_id << " is of type " << get_property_type(property_info.second)
0096 << " not " << get_property_type(type_float) << endl;
0097 exit(1);
0098 }
0099 prop_map[prop_id] = u_property(value).get_storage();
0100 }
0101
0102 void EicEventHeaderv1::set_property(const PROPERTY prop_id, const int value)
0103 {
0104 if (!check_property(prop_id, type_int))
0105 {
0106 pair<const string, PROPERTY_TYPE> property_info = get_property_info(prop_id);
0107 cout << PHWHERE << " Property " << property_info.first << " with id "
0108 << prop_id << " is of type " << get_property_type(property_info.second)
0109 << " not " << get_property_type(type_int) << endl;
0110 exit(1);
0111 }
0112 prop_map[prop_id] = u_property(value).get_storage();
0113 }
0114
0115 void EicEventHeaderv1::set_property(const PROPERTY prop_id, const unsigned int value)
0116 {
0117 if (!check_property(prop_id, type_uint))
0118 {
0119 pair<const string, PROPERTY_TYPE> property_info = get_property_info(prop_id);
0120 cout << PHWHERE << " Property " << property_info.first << " with id "
0121 << prop_id << " is of type " << get_property_type(property_info.second)
0122 << " not " << get_property_type(type_uint) << endl;
0123 exit(1);
0124 }
0125 prop_map[prop_id] = u_property(value).get_storage();
0126 }
0127
0128 unsigned int
0129 EicEventHeaderv1::get_property_nocheck(const PROPERTY prop_id) const
0130 {
0131 prop_map_t::const_iterator iter = prop_map.find(prop_id);
0132 if (iter != prop_map.end())
0133 {
0134 return iter->second;
0135 }
0136 return std::numeric_limits<unsigned int>::max();
0137 }