Skip to content

Commit

Permalink
Fix for sharing session with the base PopCon
Browse files Browse the repository at this point in the history
  • Loading branch information
ggovi committed May 16, 2017
1 parent e0c1840 commit c85c664
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions CondTools/RunInfo/interface/PopConBTransitionSourceHandler.h
Expand Up @@ -34,11 +34,9 @@ namespace popcon {
bool checkBOn() {
//the output boolean is set to true as default
bool isBOn = true;
cond::persistency::Session& session = PopConSourceHandler<T>::dbSession();
//reading RunInfo from Conditions
edm::LogInfo( "PopConBTransitionSourceHandler" ) << "[" << "PopConBTransitionSourceHandler::" << __func__ << "]: "
<< "Initialising CondDB read-only session to " << m_connectionString << std::endl;
cond::persistency::Session session = m_connection.createReadOnlySession( m_connectionString, "" );
session.transaction().start();
cond::persistency::TransactionScope trans( session.transaction() );
edm::LogInfo( "PopConBTransitionSourceHandler" ) << "[" << "PopConBTransitionSourceHandler::" << __func__ << "]: "
<< "Loading tag for RunInfo " << m_tagForRunInfo
<< " and IOV valid for run number: " << m_run << std::endl;
Expand All @@ -59,18 +57,15 @@ namespace popcon {
if( avg_current != current_default && avg_current <= m_currentThreshold ) isBOn = false;
edm::LogInfo( "PopConBTransitionSourceHandler" ) << "[" << "PopConBTransitionSourceHandler::" << __func__ << "]: "
<< "The magnet was " << ( isBOn ? "ON" : "OFF" )
<< " during run " << m_run << std::endl;
session.transaction().commit();
<< " during run " << m_run << std::endl;
trans.close();
return isBOn;
}

virtual void getObjectsForBTransition( bool isBOn ) {
//reading payloads for 0T and 3.8T from Conditions
edm::LogInfo( "PopConBTransitionSourceHandler" ) << "[" << "PopConBTransitionSourceHandler::" << __func__ << "]: "
<< "Initialising CondDB session to " << m_connectionString << std::endl;
cond::persistency::Session session = m_connection.createSession( m_connectionString, true );
cond::persistency::Session& session = PopConSourceHandler<T>::dbSession();
cond::persistency::TransactionScope trans( session.transaction() );
trans.start( false );
edm::LogInfo( "PopConBTransitionSourceHandler" ) << "[" << "PopConBTransitionSourceHandler::" << __func__ << "]: "
<< "Loading tag for B " << ( isBOn ? "ON" : "OFF" ) << ": "
<< ( isBOn ? m_tagForBOn : m_tagForBOff )
Expand All @@ -90,7 +85,13 @@ namespace popcon {
<< ( isBOn ? "ON" : "OFF" );
edm::LogInfo( "PopConBTransitionSourceHandler" ) << "[" << "PopConBTransitionSourceHandler::" << __func__ << "]: "
<< ss.str() << std::endl;
cond::persistency::IOVEditor editor = session.editIov( destTag );
cond::persistency::IOVEditor editor;
if( session.existsIov( destTag ) ){
editor = session.editIov( destTag );
} else {
editor = session.createIov<T>( destTag, iov.timeType() );
editor.setDescription( "Tag created by PopConBTransitionSourceHandler" );
}
editor.insert( m_run, currentIov.payloadId );
editor.flush();
this->m_userTextLog = ss.str();
Expand All @@ -103,7 +104,7 @@ namespace popcon {
<< " in the destination tag " << destTag
<< ".\nNo transfer needed." <<std::endl;
}
trans.commit();
trans.close();
}

virtual void getNewObjects() override final {
Expand Down

0 comments on commit c85c664

Please sign in to comment.