CMS 3D CMS Logo

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

#include <L1ConfigOnlineProdBaseExt.h>

Inheritance diagram for L1ConfigOnlineProdBaseExt< TRcd, TData >:
edm::ESProducer edm::ESProxyFactoryProducer edm::eventsetup::DataProxyProvider

Public Member Functions

 L1ConfigOnlineProdBaseExt (const edm::ParameterSet &)
 
virtual std::shared_ptr< TData > newObject (const std::string &objectKey, const TRcd &iRecord)=0
 
std::shared_ptr< TData > produce (const TRcd &iRecord)
 
 ~L1ConfigOnlineProdBaseExt ()
 
- 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 L1ConfigOnlineProdBaseExt< TRcd, TData >

Definition at line 33 of file L1ConfigOnlineProdBaseExt.h.

Constructor & Destructor Documentation

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

Definition at line 65 of file L1ConfigOnlineProdBaseExt.h.

References cond::persistency::ConnectionPool::configure(), l1t::OMDSReader::connect(), cond::persistency::ConnectionPool::createSession(), edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), L1ConfigOnlineProdBaseExt< TRcd, TData >::m_copyFromCondDB, L1ConfigOnlineProdBaseExt< TRcd, TData >::m_dbSession, L1ConfigOnlineProdBaseExt< TRcd, TData >::m_omdsReader, cond::persistency::ConnectionPool::setAuthenticationPath(), edm::ESProducer::setWhatProduced(), and AlCaHLTBitMon_QueryRunRegistry::string.

66  : m_omdsReader(),
67  m_forceGeneration( iConfig.getParameter< bool >( "forceGeneration" ) ),
68  m_dbSession(),
69  m_copyFromCondDB( false )
70 {
71  //the following line is needed to tell the framework what
72  // data is being produced
73  setWhatProduced(this);
74 
75  //now do what ever other initialization is needed
76 
77  if( iConfig.exists( "copyFromCondDB" ) )
78  {
79  m_copyFromCondDB = iConfig.getParameter< bool >( "copyFromCondDB" ) ;
80 
81  if( m_copyFromCondDB )
82  {
83  cond::persistency::ConnectionPool connectionPool;
84  // Connect DB Session
85  connectionPool.setAuthenticationPath(
86  iConfig.getParameter< std::string >( "onlineAuthentication" ) ) ;
87  connectionPool.configure() ;
88  m_dbSession = connectionPool.createSession( iConfig.getParameter< std::string >( "onlineDB" ) ) ;
89  }
90  }
91  else
92  {
94  iConfig.getParameter< std::string >( "onlineDB" ),
95  iConfig.getParameter< std::string >( "onlineAuthentication" ) ) ;
96  }
97 }
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 >
L1ConfigOnlineProdBaseExt< TRcd, TData >::~L1ConfigOnlineProdBaseExt ( )

Definition at line 100 of file L1ConfigOnlineProdBaseExt.h.

101 {
102 
103  // do anything here that needs to be done at desctruction time
104  // (e.g. close files, deallocate resources etc.)
105 
106 }

Member Function Documentation

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

// Get L1TriggerKeyList L1TriggerKeyList keyList ;

l1t::DataWriter dataWriter ;

<< "Problem getting last L1TriggerKeyList" ;

Definition at line 183 of file L1ConfigOnlineProdBaseExt.h.

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

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

187 {
188  // Get L1TriggerKeyExt
189  const L1TriggerKeyExtRcd& keyRcd =
190  record.template getRecord< L1TriggerKeyExtRcd >() ;
191 
192  // Explanation of funny syntax: since record is dependent, we are not
193  // expecting getRecord to be a template so the compiler parses it
194  // as a non-template. http://gcc.gnu.org/ml/gcc-bugs/2005-11/msg03685.html
195 
196  // If L1TriggerKeyExt is invalid, then all configuration objects are
197  // already in ORCON.
199  try
200  {
201  keyRcd.get( key ) ;
202  }
204  {
205  objectKey = std::string() ;
206  return false ;
207  }
208 
209  // Get object key from L1TriggerKeyExt
210  std::string recordName = edm::typelookup::className<TRcd>();
211  std::string dataType = edm::typelookup::className<TData>();
212 
213  objectKey = key->get( recordName, dataType ) ;
214 
215 /* edm::LogVerbatim( "L1-O2O" ) */
216 /* << "L1ConfigOnlineProdBase record " << recordName */
217 /* << " type " << dataType << " obj key " << objectKey ; */
218 
219  // Get L1TriggerKeyListExt
220  L1TriggerKeyListExt keyList ;
223  l1t::DataWriterExt dataWriter ;
225  if( !dataWriter.fillLastTriggerKeyList( keyList ) )
226  {
227  edm::LogError( "L1-O2O" )
228  << "Problem getting last L1TriggerKeyListExt" ;
230  }
231 
232  // If L1TriggerKeyList does not contain object key, token is empty
233 
234  return
235  keyList.token( recordName, dataType, objectKey ) == std::string() ;
236 }
bool fillLastTriggerKeyList(L1TriggerKeyListExt &output)
JetCorrectorParameters::Record record
Definition: classes.h:7
void get(HolderT &iHolder) const
std::string token(const std::string &tscKey) const
template<class TRcd, class TData>
virtual std::shared_ptr< TData > L1ConfigOnlineProdBaseExt< TRcd, TData >::newObject ( const std::string &  objectKey,
const TRcd &  iRecord 
)
pure virtual
template<class TRcd, class TData >
std::shared_ptr< TData > L1ConfigOnlineProdBaseExt< TRcd, TData >::produce ( const TRcd &  iRecord)

// Get L1TriggerKeyList from EventSetup const L1TriggerKeyListRcd& keyListRcd =

iRecord.template getRecord< L1TriggerKeyListRcd >() ; edm::ESHandle< L1TriggerKeyList > keyList ;

Definition at line 110 of file L1ConfigOnlineProdBaseExt.h.

References cond::persistency::Transaction::commit(), MergeFilesAndCalculateEfficiencies_cfg::dataType, cond::persistency::Session::fetchPayload(), edm::eventsetup::EventSetupRecord::get(), L1ConfigOnlineProdBaseExt< TRcd, TData >::getObjectKey(), crabWrapper::key, L1ConfigOnlineProdBaseExt< TRcd, TData >::m_copyFromCondDB, L1ConfigOnlineProdBaseExt< TRcd, TData >::m_dbSession, L1ConfigOnlineProdBaseExt< TRcd, TData >::m_forceGeneration, L1ConfigOnlineProdBaseExt< 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().

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

Member Data Documentation

template<class TRcd, class TData>
bool L1ConfigOnlineProdBaseExt< TRcd, TData >::m_copyFromCondDB
protected
template<class TRcd, class TData>
cond::persistency::Session L1ConfigOnlineProdBaseExt< TRcd, TData >::m_dbSession
protected
template<class TRcd, class TData>
bool L1ConfigOnlineProdBaseExt< TRcd, TData >::m_forceGeneration
protected
template<class TRcd, class TData>
l1t::OMDSReader L1ConfigOnlineProdBaseExt< TRcd, TData >::m_omdsReader
protected