CMS 3D CMS Logo

L1TriggerKeyExt.h
Go to the documentation of this file.
1 #ifndef CondFormats_L1TObjects_L1TriggerKeyExt_h
2 #define CondFormats_L1TObjects_L1TriggerKeyExt_h
3 
5 
6 #include <string>
7 #include <map>
8 
9 /* L1 key used to load all other configuration data from offline db.
10  * This class is just a proxy to the real data. It will contain mapping from data and record
11  * pair to the payload token that could be used to read data. So the use case could be as follows:
12  * 1. User read L1TriggerKey for given Tag and IOV pair.
13  * 2. For each record and type that user whant to load, it ask method get for the payload.
14  * 3. Reads the data with payloads extracted from step 2.
15  *
16  * It is not adviced for user to use this class and direct Pool DB manipulation. One should use
17  * DataReader and DataWriter classes.
18  *
19  * The good point to note is that IOV of all L1 trigger condfiguration is controled bay IOV of L1TriggeKey.
20  * If new configuration has to be created - new L1TriggerKey has to be saved/loaded. More then one key can use
21  * the same paylaod token. This would just mean that data pointed by this payload token has not changed.
22  */
24 public:
25  typedef std::map<std::string, std::string> RecordToKey;
26 
28 
29  // Empty strings cannot be stored in the CondDB, so define a null key string.
30  const static std::string kNullKey;
31 
32  const static std::string kEmptyKey;
33 
34  // Constructors
36  for (int i = 0; i < kNumberSubsystems; ++i) {
38  }
39  }
40 
41  /* Adds new record and type mapping to payload. If such exists, nothing happens */
42  void add(const std::string& record, const std::string& type, const std::string& key) {
43  m_recordToKey.insert(std::make_pair(record + "@" + type, key.empty() ? kNullKey : key));
44  }
45 
46  void add(const RecordToKey& map) {
47  for (RecordToKey::const_iterator itr = map.begin(); itr != map.end(); ++itr) {
48  m_recordToKey.insert(std::make_pair(itr->first, itr->second.empty() ? kNullKey : itr->second));
49  }
50  }
51 
53 
55  m_subsystemKeys[subsystem] = key.empty() ? kNullKey : key;
56  }
57 
58  /* Gets payload key for record and type. If no such paylaod exists, emtpy string
59  * is returned.
60  */
62  RecordToKey::const_iterator it = m_recordToKey.find(record + "@" + type);
63  if (it == m_recordToKey.end())
64  return std::string();
65  else
66  return it->second == kNullKey ? kEmptyKey : it->second;
67  }
68 
69  const std::string& tscKey() const { return m_tscKey; }
70 
72  std::map<int, std::string>::const_iterator key = m_subsystemKeys.find(subsystem);
73  return key == m_subsystemKeys.end() || key->second == kNullKey ? kEmptyKey : key->second;
74  }
75 
76  // NB: null keys are represented by kNullKey, not by an empty string
77  const RecordToKey& recordToKeyMap() const { return m_recordToKey; }
78 
79 protected:
80  /* Mapping from records and types to tokens.
81  * I as unvable to make type std::map<std::pair<std::string, std::string>, std::string> persistent
82  * so record and type are concatanated with @ sign and resulting string is used as a key.
83  */
84 
85  // wsun 03/2008: instead of tokens, store the configuration keys instead.
86  /* typedef std::map<std::string, std::string> RecordsToToken; */
87  /* RecordsToToken recordsToToken; */
89 
90  // wsun 03/2008: add data member for TSC key
92  std::map<int, std::string> m_subsystemKeys;
93 
95 };
96 
97 #endif
hcal_dqm_sourceclient-live_cfg.subsystem
subsystem
Definition: hcal_dqm_sourceclient-live_cfg.py:16
L1TriggerKeyExt::kuGMT
Definition: L1TriggerKeyExt.h:27
mps_fire.i
i
Definition: mps_fire.py:428
L1TriggerKeyExt::kBMTF
Definition: L1TriggerKeyExt.h:27
L1TriggerKeyExt::add
void add(const std::string &record, const std::string &type, const std::string &key)
Definition: L1TriggerKeyExt.h:42
L1TriggerKeyExt::kNullKey
const static std::string kNullKey
Definition: L1TriggerKeyExt.h:30
L1TriggerKeyExt::subsystemKey
const std::string & subsystemKey(L1Subsystems subsystem) const
Definition: L1TriggerKeyExt.h:71
COND_SERIALIZABLE
#define COND_SERIALIZABLE
Definition: Serializable.h:39
GlobalPosition_Frontier_DevDB_cff.record
record
Definition: GlobalPosition_Frontier_DevDB_cff.py:10
L1TriggerKeyExt::m_subsystemKeys
std::map< int, std::string > m_subsystemKeys
Definition: L1TriggerKeyExt.h:92
L1TriggerKeyExt::setSubsystemKey
void setSubsystemKey(L1Subsystems subsystem, const std::string &key)
Definition: L1TriggerKeyExt.h:54
L1TriggerKeyExt::kEmptyKey
const static std::string kEmptyKey
Definition: L1TriggerKeyExt.h:32
L1TriggerKeyExt::RecordToKey
std::map< std::string, std::string > RecordToKey
Definition: L1TriggerKeyExt.h:25
L1TriggerKeyExt::recordToKeyMap
const RecordToKey & recordToKeyMap() const
Definition: L1TriggerKeyExt.h:77
L1TriggerKeyExt::kCALO
Definition: L1TriggerKeyExt.h:27
L1TriggerKeyExt::m_tscKey
std::string m_tscKey
Definition: L1TriggerKeyExt.h:91
L1TriggerKeyExt::add
void add(const RecordToKey &map)
Definition: L1TriggerKeyExt.h:46
L1TriggerKeyExt::tscKey
const std::string & tscKey() const
Definition: L1TriggerKeyExt.h:69
L1TriggerKeyExt::kOMTF
Definition: L1TriggerKeyExt.h:27
L1TriggerKeyExt::m_recordToKey
RecordToKey m_recordToKey
Definition: L1TriggerKeyExt.h:88
L1TriggerKeyExt::kNumberSubsystems
Definition: L1TriggerKeyExt.h:27
L1TriggerKeyExt::kTWINMUX
Definition: L1TriggerKeyExt.h:27
L1TriggerKeyExt
Definition: L1TriggerKeyExt.h:23
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
type
type
Definition: SiPixelVCal_PayloadInspector.cc:37
L1TriggerKeyExt::L1TriggerKeyExt
L1TriggerKeyExt()
Definition: L1TriggerKeyExt.h:35
Serializable.h
itr
std::vector< std::pair< float, float > >::iterator itr
Definition: HGCDigitizer.cc:29
L1TriggerKeyExt::get
std::string get(const std::string &record, const std::string &type) const
Definition: L1TriggerKeyExt.h:61
L1TriggerKeyExt::kEMTF
Definition: L1TriggerKeyExt.h:27
L1TriggerKeyExt::kuGT
Definition: L1TriggerKeyExt.h:27
L1TriggerKeyExt::L1Subsystems
L1Subsystems
Definition: L1TriggerKeyExt.h:27
genParticles_cff.map
map
Definition: genParticles_cff.py:11
crabWrapper.key
key
Definition: crabWrapper.py:19
L1TriggerKeyExt::setTSCKey
void setTSCKey(const std::string &tscKey)
Definition: L1TriggerKeyExt.h:52