CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1TriggerKey.h
Go to the documentation of this file.
1 #ifndef CondFormats_L1TObjects_L1TriggerKey_h
2 #define CondFormats_L1TObjects_L1TriggerKey_h
3 
4 #include <string>
5 #include <map>
6 
7 /* L1 key used to load all other configuration data from offline db.
8  * This class is just a proxy to the real data. It will contain mapping from data and record
9  * pair to the payload token that could be used to read data. So the use case could be as follows:
10  * 1. User read L1TriggerKey for given Tag and IOV pair.
11  * 2. For each record and type that user whant to load, it ask method get for the payload.
12  * 3. Reads the data with payloads extracted from step 2.
13  *
14  * It is not adviced for user to use this class and direct Pool DB manipulation. One should use
15  * DataReader and DataWriter classes.
16  *
17  * The good point to note is that IOV of all L1 trigger condfiguration is controled bay IOV of L1TriggeKey.
18  * If new configuration has to be created - new L1TriggerKey has to be saved/loaded. More then one key can use
19  * the same paylaod token. This would just mean that data pointed by this payload token has not changed.
20  */
22 {
23 public:
24  typedef std::map<std::string, std::string> RecordToKey;
25 
27  {
34  kGT,
37  } ;
38 
39  // Empty strings cannot be stored in the CondDB, so define a null key string.
40  static std::string kNullKey ;
41 
42  static std::string kEmptyKey ;
43 
44  // Constructors
46  {
47  for( int i = 0 ; i < kNumberSubsystems ; ++i )
48  {
50  }
51  }
52 
53  /* Adds new record and type mapping to payload. If such exists, nothing happens */
54  void add (const std::string & record, const std::string & type, const std::string & key)
55  { m_recordToKey.insert (std::make_pair (record + "@" + type, key.empty() ? kNullKey : key)); }
56 
57  void add (const RecordToKey& map)
58  {
59  for( RecordToKey::const_iterator itr = map.begin() ;
60  itr != map.end() ;
61  ++itr )
62  {
63  m_recordToKey.insert( std::make_pair( itr->first, itr->second.empty() ? kNullKey : itr->second ) ) ;
64  }
65  }
66 
67  void setTSCKey( const std::string& tscKey )
68  { m_tscKey = tscKey ; }
69 
70  void setSubsystemKey( L1Subsystems subsystem, const std::string& key )
71  { m_subsystemKeys[ subsystem ] = key.empty() ? kNullKey : key ; }
72 
73  /* Gets payload key for record and type. If no such paylaod exists, emtpy string
74  * is returned.
75  */
76  std::string get (const std::string & record, const std::string & type) const
77  {
78  RecordToKey::const_iterator it = m_recordToKey.find (record + "@" + type);
79  if (it == m_recordToKey.end ())
80  return std::string ();
81  else
82  return it->second == kNullKey ? kEmptyKey : it->second ;
83  }
84 
85  const std::string& tscKey() const
86  { return m_tscKey ; }
87 
88  const std::string& subsystemKey( L1Subsystems subsystem ) const
90 
91  // NB: null keys are represented by kNullKey, not by an empty string
92  const RecordToKey& recordToKeyMap() const
93  { return m_recordToKey ; }
94 
95 protected:
96  /* Mapping from records and types to tokens.
97  * I as unvable to make type std::map<std::pair<std::string, std::string>, std::string> persistent
98  * so record and type are concatanated with @ sign and resulting string is used as a key.
99  */
100 
101  // wsun 03/2008: instead of tokens, store the configuration keys instead.
102 /* typedef std::map<std::string, std::string> RecordsToToken; */
103 /* RecordsToToken recordsToToken; */
105 
106 
107  // wsun 03/2008: add data member for TSC key
108  std::string m_tscKey ;
110 };
111 
112 #endif
type
Definition: HCALResponse.h:22
int i
Definition: DBlmapReader.cc:9
void add(const RecordToKey &map)
Definition: L1TriggerKey.h:57
std::map< std::string, std::string > RecordToKey
Definition: L1TriggerKey.h:24
JetCorrectorParameters::Record record
Definition: classes.h:11
RecordToKey m_recordToKey
Definition: L1TriggerKey.h:104
dictionary map
Definition: Association.py:205
void setTSCKey(const std::string &tscKey)
Definition: L1TriggerKey.h:67
void add(const std::string &record, const std::string &type, const std::string &key)
Definition: L1TriggerKey.h:54
const RecordToKey & recordToKeyMap() const
Definition: L1TriggerKey.h:92
std::string m_subsystemKeys[kNumberSubsystems]
Definition: L1TriggerKey.h:109
static std::string kEmptyKey
Definition: L1TriggerKey.h:42
std::string m_tscKey
Definition: L1TriggerKey.h:108
const std::string & tscKey() const
Definition: L1TriggerKey.h:85
list key
Definition: combine.py:13
static std::string kNullKey
Definition: L1TriggerKey.h:40
void setSubsystemKey(L1Subsystems subsystem, const std::string &key)
Definition: L1TriggerKey.h:70
const std::string & subsystemKey(L1Subsystems subsystem) const
Definition: L1TriggerKey.h:88