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::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
 
ESRecordIndex const * getTokenRecordIndices (unsigned int iIndex) const
 
bool hasMayConsumes () const noexcept
 
size_t numberOfTokenIndices (unsigned int iIndex) const
 
ESProducer const & operator= (const ESProducer &)=delete
 
SerialTaskQueueChainqueue ()
 
template<typename Record >
std::optional< std::vector< ESProxyIndex > > updateFromMayConsumes (unsigned int iIndex, const Record &iRecord) const
 
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 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 TArg >
ESConsumesCollectorT< TRecord > setWhatProduced (T *iThis, TReturn(T ::*iMethod)(const TRecord &), const TArg &iDec, const es::Label &iLabel={})
 
void usesResources (std::vector< std::string > const &)
 
- 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
 

Private Attributes

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

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

83  : m_omdsReader(),
84  m_forceGeneration(iConfig.getParameter<bool>("forceGeneration")),
85  m_dbSession(),
86  m_copyFromCondDB(false) {
87  //the following line is needed to tell the framework what
88  // data is being produced
89  auto cc = setWhatProduced(this);
90 
91  //now do what ever other initialization is needed
92  l1TriggerKeyListToken_ = cc.consumes();
93  l1TriggerKeyToken_ = cc.consumes();
94 
95  if (iConfig.exists("copyFromCondDB")) {
96  m_copyFromCondDB = iConfig.getParameter<bool>("copyFromCondDB");
97 
98  if (m_copyFromCondDB) {
99  cond::persistency::ConnectionPool connectionPool;
100  // Connect DB Session
101  connectionPool.setAuthenticationPath(iConfig.getParameter<std::string>("onlineAuthentication"));
102  connectionPool.configure();
103  m_dbSession = connectionPool.createSession(iConfig.getParameter<std::string>("onlineDB"));
104  }
105  } else {
106  m_omdsReader.connect(iConfig.getParameter<std::string>("onlineDB"),
107  iConfig.getParameter<std::string>("onlineAuthentication"));
108  }
109 }
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:163
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
cond::persistency::Session m_dbSession
bool exists(std::string const &parameterName) const
checks if a parameter exists
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)

◆ ~L1ConfigOnlineProdBase()

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

Definition at line 112 of file L1ConfigOnlineProdBase.h.

112  {
113  // do anything here that needs to be done at desctruction time
114  // (e.g. close files, deallocate resources etc.)
115 }

Member Function Documentation

◆ getObjectKey()

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

Definition at line 163 of file L1ConfigOnlineProdBase.h.

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

118  {
119  std::unique_ptr<TData> pData;
120 
121  // Get object key and check if already in ORCON
123  if (getObjectKey(iRecord, key) || m_forceGeneration) {
124  if (m_copyFromCondDB) {
125  auto keyList = iRecord.getHandle(l1TriggerKeyListToken_);
126 
127  // Find payload token
128  std::string recordName = edm::typelookup::className<TRcd>();
129  std::string dataType = edm::typelookup::className<TData>();
130  std::string payloadToken = keyList->token(recordName, dataType, key);
131 
132  edm::LogVerbatim("L1-O2O") << "Copying payload for " << recordName << "@" << dataType << " obj key " << key
133  << " from CondDB.";
134  edm::LogVerbatim("L1-O2O") << "TOKEN " << payloadToken;
135 
136  // Get object from POOL
137  // Copied from l1t::DataWriter::readObject()
138  if (!payloadToken.empty()) {
140  pData = m_dbSession.fetchPayload<TData>(payloadToken);
142  }
143  } else {
144  pData = newObject(key);
145  }
146 
147  // if( pData.get() == 0 )
148  if (pData == std::unique_ptr<TData>()) {
149  std::string dataType = edm::typelookup::className<TData>();
150 
151  throw l1t::DataInvalidException("Unable to generate " + dataType + " for key " + key + ".");
152  }
153  } else {
154  std::string dataType = edm::typelookup::className<TData>();
155 
156  throw l1t::DataAlreadyPresentException(dataType + " for key " + key + " already in CondDB.");
157  }
158 
159  return pData;
160 }
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_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 68 of file L1ConfigOnlineProdBase.h.

◆ m_omdsReader

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