CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Protected Member Functions | Protected Attributes
L1ConfigOnlineProdBase< TRcd, TData > Class Template Referenceabstract

#include <CondTools/L1Trigger/interface/L1ConfigOnlineProdBase.h>

Inheritance diagram for L1ConfigOnlineProdBase< TRcd, TData >:
edm::ESProducer edm::ESProxyFactoryProducer edm::eventsetup::DataProxyProvider

Public Member Functions

 L1ConfigOnlineProdBase (const edm::ParameterSet &)
 
virtual boost::shared_ptr< TData > newObject (const std::string &objectKey)=0
 
boost::shared_ptr< TData > produce (const TRcd &iRecord)
 
 ~L1ConfigOnlineProdBase ()
 
- Public Member Functions inherited from edm::ESProducer
 ESProducer ()
 
virtual ~ESProducer ()
 
- Public Member Functions inherited from edm::ESProxyFactoryProducer
 ESProxyFactoryProducer ()
 
virtual void newInterval (const eventsetup::EventSetupRecordKey &iRecordType, const ValidityInterval &iInterval)
 overrides DataProxyProvider method More...
 
virtual ~ESProxyFactoryProducer ()
 
- Public Member Functions inherited from edm::eventsetup::DataProxyProvider
 DataProxyProvider ()
 
const ComponentDescriptiondescription () const
 
bool isUsingRecord (const EventSetupRecordKey &) const
 
const KeyedProxieskeyedProxies (const EventSetupRecordKey &iRecordKey) const
 
void resetProxies (const EventSetupRecordKey &iRecordType)
 
void resetProxiesIfTransient (const EventSetupRecordKey &iRecordType)
 
void setAppendToDataLabel (const edm::ParameterSet &)
 
void setDescription (const ComponentDescription &iDescription)
 
std::set< EventSetupRecordKeyusingRecords () const
 
virtual ~DataProxyProvider ()
 

Protected Member Functions

bool getObjectKey (const TRcd &record, boost::shared_ptr< TData > data, std::string &objectKey)
 
- Protected Member Functions inherited from edm::ESProducer
template<typename T >
void setWhatProduced (T *iThis, const es::Label &iLabel=es::Label())
 
template<typename T >
void setWhatProduced (T *iThis, const char *iLabel)
 
template<typename T >
void setWhatProduced (T *iThis, const std::string &iLabel)
 
template<typename T , typename TDecorator >
void setWhatProduced (T *iThis, const TDecorator &iDec, const es::Label &iLabel=es::Label())
 
template<typename T , typename TReturn , typename TRecord >
void setWhatProduced (T *iThis, TReturn(T::*iMethod)(const TRecord &), const es::Label &iLabel=es::Label())
 
template<typename T , typename TReturn , typename TRecord , typename TArg >
void setWhatProduced (T *iThis, TReturn(T::*iMethod)(const TRecord &), const TArg &iDec, const es::Label &iLabel=es::Label())
 
- Protected Member Functions inherited from edm::ESProxyFactoryProducer
template<class TFactory >
void registerFactory (std::auto_ptr< TFactory > iFactory, const std::string &iLabel=std::string())
 
virtual void registerFactoryWithKey (const eventsetup::EventSetupRecordKey &iRecord, std::auto_ptr< eventsetup::ProxyFactoryBase > &iFactory, const std::string &iLabel=std::string())
 
virtual void registerProxies (const eventsetup::EventSetupRecordKey &iRecord, KeyedProxies &aProxyList)
 override DataProxyProvider method More...
 
- Protected Member Functions inherited from edm::eventsetup::DataProxyProvider
void eraseAll (const EventSetupRecordKey &iRecordKey)
 deletes all the Proxies in aStream More...
 
void invalidateProxies (const EventSetupRecordKey &iRecordKey)
 
template<class T >
void usingRecord ()
 
void usingRecordWithKey (const EventSetupRecordKey &)
 

Protected Attributes

bool m_copyFromCondDB
 
cond::DbConnection m_dbConnection
 
cond::DbSession m_dbSession
 
bool m_forceGeneration
 
l1t::OMDSReader m_omdsReader
 

Additional Inherited Members

- Public Types inherited from edm::eventsetup::DataProxyProvider
typedef std::vector< std::pair
< DataKey, boost::shared_ptr
< DataProxy > > > 
KeyedProxies
 
typedef std::vector
< EventSetupRecordKey
Keys
 
typedef std::map
< EventSetupRecordKey,
KeyedProxies
RecordProxies
 
- Static Public Member Functions inherited from edm::eventsetup::DataProxyProvider
static void prevalidate (ConfigurationDescriptions &)
 

Detailed Description

template<class TRcd, class TData>
class L1ConfigOnlineProdBase< TRcd, TData >

Description: Abstract templated base class for producers that reads OMDS to retrieve configuration data for a given key and generates the corresponding C++ objects.

Usage: <usage>

Definition at line 54 of file L1ConfigOnlineProdBase.h.

Constructor & Destructor Documentation

template<class TRcd , class TData >
L1ConfigOnlineProdBase< TRcd, TData >::L1ConfigOnlineProdBase ( const edm::ParameterSet iConfig)

Definition at line 87 of file L1ConfigOnlineProdBase.h.

References cond::DbConnection::configuration(), cond::DbConnection::configure(), l1t::OMDSReader::connect(), cond::DbConnection::createSession(), edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), L1ConfigOnlineProdBase< TRcd, TData >::m_copyFromCondDB, L1ConfigOnlineProdBase< TRcd, TData >::m_dbConnection, L1ConfigOnlineProdBase< TRcd, TData >::m_dbSession, L1ConfigOnlineProdBase< TRcd, TData >::m_omdsReader, cond::DbSession::open(), cond::DbConnectionConfiguration::setAuthenticationPath(), and edm::ESProducer::setWhatProduced().

88  : m_omdsReader(),
89  m_forceGeneration( iConfig.getParameter< bool >( "forceGeneration" ) ),
91  m_dbSession(),
92  m_copyFromCondDB( false )
93 {
94  //the following line is needed to tell the framework what
95  // data is being produced
96  setWhatProduced(this);
97 
98  //now do what ever other initialization is needed
99 
100  if( iConfig.exists( "copyFromCondDB" ) )
101  {
102  m_copyFromCondDB = iConfig.getParameter< bool >( "copyFromCondDB" ) ;
103 
104  if( m_copyFromCondDB )
105  {
106  // Connect DbSession
108  iConfig.getParameter< std::string >( "onlineAuthentication" ) ) ;
112  iConfig.getParameter< std::string >( "onlineDB" ),
113  true ); // read-only
114  }
115  }
116  else
117  {
119  iConfig.getParameter< std::string >( "onlineDB" ),
120  iConfig.getParameter< std::string >( "onlineAuthentication" ) ) ;
121  }
122 }
T getParameter(std::string const &) const
void open(const std::string &connectionString, bool readOnly=false)
Definition: DbSession.cc:144
DbConnectionConfiguration & configuration()
Definition: DbConnection.cc:89
bool exists(std::string const &parameterName) const
checks if a parameter exists
void setWhatProduced(T *iThis, const es::Label &iLabel=es::Label())
Definition: ESProducer.h:115
void connect(const std::string &connectString, const std::string &authenticationPath)
Definition: OMDSReader.cc:50
DbSession createSession() const
Definition: DbConnection.cc:72
cond::DbConnection m_dbConnection
void setAuthenticationPath(const std::string &p)
template<class TRcd , class TData >
L1ConfigOnlineProdBase< TRcd, TData >::~L1ConfigOnlineProdBase ( )

Definition at line 125 of file L1ConfigOnlineProdBase.h.

126 {
127 
128  // do anything here that needs to be done at desctruction time
129  // (e.g. close files, deallocate resources etc.)
130 
131 }

Member Function Documentation

template<class TRcd, class TData>
bool L1ConfigOnlineProdBase< TRcd, TData >::getObjectKey ( const TRcd &  record,
boost::shared_ptr< TData >  data,
std::string &  objectKey 
)
protected

Definition at line 204 of file L1ConfigOnlineProdBase.h.

References dtTPAnalyzer_cfg::dataType, funct::false, l1t::DataWriter::fillLastTriggerKeyList(), edm::eventsetup::EventSetupRecord::get(), combine::key, ecalTPGAnalyzer_cfg::recordName, and L1TriggerKeyList::token().

208 {
209  // Get L1TriggerKey
210  const L1TriggerKeyRcd& keyRcd =
211  record.template getRecord< L1TriggerKeyRcd >() ;
212 
213  // Explanation of funny syntax: since record is dependent, we are not
214  // expecting getRecord to be a template so the compiler parses it
215  // as a non-template. http://gcc.gnu.org/ml/gcc-bugs/2005-11/msg03685.html
216 
217  // If L1TriggerKey is invalid, then all configuration objects are
218  // already in ORCON.
220  try
221  {
222  keyRcd.get( key ) ;
223  }
225  {
226  objectKey = std::string() ;
227  return false ;
228  }
229 
230  // Get object key from L1TriggerKey
231  std::string recordName = edm::typelookup::className<TRcd>();
232  std::string dataType = edm::typelookup::className<TData>();
233 
234  objectKey = key->get( recordName, dataType ) ;
235 
236 /* edm::LogVerbatim( "L1-O2O" ) */
237 /* << "L1ConfigOnlineProdBase record " << recordName */
238 /* << " type " << dataType << " obj key " << objectKey ; */
239 
240  // Get L1TriggerKeyList
241  L1TriggerKeyList keyList ;
242  l1t::DataWriter dataWriter ;
243  if( !dataWriter.fillLastTriggerKeyList( keyList ) )
244  {
245  edm::LogError( "L1-O2O" )
246  << "Problem getting last L1TriggerKeyList" ;
247  }
248 
249  // If L1TriggerKeyList does not contain object key, token is empty
250  return
251  keyList.token( recordName, dataType, objectKey ) == std::string() ;
252 }
JetCorrectorParameters::Record record
Definition: classes.h:11
void get(HolderT &iHolder) const
bool fillLastTriggerKeyList(L1TriggerKeyList &output)
Definition: DataWriter.cc:210
std::string token(const std::string &tscKey) const
list key
Definition: combine.py:13
template<class TRcd, class TData>
virtual boost::shared_ptr< TData > L1ConfigOnlineProdBase< TRcd, TData >::newObject ( const std::string &  objectKey)
pure virtual
template<class TRcd, class TData >
boost::shared_ptr< TData > L1ConfigOnlineProdBase< TRcd, TData >::produce ( const TRcd &  iRecord)

Definition at line 135 of file L1ConfigOnlineProdBase.h.

References cond::DbScopedTransaction::commit(), dtTPAnalyzer_cfg::dataType, edm::eventsetup::EventSetupRecord::get(), combine::key, ecalTPGAnalyzer_cfg::recordName, and cond::DbScopedTransaction::start().

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

136 {
137  using namespace edm::es;
138  boost::shared_ptr< TData > pData ;
139 
140  // Get object key and check if already in ORCON
141  std::string key ;
142  if( getObjectKey( iRecord, pData, key ) || m_forceGeneration )
143  {
144  if( m_copyFromCondDB )
145  {
146  // Get L1TriggerKeyList from EventSetup
147  const L1TriggerKeyListRcd& keyListRcd =
148  iRecord.template getRecord< L1TriggerKeyListRcd >() ;
150  keyListRcd.get( keyList ) ;
151 
152  // Find payload token
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 ) ;
157 
158  edm::LogVerbatim( "L1-O2O" )
159  << "Copying payload for " << recordName
160  << "@" << dataType << " obj key " << key
161  << " from CondDB." ;
162  edm::LogVerbatim( "L1-O2O" )
163  << "TOKEN " << payloadToken ;
164 
165  // Get object from POOL
166  // Copied from l1t::DataWriter::readObject()
167  if( !payloadToken.empty() )
168  {
170  tr.start( true ) ;
171  pData = m_dbSession.getTypedObject<TData>( payloadToken ) ;
172  tr.commit ();
173  }
174  }
175  else
176  {
177  pData = newObject( key ) ;
178  }
179 
180  // if( pData.get() == 0 )
181  if( pData == boost::shared_ptr< TData >() )
182  {
183  std::string dataType = edm::typelookup::className<TData>();
184 
185  throw l1t::DataInvalidException( "Unable to generate " +
186  dataType + " for key " + key +
187  "." ) ;
188  }
189  }
190  else
191  {
192  std::string dataType = edm::typelookup::className<TData>();
193 
194  throw l1t::DataAlreadyPresentException( dataType +
195  " for key " + key + " already in CondDB." ) ;
196  }
197 
198  return pData ;
199 }
bool getObjectKey(const TRcd &record, boost::shared_ptr< TData > data, std::string &objectKey)
virtual boost::shared_ptr< TData > newObject(const std::string &objectKey)=0
void get(HolderT &iHolder) const
list key
Definition: combine.py:13
boost::shared_ptr< T > getTypedObject(const std::string &objectId)
Definition: DbSession.h:125

Member Data Documentation

template<class TRcd, class TData>
bool L1ConfigOnlineProdBase< TRcd, TData >::m_copyFromCondDB
protected
template<class TRcd, class TData>
cond::DbConnection L1ConfigOnlineProdBase< TRcd, TData >::m_dbConnection
protected
template<class TRcd, class TData>
cond::DbSession L1ConfigOnlineProdBase< TRcd, TData >::m_dbSession
protected
template<class TRcd, class TData>
bool L1ConfigOnlineProdBase< TRcd, TData >::m_forceGeneration
protected

Definition at line 69 of file L1ConfigOnlineProdBase.h.

template<class TRcd, class TData>
l1t::OMDSReader L1ConfigOnlineProdBase< TRcd, TData >::m_omdsReader
protected