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  //virtual ~EmptyESSource();
15 
16  // ---------- const member functions ---------------------
17 
18  // ---------- static member functions --------------------
19 
20  // ---------- member functions ---------------------------
22  IOVSyncValue const& iTime,
23  ValidityInterval& oInterval) override;
24 
25  private:
26  EmptyESSource(EmptyESSource const&) = delete; // stop default
27 
28  EmptyESSource const& operator=(EmptyESSource const&) = delete; // stop default
29 
30  void delaySettingRecords() override;
31  // ---------- member data --------------------------------
33  std::set<IOVSyncValue> setOfIOV_;
34  bool iovIsTime_;
35  };
36 
38  : recordName_(pset.getParameter<std::string>("recordName")),
39  iovIsTime_(!pset.getParameter<bool>("iovIsRunNotTime")) {
40  std::vector<unsigned int> temp(pset.getParameter<std::vector<unsigned int> >("firstValid"));
41  for (std::vector<unsigned int>::iterator itValue = temp.begin(), itValueEnd = temp.end(); itValue != itValueEnd;
42  ++itValue) {
43  if (iovIsTime_) {
44  setOfIOV_.insert(IOVSyncValue(Timestamp(*itValue)));
45  } else {
46  setOfIOV_.insert(IOVSyncValue(EventID(*itValue, 0, 0)));
47  }
48  }
49  //copy_all(temp, inserter(setOfIOV_ , setOfIOV_.end()));
50  }
51 
54  if (recordKey == eventsetup::EventSetupRecordKey()) {
56  << " The Record type named \"" << recordName_ << "\" could not be found. Please check the spelling. \n"
57  << "If the spelling is fine, then no module in the job requires this Record and therefore EmptyESSource can "
58  "not function.\n"
59  "In such a case please either remove the EmptyESSource with label'"
60  << descriptionForFinder().label_ << "' from your job or add a module which needs the Record to your job.";
61  }
62  findingRecordWithKey(recordKey);
63  }
64 
66  IOVSyncValue const& iTime,
67  ValidityInterval& oInterval) {
69  //if no intervals given, fail immediately
70  if (setOfIOV_.empty()) {
71  return;
72  }
73 
74  std::pair<std::set<IOVSyncValue>::iterator, std::set<IOVSyncValue>::iterator> itFound =
75  setOfIOV_.equal_range(iTime);
76 
77  //we have overshot
78  if (itFound.first == itFound.second) {
79  if (itFound.first == setOfIOV_.begin()) {
80  //request is before first valid interval, so fail
81  return;
82  }
83  //go back one step
84  --itFound.first;
85  }
86  if (itFound.first == setOfIOV_.end()) {
87  return;
88  }
89 
90  IOVSyncValue endOfInterval = IOVSyncValue::endOfTime();
91 
92  if (itFound.second != setOfIOV_.end()) {
93  if (iovIsTime_) {
94  endOfInterval = IOVSyncValue(Timestamp(itFound.second->time().value() - 1));
95  } else {
96  endOfInterval = IOVSyncValue(itFound.second->eventID().previousRunLastEvent(0));
97  }
98  }
99  oInterval = ValidityInterval(*(itFound.first), endOfInterval);
100  }
101 
102 } // namespace edm
103 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:19
static HCTypeTag findType(char const *iTypeName)
find a type based on the types name, if not found will return default HCTypeTag
std::set< IOVSyncValue > setOfIOV_
HLT enums.
static const ValidityInterval & invalidInterval()
#define DEFINE_FWK_EVENTSETUP_SOURCE(type)
Definition: SourceFactory.h:91
void findingRecordWithKey(const eventsetup::EventSetupRecordKey &)
std::string recordName_