00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include "HltDataTypes/EventType.h"
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 const EventType::EventTypeCode EventType::IS_SIMULATION = 0;
00025 const EventType::EventTypeCode EventType::IS_TESTBEAM = 1;
00026 const EventType::EventTypeCode EventType::IS_CALIBRATION = 2;
00027
00028
00029 EventType::EventType()
00030 {}
00031
00032
00033 EventType::~EventType()
00034 {}
00035
00036
00037 void
00038 EventType::add_type (EventTypeCode type_code)
00039 {
00040 if(m_bit_mask.size() <= type_code) m_bit_mask.resize(type_code + 1, false);
00041 m_bit_mask[type_code] = true;
00042 }
00043
00044 void
00045 EventType::set_user_type (const std::string& user_type)
00046 {
00047 m_user_type = user_type;
00048 }
00049
00050 void
00051 EventType::set_detdescr_tags(const NameTagPairVec& pairs)
00052 {
00053
00054
00055
00056
00057 m_user_type = user_type();
00058
00059 char sep = '#';
00060 for (unsigned int i = 0; i < pairs.size(); ++i) {
00061 m_user_type += sep;
00062 m_user_type += pairs[i].first;
00063 m_user_type += sep;
00064 m_user_type += pairs[i].second;
00065 }
00066 }
00067
00068
00069 bool
00070 EventType::test (EventTypeCode type_code) const
00071 {
00072 if (m_bit_mask.size() <= type_code) return false;
00073 return m_bit_mask[type_code];
00074 }
00075
00076 const std::string&
00077 EventType::user_type (void) const
00078 {
00079 char sep = '#';
00080 std::string::size_type beg = m_user_type.find(sep);
00081 static std::string user_type;
00082 if (beg != std::string::npos) {
00083 user_type = m_user_type.substr(0, beg);
00084 }
00085 else {
00086 user_type = m_user_type;
00087 }
00088 return user_type;
00089 }
00090
00091
00092 void
00093 EventType::get_detdescr_tags(NameTagPairVec& pairs)
00094 {
00095
00096
00097
00098 char sep = '#';
00099 bool done = false;
00100 std::string::size_type beg = m_user_type.find(sep);
00101 do {
00102 if (beg != std::string::npos) {
00103 std::string::size_type end1 = m_user_type.find(sep, beg+1);
00104 if (end1 != std::string::npos) {
00105 std::string::size_type end2 = m_user_type.find(sep, end1+1);
00106 if (end2 != std::string::npos) {
00107
00108 std::string first = m_user_type.substr(beg+1, end1-beg-1);
00109 std::string second = m_user_type.substr(end1+1, end2-end1-1);
00110 pairs.push_back(NameTagPair(first,second));
00111
00112
00113 beg = end2;
00114 }
00115 else {
00116
00117 std::string first = m_user_type.substr(beg+1, end1-beg-1);
00118 std::string second = m_user_type.substr(end1+1, m_user_type.size()-1);
00119 pairs.push_back(NameTagPair(first,second));
00120 done = true;
00121 }
00122 }
00123 else {
00124 done = true;
00125 }
00126 }
00127 else {
00128 done = true;
00129 }
00130 } while (!done);
00131 }
00132
00133
00134 EventType::BitMaskIterator
00135 EventType::bit_mask_begin (void) const
00136 {
00137 return m_bit_mask.begin();
00138 }
00139
00140 EventType::BitMaskIterator
00141 EventType::bit_mask_end (void) const
00142 {
00143 return m_bit_mask.end();
00144 }