CMS 3D CMS Logo

List of all members | Public Member Functions
l1t::DataWriter Class Reference

#include <DataWriter.h>

Public Member Functions

 DataWriter ()
 
bool fillLastTriggerKeyList (L1TriggerKeyList &output)
 
std::string lastPayloadToken (const std::string &recordName)
 
std::string payloadToken (const std::string &recordName, edm::RunNumber_t runNumber)
 
template<class T >
void readObject (const std::string &payloadToken, T &outputObject)
 
bool updateIOV (const std::string &esRecordName, const std::string &payloadToken, edm::RunNumber_t sinceRun, bool logTransactions=false)
 
void writeKeyList (L1TriggerKeyList *keyList, edm::RunNumber_t sinceRun=0, bool logTransactions=false)
 
std::string writePayload (const edm::EventSetup &setup, const std::string &recordType)
 
 ~DataWriter ()
 

Detailed Description

Definition at line 35 of file DataWriter.h.

Constructor & Destructor Documentation

◆ DataWriter()

l1t::DataWriter::DataWriter ( )

Definition at line 12 of file DataWriter.cc.

12 {}

◆ ~DataWriter()

l1t::DataWriter::~DataWriter ( )

Definition at line 13 of file DataWriter.cc.

13 {}

Member Function Documentation

◆ fillLastTriggerKeyList()

bool l1t::DataWriter::fillLastTriggerKeyList ( L1TriggerKeyList output)

Definition at line 147 of file DataWriter.cc.

147  {
148  std::string keyListToken = lastPayloadToken("L1TriggerKeyListRcd");
149  if (keyListToken.empty()) {
150  return false;
151  } else {
152  readObject(keyListToken, output);
153  return true;
154  }
155  }

References lastPayloadToken(), convertSQLitetoXML_cfg::output, readObject(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by L1CondDBIOVWriter::analyze(), L1CondDBPayloadWriter::analyze(), L1O2OTestAnalyzer::analyze(), L1GtRunSettingsViewer::analyze(), L1ConfigOnlineProdBase< L1HtMissScaleRcd, L1CaloEtScale >::getObjectKey(), and L1SubsystemKeysOnlineProd::produce().

◆ lastPayloadToken()

std::string l1t::DataWriter::lastPayloadToken ( const std::string &  recordName)

Definition at line 136 of file DataWriter.cc.

136  {
138  if (!poolDb.isAvailable()) {
139  throw cond::Exception("DataWriter: PoolDBOutputService not available.");
140  }
141 
143  poolDb->tagInfo(recordName, tagInfo);
144  return tagInfo.lastInterval.payloadId;
145  }

References edm::Service< T >::isAvailable(), align_cfg::recordName, cond::service::PoolDBOutputService::tagInfo(), and dumpRecoGeometry_cfg::tagInfo.

Referenced by fillLastTriggerKeyList().

◆ payloadToken()

std::string l1t::DataWriter::payloadToken ( const std::string &  recordName,
edm::RunNumber_t  runNumber 
)

Definition at line 113 of file DataWriter.cc.

113  {
115  if (!poolDb.isAvailable()) {
116  throw cond::Exception("DataWriter: PoolDBOutputService not available.");
117  }
118 
119  // Get tag corresponding to EventSetup record name.
120  std::string iovTag = poolDb->tag(recordName);
121 
122  // Get IOV token for tag.
123  cond::persistency::Session session = poolDb->session();
124  cond::persistency::IOVProxy iov = session.readIov(iovTag);
125  session.transaction().start();
126  auto iovs = iov.selectAll();
128  auto iP = iovs.find(runNumber);
129  if (iP != iovs.end()) {
130  payloadToken = (*iP).payloadId;
131  }
132  session.transaction().commit();
133  return payloadToken;
134  }

References cond::persistency::Transaction::commit(), edm::Service< T >::isAvailable(), cond::persistency::Session::readIov(), align_cfg::recordName, convertSQLiteXML::runNumber, cond::persistency::IOVProxy::selectAll(), cond::service::PoolDBOutputService::session(), cond::persistency::Transaction::start(), AlCaHLTBitMon_QueryRunRegistry::string, cond::service::PoolDBOutputService::tag(), and cond::persistency::Session::transaction().

Referenced by readObject(), updateIOV(), writeKeyList(), and writePayload().

◆ readObject()

template<class T >
void l1t::DataWriter::readObject ( const std::string &  payloadToken,
T outputObject 
)

Definition at line 72 of file DataWriter.h.

72  {
74  if (!poolDb.isAvailable()) {
75  throw cond::Exception("DataWriter: PoolDBOutputService not available.");
76  }
77 
78  cond::persistency::Session session = poolDb->session();
79  session.transaction().start(true);
80 
81  // Get object from CondDB
82  std::shared_ptr<T> ref = session.fetchPayload<T>(payloadToken);
83  outputObject = *ref;
84  session.transaction().commit();
85  }

References cond::persistency::Transaction::commit(), cond::persistency::Session::fetchPayload(), edm::Service< T >::isAvailable(), payloadToken(), cond::service::PoolDBOutputService::session(), cond::persistency::Transaction::start(), and cond::persistency::Session::transaction().

Referenced by L1CondDBIOVWriter::analyze(), L1GtRunSettingsViewer::analyze(), and fillLastTriggerKeyList().

◆ updateIOV()

bool l1t::DataWriter::updateIOV ( const std::string &  esRecordName,
const std::string &  payloadToken,
edm::RunNumber_t  sinceRun,
bool  logTransactions = false 
)

Definition at line 72 of file DataWriter.cc.

75  {
76  edm::LogVerbatim("L1-O2O") << esRecordName << " PAYLOAD TOKEN " << payloadToken;
77 
79  if (!poolDb.isAvailable()) {
80  throw cond::Exception("DataWriter: PoolDBOutputService not available.");
81  }
82 
83  bool iovUpdated = true;
84 
85  if (poolDb->isNewTagRequest(esRecordName)) {
86  sinceRun = poolDb->beginOfTime();
87  poolDb->createNewIOV(payloadToken, sinceRun, esRecordName);
88  } else {
90  poolDb->tagInfo(esRecordName, tagInfo);
91 
92  if (sinceRun == 0) // find last since and add 1
93  {
94  sinceRun = tagInfo.lastInterval.since;
95  ++sinceRun;
96  }
97 
98  if (tagInfo.lastInterval.payloadId != payloadToken) {
99  poolDb->appendSinceTime(payloadToken, sinceRun, esRecordName);
100  } else {
101  iovUpdated = false;
102  edm::LogVerbatim("L1-O2O") << "IOV already up to date.";
103  }
104  }
105 
106  if (iovUpdated) {
107  edm::LogVerbatim("L1-O2O") << esRecordName << " " << poolDb->tag(esRecordName) << " SINCE " << sinceRun;
108  }
109 
110  return iovUpdated;
111  }

References cond::service::PoolDBOutputService::appendSinceTime(), cond::service::PoolDBOutputService::beginOfTime(), cond::service::PoolDBOutputService::createNewIOV(), edm::Service< T >::isAvailable(), cond::service::PoolDBOutputService::isNewTagRequest(), payloadToken(), cond::service::PoolDBOutputService::tag(), cond::service::PoolDBOutputService::tagInfo(), and dumpRecoGeometry_cfg::tagInfo.

Referenced by CaloConfigWriter::analyze(), L1TCaloParamsWriter::analyze(), CaloParamsWriter::analyze(), L1CondDBIOVWriter::analyze(), and writeKeyList().

◆ writeKeyList()

void l1t::DataWriter::writeKeyList ( L1TriggerKeyList keyList,
edm::RunNumber_t  sinceRun = 0,
bool  logTransactions = false 
)

tr.start( false );

Definition at line 49 of file DataWriter.cc.

49  {
51  if (!poolDb.isAvailable()) {
52  throw cond::Exception("DataWriter: PoolDBOutputService not available.");
53  }
54 
55  cond::persistency::Session session = poolDb->session();
58 
59  // Write L1TriggerKeyList payload and save payload token before committing
60  std::shared_ptr<L1TriggerKeyList> pointer(keyList);
61  std::string payloadToken = session.storePayload(*pointer);
62 
63  // Commit before calling updateIOV(), otherwise PoolDBOutputService gets
64  // confused.
65  //tr.commit ();
66  tr.close();
67 
68  // Set L1TriggerKeyList IOV
69  updateIOV("L1TriggerKeyListRcd", payloadToken, sinceRun, logTransactions);
70  }

References edm::Service< T >::isAvailable(), payloadToken(), cond::service::PoolDBOutputService::session(), cond::persistency::Session::storePayload(), AlCaHLTBitMon_QueryRunRegistry::string, cond::persistency::Session::transaction(), and updateIOV().

Referenced by L1CondDBPayloadWriter::analyze().

◆ writePayload()

std::string l1t::DataWriter::writePayload ( const edm::EventSetup setup,
const std::string &  recordType 
)

Definition at line 15 of file DataWriter.cc.

15  {
16  WriterFactory* factory = WriterFactory::get();
17  std::unique_ptr<WriterProxy> writer(factory->create(recordType + "@Writer"));
18  if (writer.get() == nullptr) {
19  throw cond::Exception("DataWriter: could not create WriterProxy with name " + recordType + "@Writer");
20  }
21 
23  if (!poolDb.isAvailable()) {
24  throw cond::Exception("DataWriter: PoolDBOutputService not available.");
25  }
26 
27  // 2010-02-16: Move session and transaction to WriterProxy::save(). Otherwise, if another transaction is
28  // started while WriterProxy::save() is called (e.g. in a ESProducer like L1ConfigOnlineProdBase), the
29  // transaction here will become read-only.
30  // cond::DbSession session = poolDb->session();
31  // cond::DbScopedTransaction tr(session);
32 
34  // // if throw transaction will unroll
35  // tr.start(false);
36 
37  // update key to have new payload registered for record-type pair.
38  // std::string payloadToken = writer->save( setup, session ) ;
40 
41  edm::LogVerbatim("L1-O2O") << recordType << " PAYLOAD TOKEN " << payloadToken;
42 
43  tr.close();
44  // tr.commit ();
45 
46  return payloadToken;
47  }

References get, edm::Service< T >::isAvailable(), payloadToken(), cond::service::PoolDBOutputService::session(), singleTopDQM_cfi::setup, AlCaHLTBitMon_QueryRunRegistry::string, cond::persistency::Session::transaction(), and cscNeutronWriter_cfi::writer.

Referenced by CaloConfigWriter::analyze(), L1TCaloParamsWriter::analyze(), CaloParamsWriter::analyze(), and L1CondDBPayloadWriter::analyze().

cond::persistency::TransactionScope
Definition: Session.h:231
cond::service::PoolDBOutputService::tag
std::string tag(const std::string &recordName)
Definition: PoolDBOutputService.cc:96
l1t::DataWriter::updateIOV
bool updateIOV(const std::string &esRecordName, const std::string &payloadToken, edm::RunNumber_t sinceRun, bool logTransactions=false)
Definition: DataWriter.cc:72
cond::service::PoolDBOutputService::beginOfTime
cond::Time_t beginOfTime() const
Definition: PoolDBOutputService.cc:187
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:32
align_cfg.recordName
recordName
Definition: align_cfg.py:66
cond::service::PoolDBOutputService::tagInfo
bool tagInfo(const std::string &recordName, cond::TagInfo_t &result)
Definition: PoolDBOutputService.cc:369
cond::service::PoolDBOutputService::appendSinceTime
void appendSinceTime(const T *payloadObj, cond::Time_t sinceTime, const std::string &recordName)
Definition: PoolDBOutputService.h:135
cscNeutronWriter_cfi.writer
writer
Definition: cscNeutronWriter_cfi.py:6
l1t::DataWriter::lastPayloadToken
std::string lastPayloadToken(const std::string &recordName)
Definition: DataWriter.cc:136
edm::Service::isAvailable
bool isAvailable() const
Definition: Service.h:40
cond::persistency::IOVProxy::selectAll
IOVArray selectAll()
Definition: IOVProxy.cc:171
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
convertSQLiteXML.runNumber
runNumber
Definition: convertSQLiteXML.py:91
cond::persistency::Session::fetchPayload
std::unique_ptr< T > fetchPayload(const cond::Hash &payloadHash)
Definition: Session.h:213
cond::service::PoolDBOutputService::createNewIOV
void createNewIOV(const T *firstPayloadObj, cond::Time_t firstSinceTime, cond::Time_t, const std::string &recordName)
Definition: PoolDBOutputService.h:110
cond::service::PoolDBOutputService::session
cond::persistency::Session session() const
Definition: PoolDBOutputService.cc:94
l1t::DataWriter::payloadToken
std::string payloadToken(const std::string &recordName, edm::RunNumber_t runNumber)
Definition: DataWriter.cc:113
cond::persistency::Session::readIov
IOVProxy readIov(const std::string &tag)
Definition: Session.cc:63
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cond::persistency::IOVProxy
Definition: IOVProxy.h:92
l1t::WriterFactory
edmplugin::PluginFactory< l1t::WriterProxy *()> WriterFactory
Definition: WriterProxy.h:79
cond::persistency::Session
Definition: Session.h:63
edm::Service< cond::service::PoolDBOutputService >
cond::persistency::Transaction::commit
void commit()
Definition: Session.cc:23
cond::Exception
persistency::Exception Exception
Definition: Exception.h:25
edm::LogVerbatim
Definition: MessageLogger.h:297
get
#define get
cond::persistency::Session::storePayload
cond::Hash storePayload(const T &payload, const boost::posix_time::ptime &creationTime=boost::posix_time::microsec_clock::universal_time())
Definition: Session.h:186
cond::persistency::Session::transaction
Transaction & transaction()
Definition: Session.cc:52
cond::persistency::Transaction::start
void start(bool readOnly=true)
Definition: Session.cc:18
l1t::DataWriter::readObject
void readObject(const std::string &payloadToken, T &outputObject)
Definition: DataWriter.h:72
T
long double T
Definition: Basic3DVectorLD.h:48
cond::service::PoolDBOutputService::isNewTagRequest
bool isNewTagRequest(const std::string &recordName)
Definition: PoolDBOutputService.cc:100
dumpRecoGeometry_cfg.tagInfo
tagInfo
Definition: dumpRecoGeometry_cfg.py:194
cond::TagInfo_t
Definition: Types.h:69