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

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(), L1CondDBIOVWriterExt::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::lastPayloadToken, cond::service::PoolDBOutputService::tagInfo(), and dumpRecoGeometry_cfg::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.lastPayloadToken;
146  }
persistency::Exception Exception
Definition: Exception.h:25
bool isAvailable() const
Definition: Service.h:40
void tagInfo(const std::string &recordName, cond::TagInfo_t &result)
std::string lastPayloadToken
Definition: Types.h:75
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(), cond::persistency::IOVProxy::end(), cond::persistency::IOVProxy::find(), edm::Service< T >::isAvailable(), cond::persistency::Session::readIov(), cond::service::PoolDBOutputService::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.
124  cond::persistency::Session session = poolDb->session();
125  cond::persistency::IOVProxy iov = session.readIov(iovTag);
126  session.transaction().start();
127 
129  auto iP = iov.find(runNumber);
130  if (iP != iov.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
Transaction & transaction()
Definition: Session.cc:43
std::string tag(const std::string &recordName)
IOVProxy readIov(const std::string &tag, bool full=false)
Definition: Session.cc:54
std::string payloadToken(const std::string &recordName, edm::RunNumber_t runNumber)
bool isAvailable() const
Definition: Service.h:40
Iterator find(cond::Time_t time)
Definition: IOVProxy.cc:322
Iterator end() const
Definition: IOVProxy.cc:293
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(), and cond::service::PoolDBOutputService::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();
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  }
persistency::Exception Exception
Definition: Exception.h:25
cond::persistency::Session session() const
std::unique_ptr< T > fetchPayload(const cond::Hash &payloadHash)
Definition: Session.h:224
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(), cond::service::PoolDBOutputService::endOfTime(), edm::Service< T >::isAvailable(), cond::service::PoolDBOutputService::isNewTagRequest(), cond::TagInfo_t::lastInterval, cond::TagInfo_t::lastPayloadToken, payloadToken(), cond::service::PoolDBOutputService::tag(), cond::service::PoolDBOutputService::tagInfo(), and dumpRecoGeometry_cfg::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, poolDb->endOfTime(), esRecordName, logTransactions);
89  } else {
91  poolDb->tagInfo(esRecordName, tagInfo);
92 
93  if (sinceRun == 0) // find last since and add 1
94  {
95  sinceRun = tagInfo.lastInterval.first;
96  ++sinceRun;
97  }
98 
99  if (tagInfo.lastPayloadToken != payloadToken) {
100  poolDb->appendSinceTime(payloadToken, sinceRun, esRecordName, logTransactions);
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
std::string tag(const std::string &recordName)
cond::ValidityInterval lastInterval
Definition: Types.h:74
void appendSinceTime(T *payloadObj, cond::Time_t sinceTime, const std::string &recordName, bool withlogging=false)
bool isNewTagRequest(const std::string &recordName)
std::string payloadToken(const std::string &recordName, edm::RunNumber_t runNumber)
bool isAvailable() const
Definition: Service.h:40
void createNewIOV(T *firstPayloadObj, cond::Time_t firstSinceTime, cond::Time_t firstTillTime, const std::string &recordName, bool withlogging=false)
void tagInfo(const std::string &recordName, cond::TagInfo_t &result)
std::string lastPayloadToken
Definition: Types.h:75
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(), 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();
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  }
persistency::Exception Exception
Definition: Exception.h:25
cond::persistency::Session session() const
Transaction & transaction()
Definition: Session.cc:43
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:197
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 timingPdfMaker::get, edm::Service< T >::isAvailable(), payloadToken(), AlCaHLTBitMon_QueryRunRegistry::string, and cscNeutronWriter_cfi::writer.

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
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