File indexing completed on 2024-04-06 12:03:12
0001 #ifndef CondTools_L1Trigger_DataWriter_h
0002 #define CondTools_L1Trigger_DataWriter_h
0003
0004
0005 #include "FWCore/Framework/interface/IOVSyncValue.h"
0006 #include "FWCore/Framework/interface/EventSetup.h"
0007 #include "FWCore/Framework/interface/DataKey.h"
0008
0009 #include "FWCore/ServiceRegistry/interface/Service.h"
0010 #include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
0011 #include "CondCore/CondDB/interface/Session.h"
0012
0013 #include "DataFormats/Provenance/interface/RunID.h"
0014
0015
0016 #include "CondFormats/L1TObjects/interface/L1TriggerKeyList.h"
0017 #include "CondFormats/L1TObjects/interface/L1TriggerKey.h"
0018
0019 #include "CondTools/L1Trigger/interface/WriterProxy.h"
0020
0021 #include <string>
0022 #include <map>
0023
0024 namespace l1t {
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035 class DataWriter {
0036 public:
0037 DataWriter();
0038 ~DataWriter();
0039
0040
0041
0042
0043
0044 std::string writePayload(const edm::EventSetup& setup, const std::string& recordType);
0045
0046
0047
0048
0049
0050 bool updateIOV(const std::string& esRecordName,
0051 const std::string& payloadToken,
0052 edm::RunNumber_t sinceRun,
0053 bool logTransactions = false);
0054
0055
0056 void writeKeyList(L1TriggerKeyList* keyList, edm::RunNumber_t sinceRun = 0, bool logTransactions = false);
0057
0058
0059 template <class T>
0060 void readObject(const std::string& payloadToken, T& outputObject);
0061
0062 std::string payloadToken(const std::string& recordName, edm::RunNumber_t runNumber);
0063
0064 std::string lastPayloadToken(const std::string& recordName);
0065
0066 bool fillLastTriggerKeyList(L1TriggerKeyList& output);
0067
0068 protected:
0069 };
0070
0071 template <class T>
0072 void DataWriter::readObject(const std::string& payloadToken, T& outputObject) {
0073 edm::Service<cond::service::PoolDBOutputService> poolDb;
0074 if (!poolDb.isAvailable()) {
0075 throw cond::Exception("DataWriter: PoolDBOutputService not available.");
0076 }
0077
0078 cond::persistency::Session session = poolDb->session();
0079 session.transaction().start(true);
0080
0081
0082 std::shared_ptr<T> ref = session.fetchPayload<T>(payloadToken);
0083 outputObject = *ref;
0084 session.transaction().commit();
0085 }
0086
0087 }
0088
0089 #endif