1 #ifndef CondTools_L1Trigger_L1ConfigOnlineProdBase_h
2 #define CondTools_L1Trigger_L1ConfigOnlineProdBase_h
26 #include "boost/shared_ptr.hpp"
53 template<
class TRcd,
class TData >
59 boost::shared_ptr< TData >
produce(
const TRcd& iRecord);
61 virtual boost::shared_ptr< TData >
newObject(
62 const std::string& objectKey ) = 0 ;
76 boost::shared_ptr< TData >
data,
77 std::string& objectKey ) ;
86 template<
class TRcd,
class TData >
89 m_forceGeneration( iConfig.getParameter< bool >(
"forceGeneration" ) ),
92 m_copyFromCondDB(
false )
100 if( iConfig.
exists(
"copyFromCondDB" ) )
108 iConfig.
getParameter< std::string >(
"onlineAuthentication" ) ) ;
120 iConfig.
getParameter< std::string >(
"onlineAuthentication" ) ) ;
124 template<
class TRcd,
class TData >
133 template<
class TRcd,
class TData >
134 boost::shared_ptr< TData >
137 using namespace edm::es;
138 boost::shared_ptr< TData > pData ;
142 if( getObjectKey( iRecord, pData,
key ) || m_forceGeneration )
144 if( m_copyFromCondDB )
148 iRecord.template getRecord< L1TriggerKeyListRcd >() ;
150 keyListRcd.
get( keyList ) ;
153 std::string
recordName = edm::typelookup::className<TRcd>();
154 std::string
dataType = edm::typelookup::className<TData>();
155 std::string payloadToken =
156 keyList->token( recordName, dataType,
key ) ;
159 <<
"Copying payload for " << recordName
160 <<
"@" << dataType <<
" obj key " <<
key
163 <<
"TOKEN " << payloadToken ;
167 if( !payloadToken.empty() )
171 pData = m_dbSession.getTypedObject<TData>( payloadToken ) ;
177 pData = newObject(
key ) ;
181 if( pData == boost::shared_ptr< TData >() )
183 std::string
dataType = edm::typelookup::className<TData>();
186 dataType +
" for key " +
key +
192 std::string
dataType = edm::typelookup::className<TData>();
195 " for key " +
key +
" already in CondDB." ) ;
202 template<
class TRcd,
class TData >
206 boost::shared_ptr< TData >
data,
207 std::string& objectKey )
211 record.template getRecord< L1TriggerKeyRcd >() ;
226 objectKey = std::string() ;
231 std::string
recordName = edm::typelookup::className<TRcd>();
232 std::string
dataType = edm::typelookup::className<TData>();
234 objectKey = key->get( recordName, dataType ) ;
246 <<
"Problem getting last L1TriggerKeyList" ;
251 keyList.
token( recordName, dataType, objectKey ) == std::string() ;
T getParameter(std::string const &) const
bool getObjectKey(const TRcd &record, boost::shared_ptr< TData > data, std::string &objectKey)
void open(const std::string &connectionString, bool readOnly=false)
DbConnectionConfiguration & configuration()
bool exists(std::string const ¶meterName) const
checks if a parameter exists
boost::shared_ptr< TData > produce(const TRcd &iRecord)
virtual boost::shared_ptr< TData > newObject(const std::string &objectKey)=0
void setWhatProduced(T *iThis, const es::Label &iLabel=es::Label())
cond::DbSession m_dbSession
void get(HolderT &iHolder) const
int start(bool readOnly=false)
start transaction
l1t::OMDSReader m_omdsReader
bool fillLastTriggerKeyList(L1TriggerKeyList &output)
void connect(const std::string &connectString, const std::string &authenticationPath)
~L1ConfigOnlineProdBase()
DbSession createSession() const
L1ConfigOnlineProdBase(const edm::ParameterSet &)
std::string token(const std::string &tscKey) const
cond::DbConnection m_dbConnection
void setAuthenticationPath(const std::string &p)
int commit()
commit transaction. Will disconnect from database if connection timeout==0 or connectted time close t...