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;
T getParameter(std::string const &) const
void delaySettingRecords() override
void setIntervalFor(eventsetup::EventSetupRecordKey const &, IOVSyncValue const &iTime, ValidityInterval &oInterval) override
EmptyESSource(ParameterSet const &)
EmptyESSource const & operator=(EmptyESSource const &)=delete
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:82
const eventsetup::ComponentDescription & descriptionForFinder() const
std::pair< Time_t, Time_t > ValidityInterval
Definition: Time.h:17
static HCTypeTag findType(char const *iTypeName)
find a type based on the types name, if not found will return default HCTypeTag
void addDefault(ParameterSetDescription const &psetDescription)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
std::set< IOVSyncValue > setOfIOV_
static void fillDescriptions(ConfigurationDescriptions &descriptions)
HLT enums.
static const ValidityInterval & invalidInterval()
#define DEFINE_FWK_EVENTSETUP_SOURCE(type)
Definition: SourceFactory.h:91
void findingRecordWithKey(const eventsetup::EventSetupRecordKey &)
std::string recordName_