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::DataProxyProvider 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::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)
 
virtual void updateLookup (ESRecordsToProxyIndices const &)
 
std::set< EventSetupRecordKeyusingRecords () const
 
virtual ~DataProxyProvider () 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::DataProxyProvider
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
 
KeyedProxiesVector registerProxies (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::DataProxyProvider
using KeyedProxiesVector = std::vector< std::pair< DataKey, std::shared_ptr< DataProxy > >>
 
- Protected Member Functions inherited from edm::eventsetup::DataProxyProvider
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 119 of file TestESSource.cc.

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

120  : count_(0),
121  count1_(0),
122  count2_(0),
123  iterations_(pset.getParameter<unsigned int>("iterations")),
124  pi_(std::acos(-1)),
125  expectedNumberOfConcurrentIOVs_(pset.getParameter<unsigned int>("expectedNumberOfConcurrentIOVs")),
126  checkIOVInitialization_(pset.getParameter<bool>("checkIOVInitialization")) {
127  std::vector<unsigned int> temp(pset.getParameter<std::vector<unsigned int>>("firstValidLumis"));
128  for (auto val : temp) {
130  }
131 
132  findingRecord<ESTestRecordI>();
133  usingRecord<ESTestRecordI>();
134  }
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 136 of file TestESSource.cc.

136 {}

Member Function Documentation

◆ busyWait()

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

Definition at line 225 of file TestESSource.cc.

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

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

225  {
226  edm::LogAbsolute("TestESSource::busyWait") << "Start TestESSource::busyWait " << msg;
227  double sum = 0.;
228  const double stepSize = pi_ / iterations_;
229  for (unsigned int i = 0; i < iterations_; ++i) {
230  sum += stepSize * cos(i * stepSize);
231  }
232  edm::LogAbsolute("TestESSource::busyWait") << "Stop TestESSource::busyWait " << msg << " " << sum;
233  }
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 138 of file TestESSource.cc.

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

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

◆ initConcurrentIOVs()

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

Reimplemented from edm::eventsetup::DataProxyProvider.

Definition at line 211 of file TestESSource.cc.

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

211  {
212  edm::LogAbsolute("TestESSource::initConcurrentIOVs")
213  << "Start TestESSource::initConcurrentIOVs " << nConcurrentIOVs << " " << key.name();
214  if (EventSetupRecordKey::makeKey<ESTestRecordI>() != key) {
215  throw cms::Exception("TestFailure") << "TestESSource::initConcurrentIOVs,"
216  << " unexpected EventSetupRecordKey";
217  }
218  if (expectedNumberOfConcurrentIOVs_ != 0 && nConcurrentIOVs != expectedNumberOfConcurrentIOVs_) {
219  throw cms::Exception("TestFailure") << "TestESSource::initConcurrentIOVs,"
220  << " unexpected number of concurrent IOVs";
221  }
222  nConcurrentIOVs_ = nConcurrentIOVs;
223  }
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; }

◆ registerProxies()

edm::eventsetup::DataProxyProvider::KeyedProxiesVector edmtest::TestESSource::registerProxies ( EventSetupRecordKey const &  ,
unsigned int  iovIndex 
)
overrideprivatevirtual

Implements edm::eventsetup::DataProxyProvider.

Definition at line 197 of file TestESSource.cc.

References Exception, expectedNumberOfConcurrentIOVs_, and nConcurrentIOVs_.

198  {
200  throw cms::Exception("TestFailure") << "TestESSource::registerProxies,"
201  << " unexpected number of concurrent IOVs";
202  }
203  KeyedProxiesVector keyedProxiesVector;
204 
205  edm::eventsetup::DataKey dataKey(edm::eventsetup::DataKey::makeTypeTag<IOVTestInfo>(), edm::eventsetup::IdTags(""));
206  keyedProxiesVector.emplace_back(dataKey, std::make_shared<TestESSourceTestProxy>(this));
207 
208  return keyedProxiesVector;
209  }
unsigned int expectedNumberOfConcurrentIOVs_
Definition: TestESSource.cc:81
unsigned int nConcurrentIOVs_
Definition: TestESSource.cc:82
std::vector< std::pair< DataKey, std::shared_ptr< DataProxy > >> KeyedProxiesVector

◆ setIntervalFor()

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

Implements edm::EventSetupRecordIntervalFinder.

Definition at line 148 of file TestESSource.cc.

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

150  {
151  std::lock_guard<std::mutex> guard(mutex_);
153  // Note that this check should pass with the specific configuration where I enable
154  // the check, but in general it does not have to be true. The counts are offset
155  // by 1 because the beginRun IOV is invalid (no IOV initialization).
156  if (count1_ > 0 && count2_ + 1 != count1_) {
157  throw cms::Exception("TestFailure") << "TestESSource::setIntervalFor,"
158  << " unexpected number of IOV initializations";
159  }
160  }
161  ++count_;
162  ++count1_;
163  if (count_.load() > 1) {
164  throw cms::Exception("TestFailure") << "TestESSource::setIntervalFor,"
165  << " functions in mutex should not run concurrently";
166  }
167  busyWait("setIntervalFor");
169 
170  if (setOfIOV_.empty()) {
171  --count_;
172  return;
173  }
174 
175  std::pair<std::set<edm::IOVSyncValue>::iterator, std::set<edm::IOVSyncValue>::iterator> itFound =
176  setOfIOV_.equal_range(syncValue);
177 
178  if (itFound.first == itFound.second) {
179  if (itFound.first == setOfIOV_.begin()) {
180  //request is before first valid interval, so fail
181  --count_;
182  return;
183  }
184  //go back one step
185  --itFound.first;
186  }
187 
189  if (itFound.second != setOfIOV_.end()) {
190  endOfInterval = edm::IOVSyncValue(
191  edm::EventID(1, itFound.second->eventID().luminosityBlock() - 1, edm::EventID::maxEventNumber()));
192  }
193  iov = edm::ValidityInterval(*(itFound.first), endOfInterval);
194  --count_;
195  }
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::TestESSourceTestProxy::prefetch(), and setIntervalFor().

◆ expectedNumberOfConcurrentIOVs_

unsigned int edmtest::TestESSource::expectedNumberOfConcurrentIOVs_
private

Definition at line 81 of file TestESSource.cc.

Referenced by initConcurrentIOVs(), and registerProxies().

◆ 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 registerProxies().

◆ 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().