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::unique_ptr< TData > newObject (const std::string &objectKey)=0
 
virtual std::unique_ptr< TData > produce (const TRcd &iRecord)
 
 ~L1ConfigOnlineProdBase () override
 
- Public Member Functions inherited from edm::ESProducer
 ESProducer ()
 
 ESProducer (const ESProducer &)=delete
 
ESProxyIndex const * getTokenIndices (unsigned int iIndex) const
 
ESProducer const & operator= (const ESProducer &)=delete
 
template<typename Record >
void updateFromMayConsumes (unsigned int iIndex, const Record &iRecord)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &) final
 
 ~ESProducer () noexcept(false) override
 
- Public Member Functions inherited from edm::ESProxyFactoryProducer
 ESProxyFactoryProducer ()
 
 ESProxyFactoryProducer (const ESProxyFactoryProducer &)=delete
 
const ESProxyFactoryProduceroperator= (const ESProxyFactoryProducer &)=delete
 
 ~ESProxyFactoryProducer () noexcept(false) override
 
- Public Member Functions inherited from edm::eventsetup::DataProxyProvider
void createKeyedProxies (EventSetupRecordKey const &key, unsigned int nConcurrentIOVs)
 
 DataProxyProvider ()
 
 DataProxyProvider (const DataProxyProvider &)=delete
 
const ComponentDescriptiondescription () const
 
void fillRecordsNotAllowingConcurrentIOVs (std::set< EventSetupRecordKey > &recordsNotAllowingConcurrentIOVs) const
 
virtual void initConcurrentIOVs (EventSetupRecordKey const &key, unsigned int nConcurrentIOVs)
 
bool isUsingRecord (const EventSetupRecordKey &key) const
 
KeyedProxieskeyedProxies (const EventSetupRecordKey &iRecordKey, unsigned int iovIndex=0)
 
const DataProxyProvideroperator= (const DataProxyProvider &)=delete
 
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::string &objectKey)
 
- Protected Member Functions inherited from edm::ESProducer
template<typename T >
auto setWhatProduced (T *iThis, const char *iLabel)
 
template<typename T >
auto setWhatProduced (T *iThis, const es::Label &iLabel={})
 
template<typename T >
auto setWhatProduced (T *iThis, const std::string &iLabel)
 
template<typename T , typename TDecorator >
auto setWhatProduced (T *iThis, const TDecorator &iDec, const es::Label &iLabel={})
 
template<typename T , typename TReturn , typename TRecord >
auto setWhatProduced (T *iThis, TReturn(T ::*iMethod)(const TRecord &), const es::Label &iLabel={})
 
template<typename T , typename TReturn , typename TRecord , typename TArg >
ESConsumesCollectorT< TRecord > setWhatProduced (T *iThis, TReturn(T ::*iMethod)(const TRecord &), const TArg &iDec, const es::Label &iLabel={})
 
- 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 EventSetupRecordKey &iRecord, std::unique_ptr< eventsetup::ProxyFactoryBase > iFactory, const std::string &iLabel=std::string())
 
KeyedProxiesVector registerProxies (const EventSetupRecordKey &, unsigned int iovIndex) override
 
- Protected Member Functions inherited from edm::eventsetup::DataProxyProvider
template<class T >
void usingRecord ()
 
void usingRecordWithKey (const EventSetupRecordKey &key)
 

Protected Attributes

bool m_copyFromCondDB
 
cond::persistency::Session m_dbSession
 
bool m_forceGeneration
 
l1t::OMDSReader m_omdsReader
 

Additional Inherited Members

- Static Public Member Functions inherited from edm::eventsetup::DataProxyProvider
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Types inherited from edm::ESProxyFactoryProducer
using EventSetupRecordKey = eventsetup::EventSetupRecordKey
 
- Protected Types inherited from edm::eventsetup::DataProxyProvider
using KeyedProxiesVector = std::vector< std::pair< DataKey, std::shared_ptr< DataProxy > >>
 

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

◆ L1ConfigOnlineProdBase()

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

Definition at line 80 of file L1ConfigOnlineProdBase.h.

81  : m_omdsReader(),
82  m_forceGeneration(iConfig.getParameter<bool>("forceGeneration")),
83  m_dbSession(),
84  m_copyFromCondDB(false) {
85  //the following line is needed to tell the framework what
86  // data is being produced
87  setWhatProduced(this);
88 
89  //now do what ever other initialization is needed
90 
91  if (iConfig.exists("copyFromCondDB")) {
92  m_copyFromCondDB = iConfig.getParameter<bool>("copyFromCondDB");
93 
94  if (m_copyFromCondDB) {
95  cond::persistency::ConnectionPool connectionPool;
96  // Connect DB Session
97  connectionPool.setAuthenticationPath(iConfig.getParameter<std::string>("onlineAuthentication"));
98  connectionPool.configure();
99  m_dbSession = connectionPool.createSession(iConfig.getParameter<std::string>("onlineDB"));
100  }
101  } else {
102  m_omdsReader.connect(iConfig.getParameter<std::string>("onlineDB"),
103  iConfig.getParameter<std::string>("onlineAuthentication"));
104  }
105 }

◆ ~L1ConfigOnlineProdBase()

template<class TRcd , class TData >
L1ConfigOnlineProdBase< TRcd, TData >::~L1ConfigOnlineProdBase ( )
override

Definition at line 108 of file L1ConfigOnlineProdBase.h.

108  {
109  // do anything here that needs to be done at desctruction time
110  // (e.g. close files, deallocate resources etc.)
111 }

Member Function Documentation

◆ getObjectKey()

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

Definition at line 162 of file L1ConfigOnlineProdBase.h.

162  {
163  // Get L1TriggerKey
164  const L1TriggerKeyRcd& keyRcd = record.template getRecord<L1TriggerKeyRcd>();
165 
166  // Explanation of funny syntax: since record is dependent, we are not
167  // expecting getRecord to be a template so the compiler parses it
168  // as a non-template. http://gcc.gnu.org/ml/gcc-bugs/2005-11/msg03685.html
169 
170  // If L1TriggerKey is invalid, then all configuration objects are
171  // already in ORCON.
173  try {
174  keyRcd.get(key);
175  } catch (l1t::DataAlreadyPresentException& ex) {
176  objectKey = std::string();
177  return false;
178  }
179 
180  // Get object key from L1TriggerKey
181  std::string recordName = edm::typelookup::className<TRcd>();
182  std::string dataType = edm::typelookup::className<TData>();
183 
184  objectKey = key->get(recordName, dataType);
185 
186  /* edm::LogVerbatim( "L1-O2O" ) */
187  /* << "L1ConfigOnlineProdBase record " << recordName */
188  /* << " type " << dataType << " obj key " << objectKey ; */
189 
190  // Get L1TriggerKeyList
191  L1TriggerKeyList keyList;
192  l1t::DataWriter dataWriter;
193  if (!dataWriter.fillLastTriggerKeyList(keyList)) {
194  edm::LogError("L1-O2O") << "Problem getting last L1TriggerKeyList";
195  }
196 
197  // If L1TriggerKeyList does not contain object key, token is empty
198  return keyList.token(recordName, dataType, objectKey).empty();
199 }

◆ newObject()

template<class TRcd, class TData>
virtual std::unique_ptr<TData> L1ConfigOnlineProdBase< TRcd, TData >::newObject ( const std::string &  objectKey)
pure virtual

◆ produce()

template<class TRcd, class TData >
std::unique_ptr< TData > L1ConfigOnlineProdBase< TRcd, TData >::produce ( const TRcd &  iRecord)
virtual

Reimplemented in L1CaloHcalScaleConfigOnlineProd.

Definition at line 114 of file L1ConfigOnlineProdBase.h.

114  {
115  std::unique_ptr<TData> pData;
116 
117  // Get object key and check if already in ORCON
119  if (getObjectKey(iRecord, key) || m_forceGeneration) {
120  if (m_copyFromCondDB) {
121  // Get L1TriggerKeyList from EventSetup
122  const L1TriggerKeyListRcd& keyListRcd = iRecord.template getRecord<L1TriggerKeyListRcd>();
124  keyListRcd.get(keyList);
125 
126  // Find payload token
127  std::string recordName = edm::typelookup::className<TRcd>();
128  std::string dataType = edm::typelookup::className<TData>();
129  std::string payloadToken = keyList->token(recordName, dataType, key);
130 
131  edm::LogVerbatim("L1-O2O") << "Copying payload for " << recordName << "@" << dataType << " obj key " << key
132  << " from CondDB.";
133  edm::LogVerbatim("L1-O2O") << "TOKEN " << payloadToken;
134 
135  // Get object from POOL
136  // Copied from l1t::DataWriter::readObject()
137  if (!payloadToken.empty()) {
139  pData = m_dbSession.fetchPayload<TData>(payloadToken);
141  }
142  } else {
143  pData = newObject(key);
144  }
145 
146  // if( pData.get() == 0 )
147  if (pData == std::unique_ptr<TData>()) {
148  std::string dataType = edm::typelookup::className<TData>();
149 
150  throw l1t::DataInvalidException("Unable to generate " + dataType + " for key " + key + ".");
151  }
152  } else {
153  std::string dataType = edm::typelookup::className<TData>();
154 
155  throw l1t::DataAlreadyPresentException(dataType + " for key " + key + " already in CondDB.");
156  }
157 
158  return pData;
159 }

Member Data Documentation

◆ m_copyFromCondDB

template<class TRcd, class TData>
bool L1ConfigOnlineProdBase< TRcd, TData >::m_copyFromCondDB
protected

◆ m_dbSession

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

◆ m_forceGeneration

template<class TRcd, class TData>
bool L1ConfigOnlineProdBase< TRcd, TData >::m_forceGeneration
protected

Definition at line 66 of file L1ConfigOnlineProdBase.h.

◆ m_omdsReader

template<class TRcd, class TData>
l1t::OMDSReader L1ConfigOnlineProdBase< TRcd, TData >::m_omdsReader
protected
L1ConfigOnlineProdBase::m_omdsReader
l1t::OMDSReader m_omdsReader
Definition: L1ConfigOnlineProdBase.h:65
L1TriggerKeyRcd
Definition: L1TriggerKeyRcd.h:30
align_cfg.recordName
recordName
Definition: align_cfg.py:66
edm::ESProducer::setWhatProduced
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:138
GlobalPosition_Frontier_DevDB_cff.record
record
Definition: GlobalPosition_Frontier_DevDB_cff.py:10
l1t::DataAlreadyPresentException
Definition: Exception.h:32
L1ConfigOnlineProdBase::m_forceGeneration
bool m_forceGeneration
Definition: L1ConfigOnlineProdBase.h:66
cond::persistency::ConnectionPool::createSession
Session createSession(const std::string &connectionString, bool writeCapable=false)
Definition: ConnectionPool.cc:158
DTskim_cfg.dataType
dataType
Definition: DTskim_cfg.py:56
l1t::DataInvalidException
Definition: Exception.h:51
cond::persistency::Session::fetchPayload
std::unique_ptr< T > fetchPayload(const cond::Hash &payloadHash)
Definition: Session.h:213
L1ConfigOnlineProdBase::newObject
virtual std::unique_ptr< TData > newObject(const std::string &objectKey)=0
cond::persistency::ConnectionPool
Definition: ConnectionPool.h:35
edm::ESHandle
Definition: DTSurvey.h:22
l1t::OMDSReader::connect
void connect(const std::string &connectString, const std::string &authenticationPath)
Definition: OMDSReader.cc:43
L1ConfigOnlineProdBase::getObjectKey
bool getObjectKey(const TRcd &record, std::string &objectKey)
Definition: L1ConfigOnlineProdBase.h:162
edm::eventsetup::DependentRecordImplementation::get
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const
Definition: DependentRecordImplementation.h:112
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ParameterSet::exists
bool exists(std::string const &parameterName) const
checks if a parameter exists
Definition: ParameterSet.cc:674
L1TriggerKeyList
Definition: L1TriggerKeyList.h:32
edm::LogError
Definition: MessageLogger.h:183
cond::persistency::Transaction::commit
void commit()
Definition: Session.cc:23
cond::persistency::ConnectionPool::setAuthenticationPath
void setAuthenticationPath(const std::string &p)
Definition: ConnectionPool.cc:31
edm::LogVerbatim
Definition: MessageLogger.h:297
L1ConfigOnlineProdBase::m_copyFromCondDB
bool m_copyFromCondDB
Definition: L1ConfigOnlineProdBase.h:76
cond::persistency::ConnectionPool::configure
void configure()
Definition: ConnectionPool.cc:125
L1ConfigOnlineProdBase::m_dbSession
cond::persistency::Session m_dbSession
Definition: L1ConfigOnlineProdBase.h:75
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
cond::persistency::Session::transaction
Transaction & transaction()
Definition: Session.cc:52
cond::persistency::Transaction::start
void start(bool readOnly=true)
Definition: Session.cc:18
l1t::DataWriter::fillLastTriggerKeyList
bool fillLastTriggerKeyList(L1TriggerKeyList &output)
Definition: DataWriter.cc:147
l1t::DataWriter
Definition: DataWriter.h:35
edm::eventsetup::EventSetupRecordImplementation::get
PRODUCT const & get(ESGetToken< PRODUCT, T > const &iToken) const
Definition: EventSetupRecordImplementation.h:74
L1TriggerKeyList::token
std::string token(const std::string &tscKey) const
Definition: L1TriggerKeyList.cc:96
L1TriggerKeyListRcd
Definition: L1TriggerKeyListRcd.h:24
crabWrapper.key
key
Definition: crabWrapper.py:19