CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
edmtest::TestESSource Class Reference
Inheritance diagram for edmtest::TestESSource:
edm::eventsetup::ESProductResolverProvider edm::EventSetupRecordIntervalFinder

Public Types

using EventSetupRecordKey = edm::eventsetup::EventSetupRecordKey
 

Public Member Functions

void busyWait (char const *msg) const
 
 TestESSource (edm::ParameterSet const &)
 
 ~TestESSource () 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
 
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)
 
virtual void updateLookup (ESRecordsToProductResolverIndices const &)
 
std::set< EventSetupRecordKeyusingRecords () const
 
virtual ~ESProductResolverProvider () noexcept(false)
 
- Public Member Functions inherited from edm::EventSetupRecordIntervalFinder
bool concurrentFinder () const
 
const eventsetup::ComponentDescriptiondescriptionForFinder () const
 
 EventSetupRecordIntervalFinder ()
 
 EventSetupRecordIntervalFinder (const EventSetupRecordIntervalFinder &)=delete
 
std::set< eventsetup::EventSetupRecordKeyfindingForRecords () const
 
const ValidityIntervalfindIntervalFor (const eventsetup::EventSetupRecordKey &, const IOVSyncValue &)
 
bool nonconcurrentAndIOVNeedsUpdate (const eventsetup::EventSetupRecordKey &key, const IOVSyncValue &syncValue) const
 
const EventSetupRecordIntervalFinderoperator= (const EventSetupRecordIntervalFinder &)=delete
 
void resetInterval (const eventsetup::EventSetupRecordKey &)
 
void setDescriptionForFinder (const eventsetup::ComponentDescription &iDescription)
 
virtual ~EventSetupRecordIntervalFinder () noexcept(false)
 

Static Public Member Functions

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

Public Attributes

std::atomic< unsigned int > count1_
 
std::atomic< unsigned int > count2_
 
std::atomic< unsigned int > count_
 
std::mutex mutex_
 
edm::SerialTaskQueue queue_
 

Private Member Functions

void initConcurrentIOVs (EventSetupRecordKey const &, unsigned int nConcurrentIOVs) override
 
bool isConcurrentFinder () const override
 
KeyedResolversVector registerResolvers (EventSetupRecordKey const &, unsigned int iovIndex) override
 
void setIntervalFor (EventSetupRecordKey const &, edm::IOVSyncValue const &, edm::ValidityInterval &) override
 

Private Attributes

bool checkIOVInitialization_
 
unsigned int expectedNumberOfConcurrentIOVs_
 
const unsigned int iterations_
 
unsigned int nConcurrentIOVs_ = 0
 
const double pi_
 
std::set< edm::IOVSyncValuesetOfIOV_
 

Additional Inherited Members

- Protected Types inherited from edm::eventsetup::ESProductResolverProvider
using KeyedResolversVector = std::vector< std::pair< DataKey, std::shared_ptr< ESProductResolver > >>
 
- Protected Member Functions inherited from edm::eventsetup::ESProductResolverProvider
template<class T >
void usingRecord ()
 
void usingRecordWithKey (const EventSetupRecordKey &key)
 
- Protected Member Functions inherited from edm::EventSetupRecordIntervalFinder
template<class T >
void findingRecord ()
 
void findingRecordWithKey (const eventsetup::EventSetupRecordKey &)
 

Detailed Description

Definition at line 56 of file TestESSource.cc.

Member Typedef Documentation

◆ EventSetupRecordKey

Definition at line 58 of file TestESSource.cc.

Constructor & Destructor Documentation

◆ TestESSource()

edmtest::TestESSource::TestESSource ( edm::ParameterSet const &  pset)
explicit

Definition at line 120 of file TestESSource.cc.

References muonDTDigis_cfi::pset, setOfIOV_, groupFilesInBlocks::temp, and heppy_batch::val.

121  : count_(0),
122  count1_(0),
123  count2_(0),
124  iterations_(pset.getParameter<unsigned int>("iterations")),
125  pi_(std::acos(-1)),
126  expectedNumberOfConcurrentIOVs_(pset.getParameter<unsigned int>("expectedNumberOfConcurrentIOVs")),
127  checkIOVInitialization_(pset.getParameter<bool>("checkIOVInitialization")) {
128  std::vector<unsigned int> temp(pset.getParameter<std::vector<unsigned int>>("firstValidLumis"));
129  for (auto val : temp) {
131  }
132 
133  findingRecord<ESTestRecordI>();
134  usingRecord<ESTestRecordI>();
135  }
std::set< edm::IOVSyncValue > setOfIOV_
Definition: TestESSource.cc:78
unsigned int expectedNumberOfConcurrentIOVs_
Definition: TestESSource.cc:81
std::atomic< unsigned int > count1_
Definition: TestESSource.cc:67
std::atomic< unsigned int > count_
Definition: TestESSource.cc:66
const unsigned int iterations_
Definition: TestESSource.cc:79
std::atomic< unsigned int > count2_
Definition: TestESSource.cc:68

◆ ~TestESSource()

edmtest::TestESSource::~TestESSource ( )
override

Definition at line 137 of file TestESSource.cc.

137 {}

Member Function Documentation

◆ busyWait()

void edmtest::TestESSource::busyWait ( char const *  msg) const

Definition at line 226 of file TestESSource.cc.

References funct::cos(), mps_fire::i, iterations_, mps_check::msg, and pi_.

Referenced by edmtest::TestESSourceTestResolver::prefetch(), and setIntervalFor().

226  {
227  edm::LogAbsolute("TestESSource::busyWait") << "Start TestESSource::busyWait " << msg;
228  double sum = 0.;
229  const double stepSize = pi_ / iterations_;
230  for (unsigned int i = 0; i < iterations_; ++i) {
231  sum += stepSize * cos(i * stepSize);
232  }
233  edm::LogAbsolute("TestESSource::busyWait") << "Stop TestESSource::busyWait " << msg << " " << sum;
234  }
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
tuple msg
Definition: mps_check.py:286
const unsigned int iterations_
Definition: TestESSource.cc:79
Log< level::System, true > LogAbsolute

◆ fillDescriptions()

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

Definition at line 139 of file TestESSource.cc.

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

139  {
141  std::vector<unsigned int> emptyVector;
142  desc.add<unsigned int>("iterations", 10 * 1000 * 1000);
143  desc.add<bool>("checkIOVInitialization", false);
144  desc.add<unsigned int>("expectedNumberOfConcurrentIOVs", 0);
145  desc.add<std::vector<unsigned int>>("firstValidLumis", emptyVector);
146  descriptions.addDefault(desc);
147  }
void addDefault(ParameterSetDescription const &psetDescription)

◆ initConcurrentIOVs()

void edmtest::TestESSource::initConcurrentIOVs ( EventSetupRecordKey const &  key,
unsigned int  nConcurrentIOVs 
)
overrideprivatevirtual

Reimplemented from edm::eventsetup::ESProductResolverProvider.

Definition at line 212 of file TestESSource.cc.

References Exception, expectedNumberOfConcurrentIOVs_, crabWrapper::key, and nConcurrentIOVs_.

212  {
213  edm::LogAbsolute("TestESSource::initConcurrentIOVs")
214  << "Start TestESSource::initConcurrentIOVs " << nConcurrentIOVs << " " << key.name();
215  if (EventSetupRecordKey::makeKey<ESTestRecordI>() != key) {
216  throw cms::Exception("TestFailure") << "TestESSource::initConcurrentIOVs,"
217  << " unexpected EventSetupRecordKey";
218  }
219  if (expectedNumberOfConcurrentIOVs_ != 0 && nConcurrentIOVs != expectedNumberOfConcurrentIOVs_) {
220  throw cms::Exception("TestFailure") << "TestESSource::initConcurrentIOVs,"
221  << " unexpected number of concurrent IOVs";
222  }
223  nConcurrentIOVs_ = nConcurrentIOVs;
224  }
unsigned int expectedNumberOfConcurrentIOVs_
Definition: TestESSource.cc:81
unsigned int nConcurrentIOVs_
Definition: TestESSource.cc:82
Log< level::System, true > LogAbsolute

◆ isConcurrentFinder()

bool edmtest::TestESSource::isConcurrentFinder ( ) const
inlineoverrideprivatevirtual

Reimplemented from edm::EventSetupRecordIntervalFinder.

Definition at line 73 of file TestESSource.cc.

73 { return true; }

◆ registerResolvers()

edm::eventsetup::ESProductResolverProvider::KeyedResolversVector edmtest::TestESSource::registerResolvers ( EventSetupRecordKey const &  ,
unsigned int  iovIndex 
)
overrideprivatevirtual

Implements edm::eventsetup::ESProductResolverProvider.

Definition at line 198 of file TestESSource.cc.

References Exception, expectedNumberOfConcurrentIOVs_, and nConcurrentIOVs_.

199  {
201  throw cms::Exception("TestFailure") << "TestESSource::registerResolvers,"
202  << " unexpected number of concurrent IOVs";
203  }
204  KeyedResolversVector keyedResolversVector;
205 
206  edm::eventsetup::DataKey dataKey(edm::eventsetup::DataKey::makeTypeTag<IOVTestInfo>(), edm::eventsetup::IdTags(""));
207  keyedResolversVector.emplace_back(dataKey, std::make_shared<TestESSourceTestResolver>(this));
208 
209  return keyedResolversVector;
210  }
unsigned int expectedNumberOfConcurrentIOVs_
Definition: TestESSource.cc:81
unsigned int nConcurrentIOVs_
Definition: TestESSource.cc:82
std::vector< std::pair< DataKey, std::shared_ptr< ESProductResolver > >> KeyedResolversVector

◆ setIntervalFor()

void edmtest::TestESSource::setIntervalFor ( EventSetupRecordKey const &  ,
edm::IOVSyncValue const &  syncValue,
edm::ValidityInterval iov 
)
overrideprivatevirtual

Implements edm::EventSetupRecordIntervalFinder.

Definition at line 149 of file TestESSource.cc.

References busyWait(), checkIOVInitialization_, count1_, count2_, count_, edm::IOVSyncValue::endOfTime(), Exception, edm::ValidityInterval::invalidInterval(), edm::EventID::maxEventNumber(), mutex_, and setOfIOV_.

151  {
152  std::lock_guard<std::mutex> guard(mutex_);
154  // Note that this check should pass with the specific configuration where I enable
155  // the check, but in general it does not have to be true. The counts are offset
156  // by 1 because the beginRun IOV is invalid (no IOV initialization).
157  if (count1_ > 0 && count2_ + 1 != count1_) {
158  throw cms::Exception("TestFailure") << "TestESSource::setIntervalFor,"
159  << " unexpected number of IOV initializations";
160  }
161  }
162  ++count_;
163  ++count1_;
164  if (count_.load() > 1) {
165  throw cms::Exception("TestFailure") << "TestESSource::setIntervalFor,"
166  << " functions in mutex should not run concurrently";
167  }
168  busyWait("setIntervalFor");
170 
171  if (setOfIOV_.empty()) {
172  --count_;
173  return;
174  }
175 
176  std::pair<std::set<edm::IOVSyncValue>::iterator, std::set<edm::IOVSyncValue>::iterator> itFound =
177  setOfIOV_.equal_range(syncValue);
178 
179  if (itFound.first == itFound.second) {
180  if (itFound.first == setOfIOV_.begin()) {
181  //request is before first valid interval, so fail
182  --count_;
183  return;
184  }
185  //go back one step
186  --itFound.first;
187  }
188 
190  if (itFound.second != setOfIOV_.end()) {
191  endOfInterval = edm::IOVSyncValue(
192  edm::EventID(1, itFound.second->eventID().luminosityBlock() - 1, edm::EventID::maxEventNumber()));
193  }
194  iov = edm::ValidityInterval(*(itFound.first), endOfInterval);
195  --count_;
196  }
std::set< edm::IOVSyncValue > setOfIOV_
Definition: TestESSource.cc:78
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:82
std::pair< Time_t, Time_t > ValidityInterval
Definition: Time.h:17
std::atomic< unsigned int > count1_
Definition: TestESSource.cc:67
std::atomic< unsigned int > count_
Definition: TestESSource.cc:66
void busyWait(char const *msg) const
static EventNumber_t maxEventNumber()
Definition: EventID.h:96
static const ValidityInterval & invalidInterval()
std::atomic< unsigned int > count2_
Definition: TestESSource.cc:68

Member Data Documentation

◆ checkIOVInitialization_

bool edmtest::TestESSource::checkIOVInitialization_
private

Definition at line 83 of file TestESSource.cc.

Referenced by setIntervalFor().

◆ count1_

std::atomic<unsigned int> edmtest::TestESSource::count1_

Definition at line 67 of file TestESSource.cc.

Referenced by setIntervalFor().

◆ count2_

std::atomic<unsigned int> edmtest::TestESSource::count2_

◆ count_

std::atomic<unsigned int> edmtest::TestESSource::count_

Definition at line 66 of file TestESSource.cc.

Referenced by edmtest::TestESSourceTestResolver::prefetch(), and setIntervalFor().

◆ expectedNumberOfConcurrentIOVs_

unsigned int edmtest::TestESSource::expectedNumberOfConcurrentIOVs_
private

Definition at line 81 of file TestESSource.cc.

Referenced by initConcurrentIOVs(), and registerResolvers().

◆ iterations_

const unsigned int edmtest::TestESSource::iterations_
private

Definition at line 79 of file TestESSource.cc.

Referenced by busyWait().

◆ mutex_

std::mutex edmtest::TestESSource::mutex_

Definition at line 70 of file TestESSource.cc.

Referenced by setIntervalFor().

◆ nConcurrentIOVs_

unsigned int edmtest::TestESSource::nConcurrentIOVs_ = 0
private

Definition at line 82 of file TestESSource.cc.

Referenced by initConcurrentIOVs(), and registerResolvers().

◆ pi_

const double edmtest::TestESSource::pi_
private

Definition at line 80 of file TestESSource.cc.

Referenced by busyWait().

◆ queue_

edm::SerialTaskQueue edmtest::TestESSource::queue_

Definition at line 69 of file TestESSource.cc.

◆ setOfIOV_

std::set<edm::IOVSyncValue> edmtest::TestESSource::setOfIOV_
private

Definition at line 78 of file TestESSource.cc.

Referenced by setIntervalFor(), and TestESSource().