File indexing completed on 2024-04-06 12:02:21
0001 #ifndef CondFormats_L1TObjects_L1TriggerKey_h
0002 #define CondFormats_L1TObjects_L1TriggerKey_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 L1TriggerKey {
0024 public:
0025 typedef std::map<std::string, std::string> RecordToKey;
0026
0027 enum L1Subsystems { kCSCTF, kDTTF, kRPC, kGMT, kRCT, kGCT, kGT, kTSP0, kNumberSubsystems };
0028
0029
0030 const static std::string kNullKey;
0031
0032 const static std::string kEmptyKey;
0033
0034
0035 L1TriggerKey() {
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.insert(std::make_pair(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.insert(std::make_pair(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 return m_subsystemKeys[subsystem] == kNullKey ? kEmptyKey : m_subsystemKeys[subsystem];
0073 }
0074
0075
0076 const RecordToKey& recordToKeyMap() const { return m_recordToKey; }
0077
0078 protected:
0079
0080
0081
0082
0083
0084
0085
0086
0087 RecordToKey m_recordToKey;
0088
0089
0090 std::string m_tscKey;
0091 std::string m_subsystemKeys[kNumberSubsystems];
0092
0093 COND_SERIALIZABLE;
0094 };
0095
0096 #endif