#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 () |
Definition at line 39 of file DataWriter.h.
l1t::DataWriter::DataWriter | ( | ) |
Definition at line 13 of file DataWriter.cc.
{}
l1t::DataWriter::~DataWriter | ( | ) |
Definition at line 14 of file DataWriter.cc.
{}
bool l1t::DataWriter::fillLastTriggerKeyList | ( | L1TriggerKeyList & | output | ) |
Definition at line 206 of file DataWriter.cc.
References funct::false, lastPayloadToken(), readObject(), and funct::true.
Referenced by L1O2OTestAnalyzer::analyze(), L1CondDBPayloadWriter::analyze(), and L1ConfigOnlineProdBase< TRcd, TData >::getObjectKey().
{ std::string keyListToken = lastPayloadToken( "L1TriggerKeyListRcd" ) ; if( keyListToken.empty() ) { return false ; } else { readObject( keyListToken, output ) ; return true ; } }
std::string l1t::DataWriter::lastPayloadToken | ( | const std::string & | recordName | ) |
Definition at line 191 of file DataWriter.cc.
References Exception, edm::Service< T >::isAvailable(), and cond::TagInfo::lastPayloadToken.
Referenced by fillLastTriggerKeyList().
{ edm::Service<cond::service::PoolDBOutputService> poolDb; if( !poolDb.isAvailable() ) { throw cond::Exception( "DataWriter: PoolDBOutputService not available." ) ; } cond::TagInfo tagInfo ; poolDb->tagInfo( recordName, tagInfo ) ; return tagInfo.lastPayloadToken ; }
std::string l1t::DataWriter::payloadToken | ( | const std::string & | recordName, |
edm::RunNumber_t | runNumber | ||
) |
Definition at line 153 of file DataWriter.cc.
References cond::DbScopedTransaction::commit(), Exception, cond::MetaData::getToken(), cond::MetaData::hasTag(), edm::Service< T >::isAvailable(), cond::IOVService::payloadToken(), python::CommonUtils::session, and cond::DbScopedTransaction::start().
Referenced by L1O2OTestAnalyzer::analyze(), readObject(), updateIOV(), writeKeyList(), and writePayload().
{ edm::Service<cond::service::PoolDBOutputService> poolDb; if( !poolDb.isAvailable() ) { throw cond::Exception( "DataWriter: PoolDBOutputService not available." ) ; } // Get tag corresponding to EventSetup record name. std::string iovTag = poolDb->tag( recordName ) ; // Get IOV token for tag. cond::DbSession session = poolDb->session(); cond::DbScopedTransaction tr(session); tr.start(true); cond::MetaData metadata(session ) ; std::string iovToken ; if( metadata.hasTag( iovTag ) ) { iovToken = metadata.getToken( iovTag ) ; } if( iovToken.empty() ) { return std::string() ; } // Get payload token for run number. cond::IOVService iovService( session ) ; std::string payloadToken = iovService.payloadToken( iovToken, runNumber ) ; tr.commit() ; return payloadToken ; }
void l1t::DataWriter::readObject | ( | const std::string & | payloadToken, |
T & | outputObject | ||
) |
Definition at line 82 of file DataWriter.h.
References cond::DbScopedTransaction::commit(), Exception, cond::DbSession::getTypedObject(), edm::Service< T >::isAvailable(), payloadToken(), MultipleCompare::ref, python::CommonUtils::session, and cond::DbScopedTransaction::start().
Referenced by L1CondDBIOVWriter::analyze(), and fillLastTriggerKeyList().
{ edm::Service<cond::service::PoolDBOutputService> poolDb; if( !poolDb.isAvailable() ) { throw cond::Exception( "DataWriter: PoolDBOutputService not available." ) ; } cond::DbSession session = poolDb->session(); cond::DbScopedTransaction tr(session); tr.start(true); // Get object from POOL boost::shared_ptr<T> ref = session.getTypedObject<T>(payloadToken) ; outputObject = *ref ; tr.commit (); }
bool l1t::DataWriter::updateIOV | ( | const std::string & | esRecordName, |
const std::string & | payloadToken, | ||
edm::RunNumber_t | sinceRun, | ||
bool | logTransactions = false |
||
) |
Definition at line 91 of file DataWriter.cc.
References Exception, funct::false, edm::Service< T >::isAvailable(), cond::TagInfo::lastInterval, cond::TagInfo::lastPayloadToken, payloadToken(), and funct::true.
Referenced by L1CondDBIOVWriter::analyze(), and writeKeyList().
{ edm::LogVerbatim( "L1-O2O" ) << esRecordName << " PAYLOAD TOKEN " << payloadToken ; edm::Service<cond::service::PoolDBOutputService> poolDb; if (!poolDb.isAvailable()) { throw cond::Exception( "DataWriter: PoolDBOutputService not available." ) ; } bool iovUpdated = true ; if( poolDb->isNewTagRequest( esRecordName ) ) { sinceRun = poolDb->beginOfTime() ; poolDb->createNewIOV( payloadToken, sinceRun, poolDb->endOfTime(), esRecordName, logTransactions ) ; } else { cond::TagInfo tagInfo ; poolDb->tagInfo( esRecordName, tagInfo ) ; if( sinceRun == 0 ) // find last since and add 1 { sinceRun = tagInfo.lastInterval.first ; ++sinceRun ; } if( tagInfo.lastPayloadToken != payloadToken ) { poolDb->appendSinceTime( payloadToken, sinceRun, esRecordName, logTransactions ) ; } else { iovUpdated = false ; edm::LogVerbatim( "L1-O2O" ) << "IOV already up to date." ; } } if( iovUpdated ) { edm::LogVerbatim( "L1-O2O" ) << esRecordName << " " << poolDb->tag( esRecordName ) << " SINCE " << sinceRun ; } return iovUpdated ; }
void l1t::DataWriter::writeKeyList | ( | L1TriggerKeyList * | keyList, |
edm::RunNumber_t | sinceRun = 0 , |
||
bool | logTransactions = false |
||
) |
Definition at line 58 of file DataWriter.cc.
References cond::classNameForTypeId(), cond::DbScopedTransaction::commit(), Exception, edm::Service< T >::isAvailable(), payloadToken(), python::CommonUtils::session, cond::DbScopedTransaction::start(), cond::DbSession::storeObject(), and updateIOV().
Referenced by L1CondDBPayloadWriter::analyze().
{ edm::Service<cond::service::PoolDBOutputService> poolDb; if( !poolDb.isAvailable() ) { throw cond::Exception( "DataWriter: PoolDBOutputService not available." ) ; } cond::DbSession session = poolDb->session(); cond::DbScopedTransaction tr(session); tr.start(false); // Write L1TriggerKeyList payload and save payload token before committing boost::shared_ptr<L1TriggerKeyList> pointer(keyList); std::string payloadToken = session.storeObject(pointer.get(), cond::classNameForTypeId(typeid(L1TriggerKeyList)) ); // Commit before calling updateIOV(), otherwise PoolDBOutputService gets // confused. tr.commit (); // Set L1TriggerKeyList IOV updateIOV( "L1TriggerKeyListRcd", payloadToken, sinceRun, logTransactions ) ; }
std::string l1t::DataWriter::writePayload | ( | const edm::EventSetup & | setup, |
const std::string & | recordType | ||
) |
Definition at line 19 of file DataWriter.cc.
References Exception, reco::get(), edm::Service< T >::isAvailable(), and payloadToken().
Referenced by L1CondDBPayloadWriter::analyze().
{ WriterFactory* factory = WriterFactory::get(); std::auto_ptr<WriterProxy> writer(factory->create( recordType + "@Writer" )) ; if( writer.get() == 0 ) { throw cond::Exception( "DataWriter: could not create WriterProxy with name " + recordType + "@Writer" ) ; } edm::Service<cond::service::PoolDBOutputService> poolDb; if (!poolDb.isAvailable()) { throw cond::Exception( "DataWriter: PoolDBOutputService not available." ) ; } // 2010-02-16: Move session and transaction to WriterProxy::save(). Otherwise, if another transaction is // started while WriterProxy::save() is called (e.g. in a ESProducer like L1ConfigOnlineProdBase), the // transaction here will become read-only. // cond::DbSession session = poolDb->session(); // cond::DbScopedTransaction tr(session); // // if throw transaction will unroll // tr.start(false); // update key to have new payload registered for record-type pair. // std::string payloadToken = writer->save( setup, session ) ; std::string payloadToken = writer->save( setup ) ; edm::LogVerbatim( "L1-O2O" ) << recordType << " PAYLOAD TOKEN " << payloadToken ; // tr.commit (); return payloadToken ; }