test
CMS 3D CMS Logo

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