File indexing completed on 2023-10-25 09:47:00
0001
0002 #include "FWCore/Framework/interface/NumberOfConcurrentIOVs.h"
0003
0004 #include "FWCore/Framework/interface/EventSetupProvider.h"
0005 #include "FWCore/Framework/interface/HCTypeTag.h"
0006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0007 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0008 #include "FWCore/Utilities/interface/Exception.h"
0009
0010 #include <algorithm>
0011 #include <cassert>
0012 #include <string>
0013
0014 namespace edm {
0015 namespace eventsetup {
0016
0017 NumberOfConcurrentIOVs::NumberOfConcurrentIOVs() : numberConcurrentIOVs_(1) {}
0018
0019 void NumberOfConcurrentIOVs::readConfigurationParameters(ParameterSet const* eventSetupPset,
0020 unsigned int maxConcurrentIOVs,
0021 bool dumpOptions) {
0022 if (eventSetupPset) {
0023 maxConcurrentIOVs_ = maxConcurrentIOVs;
0024 numberConcurrentIOVs_ = eventSetupPset->getUntrackedParameter<unsigned int>("numberOfConcurrentIOVs");
0025 if (numberConcurrentIOVs_ == 0 || numberConcurrentIOVs_ > maxConcurrentIOVs) {
0026 numberConcurrentIOVs_ = maxConcurrentIOVs;
0027 }
0028 if (dumpOptions) {
0029 LogAbsolute("Options") << "Number of Concurrent IOVs = " << numberConcurrentIOVs_;
0030 }
0031
0032 ParameterSet const& pset(eventSetupPset->getUntrackedParameterSet("forceNumberOfConcurrentIOVs"));
0033 std::vector<std::string> recordNames = pset.getParameterNames();
0034 forceNumberOfConcurrentIOVs_.reserve(recordNames.size());
0035 for (auto const& recordName : recordNames) {
0036 EventSetupRecordKey recordKey(eventsetup::EventSetupRecordKey::TypeTag::findType(recordName));
0037 forceNumberOfConcurrentIOVs_.emplace_back(recordKey, pset.getUntrackedParameter<unsigned int>(recordName));
0038 }
0039 std::sort(forceNumberOfConcurrentIOVs_.begin(),
0040 forceNumberOfConcurrentIOVs_.end(),
0041 [](auto const& left, auto const& right) { return left.first < right.first; });
0042 }
0043 }
0044
0045 void NumberOfConcurrentIOVs::fillRecordsNotAllowingConcurrentIOVs(EventSetupProvider const& eventSetupProvider) {
0046 eventSetupProvider.fillRecordsNotAllowingConcurrentIOVs(recordsNotAllowingConcurrentIOVs_);
0047 }
0048
0049 unsigned int NumberOfConcurrentIOVs::numberOfConcurrentIOVs(EventSetupRecordKey const& eventSetupKey,
0050 bool printInfoMsg) const {
0051 assert(numberConcurrentIOVs_ != 0);
0052 auto iter = std::lower_bound(forceNumberOfConcurrentIOVs_.begin(),
0053 forceNumberOfConcurrentIOVs_.end(),
0054 std::make_pair(eventSetupKey, 0u),
0055 [](auto const& left, auto const& right) { return left.first < right.first; });
0056 if (iter != forceNumberOfConcurrentIOVs_.end() && iter->first == eventSetupKey) {
0057 if (printInfoMsg && iter->second > maxConcurrentIOVs_) {
0058 LogInfo("Configuration") << "For record " << eventSetupKey.name() << " you have configured " << iter->second
0059 << " concurrent IOVs.\n"
0060 << "But you cannot have more concurrent IOVs than lumis or streams.\n"
0061 << "There will not be more than " << maxConcurrentIOVs_ << " concurrent IOVs.\n";
0062 }
0063 return std::min(iter->second, maxConcurrentIOVs_);
0064 }
0065 if (recordsNotAllowingConcurrentIOVs_.find(eventSetupKey) != recordsNotAllowingConcurrentIOVs_.end()) {
0066 return 1;
0067 }
0068 if (printInfoMsg && numberConcurrentIOVs_ > maxConcurrentIOVs_) {
0069 LogInfo("Configuration") << "For record " << eventSetupKey.name() << " you have configured "
0070 << numberConcurrentIOVs_ << " concurrent IOVs.\n"
0071 << "But you cannot have more concurrent IOVs than lumis or streams.\n"
0072 << "There will not be more than " << maxConcurrentIOVs_ << " concurrent IOVs.\n";
0073 }
0074 return numberConcurrentIOVs_;
0075 }
0076
0077 void NumberOfConcurrentIOVs::clear() {
0078
0079 numberConcurrentIOVs_ = 0;
0080
0081
0082 recordsNotAllowingConcurrentIOVs_.clear();
0083 std::vector<std::pair<EventSetupRecordKey, unsigned int>>().swap(forceNumberOfConcurrentIOVs_);
0084 }
0085 }
0086 }