CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
cond::persistency::Session Class Reference

#include <Session.h>

Public Member Functions

void clearIov (const std::string &tag)
 
void close ()
 
std::string connectionString ()
 
coral::ISessionProxy & coralSession ()
 
void createDatabase ()
 
GTEditor createGlobalTag (const std::string &name)
 
template<typename T >
IOVEditor createIov (const std::string &tag, cond::TimeType timeType, cond::SynchronizationType synchronizationType=cond::SYNCH_ANY)
 
IOVEditor createIov (const std::string &payloadType, const std::string &tag, cond::TimeType timeType, cond::SynchronizationType synchronizationType=cond::SYNCH_ANY)
 
IOVEditor createIov (const std::string &payloadType, const std::string &tag, cond::TimeType timeType, cond::SynchronizationType synchronizationType, const boost::posix_time::ptime &creationTime)
 
IOVEditor createIovForPayload (const Hash &payloadHash, const std::string &tag, cond::TimeType timeType, cond::SynchronizationType synchronizationType=cond::SYNCH_ANY)
 
GTEditor editGlobalTag (const std::string &name)
 
IOVEditor editIov (const std::string &tag)
 
RunInfoEditor editRunInfo ()
 
bool existsDatabase ()
 
bool existsGlobalTag (const std::string &name)
 
bool existsIov (const std::string &tag)
 
template<typename T >
std::unique_ptr< TfetchPayload (const cond::Hash &payloadHash)
 
bool fetchPayloadData (const cond::Hash &payloadHash, std::string &payloadType, cond::Binary &payloadData, cond::Binary &streamerInfoData)
 
cond::RunInfo_t getLastRun ()
 
RunInfoProxy getRunInfo (cond::Time_t start, cond::Time_t end)
 
coral::ISchema & nominalSchema ()
 
Sessionoperator= (const Session &rhs)
 
GTProxy readGlobalTag (const std::string &name)
 
GTProxy readGlobalTag (const std::string &name, const std::string &preFix, const std::string &postFix)
 
IOVProxy readIov (const std::string &tag)
 
IOVProxy readIov (const std::string &tag, const boost::posix_time::ptime &snapshottime)
 
 Session ()
 
 Session (const std::shared_ptr< SessionImpl > &sessionImpl)
 
 Session (const Session &rhs)
 
template<typename T >
cond::Hash storePayload (const T &payload, const boost::posix_time::ptime &creationTime=boost::posix_time::microsec_clock::universal_time())
 
cond::Hash storePayloadData (const std::string &payloadObjectType, const std::pair< Binary, Binary > &payloadAndStreamerInfoData, const boost::posix_time::ptime &creationTime)
 
Transactiontransaction ()
 
virtual ~Session ()
 

Private Attributes

std::shared_ptr< SessionImplm_session
 
Transaction m_transaction
 

Detailed Description

Definition at line 63 of file Session.h.

Constructor & Destructor Documentation

◆ Session() [1/3]

Session::Session ( )

Definition at line 35 of file Session.cc.

35 : m_session(new SessionImpl), m_transaction(*m_session) {}
Transaction m_transaction
Definition: Session.h:175
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:174

◆ Session() [2/3]

Session::Session ( const std::shared_ptr< SessionImpl > &  sessionImpl)
explicit

Definition at line 37 of file Session.cc.

38  : m_session(sessionImpl), m_transaction(*m_session) {}
Transaction m_transaction
Definition: Session.h:175
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:174

◆ Session() [3/3]

Session::Session ( const Session rhs)

Definition at line 40 of file Session.cc.

40 : m_session(rhs.m_session), m_transaction(rhs.m_transaction) {}
Transaction m_transaction
Definition: Session.h:175
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:174

◆ ~Session()

Session::~Session ( )
virtual

Definition at line 42 of file Session.cc.

42 {}

Member Function Documentation

◆ clearIov()

void Session::clearIov ( const std::string &  tag)

Definition at line 137 of file Session.cc.

References m_session, and makeGlobalPositionRcd_cfg::tag.

137  {
138  m_session->openIovDb();
139  m_session->iovSchema().iovTable().erase(tag);
140  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:174

◆ close()

void Session::close ( void  )

◆ connectionString()

std::string Session::connectionString ( )

Definition at line 216 of file Session.cc.

References m_session.

Referenced by PCLMetadataWriter::endRun(), cond::persistency::PayloadReader::fetch(), cond::persistency::importIovs(), and popcon::PopCon::initialize().

216 { return m_session->connectionString; }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:174

◆ coralSession()

coral::ISessionProxy & Session::coralSession ( )

◆ createDatabase()

void Session::createDatabase ( )

Definition at line 61 of file Session.cc.

References m_session.

Referenced by cond::persistency::importIovs().

61 { m_session->openDb(); }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:174

◆ createGlobalTag()

GTEditor Session::createGlobalTag ( const std::string &  name)

Definition at line 147 of file Session.cc.

References m_session, Skims_PA_cff::name, and cond::persistency::throwException().

147  {
148  m_session->openGTDb();
149  if (m_session->gtSchema().gtTable().select(name))
150  throwException("The specified Global Tag \"" + name + "\" already exist in the database.",
151  "Session::createGlobalTag");
152  GTEditor editor(m_session, name);
153  return editor;
154  }
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:12
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:174

◆ createIov() [1/3]

template<typename T >
IOVEditor Session::createIov ( const std::string &  tag,
cond::TimeType  timeType,
cond::SynchronizationType  synchronizationType = cond::SYNCH_ANY 
)
inline

Definition at line 179 of file Session.h.

References makeGlobalPositionRcd_cfg::tag.

Referenced by SiStripDetVOffHandler::analyze(), SiStripPayloadHandler< SiStripPayload >::analyze(), cond::persistency::copyIov(), popcon::PopConBTransitionSourceHandler< T >::getObjectsForBTransition(), popcon::PopConESTransitionSourceHandler< T >::getObjectsForESTransition(), cond::persistency::importIovs(), and cond::service::PoolDBOutputService::writeMany().

181  {
182  return createIov(cond::demangledName(typeid(T)), tag, timeType, synchronizationType);
183  }
IOVEditor createIov(const std::string &tag, cond::TimeType timeType, cond::SynchronizationType synchronizationType=cond::SYNCH_ANY)
Definition: Session.h:179
long double T

◆ createIov() [2/3]

IOVEditor Session::createIov ( const std::string &  payloadType,
const std::string &  tag,
cond::TimeType  timeType,
cond::SynchronizationType  synchronizationType = cond::SYNCH_ANY 
)

Definition at line 91 of file Session.cc.

References m_session, HLT_2023v12_cff::payloadType, makeGlobalPositionRcd_cfg::tag, and cond::persistency::throwException().

94  {
95  m_session->openDb();
96  if (m_session->iovSchema().tagTable().select(tag))
97  throwException("The specified tag \"" + tag + "\" already exist in the database.", "Session::createIov");
98  IOVEditor editor(m_session, tag, timeType, payloadType, synchronizationType);
99  return editor;
100  }
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:12
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:174

◆ createIov() [3/3]

IOVEditor Session::createIov ( const std::string &  payloadType,
const std::string &  tag,
cond::TimeType  timeType,
cond::SynchronizationType  synchronizationType,
const boost::posix_time::ptime &  creationTime 
)

Definition at line 102 of file Session.cc.

References beamSpotPI::creationTime, m_session, HLT_2023v12_cff::payloadType, makeGlobalPositionRcd_cfg::tag, and cond::persistency::throwException().

106  {
107  m_session->openDb();
108  if (m_session->iovSchema().tagTable().select(tag))
109  throwException("The specified tag \"" + tag + "\" already exist in the database.", "Session::createIov");
110  IOVEditor editor(m_session, tag, timeType, payloadType, synchronizationType, creationTime);
111  return editor;
112  }
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:12
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:174

◆ createIovForPayload()

IOVEditor Session::createIovForPayload ( const Hash payloadHash,
const std::string &  tag,
cond::TimeType  timeType,
cond::SynchronizationType  synchronizationType = cond::SYNCH_ANY 
)

Definition at line 114 of file Session.cc.

References m_session, HLT_2023v12_cff::payloadType, AlCaHLTBitMon_QueryRunRegistry::string, makeGlobalPositionRcd_cfg::tag, and cond::persistency::throwException().

117  {
118  m_session->openDb();
119  if (m_session->iovSchema().tagTable().select(tag))
120  throwException("The specified tag \"" + tag + "\" already exist in the database.",
121  "Session::createIovForPayload");
123  if (!m_session->iovSchema().payloadTable().getType(payloadHash, payloadType))
124  throwException("The specified payloadId \"" + payloadHash + "\" does not exist in the database.",
125  "Session::createIovForPayload");
126  IOVEditor editor(m_session, tag, timeType, payloadType, synchronizationType);
127  return editor;
128  }
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:12
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:174

◆ editGlobalTag()

GTEditor Session::editGlobalTag ( const std::string &  name)

Definition at line 156 of file Session.cc.

References cond::persistency::GTEditor::load(), m_session, and Skims_PA_cff::name.

156  {
157  m_session->openGTDb();
158  GTEditor editor(m_session);
159  editor.load(name);
160  return editor;
161  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:174

◆ editIov()

IOVEditor Session::editIov ( const std::string &  tag)

◆ editRunInfo()

RunInfoEditor Session::editRunInfo ( )

Definition at line 210 of file Session.cc.

References cond::persistency::RunInfoEditor::init(), and m_session.

Referenced by RunInfoUpdate::appendNewRun(), and RunInfoUpdate::import().

210  {
211  RunInfoEditor editor(m_session);
212  editor.init();
213  return editor;
214  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:174

◆ existsDatabase()

bool Session::existsDatabase ( )

Definition at line 55 of file Session.cc.

References cond::persistency::SessionImpl::DO_NOT_THROW, and m_session.

Referenced by SiStripDetVOffHandler::analyze(), cond::persistency::importIovs(), and popcon::PopCon::initialize().

55  {
57  return m_session->transaction->iovDbExists;
58  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:174

◆ existsGlobalTag()

bool Session::existsGlobalTag ( const std::string &  name)

Definition at line 142 of file Session.cc.

References m_session, and Skims_PA_cff::name.

142  {
143  m_session->openGTDb();
144  return m_session->gtSchema().gtTable().select(name);
145  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:174

◆ existsIov()

bool Session::existsIov ( const std::string &  tag)

◆ fetchPayload()

template<typename T >
std::unique_ptr< T > Session::fetchPayload ( const cond::Hash payloadHash)
inline

Definition at line 213 of file Session.h.

References MillePedeFileConverter_cfg::e, fetchPayloadData(), HLT_2023v12_cff::payloadType, runTheMatrix::ret, AlCaHLTBitMon_QueryRunRegistry::string, and cond::persistency::throwException().

Referenced by SiStripDetVOffHandler::analyze(), SiStripDetVOffTkMapPlotter::analyze(), SiStripDetVOffPrinter::analyze(), SiStripPayloadHandler< SiStripPayload >::analyze(), SiStripDetVOffTrendPlotter::analyze(), BeamSpotRcdPrinter::analyze(), FastSiPixelFEDChannelContainerFromQuality::analyze(), popcon::PopConBTransitionSourceHandler< T >::checkBOn(), cond::persistency::PayloadReader::fetch(), cond::payloadInspector::PlotBase::fetchPayload(), LHCInfoPopConSourceHandler::getNewObjects(), LHCInfoPerLSPopConSourceHandler::getNewObjects(), LHCInfoPerFillPopConSourceHandler::getNewObjects(), RunInfoUpdate::import(), popcon::PopConSourceHandler< CastorPedestals >::lastPayload(), cond::persistency::PayloadProxy< std::vector< cond::Time_t > >::loadPayload(), l1t::DataWriter::readObject(), and l1t::DataWriterExt::readObject().

213  {
214  cond::Binary payloadData;
215  cond::Binary streamerInfoData;
217  if (!fetchPayloadData(payloadHash, payloadType, payloadData, streamerInfoData))
218  throwException("Payload with id " + payloadHash + " has not been found in the database.",
219  "Session::fetchPayload");
220  std::unique_ptr<T> ret;
221  try {
222  ret = deserialize<T>(payloadType, payloadData, streamerInfoData);
223  } catch (const cond::persistency::Exception& e) {
224  std::string em(e.what());
225  throwException("Payload of type " + payloadType + " with id " + payloadHash + " could not be loaded. " + em,
226  "Session::fetchPayload");
227  }
228  return ret;
229  }
Base exception class for the object to relational access.
Definition: Exception.h:11
ret
prodAgent to be discontinued
bool fetchPayloadData(const cond::Hash &payloadHash, std::string &payloadType, cond::Binary &payloadData, cond::Binary &streamerInfoData)
Definition: Session.cc:185
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:12

◆ fetchPayloadData()

bool Session::fetchPayloadData ( const cond::Hash payloadHash,
std::string &  payloadType,
cond::Binary payloadData,
cond::Binary streamerInfoData 
)

Definition at line 185 of file Session.cc.

References m_session, and HLT_2023v12_cff::payloadType.

Referenced by cond::persistency::fetch(), cond::persistency::fetchIfExists(), fetchPayload(), and cond::persistency::importPayload().

188  {
189  m_session->openIovDb();
190  return m_session->iovSchema().payloadTable().select(payloadHash, payloadType, payloadData, streamerInfoData);
191  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:174

◆ getLastRun()

cond::RunInfo_t Session::getLastRun ( )

Definition at line 201 of file Session.cc.

References m_session, runTheMatrix::ret, and cond::persistency::throwException().

201  {
202  if (!m_session->transaction.get())
203  throwException("The transaction is not active.", "Session::getRunInfo");
204  m_session->openRunInfoDb();
206  ret.run = m_session->runInfoSchema().runInfoTable().getLastInserted(ret.start, ret.end);
207  return ret;
208  }
ret
prodAgent to be discontinued
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:12
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:174

◆ getRunInfo()

RunInfoProxy Session::getRunInfo ( cond::Time_t  start,
cond::Time_t  end 
)

Definition at line 193 of file Session.cc.

References cond::persistency::RunInfoProxy::load(), m_session, and cond::persistency::throwException().

Referenced by cond::payloadInspector::TimeHistoryPlot< PayloadType, std::pair< double, double > >::fill().

193  {
194  if (!m_session->transaction.get())
195  throwException("The transaction is not active.", "Session::getRunInfo");
196  RunInfoProxy proxy(m_session);
197  proxy.load(start, end);
198  return proxy;
199  }
Definition: start.py:1
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:12
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:174

◆ nominalSchema()

coral::ISchema & Session::nominalSchema ( )

◆ operator=()

Session & Session::operator= ( const Session rhs)

Definition at line 44 of file Session.cc.

References m_session, and m_transaction.

44  {
45  m_session = rhs.m_session;
46  m_transaction = rhs.m_transaction;
47  return *this;
48  }
Transaction m_transaction
Definition: Session.h:175
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:174

◆ readGlobalTag() [1/2]

GTProxy Session::readGlobalTag ( const std::string &  name)

Definition at line 163 of file Session.cc.

References cond::persistency::GTProxy::load(), m_session, and Skims_PA_cff::name.

Referenced by CondDBESSource::fillTagCollectionFromGT().

163  {
164  m_session->openGTDb();
165  GTProxy proxy(m_session);
166  proxy.load(name);
167  return proxy;
168  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:174

◆ readGlobalTag() [2/2]

GTProxy Session::readGlobalTag ( const std::string &  name,
const std::string &  preFix,
const std::string &  postFix 
)

Definition at line 170 of file Session.cc.

References cond::persistency::GTProxy::load(), m_session, and Skims_PA_cff::name.

170  {
171  m_session->openGTDb();
172  GTProxy proxy(m_session);
173  proxy.load(name, preFix, postFix);
174  return proxy;
175  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:174

◆ readIov() [1/2]

IOVProxy Session::readIov ( const std::string &  tag)

◆ readIov() [2/2]

IOVProxy Session::readIov ( const std::string &  tag,
const boost::posix_time::ptime &  snapshottime 
)

Definition at line 70 of file Session.cc.

References cond::persistency::IOVProxy::load(), m_session, and TauJetAlgoParameters_cfi::tagName.

70  {
71  m_session->openIovDb();
72  IOVProxy proxy(m_session);
73  proxy.load(tagName, snapshottime);
74  return proxy;
75  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:174

◆ storePayload()

template<typename T >
cond::Hash Session::storePayload ( const T payload,
const boost::posix_time::ptime &  creationTime = boost::posix_time::microsec_clock::universal_time() 
)
inline

Definition at line 186 of file Session.h.

References beamSpotPI::creationTime, MillePedeFileConverter_cfg::e, jetsAK4_Puppi_cff::payload, runTheMatrix::ret, cond::serialize(), storePayloadData(), AlCaHLTBitMon_QueryRunRegistry::string, and cond::persistency::throwException().

Referenced by SiStripDetVOffHandler::analyze(), SiStripPayloadHandler< SiStripPayload >::analyze(), cond::service::PoolDBOutputService::appendOneIOV(), cond::service::PoolDBOutputService::createOneIOV(), l1t::WriterProxyT< Record, Type >::save(), AlCaRecoTriggerBitsRcdUpdate::writeBitsToDB(), l1t::DataWriter::writeKeyList(), l1t::DataWriterExt::writeKeyList(), cond::service::PoolDBOutputService::writeMany(), and cond::service::PoolDBOutputService::writeOneIOV().

186  {
187  std::string payloadObjectType = cond::demangledName(typeid(payload));
188  cond::Hash ret;
189  try {
190  ret = storePayloadData(payloadObjectType, serialize(payload), creationTime);
191  } catch (const cond::persistency::Exception& e) {
192  std::string em(e.what());
193  throwException("Payload of type " + payloadObjectType + " could not be stored. " + em, "Session::storePayload");
194  }
195  return ret;
196  }
Base exception class for the object to relational access.
Definition: Exception.h:11
std::pair< Binary, Binary > serialize(const T &payload)
Definition: Serialization.h:66
ret
prodAgent to be discontinued
std::string Hash
Definition: Types.h:43
cond::Hash storePayloadData(const std::string &payloadObjectType, const std::pair< Binary, Binary > &payloadAndStreamerInfoData, const boost::posix_time::ptime &creationTime)
Definition: Session.cc:177
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:12

◆ storePayloadData()

cond::Hash Session::storePayloadData ( const std::string &  payloadObjectType,
const std::pair< Binary, Binary > &  payloadAndStreamerInfoData,
const boost::posix_time::ptime &  creationTime 
)

Definition at line 177 of file Session.cc.

References beamSpotPI::creationTime, and m_session.

Referenced by cond::persistency::importPayload(), and storePayload().

179  {
180  m_session->openDb();
181  return m_session->iovSchema().payloadTable().insertIfNew(
182  payloadObjectType, payloadAndStreamerInfoData.first, payloadAndStreamerInfoData.second, creationTime);
183  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:174

◆ transaction()

Transaction & Session::transaction ( )

Definition at line 52 of file Session.cc.

References m_transaction.

Referenced by SiStripDetVOffHandler::analyze(), SiStripDetVOffTkMapPlotter::analyze(), SiStripDetVOffPrinter::analyze(), SiStripPayloadHandler< SiStripPayload >::analyze(), SiStripDetVOffTrendPlotter::analyze(), BeamSpotRcdPrinter::analyze(), FastSiPixelFEDChannelContainerFromQuality::analyze(), cond::service::PoolDBOutputService::appendOneIOV(), popcon::PopConBTransitionSourceHandler< T >::checkBOn(), popcon::PopConESTransitionSourceHandler< T >::checkLowGain(), l1t::OMDSReader::connect(), cond::persistency::copyIov(), cond::service::PoolDBOutputService::createOneIOV(), cond::persistency::PayloadReader::fetch(), CondDBESSource::fillTagCollectionFromGT(), popcon::PopCon::finalize(), FillInfoPopConSourceHandler::getNewObjects(), LHCInfoPopConSourceHandler::getNewObjects(), DTLVStatusHandler::getNewObjects(), DTHVStatusHandler::getNewObjects(), LHCInfoPerLSPopConSourceHandler::getNewObjects(), LHCInfoPerFillPopConSourceHandler::getNewObjects(), popcon::PopConBTransitionSourceHandler< T >::getObjectsForBTransition(), popcon::PopConESTransitionSourceHandler< T >::getObjectsForESTransition(), cond::persistency::importIovs(), popcon::PopCon::initialize(), SiStripCoralIface::initialize(), cond::persistency::PayloadProxy< std::vector< cond::Time_t > >::make(), l1t::OMDSReader::OMDSReader(), l1t::DataWriter::payloadToken(), l1t::DataWriterExt::payloadToken(), cond::service::OnlineDBOutputService::preLoadIov(), L1RCTOmdsFedVectorProducer::produce(), l1t::DataWriter::readObject(), l1t::DataWriterExt::readObject(), l1t::WriterProxyT< Record, Type >::save(), l1t::DataWriter::writeKeyList(), l1t::DataWriterExt::writeKeyList(), cond::service::PoolDBOutputService::writeMany(), cond::service::PoolDBOutputService::writeOneIOV(), l1t::DataWriter::writePayload(), and popcon::PopCon::~PopCon().

52 { return m_transaction; }
Transaction m_transaction
Definition: Session.h:175

Member Data Documentation

◆ m_session

std::shared_ptr<SessionImpl> cond::persistency::Session::m_session
private

◆ m_transaction

Transaction cond::persistency::Session::m_transaction
private

Definition at line 175 of file Session.h.

Referenced by operator=(), and transaction().