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::persistency::Session 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 53 of file L1ConfigOnlineProdBase.h.

Constructor & Destructor Documentation

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

Definition at line 85 of file L1ConfigOnlineProdBase.h.

References cond::persistency::ConnectionPool::configure(), l1t::OMDSReader::connect(), cond::persistency::ConnectionPool::createSession(), edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), L1ConfigOnlineProdBase< TRcd, TData >::m_copyFromCondDB, L1ConfigOnlineProdBase< TRcd, TData >::m_dbSession, L1ConfigOnlineProdBase< TRcd, TData >::m_omdsReader, cond::persistency::ConnectionPool::setAuthenticationPath(), edm::ESProducer::setWhatProduced(), and AlCaHLTBitMon_QueryRunRegistry::string.

86  : m_omdsReader(),
87  m_forceGeneration( iConfig.getParameter< bool >( "forceGeneration" ) ),
88  m_dbSession(),
89  m_copyFromCondDB( false )
90 {
91  //the following line is needed to tell the framework what
92  // data is being produced
93  setWhatProduced(this);
94 
95  //now do what ever other initialization is needed
96 
97  if( iConfig.exists( "copyFromCondDB" ) )
98  {
99  m_copyFromCondDB = iConfig.getParameter< bool >( "copyFromCondDB" ) ;
100 
101  if( m_copyFromCondDB )
102  {
103  cond::persistency::ConnectionPool connectionPool;
104  // Connect DB Session
105  connectionPool.setAuthenticationPath(
106  iConfig.getParameter< std::string >( "onlineAuthentication" ) ) ;
107  connectionPool.configure() ;
108  m_dbSession = connectionPool.createSession( iConfig.getParameter< std::string >( "onlineDB" ) ) ;
109  }
110  }
111  else
112  {
114  iConfig.getParameter< std::string >( "onlineDB" ),
115  iConfig.getParameter< std::string >( "onlineAuthentication" ) ) ;
116  }
117 }
T getParameter(std::string const &) const
cond::persistency::Session m_dbSession
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
Session createSession(const std::string &connectionString, bool writeCapable=false, BackendType backType=DEFAULT_DB)
void connect(const std::string &connectString, const std::string &authenticationPath)
Definition: OMDSReader.cc:50
void setAuthenticationPath(const std::string &p)
template<class TRcd , class TData >
L1ConfigOnlineProdBase< TRcd, TData >::~L1ConfigOnlineProdBase ( )

Definition at line 120 of file L1ConfigOnlineProdBase.h.

121 {
122 
123  // do anything here that needs to be done at desctruction time
124  // (e.g. close files, deallocate resources etc.)
125 
126 }

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 198 of file L1ConfigOnlineProdBase.h.

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

202 {
203  // Get L1TriggerKey
204  const L1TriggerKeyRcd& keyRcd =
205  record.template getRecord< L1TriggerKeyRcd >() ;
206 
207  // Explanation of funny syntax: since record is dependent, we are not
208  // expecting getRecord to be a template so the compiler parses it
209  // as a non-template. http://gcc.gnu.org/ml/gcc-bugs/2005-11/msg03685.html
210 
211  // If L1TriggerKey is invalid, then all configuration objects are
212  // already in ORCON.
214  try
215  {
216  keyRcd.get( key ) ;
217  }
219  {
220  objectKey = std::string() ;
221  return false ;
222  }
223 
224  // Get object key from L1TriggerKey
225  std::string recordName = edm::typelookup::className<TRcd>();
226  std::string dataType = edm::typelookup::className<TData>();
227 
228  objectKey = key->get( recordName, dataType ) ;
229 
230 /* edm::LogVerbatim( "L1-O2O" ) */
231 /* << "L1ConfigOnlineProdBase record " << recordName */
232 /* << " type " << dataType << " obj key " << objectKey ; */
233 
234  // Get L1TriggerKeyList
235  L1TriggerKeyList keyList ;
236  l1t::DataWriter dataWriter ;
237  if( !dataWriter.fillLastTriggerKeyList( keyList ) )
238  {
239  edm::LogError( "L1-O2O" )
240  << "Problem getting last L1TriggerKeyList" ;
241  }
242 
243  // If L1TriggerKeyList does not contain object key, token is empty
244  return
245  keyList.token( recordName, dataType, objectKey ) == std::string() ;
246 }
JetCorrectorParameters::Record record
Definition: classes.h:7
void get(HolderT &iHolder) const
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
bool fillLastTriggerKeyList(L1TriggerKeyList &output)
Definition: DataWriter.cc:196
std::string token(const std::string &tscKey) const
volatile std::atomic< bool > shutdown_flag false
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 130 of file L1ConfigOnlineProdBase.h.

References dtTPAnalyzer_cfg::dataType, edm::eventsetup::EventSetupRecord::get(), relval_steps::key, ecalTPGAnalyzer_cfg::recordName, and AlCaHLTBitMon_QueryRunRegistry::string.

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

131 {
132  using namespace edm::es;
133  boost::shared_ptr< TData > pData ;
134 
135  // Get object key and check if already in ORCON
136  std::string key ;
137  if( getObjectKey( iRecord, pData, key ) || m_forceGeneration )
138  {
139  if( m_copyFromCondDB )
140  {
141  // Get L1TriggerKeyList from EventSetup
142  const L1TriggerKeyListRcd& keyListRcd =
143  iRecord.template getRecord< L1TriggerKeyListRcd >() ;
145  keyListRcd.get( keyList ) ;
146 
147  // Find payload token
148  std::string recordName = edm::typelookup::className<TRcd>();
149  std::string dataType = edm::typelookup::className<TData>();
150  std::string payloadToken =
151  keyList->token( recordName, dataType, key ) ;
152 
153  edm::LogVerbatim( "L1-O2O" )
154  << "Copying payload for " << recordName
155  << "@" << dataType << " obj key " << key
156  << " from CondDB." ;
157  edm::LogVerbatim( "L1-O2O" )
158  << "TOKEN " << payloadToken ;
159 
160  // Get object from POOL
161  // Copied from l1t::DataWriter::readObject()
162  if( !payloadToken.empty() )
163  {
165  pData = m_dbSession.fetchPayload<TData>( payloadToken ) ;
167  }
168  }
169  else
170  {
171  pData = newObject( key ) ;
172  }
173 
174  // if( pData.get() == 0 )
175  if( pData == boost::shared_ptr< TData >() )
176  {
177  std::string dataType = edm::typelookup::className<TData>();
178 
179  throw l1t::DataInvalidException( "Unable to generate " +
180  dataType + " for key " + key +
181  "." ) ;
182  }
183  }
184  else
185  {
186  std::string dataType = edm::typelookup::className<TData>();
187 
188  throw l1t::DataAlreadyPresentException( dataType +
189  " for key " + key + " already in CondDB." ) ;
190  }
191 
192  return pData ;
193 }
bool getObjectKey(const TRcd &record, boost::shared_ptr< TData > data, std::string &objectKey)
cond::persistency::Session m_dbSession
boost::shared_ptr< T > fetchPayload(const cond::Hash &payloadHash)
Definition: Session.h:215
void start(bool readOnly=true)
Definition: Session.cc:22
virtual boost::shared_ptr< TData > newObject(const std::string &objectKey)=0
Transaction & transaction()
Definition: Session.cc:66
void get(HolderT &iHolder) const
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.

Member Data Documentation

template<class TRcd, class TData>
bool L1ConfigOnlineProdBase< TRcd, TData >::m_copyFromCondDB
protected
template<class TRcd, class TData>
cond::persistency::Session L1ConfigOnlineProdBase< TRcd, TData >::m_dbSession
protected
template<class TRcd, class TData>
bool L1ConfigOnlineProdBase< TRcd, TData >::m_forceGeneration
protected

Definition at line 68 of file L1ConfigOnlineProdBase.h.

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