CMS 3D CMS Logo

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

#include <DataWriterExt.h>

Public Member Functions

 DataWriterExt ()
 
bool fillLastTriggerKeyList (L1TriggerKeyListExt &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 (L1TriggerKeyListExt *keyList, edm::RunNumber_t sinceRun=0, bool logTransactions=false)
 
std::string writePayload (const edm::EventSetup &setup, const std::string &recordType)
 
 ~DataWriterExt ()
 

Detailed Description

Definition at line 35 of file DataWriterExt.h.

Constructor & Destructor Documentation

◆ DataWriterExt()

l1t::DataWriterExt::DataWriterExt ( )

Definition at line 12 of file DataWriterExt.cc.

12 {}

◆ ~DataWriterExt()

l1t::DataWriterExt::~DataWriterExt ( )

Definition at line 13 of file DataWriterExt.cc.

13 {}

Member Function Documentation

◆ fillLastTriggerKeyList()

bool l1t::DataWriterExt::fillLastTriggerKeyList ( L1TriggerKeyListExt output)

Definition at line 148 of file DataWriterExt.cc.

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

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

Referenced by L1CondDBIOVWriterExt::analyze(), L1CondDBPayloadWriterExt::analyze(), L1O2OTestAnalyzerExt::analyze(), L1ConfigOnlineProdBaseExt< L1TCaloParamsO2ORcd, l1t::CaloParams >::getObjectKey(), and L1SubsystemKeysOnlineProdExt::produce().

◆ lastPayloadToken()

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

Definition at line 137 of file DataWriterExt.cc.

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

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

Referenced by fillLastTriggerKeyList().

◆ payloadToken()

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

Definition at line 114 of file DataWriterExt.cc.

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

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::DataWriterExt::readObject ( const std::string &  payloadToken,
T outputObject 
)

session.transaction().start(true);

session.transaction().commit ();

Definition at line 72 of file DataWriterExt.h.

72  {
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  }

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

Referenced by L1CondDBIOVWriterExt::analyze(), and fillLastTriggerKeyList().

◆ updateIOV()

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

Definition at line 73 of file DataWriterExt.cc.

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

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 L1CondDBIOVWriterExt::analyze(), and writeKeyList().

◆ writeKeyList()

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

tr.start( false );

tr.commit ();

Definition at line 49 of file DataWriterExt.cc.

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

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

Referenced by L1CondDBPayloadWriterExt::analyze().

◆ writePayload()

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

cond::persistency::TransactionScope tr(poolDb->session().transaction());

Definition at line 15 of file DataWriterExt.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 
44  // tr.commit ();
45 
46  return payloadToken;
47  }

References get, edm::Service< T >::isAvailable(), payloadToken(), singleTopDQM_cfi::setup, AlCaHLTBitMon_QueryRunRegistry::string, and cscNeutronWriter_cfi::writer.

Referenced by L1CondDBPayloadWriterExt::analyze().

cond::persistency::TransactionScope
Definition: Session.h:231
cond::service::PoolDBOutputService::tag
std::string tag(const std::string &recordName)
Definition: PoolDBOutputService.cc:124
l1t::DataWriterExt::payloadToken
std::string payloadToken(const std::string &recordName, edm::RunNumber_t runNumber)
Definition: DataWriterExt.cc:114
cond::service::PoolDBOutputService::beginOfTime
cond::Time_t beginOfTime() const
Definition: PoolDBOutputService.cc:215
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:72
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:397
cond::service::PoolDBOutputService::appendSinceTime
void appendSinceTime(const T *payloadObj, cond::Time_t sinceTime, const std::string &recordName)
Definition: PoolDBOutputService.h:141
cscNeutronWriter_cfi.writer
writer
Definition: cscNeutronWriter_cfi.py:6
edm::Service::isAvailable
bool isAvailable() const
Definition: Service.h:40
cond::persistency::IOVProxy::selectAll
IOVArray selectAll()
Definition: IOVProxy.cc:175
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:116
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
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
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
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
T
long double T
Definition: Basic3DVectorLD.h:48
cond::service::PoolDBOutputService::isNewTagRequest
bool isNewTagRequest(const std::string &recordName)
Definition: PoolDBOutputService.cc:128
dumpRecoGeometry_cfg.tagInfo
tagInfo
Definition: dumpRecoGeometry_cfg.py:194
cond::TagInfo_t
Definition: Types.h:69
l1t::DataWriterExt::updateIOV
bool updateIOV(const std::string &esRecordName, const std::string &payloadToken, edm::RunNumber_t sinceRun, bool logTransactions=false)
Definition: DataWriterExt.cc:73
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