CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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

l1t::DataWriterExt::DataWriterExt ( )

Definition at line 12 of file DataWriterExt.cc.

12 {}
l1t::DataWriterExt::~DataWriterExt ( )

Definition at line 13 of file DataWriterExt.cc.

13 {}

Member Function Documentation

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

Definition at line 148 of file DataWriterExt.cc.

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

Referenced by L1CondDBPayloadWriterExt::analyze(), L1O2OTestAnalyzerExt::analyze(), L1ConfigOnlineProdBaseExt< TRcd, TData >::getObjectKey(), and L1SubsystemKeysOnlineProdExt::produce().

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  }
void readObject(const std::string &payloadToken, T &outputObject)
Definition: DataWriterExt.h:72
std::string lastPayloadToken(const std::string &recordName)
std::string l1t::DataWriterExt::lastPayloadToken ( const std::string &  recordName)

Definition at line 137 of file DataWriterExt.cc.

References edm::Service< T >::isAvailable(), cond::TagInfo_t::lastInterval, cond::Iov_t::payloadId, dumpRecoGeometry_cfg::tagInfo, and cond::service::PoolDBOutputService::tagInfo().

Referenced by fillLastTriggerKeyList().

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  }
persistency::Exception Exception
Definition: Exception.h:25
Iov_t lastInterval
Definition: Types.h:73
tuple recordName
Definition: align_cfg.py:66
bool isAvailable() const
Definition: Service.h:40
Hash payloadId
Definition: Types.h:55
bool tagInfo(const std::string &recordName, cond::TagInfo_t &result)
std::string l1t::DataWriterExt::payloadToken ( const std::string &  recordName,
edm::RunNumber_t  runNumber 
)

Definition at line 114 of file DataWriterExt.cc.

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

Referenced by L1O2OTestAnalyzerExt::analyze(), readObject(), updateIOV(), writeKeyList(), and writePayload().

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.
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  }
persistency::Exception Exception
Definition: Exception.h:25
void start(bool readOnly=true)
Definition: Session.cc:18
cond::persistency::Session session() const
tuple recordName
Definition: align_cfg.py:66
Transaction & transaction()
Definition: Session.cc:52
std::string tag(const std::string &recordName)
std::string payloadToken(const std::string &recordName, edm::RunNumber_t runNumber)
bool isAvailable() const
Definition: Service.h:40
IOVProxy readIov(const std::string &tag)
Definition: Session.cc:63
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.

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

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

72  {
74  if (!poolDb.isAvailable()) {
75  throw cond::Exception("DataWriter: PoolDBOutputService not available.");
76  }
77 
78  poolDb->forceInit();
81 
82  // Get object from CondDB
83  std::shared_ptr<T> ref = session.fetchPayload<T>(payloadToken);
84  outputObject = *ref;
86  }
persistency::Exception Exception
Definition: Exception.h:25
cond::persistency::Session session() const
std::unique_ptr< T > fetchPayload(const cond::Hash &payloadHash)
Definition: Session.h:213
std::string payloadToken(const std::string &recordName, edm::RunNumber_t runNumber)
bool isAvailable() const
Definition: Service.h:40
long double T
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.

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

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

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  }
persistency::Exception Exception
Definition: Exception.h:25
Log< level::Info, true > LogVerbatim
Iov_t lastInterval
Definition: Types.h:73
Time_t since
Definition: Types.h:53
std::string tag(const std::string &recordName)
void appendSinceTime(const T *payloadPtr, cond::Time_t sinceTime, const std::string &recordName)
bool isNewTagRequest(const std::string &recordName)
std::string payloadToken(const std::string &recordName, edm::RunNumber_t runNumber)
bool isAvailable() const
Definition: Service.h:40
Hash payloadId
Definition: Types.h:55
bool tagInfo(const std::string &recordName, cond::TagInfo_t &result)
void createNewIOV(const T *payloadPtr, cond::Time_t firstSinceTime, cond::Time_t, const std::string &recordName)
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.

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

Referenced by L1CondDBPayloadWriterExt::analyze().

49  {
51  if (!poolDb.isAvailable()) {
52  throw cond::Exception("DataWriter: PoolDBOutputService not available.");
53  }
54 
55  poolDb->forceInit();
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  }
persistency::Exception Exception
Definition: Exception.h:25
cond::persistency::Session session() const
Transaction & transaction()
Definition: Session.cc:52
bool updateIOV(const std::string &esRecordName, const std::string &payloadToken, edm::RunNumber_t sinceRun, bool logTransactions=false)
std::string payloadToken(const std::string &recordName, edm::RunNumber_t runNumber)
bool isAvailable() const
Definition: Service.h:40
cond::Hash storePayload(const T &payload, const boost::posix_time::ptime &creationTime=boost::posix_time::microsec_clock::universal_time())
Definition: Session.h:186
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.

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

Referenced by L1CondDBPayloadWriterExt::analyze().

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 ) ;
39  std::string payloadToken = writer->save(setup);
40 
41  edm::LogVerbatim("L1-O2O") << recordType << " PAYLOAD TOKEN " << payloadToken;
42 
44  // tr.commit ();
45 
46  return payloadToken;
47  }
persistency::Exception Exception
Definition: Exception.h:25
Log< level::Info, true > LogVerbatim
edmplugin::PluginFactory< l1t::WriterProxy *()> WriterFactory
Definition: WriterProxy.h:79
std::string payloadToken(const std::string &recordName, edm::RunNumber_t runNumber)
bool isAvailable() const
Definition: Service.h:40
#define get