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