CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Attributes
edmtest::AcquireIntESProducer Class Reference
Inheritance diagram for edmtest::AcquireIntESProducer:
edm::ESProducerExternalWork edm::ESProducer edm::ESProxyFactoryProducer edm::eventsetup::DataProxyProvider

Public Member Functions

void acquire (ESTestRecordI const &, edm::WaitingTaskWithArenaHolder)
 
 AcquireIntESProducer (edm::ParameterSet const &)
 
 AcquireIntESProducer (const AcquireIntESProducer &)=delete
 
 AcquireIntESProducer (AcquireIntESProducer &&)=delete
 
void initConcurrentIOVs (EventSetupRecordKey const &, unsigned int nConcurrentIOVs) override
 
AcquireIntESProduceroperator= (const AcquireIntESProducer &)=delete
 
AcquireIntESProduceroperator= (AcquireIntESProducer &&)=delete
 
std::unique_ptr< ESTestDataIproduce (ESTestRecordI const &)
 
std::unique_ptr< ESTestDataBproduceESTestDataB (ESTestRecordB const &)
 
 ~AcquireIntESProducer () override
 
- Public Member Functions inherited from edm::ESProducerExternalWork
 ESProducerExternalWork ()
 
template<typename T >
auto setWhatAcquiredProduced (T *iThis, const es::Label &iLabel={})
 
template<typename T >
auto setWhatAcquiredProduced (T *iThis, const char *iLabel)
 
template<typename T >
auto setWhatAcquiredProduced (T *iThis, const std::string &iLabel)
 
template<typename T , typename TDecorator >
auto setWhatAcquiredProduced (T *iThis, const TDecorator &iDec, const es::Label &iLabel={})
 
template<typename T , typename TReturn , typename TRecord >
auto setWhatAcquiredProduced (T *iThis, void(T::*iAcquireMethod)(const TRecord &, WaitingTaskWithArenaHolder), TReturn(T::*iProduceMethod)(const TRecord &), const es::Label &iLabel={})
 
template<typename T , typename TReturn , typename TRecord , typename TDecorator >
auto setWhatAcquiredProduced (T *iThis, void(T::*iAcquireMethod)(const TRecord &, WaitingTaskWithArenaHolder), TReturn(T ::*iProduceMethod)(const TRecord &), const TDecorator &iDec, const es::Label &iLabel={})
 
template<typename TAcquireFunc , typename TProduceFunc >
auto setWhatAcquiredProducedWithLambda (TAcquireFunc &&acquireFunc, TProduceFunc &&produceFunc, const es::Label &iLabel={})
 
template<typename TReturn , typename TRecord , typename TAcquireFunc , typename TProduceFunc , typename TDecorator >
ESConsumesCollectorT< TRecord > setWhatAcquiredProducedWithLambda (TAcquireFunc &&acquireFunc, TProduceFunc &&produceFunc, TDecorator &&iDec, const es::Label &iLabel={})
 
- Public Member Functions inherited from edm::ESProducer
 ESProducer ()
 
 ESProducer (const ESProducer &)=delete
 
 ESProducer (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
 
ESProduceroperator= (const ESProducer &)=delete
 
ESProduceroperator= (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
 
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)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &)
 
- Static Public Member Functions inherited from edm::eventsetup::DataProxyProvider
static void prevalidate (ConfigurationDescriptions &)
 

Private Attributes

std::vector< test_acquire::Cachecaches_
 
const unsigned int numberOfIOVsToAccumulate_
 
const unsigned int secondsToWaitForWork_
 
std::unique_ptr< test_acquire::WaitingServerserver_
 
edm::ESGetToken< IOVTestInfo, ESTestRecordItoken_
 

Additional Inherited Members

- 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 > >>
 
- 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::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)
 

Detailed Description

Description: Used in tests of the asynchronous ESProducer.

Definition at line 36 of file AcquireIntESProducer.cc.

Constructor & Destructor Documentation

◆ AcquireIntESProducer() [1/3]

edmtest::AcquireIntESProducer::AcquireIntESProducer ( edm::ParameterSet const &  pset)

Definition at line 64 of file AcquireIntESProducer.cc.

References produceESTestDataB(), edm::ESProducerExternalWork::setWhatAcquiredProduced(), edm::ESProducer::setWhatProduced(), and token_.

65  : numberOfIOVsToAccumulate_(pset.getUntrackedParameter<unsigned int>("numberOfIOVsToAccumulate")),
66  secondsToWaitForWork_(pset.getUntrackedParameter<unsigned int>("secondsToWaitForWork")) {
67  auto collector = setWhatAcquiredProduced(this, "fromAcquireIntESProducer");
68  token_ = collector.consumes<IOVTestInfo>(edm::ESInputTag{"", ""});
69 
71  }
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:165
const unsigned int numberOfIOVsToAccumulate_
auto setWhatAcquiredProduced(T *iThis, const es::Label &iLabel={})
edm::ESGetToken< IOVTestInfo, ESTestRecordI > token_
const unsigned int secondsToWaitForWork_
std::unique_ptr< ESTestDataB > produceESTestDataB(ESTestRecordB const &)

◆ ~AcquireIntESProducer()

edmtest::AcquireIntESProducer::~AcquireIntESProducer ( )
override

Definition at line 73 of file AcquireIntESProducer.cc.

References server_.

73  {
74  if (server_) {
75  server_->stop();
76  }
77  server_.reset();
78  }
std::unique_ptr< test_acquire::WaitingServer > server_

◆ AcquireIntESProducer() [2/3]

edmtest::AcquireIntESProducer::AcquireIntESProducer ( const AcquireIntESProducer )
delete

◆ AcquireIntESProducer() [3/3]

edmtest::AcquireIntESProducer::AcquireIntESProducer ( AcquireIntESProducer &&  )
delete

Member Function Documentation

◆ acquire()

void edmtest::AcquireIntESProducer::acquire ( ESTestRecordI const &  record,
edm::WaitingTaskWithArenaHolder  holder 
)

Definition at line 89 of file AcquireIntESProducer.cc.

References edmtest::IOVTestInfo::cacheIdentifier_, caches_, Exception, edm::ValidityInterval::first(), edmtest::IOVTestInfo::iovEndLumi_, edmtest::IOVTestInfo::iovEndRun_, edmtest::IOVTestInfo::iovIndex_, edmtest::IOVTestInfo::iovStartLumi_, edmtest::IOVTestInfo::iovStartRun_, edm::ValidityInterval::last(), edm::IOVSyncValue::luminosityBlockNumber(), edmtest::test_acquire::Cache::processed(), AlCaHarvesting_cff::record, edmtest::test_acquire::Cache::retrieved(), server_, and token_.

89  {
90  usleep(1000000);
91 
92  test_acquire::Cache& iovCache = caches_[record.iovIndex()];
93  iovCache.retrieved().clear();
94  iovCache.processed().clear();
95 
96  // Get some data and push it into the input cache for the ExternalWork.
97  // There is no significance to the particular data we are using.
98  // Using anything from the EventSetup would be good enough for the test.
99  // I already had test modules around that would make IOVTestInfo
100  // data, so that was easy to use. We put in known values and later
101  // check that we get the expected result (they get incremented by one
102  // to simulate some "external work", then summed in the produce method
103  // calculate a result we can check easily).
104  IOVTestInfo const& iovTestInfo = record.get(token_);
105  std::vector<int>& retrieved = iovCache.retrieved();
106  retrieved.push_back(iovTestInfo.iovStartRun_);
107  retrieved.push_back(iovTestInfo.iovStartLumi_);
108  retrieved.push_back(iovTestInfo.iovEndRun_);
109  retrieved.push_back(iovTestInfo.iovEndLumi_);
110  retrieved.push_back(iovTestInfo.cacheIdentifier_);
111 
112  server_->requestValuesAsync(record.iovIndex(), &iovCache.retrieved(), &iovCache.processed(), holder);
113 
114  edm::ValidityInterval iov = record.validityInterval();
115  if (iovTestInfo.iovStartLumi_ != iov.first().luminosityBlockNumber() ||
116  iovTestInfo.iovEndLumi_ != iov.last().luminosityBlockNumber() || iovTestInfo.iovIndex_ != record.iovIndex() ||
117  iovTestInfo.cacheIdentifier_ != record.cacheIdentifier()) {
118  throw cms::Exception("TestFailure") << "AcquireIntESProducer::acquire"
119  << "read values do not agree with record";
120  }
121  }
const IOVSyncValue & last() const
LuminosityBlockNumber_t luminosityBlockNumber() const
Definition: IOVSyncValue.h:41
const IOVSyncValue & first() const
unsigned int iovEndLumi_
Definition: IOVTestInfo.h:24
unsigned int iovIndex_
Definition: IOVTestInfo.h:25
std::unique_ptr< test_acquire::WaitingServer > server_
edm::ESGetToken< IOVTestInfo, ESTestRecordI > token_
unsigned int iovEndRun_
Definition: IOVTestInfo.h:23
unsigned int iovStartLumi_
Definition: IOVTestInfo.h:22
std::vector< test_acquire::Cache > caches_
unsigned long long cacheIdentifier_
Definition: IOVTestInfo.h:26
unsigned int iovStartRun_
Definition: IOVTestInfo.h:21
std::vector< int > const & processed() const
Definition: WaitingServer.h:62
std::vector< int > const & retrieved() const
Definition: WaitingServer.h:59

◆ fillDescriptions()

void edmtest::AcquireIntESProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 147 of file AcquireIntESProducer.cc.

References edm::ConfigurationDescriptions::addDefault(), and submitPVResolutionJobs::desc.

147  {
149  desc.addUntracked<unsigned int>("numberOfIOVsToAccumulate", 8);
150  desc.addUntracked<unsigned int>("secondsToWaitForWork", 1);
151  descriptions.addDefault(desc);
152  }
void addDefault(ParameterSetDescription const &psetDescription)

◆ initConcurrentIOVs()

void edmtest::AcquireIntESProducer::initConcurrentIOVs ( EventSetupRecordKey const &  key,
unsigned int  nConcurrentIOVs 
)
overridevirtual

Reimplemented from edm::eventsetup::DataProxyProvider.

Definition at line 80 of file AcquireIntESProducer.cc.

References caches_, crabWrapper::key, numberOfIOVsToAccumulate_, secondsToWaitForWork_, and server_.

80  {
81  if (key == EventSetupRecordKey::makeKey<ESTestRecordI>()) {
82  caches_.resize(nConcurrentIOVs);
83  server_ = std::make_unique<test_acquire::WaitingServer>(
85  server_->start();
86  }
87  }
const unsigned int numberOfIOVsToAccumulate_
std::unique_ptr< test_acquire::WaitingServer > server_
std::vector< test_acquire::Cache > caches_
const unsigned int secondsToWaitForWork_

◆ operator=() [1/2]

AcquireIntESProducer& edmtest::AcquireIntESProducer::operator= ( const AcquireIntESProducer )
delete

◆ operator=() [2/2]

AcquireIntESProducer& edmtest::AcquireIntESProducer::operator= ( AcquireIntESProducer &&  )
delete

◆ produce()

std::unique_ptr< ESTestDataI > edmtest::AcquireIntESProducer::produce ( ESTestRecordI const &  record)

Definition at line 123 of file AcquireIntESProducer.cc.

References edmtest::IOVTestInfo::cacheIdentifier_, caches_, Exception, edm::ValidityInterval::first(), edmtest::IOVTestInfo::iovEndLumi_, edmtest::IOVTestInfo::iovIndex_, edmtest::IOVTestInfo::iovStartLumi_, edm::ValidityInterval::last(), edm::IOVSyncValue::luminosityBlockNumber(), edmtest::test_acquire::Cache::processed(), AlCaHarvesting_cff::record, token_, and findQualityFiles::v.

123  {
124  usleep(1000000);
125 
126  edm::ESHandle<IOVTestInfo> iovTestInfo = record.getHandle(token_);
127  edm::ValidityInterval iov = record.validityInterval();
128  if (iovTestInfo->iovStartLumi_ != iov.first().luminosityBlockNumber() ||
129  iovTestInfo->iovEndLumi_ != iov.last().luminosityBlockNumber() || iovTestInfo->iovIndex_ != record.iovIndex() ||
130  iovTestInfo->cacheIdentifier_ != record.cacheIdentifier()) {
131  throw cms::Exception("TestFailure") << "AcquireIntESProducer::produce"
132  << "read values do not agree with record";
133  }
134 
135  test_acquire::Cache& iovCache = caches_[record.iovIndex()];
136  int sum = 0;
137  for (auto v : iovCache.processed()) {
138  sum += v;
139  }
140  return std::make_unique<ESTestDataI>(sum);
141  }
const IOVSyncValue & last() const
LuminosityBlockNumber_t luminosityBlockNumber() const
Definition: IOVSyncValue.h:41
const IOVSyncValue & first() const
unsigned int iovEndLumi_
Definition: IOVTestInfo.h:24
unsigned int iovIndex_
Definition: IOVTestInfo.h:25
edm::ESGetToken< IOVTestInfo, ESTestRecordI > token_
unsigned int iovStartLumi_
Definition: IOVTestInfo.h:22
std::vector< test_acquire::Cache > caches_
unsigned long long cacheIdentifier_
Definition: IOVTestInfo.h:26
std::vector< int > const & processed() const
Definition: WaitingServer.h:62

◆ produceESTestDataB()

std::unique_ptr< ESTestDataB > edmtest::AcquireIntESProducer::produceESTestDataB ( ESTestRecordB const &  )

Definition at line 143 of file AcquireIntESProducer.cc.

Referenced by AcquireIntESProducer().

143  {
144  return std::make_unique<ESTestDataB>(11);
145  }

Member Data Documentation

◆ caches_

std::vector<test_acquire::Cache> edmtest::AcquireIntESProducer::caches_
private

Definition at line 58 of file AcquireIntESProducer.cc.

Referenced by acquire(), initConcurrentIOVs(), and produce().

◆ numberOfIOVsToAccumulate_

const unsigned int edmtest::AcquireIntESProducer::numberOfIOVsToAccumulate_
private

Definition at line 60 of file AcquireIntESProducer.cc.

Referenced by initConcurrentIOVs().

◆ secondsToWaitForWork_

const unsigned int edmtest::AcquireIntESProducer::secondsToWaitForWork_
private

Definition at line 61 of file AcquireIntESProducer.cc.

Referenced by initConcurrentIOVs().

◆ server_

std::unique_ptr<test_acquire::WaitingServer> edmtest::AcquireIntESProducer::server_
private

Definition at line 59 of file AcquireIntESProducer.cc.

Referenced by acquire(), initConcurrentIOVs(), and ~AcquireIntESProducer().

◆ token_

edm::ESGetToken<IOVTestInfo, ESTestRecordI> edmtest::AcquireIntESProducer::token_
private

Definition at line 57 of file AcquireIntESProducer.cc.

Referenced by acquire(), AcquireIntESProducer(), and produce().