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 
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 {
25 public:
26  typedef std::map<std::string, std::string> RecordToKey;
27 
29  {
36  kGT,
39  } ;
40 
41  // Empty strings cannot be stored in the CondDB, so define a null key string.
42  const static std::string kNullKey ;
43 
44  const static std::string kEmptyKey ;
45 
46  // Constructors
48  {
49  for( int i = 0 ; i < kNumberSubsystems ; ++i )
50  {
52  }
53  }
54 
55  /* Adds new record and type mapping to payload. If such exists, nothing happens */
56  void add (const std::string & record, const std::string & type, const std::string & key)
57  { m_recordToKey.insert (std::make_pair (record + "@" + type, key.empty() ? kNullKey : key)); }
58 
59  void add (const RecordToKey& map)
60  {
61  for( RecordToKey::const_iterator itr = map.begin() ;
62  itr != map.end() ;
63  ++itr )
64  {
65  m_recordToKey.insert( std::make_pair( itr->first, itr->second.empty() ? kNullKey : itr->second ) ) ;
66  }
67  }
68 
69  void setTSCKey( const std::string& tscKey )
70  { m_tscKey = tscKey ; }
71 
73  { m_subsystemKeys[ subsystem ] = key.empty() ? kNullKey : key ; }
74 
75  /* Gets payload key for record and type. If no such paylaod exists, emtpy string
76  * is returned.
77  */
78  std::string get (const std::string & record, const std::string & type) const
79  {
80  RecordToKey::const_iterator it = m_recordToKey.find (record + "@" + type);
81  if (it == m_recordToKey.end ())
82  return std::string ();
83  else
84  return it->second == kNullKey ? kEmptyKey : it->second ;
85  }
86 
87  const std::string& tscKey() const
88  { return m_tscKey ; }
89 
92 
93  // NB: null keys are represented by kNullKey, not by an empty string
94  const RecordToKey& recordToKeyMap() const
95  { return m_recordToKey ; }
96 
97 protected:
98  /* Mapping from records and types to tokens.
99  * I as unvable to make type std::map<std::pair<std::string, std::string>, std::string> persistent
100  * so record and type are concatanated with @ sign and resulting string is used as a key.
101  */
102 
103  // wsun 03/2008: instead of tokens, store the configuration keys instead.
104 /* typedef std::map<std::string, std::string> RecordsToToken; */
105 /* RecordsToToken recordsToToken; */
107 
108 
109  // wsun 03/2008: add data member for TSC key
112 
114 };
115 
116 #endif
type
Definition: HCALResponse.h:21
int i
Definition: DBlmapReader.cc:9
static const std::string kEmptyKey
Definition: L1TriggerKey.h:44
void add(const RecordToKey &map)
Definition: L1TriggerKey.h:59
std::map< std::string, std::string > RecordToKey
Definition: L1TriggerKey.h:26
JetCorrectorParameters::Record record
Definition: classes.h:7
static const std::string kNullKey
Definition: L1TriggerKey.h:42
RecordToKey m_recordToKey
Definition: L1TriggerKey.h:106
void setTSCKey(const std::string &tscKey)
Definition: L1TriggerKey.h:69
void add(const std::string &record, const std::string &type, const std::string &key)
Definition: L1TriggerKey.h:56
const RecordToKey & recordToKeyMap() const
Definition: L1TriggerKey.h:94
std::string m_subsystemKeys[kNumberSubsystems]
Definition: L1TriggerKey.h:111
std::string m_tscKey
Definition: L1TriggerKey.h:110
#define COND_SERIALIZABLE
Definition: Serializable.h:30
const std::string & tscKey() const
Definition: L1TriggerKey.h:87
list key
Definition: combine.py:13
void setSubsystemKey(L1Subsystems subsystem, const std::string &key)
Definition: L1TriggerKey.h:72
const std::string & subsystemKey(L1Subsystems subsystem) const
Definition: L1TriggerKey.h:90