File indexing completed on 2024-04-06 12:02:24
0001 #include "CondFormats/L1TObjects/interface/L1TriggerKeyListExt.h"
0002
0003 L1TriggerKeyListExt::L1TriggerKeyListExt() {}
0004
0005
0006
0007
0008
0009
0010 L1TriggerKeyListExt::~L1TriggerKeyListExt() {}
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028 bool L1TriggerKeyListExt::addKey(const std::string& tscKey, const std::string& payloadToken, bool overwriteKey) {
0029 std::pair<KeyToToken::iterator, bool> result = m_tscKeyToToken.insert(std::make_pair(tscKey, payloadToken));
0030
0031 if (!result.second && overwriteKey) {
0032
0033 m_tscKeyToToken.erase(result.first);
0034
0035
0036 result = m_tscKeyToToken.insert(std::make_pair(tscKey, payloadToken));
0037 }
0038
0039 return result.second;
0040 }
0041
0042 bool L1TriggerKeyListExt::addKey(const std::string& recordType,
0043 const std::string& key,
0044 const std::string& payloadToken,
0045 bool overwriteKey) {
0046 RecordToKeyToToken::iterator it = m_recordKeyToken.find(recordType);
0047
0048 if (it == m_recordKeyToken.end()) {
0049 it = m_recordKeyToken.insert(std::make_pair(recordType, KeyToToken())).first;
0050 }
0051
0052 std::pair<KeyToToken::iterator, bool> result = it->second.insert(std::make_pair(key, payloadToken));
0053
0054 if (!result.second && overwriteKey) {
0055
0056 it->second.erase(result.first);
0057
0058
0059 result = it->second.insert(std::make_pair(key, payloadToken));
0060 }
0061
0062 return result.second;
0063 }
0064
0065
0066
0067
0068
0069 std::string L1TriggerKeyListExt::token(const std::string& tscKey) const {
0070 KeyToToken::const_iterator it = m_tscKeyToToken.find(tscKey);
0071
0072 if (it == m_tscKeyToToken.end()) {
0073 return std::string();
0074 } else {
0075 return it->second;
0076 }
0077 }
0078
0079 std::string L1TriggerKeyListExt::token(const std::string& recordName,
0080 const std::string& dataType,
0081 const std::string& key) const {
0082 std::string recordType = recordName + "@" + dataType;
0083 return token(recordType, key);
0084 }
0085
0086 std::string L1TriggerKeyListExt::token(const std::string& recordType, const std::string& key) const {
0087 RecordToKeyToToken::const_iterator it = m_recordKeyToken.find(recordType);
0088
0089 if (it == m_recordKeyToken.end()) {
0090 return std::string();
0091 } else {
0092 KeyToToken::const_iterator it2 = it->second.find(key);
0093
0094 if (it2 == it->second.end()) {
0095 return std::string();
0096 } else {
0097 return it2->second;
0098 }
0099 }
0100 }
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135 std::string L1TriggerKeyListExt::objectKey(const std::string& recordName, const std::string& payloadToken) const {
0136 RecordToKeyToToken::const_iterator iRecordType = m_recordKeyToken.begin();
0137 for (; iRecordType != m_recordKeyToken.end(); ++iRecordType) {
0138
0139 std::string recordInMap(iRecordType->first, 0, iRecordType->first.find_first_of("@"));
0140 if (recordInMap == recordName) {
0141
0142 KeyToToken::const_iterator iKey = iRecordType->second.begin();
0143 KeyToToken::const_iterator eKey = iRecordType->second.end();
0144 for (; iKey != eKey; ++iKey) {
0145 if (iKey->second == payloadToken) {
0146 return iKey->first;
0147 }
0148 }
0149 }
0150 }
0151
0152 return std::string();
0153 }
0154
0155 std::string L1TriggerKeyListExt::tscKey(const std::string& triggerKeyPayloadToken) const {
0156
0157 KeyToToken::const_iterator iKey = m_tscKeyToToken.begin();
0158 KeyToToken::const_iterator eKey = m_tscKeyToToken.end();
0159 for (; iKey != eKey; ++iKey) {
0160 if (iKey->second == triggerKeyPayloadToken) {
0161 return iKey->first;
0162 }
0163 }
0164
0165 return std::string();
0166 }
0167
0168
0169
0170