Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-12-17 09:22:00

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