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 ()
 
ESProxyIndex const * getTokenIndices (unsigned int iIndex) const
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &) final
 
 ~ESProducer ()(false) override
 
- Public Member Functions inherited from edm::ESProxyFactoryProducer
 ESProxyFactoryProducer ()
 
void newInterval (const eventsetup::EventSetupRecordKey &iRecordType, const ValidityInterval &iInterval) override
 overrides DataProxyProvider method More...
 
 ~ESProxyFactoryProducer () noexcept(false) override
 
- 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::string &objectKey)
 
- Protected Member Functions inherited from edm::ESProducer
 ESProducer (const ESProducer &)=delete
 
ESProducer const & operator= (const ESProducer &)=delete
 
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={})
 
- 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())
 
void registerProxies (const eventsetup::EventSetupRecordKey &iRecord, KeyedProxies &aProxyList) override
 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 83 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.

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

Definition at line 118 of file L1ConfigOnlineProdBase.h.

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

Member Function Documentation

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

Definition at line 195 of file L1ConfigOnlineProdBase.h.

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

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

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

Reimplemented in L1CaloHcalScaleConfigOnlineProd.

Definition at line 128 of file L1ConfigOnlineProdBase.h.

References cond::persistency::Transaction::commit(), MergeFilesAndCalculateEfficiencies_cfg::dataType, cond::persistency::Session::fetchPayload(), edm::eventsetup::EventSetupRecordImplementation< T >::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().

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