CMS 3D CMS Logo

EmptyESSource.cc
Go to the documentation of this file.
1 #include <set>
2 #include <sstream>
3 
8 
9 namespace edm {
10 
12  public:
14  EmptyESSource(EmptyESSource const&) = delete; // stop default
15  EmptyESSource const& operator=(EmptyESSource const&) = delete; // stop default
16 
17  // ---------- const member functions ---------------------
18 
19  // ---------- static member functions --------------------
20 
21  // ---------- member functions ---------------------------
23  IOVSyncValue const& iTime,
24  ValidityInterval& oInterval) override;
25 
26  static void fillDescriptions(ConfigurationDescriptions& descriptions);
27 
28  private:
29  void delaySettingRecords() override;
30  // ---------- member data --------------------------------
32  std::set<IOVSyncValue> setOfIOV_;
33  bool iovIsTime_;
34  };
35 
37  : recordName_(pset.getParameter<std::string>("recordName")),
38  iovIsTime_(!pset.getParameter<bool>("iovIsRunNotTime")) {
39  std::vector<unsigned int> temp(pset.getParameter<std::vector<unsigned int>>("firstValid"));
40  for (std::vector<unsigned int>::iterator itValue = temp.begin(), itValueEnd = temp.end(); itValue != itValueEnd;
41  ++itValue) {
42  if (iovIsTime_) {
43  setOfIOV_.insert(IOVSyncValue(Timestamp(*itValue)));
44  } else {
45  setOfIOV_.insert(IOVSyncValue(EventID(*itValue, 0, 0)));
46  }
47  }
48  //copy_all(temp, inserter(setOfIOV_ , setOfIOV_.end()));
49  }
50 
53  if (recordKey == eventsetup::EventSetupRecordKey()) {
55  << " The Record type named \"" << recordName_ << "\" could not be found. Please check the spelling. \n"
56  << "If the spelling is fine, then no module in the job requires this Record and therefore EmptyESSource can "
57  "not function.\n"
58  "In such a case please either remove the EmptyESSource with label'"
59  << descriptionForFinder().label_ << "' from your job or add a module which needs the Record to your job.";
60  }
61  findingRecordWithKey(recordKey);
62  }
63 
65  IOVSyncValue const& iTime,
66  ValidityInterval& oInterval) {
68  //if no intervals given, fail immediately
69  if (setOfIOV_.empty()) {
70  return;
71  }
72 
73  std::pair<std::set<IOVSyncValue>::iterator, std::set<IOVSyncValue>::iterator> itFound =
74  setOfIOV_.equal_range(iTime);
75 
76  //we have overshot
77  if (itFound.first == itFound.second) {
78  if (itFound.first == setOfIOV_.begin()) {
79  //request is before first valid interval, so fail
80  return;
81  }
82  //go back one step
83  --itFound.first;
84  }
85  if (itFound.first == setOfIOV_.end()) {
86  return;
87  }
88 
89  IOVSyncValue endOfInterval = IOVSyncValue::endOfTime();
90 
91  if (itFound.second != setOfIOV_.end()) {
92  if (iovIsTime_) {
93  endOfInterval = IOVSyncValue(Timestamp(itFound.second->time().value() - 1));
94  } else {
95  endOfInterval = IOVSyncValue(itFound.second->eventID().previousRunLastEvent(0));
96  }
97  }
98  oInterval = ValidityInterval(*(itFound.first), endOfInterval);
99  }
100 
103  desc.add<std::string>("recordName")
104  ->setComment(
105  "The name of the EventSetup Record for which intervals are to be generated.\n The record type must be used "
106  "by some module in the job else an exception will occur.");
107  desc.add<bool>("iovIsRunNotTime", true)->setComment("Sets how to interpret integer values used in 'firstValid'");
108  desc.add<std::vector<unsigned int>>("firstValid")
109  ->setComment(
110  "Sets the beginning point of an IOV. The end point is assumed to be the next entry in the list. If there "
111  "are no further entries than 'end of time' is used.");
112 
113  descriptions.addDefault(desc);
114  }
115 
116 } // namespace edm
117 using edm::EmptyESSource;
edm::EmptyESSource::EmptyESSource
EmptyESSource(ParameterSet const &)
Definition: EmptyESSource.cc:36
edm::eventsetup::heterocontainer::HCTypeTag::findType
static HCTypeTag findType(char const *iTypeName)
find a type based on the types name, if not found will return default HCTypeTag
Definition: HCTypeTag.cc:121
electrons_cff.bool
bool
Definition: electrons_cff.py:393
edm::EmptyESSource::setIntervalFor
void setIntervalFor(eventsetup::EventSetupRecordKey const &, IOVSyncValue const &iTime, ValidityInterval &oInterval) override
Definition: EmptyESSource.cc:64
edm::EventSetupRecordIntervalFinder::descriptionForFinder
const eventsetup::ComponentDescription & descriptionForFinder() const
Definition: EventSetupRecordIntervalFinder.h:43
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::EmptyESSource::setOfIOV_
std::set< IOVSyncValue > setOfIOV_
Definition: EmptyESSource.cc:32
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
edm::ValidityInterval
Definition: ValidityInterval.h:28
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
edm::EventSetupRecordIntervalFinder
Definition: EventSetupRecordIntervalFinder.h:33
edm::eventsetup::EventSetupRecordKey
Definition: EventSetupRecordKey.h:30
edm::eventsetup::ComponentDescription::label_
std::string label_
Definition: ComponentDescription.h:31
EDMException.h
edm::EmptyESSource::delaySettingRecords
void delaySettingRecords() override
Definition: EmptyESSource.cc:51
edm::EmptyESSource
Definition: EmptyESSource.cc:11
edm::EventSetupRecordIntervalFinder::findingRecordWithKey
void findingRecordWithKey(const eventsetup::EventSetupRecordKey &)
Definition: EventSetupRecordIntervalFinder.cc:44
edm::IOVSyncValue
Definition: IOVSyncValue.h:31
DEFINE_FWK_EVENTSETUP_SOURCE
#define DEFINE_FWK_EVENTSETUP_SOURCE(type)
Definition: SourceFactory.h:91
EventSetupRecordIntervalFinder.h
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
SourceFactory.h
edm::ParameterSet
Definition: ParameterSet.h:47
edm::IOVSyncValue::endOfTime
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:82
edm::EmptyESSource::operator=
EmptyESSource const & operator=(EmptyESSource const &)=delete
cond::ValidityInterval
std::pair< Time_t, Time_t > ValidityInterval
Definition: Time.h:17
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
std
Definition: JetResolutionObject.h:76
edm::EmptyESSource::recordName_
std::string recordName_
Definition: EmptyESSource.cc:31
Exception
Definition: hltDiff.cc:246
edm::EmptyESSource::fillDescriptions
static void fillDescriptions(ConfigurationDescriptions &descriptions)
Definition: EmptyESSource.cc:101
ParameterSet.h
edm::EmptyESSource::iovIsTime_
bool iovIsTime_
Definition: EmptyESSource.cc:33
edm::EventID
Definition: EventID.h:31
edm::ConfigurationDescriptions::addDefault
void addDefault(ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:99
edm::errors::Configuration
Definition: EDMException.h:36
edm::ValidityInterval::invalidInterval
static const ValidityInterval & invalidInterval()
Definition: ValidityInterval.cc:71
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
edm::Timestamp
Definition: Timestamp.h:30