CMS 3D CMS Logo

DataWriterExt.h
Go to the documentation of this file.
1 #ifndef CondTools_L1Trigger_DataWriter_h
2 #define CondTools_L1Trigger_DataWriter_h
3 
4 // Framework
8 
12 
14 
15 // L1T includes
18 
20 
21 #include <string>
22 #include <map>
23 
24 namespace l1t {
25 
26  /* This class is used to write L1 Trigger configuration data to Pool DB.
27  * It also has a function for reading L1TriggerKey directly from Pool.
28  *
29  * In order to use this class to write payloads, user has to make sure to register datatypes that she or he is
30  * interested to write to the framework. This should be done with macro REGISTER_L1_WRITER(record, type) found in
31  * WriterProxy.h file. Also, one should take care to register these data types to CondDB framework with macro
32  * REGISTER_PLUGIN(record, type) from registration_macros.h found in PluginSystem.
33  */
34 
35  class DataWriterExt {
36  public:
37  DataWriterExt();
39 
40  // Payload and IOV writing functions.
41 
42  // Get payload from EventSetup and write to DB with no IOV
43  // recordType = "record@type", return value is payload token
44  std::string writePayload(const edm::EventSetup& setup, const std::string& recordType);
45 
46  // Use PoolDBOutputService to append IOV with sinceRun to IOV sequence
47  // for given ESRecord. PoolDBOutputService knows the corresponding IOV tag.
48  // Return value is true if IOV was updated; false if IOV was already
49  // up to date.
50  bool updateIOV(const std::string& esRecordName,
52  edm::RunNumber_t sinceRun,
53  bool logTransactions = false);
54 
55  // Write L1TriggerKeyListExt payload and set IOV. Takes ownership of pointer.
56  void writeKeyList(L1TriggerKeyListExt* keyList, edm::RunNumber_t sinceRun = 0, bool logTransactions = false);
57 
58  // Read object directly from Pool, not from EventSetup.
59  template <class T>
60  void readObject(const std::string& payloadToken, T& outputObject);
61 
63 
65 
67 
68  protected:
69  };
70 
71  template <class T>
72  void DataWriterExt::readObject(const std::string& payloadToken, T& outputObject) {
74  if (!poolDb.isAvailable()) {
75  throw cond::Exception("DataWriter: PoolDBOutputService not available.");
76  }
77 
78  poolDb->forceInit();
79  cond::persistency::Session session = poolDb->session();
81 
82  // Get object from CondDB
83  std::shared_ptr<T> ref = session.fetchPayload<T>(payloadToken);
84  outputObject = *ref;
86  }
87 
88 } // namespace l1t
89 
90 #endif
edm::RunNumber_t
unsigned int RunNumber_t
Definition: RunLumiEventNumber.h:14
L1TriggerKeyListExt
Definition: L1TriggerKeyListExt.h:10
l1t::DataWriterExt::payloadToken
std::string payloadToken(const std::string &recordName, edm::RunNumber_t runNumber)
Definition: DataWriterExt.cc:114
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:72
align_cfg.recordName
recordName
Definition: align_cfg.py:66
edm::Service::isAvailable
bool isAvailable() const
Definition: Service.h:40
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
convertSQLiteXML.runNumber
runNumber
Definition: convertSQLiteXML.py:91
L1TriggerKeyExt.h
cond::persistency::Session::fetchPayload
std::unique_ptr< T > fetchPayload(const cond::Hash &payloadHash)
Definition: Session.h:213
PoolDBOutputService.h
cond::service::PoolDBOutputService::session
cond::persistency::Session session() const
Definition: PoolDBOutputService.cc:92
l1t::DataWriterExt::lastPayloadToken
std::string lastPayloadToken(const std::string &recordName)
Definition: DataWriterExt.cc:137
Service.h
l1t::DataWriterExt::DataWriterExt
DataWriterExt()
Definition: DataWriterExt.cc:12
l1t::DataWriterExt::fillLastTriggerKeyList
bool fillLastTriggerKeyList(L1TriggerKeyListExt &output)
Definition: DataWriterExt.cc:148
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
WriterProxy.h
l1t
delete x;
Definition: CaloConfig.h:22
DataKey.h
cond::persistency::Session
Definition: Session.h:63
edm::Service< cond::service::PoolDBOutputService >
cond::Exception
persistency::Exception Exception
Definition: Exception.h:25
edm::EventSetup
Definition: EventSetup.h:57
l1t::DataWriterExt::~DataWriterExt
~DataWriterExt()
Definition: DataWriterExt.cc:13
T
long double T
Definition: Basic3DVectorLD.h:48
l1t::DataWriterExt::writePayload
std::string writePayload(const edm::EventSetup &setup, const std::string &recordType)
Definition: DataWriterExt.cc:15
EventSetup.h
L1TriggerKeyListExt.h
Session.h
IOVSyncValue.h
l1t::DataWriterExt::updateIOV
bool updateIOV(const std::string &esRecordName, const std::string &payloadToken, edm::RunNumber_t sinceRun, bool logTransactions=false)
Definition: DataWriterExt.cc:73
RunID.h
l1t::DataWriterExt::readObject
void readObject(const std::string &payloadToken, T &outputObject)
Definition: DataWriterExt.h:72
cond::service::PoolDBOutputService::forceInit
void forceInit()
Definition: PoolDBOutputService.cc:201
l1t::DataWriterExt::writeKeyList
void writeKeyList(L1TriggerKeyListExt *keyList, edm::RunNumber_t sinceRun=0, bool logTransactions=false)
Definition: DataWriterExt.cc:49
l1t::DataWriterExt
Definition: DataWriterExt.h:35