CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes
L1ConfigOnlineProdBase< TRcd, TData > Class Template Referenceabstract

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

Inheritance diagram for L1ConfigOnlineProdBase< TRcd, TData >:
edm::ESProducer edm::ESProductResolverFactoryProducer edm::eventsetup::ESProductResolverProvider

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
 
 ESProducer (ESProducer &&)=delete
 
ESResolverIndex const * getTokenIndices (unsigned int iIndex) const
 
ESRecordIndex const * getTokenRecordIndices (unsigned int iIndex) const
 
bool hasMayConsumes () const noexcept
 
size_t numberOfTokenIndices (unsigned int iIndex) const
 
ESProduceroperator= (const ESProducer &)=delete
 
ESProduceroperator= (ESProducer &&)=delete
 
SerialTaskQueueChainqueue ()
 
template<typename Record >
std::optional< std::vector< ESResolverIndex > > updateFromMayConsumes (unsigned int iIndex, const Record &iRecord) const
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &) final
 
 ~ESProducer () noexcept(false) override
 
- Public Member Functions inherited from edm::ESProductResolverFactoryProducer
 ESProductResolverFactoryProducer ()
 
 ESProductResolverFactoryProducer (const ESProductResolverFactoryProducer &)=delete
 
const ESProductResolverFactoryProduceroperator= (const ESProductResolverFactoryProducer &)=delete
 
 ~ESProductResolverFactoryProducer () noexcept(false) override
 
- Public Member Functions inherited from edm::eventsetup::ESProductResolverProvider
void createKeyedResolvers (EventSetupRecordKey const &key, unsigned int nConcurrentIOVs)
 
const ComponentDescriptiondescription () const
 
 ESProductResolverProvider ()
 
 ESProductResolverProvider (const ESProductResolverProvider &)=delete
 
void fillRecordsNotAllowingConcurrentIOVs (std::set< EventSetupRecordKey > &recordsNotAllowingConcurrentIOVs) const
 
virtual void initConcurrentIOVs (EventSetupRecordKey const &key, unsigned int nConcurrentIOVs)
 
bool isUsingRecord (const EventSetupRecordKey &key) const
 
KeyedResolverskeyedResolvers (const EventSetupRecordKey &iRecordKey, unsigned int iovIndex=0)
 
const ESProductResolverProvideroperator= (const ESProductResolverProvider &)=delete
 
void setAppendToDataLabel (const edm::ParameterSet &)
 
void setDescription (const ComponentDescription &iDescription)
 
std::set< EventSetupRecordKeyusingRecords () const
 
virtual ~ESProductResolverProvider () noexcept(false)
 

Protected Member Functions

bool getObjectKey (const TRcd &record, std::string &objectKey)
 
- Protected Member Functions inherited from edm::ESProducer
ESConsumesInfoconsumesInfoPushBackNew ()
 
unsigned int consumesInfoSize () const
 
template<typename CallbackT , typename TList , typename TRecord >
void registerProducts (std::shared_ptr< std::pair< unsigned int, std::shared_ptr< CallbackT >>> iCallback, const TList *, const TRecord *iRecord, const es::Label &iLabel)
 
template<typename CallbackT , typename TRecord >
void registerProducts (std::shared_ptr< std::pair< unsigned int, std::shared_ptr< CallbackT >>>, const eventsetup::produce::Null *, const TRecord *, const es::Label &)
 
template<typename T >
auto setWhatProduced (T *iThis, const es::Label &iLabel={})
 
template<typename T >
auto setWhatProduced (T *iThis, const char *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 TDecorator >
auto setWhatProduced (T *iThis, TReturn(T ::*iMethod)(const TRecord &), const TDecorator &iDec, const es::Label &iLabel={})
 
template<typename TFunc >
auto setWhatProduced (TFunc &&func, const es::Label &iLabel={})
 
template<typename TReturn , typename TRecord , typename TFunc , typename TDecorator >
ESConsumesCollectorT< TRecord > setWhatProduced (TFunc &&func, TDecorator &&iDec, const es::Label &iLabel={})
 
void usesResources (std::vector< std::string > const &)
 
- Protected Member Functions inherited from edm::ESProductResolverFactoryProducer
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::ESProductResolverFactoryBase > iFactory, const std::string &iLabel=std::string())
 
KeyedResolversVector registerResolvers (const EventSetupRecordKey &, unsigned int iovIndex) override
 
- Protected Member Functions inherited from edm::eventsetup::ESProductResolverProvider
template<class T >
void usingRecord ()
 
void usingRecordWithKey (const EventSetupRecordKey &key)
 

Protected Attributes

std::optional< edm::ESConsumesCollectorT< TRcd > > m_consumesCollector
 
bool m_copyFromCondDB
 
cond::persistency::Session m_dbSession
 
bool m_forceGeneration
 
l1t::OMDSReader m_omdsReader
 

Private Attributes

edm::ESGetToken< L1TriggerKeyList, TRcd > l1TriggerKeyListToken_
 
edm::ESGetToken< L1TriggerKey, TRcd > l1TriggerKeyToken_
 

Additional Inherited Members

- Static Public Member Functions inherited from edm::eventsetup::ESProductResolverProvider
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Types inherited from edm::ESProductResolverFactoryProducer
using EventSetupRecordKey = eventsetup::EventSetupRecordKey
 
- Protected Types inherited from edm::eventsetup::ESProductResolverProvider
using KeyedResolversVector = std::vector< std::pair< DataKey, std::shared_ptr< ESProductResolver > >>
 

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

◆ L1ConfigOnlineProdBase()

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

Definition at line 84 of file L1ConfigOnlineProdBase.h.

85  : m_omdsReader(),
86  m_forceGeneration(iConfig.getParameter<bool>("forceGeneration")),
87  m_dbSession(),
88  m_copyFromCondDB(false) {
89  //the following line is needed to tell the framework what
90  // data is being produced
91  auto cc = setWhatProduced(this);
92 
93  //now do what ever other initialization is needed
94  l1TriggerKeyListToken_ = cc.consumes();
95  l1TriggerKeyToken_ = cc.consumes();
96 
98 
99  if (iConfig.exists("copyFromCondDB")) {
100  m_copyFromCondDB = iConfig.getParameter<bool>("copyFromCondDB");
101 
102  if (m_copyFromCondDB) {
103  cond::persistency::ConnectionPool connectionPool;
104  // Connect DB Session
105  connectionPool.setAuthenticationPath(iConfig.getParameter<std::string>("onlineAuthentication"));
106  connectionPool.configure();
107  m_dbSession = connectionPool.createSession(iConfig.getParameter<std::string>("onlineDB"));
108  }
109  } else {
110  m_omdsReader.connect(iConfig.getParameter<std::string>("onlineDB"),
111  iConfig.getParameter<std::string>("onlineAuthentication"));
112  }
113 }
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:166
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
cond::persistency::Session m_dbSession
uint32_t cc[maxCellsPerHit]
Definition: gpuFishbone.h:49
bool exists(std::string const &parameterName) const
checks if a parameter exists
std::optional< edm::ESConsumesCollectorT< TRcd > > m_consumesCollector
Session createSession(const std::string &connectionString, bool writeCapable=false)
void connect(const std::string &connectString, const std::string &authenticationPath)
Definition: OMDSReader.cc:43
edm::ESGetToken< L1TriggerKey, TRcd > l1TriggerKeyToken_
edm::ESGetToken< L1TriggerKeyList, TRcd > l1TriggerKeyListToken_
void setAuthenticationPath(const std::string &p)
def move(src, dest)
Definition: eostools.py:511

◆ ~L1ConfigOnlineProdBase()

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

Definition at line 116 of file L1ConfigOnlineProdBase.h.

116  {
117  // do anything here that needs to be done at desctruction time
118  // (e.g. close files, deallocate resources etc.)
119 }

Member Function Documentation

◆ getObjectKey()

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

Definition at line 167 of file L1ConfigOnlineProdBase.h.

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

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

122  {
123  std::unique_ptr<TData> pData;
124 
125  // Get object key and check if already in ORCON
127  if (getObjectKey(iRecord, key) || m_forceGeneration) {
128  if (m_copyFromCondDB) {
129  auto keyList = iRecord.getHandle(l1TriggerKeyListToken_);
130 
131  // Find payload token
132  std::string recordName = edm::typelookup::className<TRcd>();
133  std::string dataType = edm::typelookup::className<TData>();
134  std::string payloadToken = keyList->token(recordName, dataType, key);
135 
136  edm::LogVerbatim("L1-O2O") << "Copying payload for " << recordName << "@" << dataType << " obj key " << key
137  << " from CondDB.";
138  edm::LogVerbatim("L1-O2O") << "TOKEN " << payloadToken;
139 
140  // Get object from POOL
141  // Copied from l1t::DataWriter::readObject()
142  if (!payloadToken.empty()) {
144  pData = m_dbSession.fetchPayload<TData>(payloadToken);
146  }
147  } else {
148  pData = newObject(key);
149  }
150 
151  // if( pData.get() == 0 )
152  if (pData == std::unique_ptr<TData>()) {
153  std::string dataType = edm::typelookup::className<TData>();
154 
155  throw l1t::DataInvalidException("Unable to generate " + dataType + " for key " + key + ".");
156  }
157  } else {
158  std::string dataType = edm::typelookup::className<TData>();
159 
160  throw l1t::DataAlreadyPresentException(dataType + " for key " + key + " already in CondDB.");
161  }
162 
163  return pData;
164 }
Log< level::Info, true > LogVerbatim
bool getObjectKey(const TRcd &record, std::string &objectKey)
cond::persistency::Session m_dbSession
void start(bool readOnly=true)
Definition: Session.cc:18
std::unique_ptr< T > fetchPayload(const cond::Hash &payloadHash)
Definition: Session.h:213
Transaction & transaction()
Definition: Session.cc:52
edm::ESGetToken< L1TriggerKeyList, TRcd > l1TriggerKeyListToken_
virtual std::unique_ptr< TData > newObject(const std::string &objectKey)=0

Member Data Documentation

◆ l1TriggerKeyListToken_

template<class TRcd, class TData>
edm::ESGetToken<L1TriggerKeyList, TRcd> L1ConfigOnlineProdBase< TRcd, TData >::l1TriggerKeyListToken_
private

◆ l1TriggerKeyToken_

template<class TRcd, class TData>
edm::ESGetToken<L1TriggerKey, TRcd> L1ConfigOnlineProdBase< TRcd, TData >::l1TriggerKeyToken_
private

◆ m_consumesCollector

template<class TRcd, class TData>
std::optional<edm::ESConsumesCollectorT<TRcd> > L1ConfigOnlineProdBase< TRcd, TData >::m_consumesCollector
protected

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

◆ m_omdsReader

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