File indexing completed on 2025-01-31 02:19:03
0001 #ifndef CondFormats_L1TObjects_L1TriggerKeyExt_h
0002 #define CondFormats_L1TObjects_L1TriggerKeyExt_h
0003
0004 #include "CondFormats/Serialization/interface/Serializable.h"
0005
0006 #include <string>
0007 #include <map>
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023 class L1TriggerKeyExt {
0024 public:
0025 typedef std::map<std::string, std::string> RecordToKey;
0026
0027 enum L1Subsystems { kuGT, kuGMT, kCALO, kEMTF, kOMTF, kBMTF, kTWINMUX, kNumberSubsystems };
0028
0029
0030 const static std::string kNullKey;
0031
0032 const static std::string kEmptyKey;
0033
0034
0035 L1TriggerKeyExt() {
0036 for (int i = 0; i < kNumberSubsystems; ++i) {
0037 m_subsystemKeys[i] = kNullKey;
0038 }
0039 }
0040
0041
0042 void add(const std::string& record, const std::string& type, const std::string& key) {
0043 m_recordToKey.emplace(record + "@" + type, key.empty() ? kNullKey : key);
0044 }
0045
0046 void add(const RecordToKey& map) {
0047 for (RecordToKey::const_iterator itr = map.begin(); itr != map.end(); ++itr) {
0048 m_recordToKey.emplace(itr->first, itr->second.empty() ? kNullKey : itr->second);
0049 }
0050 }
0051
0052 void setTSCKey(const std::string& tscKey) { m_tscKey = tscKey; }
0053
0054 void setSubsystemKey(L1Subsystems subsystem, const std::string& key) {
0055 m_subsystemKeys[subsystem] = key.empty() ? kNullKey : key;
0056 }
0057
0058
0059
0060
0061 std::string get(const std::string& record, const std::string& type) const {
0062 RecordToKey::const_iterator it = m_recordToKey.find(record + "@" + type);
0063 if (it == m_recordToKey.end())
0064 return std::string();
0065 else
0066 return it->second == kNullKey ? kEmptyKey : it->second;
0067 }
0068
0069 const std::string& tscKey() const { return m_tscKey; }
0070
0071 const std::string& subsystemKey(L1Subsystems subsystem) const {
0072 std::map<int, std::string>::const_iterator key = m_subsystemKeys.find(subsystem);
0073 return key == m_subsystemKeys.end() || key->second == kNullKey ? kEmptyKey : key->second;
0074 }
0075
0076
0077 const RecordToKey& recordToKeyMap() const { return m_recordToKey; }
0078
0079 protected:
0080
0081
0082
0083
0084
0085
0086
0087
0088 RecordToKey m_recordToKey;
0089
0090
0091 std::string m_tscKey;
0092 std::map<int, std::string> m_subsystemKeys;
0093
0094 COND_SERIALIZABLE;
0095 };
0096
0097 #endif