File indexing completed on 2025-08-05 08:16:06
0001 #include "EventHeaderv1.h"
0002
0003 #include <cmath> // for NAN
0004 #include <iostream>
0005 #include <utility> // for pair
0006
0007 void EventHeaderv1::Reset()
0008 {
0009 RunNumber = 0;
0010 EvtSequence = 0;
0011 m_IntEventProperties.clear();
0012 m_FloatEventProperties.clear();
0013 return;
0014 }
0015
0016 void EventHeaderv1::identify(std::ostream &out) const
0017 {
0018 out << "identify yourself: I am an EventHeaderv1 Object" << std::endl;
0019 out << "Run Number: " << RunNumber
0020 << ", Event no: " << EvtSequence
0021 << std::endl;
0022 auto iter = m_IntEventProperties.begin();
0023 while (iter != m_IntEventProperties.end())
0024 {
0025 out << iter->first << ": " << iter->second << std::endl;
0026 ++iter;
0027 }
0028 auto iterf = m_FloatEventProperties.begin();
0029 while (iterf != m_FloatEventProperties.end())
0030 {
0031 out << iterf->first << ": " << iterf->second << std::endl;
0032 ++iterf;
0033 }
0034 return;
0035 }
0036
0037 int EventHeaderv1::isValid() const
0038 {
0039 return ((RunNumber) ? 1 : 0);
0040 }
0041
0042 void EventHeaderv1::CopyTo(EventHeader *to_copy)
0043 {
0044 to_copy->set_RunNumber(get_RunNumber());
0045 to_copy->set_EvtSequence(get_EvtSequence());
0046 for (auto const &it : m_IntEventProperties)
0047 {
0048 to_copy->set_intval(it.first, it.second);
0049 }
0050 for (auto const &it : m_FloatEventProperties)
0051 {
0052 to_copy->set_floatval(it.first, it.second);
0053 }
0054 }
0055
0056 void EventHeaderv1::set_floatval(const std::string &name, const float fval)
0057 {
0058 m_FloatEventProperties[name] = fval;
0059 }
0060
0061 float EventHeaderv1::get_floatval(const std::string &name) const
0062 {
0063 std::map<std::string, float>::const_iterator iter = m_FloatEventProperties.find(name);
0064 if (iter != m_FloatEventProperties.end())
0065 {
0066 return iter->second;
0067 }
0068 return NAN;
0069 }
0070
0071 void EventHeaderv1::set_intval(const std::string &name, const int64_t ival)
0072 {
0073 m_IntEventProperties[name] = ival;
0074 }
0075
0076 int64_t EventHeaderv1::get_intval(const std::string &name) const
0077 {
0078 auto iter = m_IntEventProperties.find(name);
0079 if (iter != m_IntEventProperties.end())
0080 {
0081 return iter->second;
0082 }
0083 return -999999;
0084 }