CMS 3D CMS Logo

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 std::shared_ptr< TData > newObject (const std::string &objectKey)=0
 
virtual std::shared_ptr< TData > produce (const TRcd &iRecord)
 
 ~L1ConfigOnlineProdBase ()
 
- Public Member Functions inherited from edm::ESProducer
 ESProducer ()
 
virtual ~ESProducer ()(false)
 
- Public Member Functions inherited from edm::ESProxyFactoryProducer
 ESProxyFactoryProducer ()
 
virtual void newInterval (const eventsetup::EventSetupRecordKey &iRecordType, const ValidityInterval &iInterval)
 overrides DataProxyProvider method More...
 
virtual ~ESProxyFactoryProducer () noexcept(false)
 
- 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 () noexcept(false)
 

Protected Member Functions

bool getObjectKey (const TRcd &record, std::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::unique_ptr< TFactory > iFactory, const std::string &iLabel=std::string())
 
virtual void registerFactoryWithKey (const eventsetup::EventSetupRecordKey &iRecord, std::unique_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, edm::propagate_const< std::shared_ptr< DataProxy > > > > KeyedProxies
 
typedef std::vector< EventSetupRecordKeyKeys
 
typedef std::map< EventSetupRecordKey, KeyedProxiesRecordProxies
 
- 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 52 of file L1ConfigOnlineProdBase.h.

Constructor & Destructor Documentation

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

Definition at line 84 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.

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

Definition at line 119 of file L1ConfigOnlineProdBase.h.

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

Member Function Documentation

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

Definition at line 197 of file L1ConfigOnlineProdBase.h.

References MergeFilesAndCalculateEfficiencies_cfg::dataType, funct::false, l1t::DataWriter::fillLastTriggerKeyList(), edm::eventsetup::EventSetupRecord::get(), crabWrapper::key, align_cfg::recordName, AlCaHLTBitMon_QueryRunRegistry::string, and L1TriggerKeyList::token().

Referenced by L1ConfigOnlineProdBase< TRcd, TData >::produce().

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

Reimplemented in L1CaloHcalScaleConfigOnlineProd.

Definition at line 129 of file L1ConfigOnlineProdBase.h.

References cond::persistency::Transaction::commit(), MergeFilesAndCalculateEfficiencies_cfg::dataType, cond::persistency::Session::fetchPayload(), edm::eventsetup::EventSetupRecord::get(), L1ConfigOnlineProdBase< TRcd, TData >::getObjectKey(), crabWrapper::key, L1ConfigOnlineProdBase< TRcd, TData >::m_copyFromCondDB, L1ConfigOnlineProdBase< TRcd, TData >::m_dbSession, L1ConfigOnlineProdBase< TRcd, TData >::m_forceGeneration, L1ConfigOnlineProdBase< TRcd, TData >::newObject(), align_cfg::recordName, cond::persistency::Transaction::start(), AlCaHLTBitMon_QueryRunRegistry::string, and cond::persistency::Session::transaction().

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

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

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
template<class TRcd, class TData>
l1t::OMDSReader L1ConfigOnlineProdBase< TRcd, TData >::m_omdsReader
protected