Go to the documentation of this file.00001 #include <set>
00002 #include <sstream>
00003
00004 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00005 #include "FWCore/Utilities/interface/EDMException.h"
00006 #include "FWCore/Framework/interface/EventSetupRecordIntervalFinder.h"
00007 #include "FWCore/Framework/interface/SourceFactory.h"
00008
00009 namespace edm {
00010
00011 class EmptyESSource : public EventSetupRecordIntervalFinder {
00012
00013 public:
00014 EmptyESSource(ParameterSet const&);
00015
00016
00017
00018
00019
00020
00021
00022 void setIntervalFor(eventsetup::EventSetupRecordKey const&,
00023 IOVSyncValue const& iTime,
00024 ValidityInterval& oInterval);
00025
00026 private:
00027 EmptyESSource(EmptyESSource const&);
00028
00029 EmptyESSource const& operator=(EmptyESSource const&);
00030
00031 void delaySettingRecords();
00032
00033 std::string recordName_;
00034 std::set <IOVSyncValue> setOfIOV_;
00035 bool iovIsTime_;
00036 };
00037
00038 EmptyESSource::EmptyESSource(ParameterSet const& pset) :
00039 recordName_(pset.getParameter<std::string>("recordName")),
00040 iovIsTime_(!pset.getParameter<bool>("iovIsRunNotTime")) {
00041 std::vector<unsigned int> temp(pset.getParameter< std::vector<unsigned int> >("firstValid"));
00042 for(std::vector<unsigned int>::iterator itValue = temp.begin(), itValueEnd = temp.end();
00043 itValue != itValueEnd;
00044 ++itValue) {
00045 if(iovIsTime_) {
00046 setOfIOV_.insert(IOVSyncValue(Timestamp(*itValue)));
00047 } else {
00048 setOfIOV_.insert(IOVSyncValue(EventID(*itValue, 0, 0)));
00049 }
00050 }
00051
00052 }
00053
00054
00055 void
00056 EmptyESSource::delaySettingRecords() {
00057 eventsetup::EventSetupRecordKey recordKey = eventsetup::EventSetupRecordKey::TypeTag::findType(recordName_);
00058 if (recordKey == eventsetup::EventSetupRecordKey()) {
00059 throw edm::Exception(errors::Configuration) << " The Record type named \"" << recordName_
00060 << "\" could not be found. Please check the spelling. \n"
00061 << "If the spelling is fine, then no module in the job requires this Record and therefore EmptyESSource can not function.\n"
00062 "In such a case please either remove the EmptyESSource with label'"
00063 << descriptionForFinder().label_ << "' from your job or add a module which needs the Record to your job.";
00064 }
00065 findingRecordWithKey(recordKey);
00066 }
00067
00068 void
00069 EmptyESSource::setIntervalFor(eventsetup::EventSetupRecordKey const&,
00070 IOVSyncValue const& iTime,
00071 ValidityInterval& oInterval) {
00072 oInterval = ValidityInterval::invalidInterval();
00073
00074 if (setOfIOV_.size() == 0) {
00075 return;
00076 }
00077
00078 std::pair< std::set<IOVSyncValue>::iterator,
00079 std::set<IOVSyncValue>::iterator > itFound = setOfIOV_.equal_range(iTime);
00080
00081
00082 if(itFound.first == itFound.second) {
00083 if(itFound.first == setOfIOV_.begin()) {
00084
00085 return;
00086 }
00087
00088 --itFound.first;
00089 }
00090 if (itFound.first == setOfIOV_.end()) {
00091 return;
00092 }
00093
00094 IOVSyncValue endOfInterval = IOVSyncValue::endOfTime();
00095
00096 if(itFound.second != setOfIOV_.end()) {
00097 if(iovIsTime_) {
00098 endOfInterval = IOVSyncValue(Timestamp(itFound.second->time().value() - 1));
00099 } else {
00100 endOfInterval = IOVSyncValue(itFound.second->eventID().previousRunLastEvent(0));
00101 }
00102 }
00103 oInterval = ValidityInterval(*(itFound.first), endOfInterval);
00104 }
00105
00106 }
00107 using edm::EmptyESSource;
00108 DEFINE_FWK_EVENTSETUP_SOURCE(EmptyESSource);