00001 #include <sstream> 00002 00003 #include "FWCore/ParameterSet/interface/ParameterSet.h" 00004 #include "FWCore/Modules/src/EmptyESSource.h" 00005 #include "FWCore/Utilities/interface/EDMException.h" 00006 00007 namespace edm { 00008 00009 EmptyESSource::EmptyESSource(const edm::ParameterSet & pset) : 00010 recordName_(pset.getParameter<std::string>("recordName")), 00011 iovIsTime_(!pset.getParameter<bool>("iovIsRunNotTime")) 00012 { 00013 std::vector<unsigned int> temp(pset.getParameter< std::vector<unsigned int> >("firstValid")); 00014 for(std::vector<unsigned int>::iterator itValue = temp.begin(), itValueEnd = temp.end(); 00015 itValue != itValueEnd; 00016 ++itValue) { 00017 if(iovIsTime_) { 00018 setOfIOV_.insert(IOVSyncValue(Timestamp(*itValue))); 00019 } else { 00020 setOfIOV_.insert(IOVSyncValue(EventID(*itValue, 0))); 00021 } 00022 } 00023 //copy_all(temp, inserter(setOfIOV_ , setOfIOV_.end())); 00024 } 00025 00026 00027 void 00028 EmptyESSource::delaySettingRecords() 00029 { 00030 eventsetup::EventSetupRecordKey recordKey = eventsetup::EventSetupRecordKey::TypeTag::findType(recordName_); 00031 if (recordKey == edm::eventsetup::EventSetupRecordKey()) { 00032 throw edm::Exception(errors::Configuration)<<" The Record type named \""<<recordName_<<"\" could not be found. Please check the spelling. \n" 00033 <<"If the spelling is fine, then no module in the job requires this Record and therefore EmptyESSource can not function.\n" 00034 "In such a case please either remove the EmptyESSource with label'" 00035 <<descriptionForFinder().label_<<"' from your job or add a module which needs the Record to your job."; 00036 } 00037 findingRecordWithKey(recordKey); 00038 } 00039 00040 void 00041 EmptyESSource::setIntervalFor(const edm::eventsetup::EventSetupRecordKey&, 00042 const edm::IOVSyncValue& iTime, 00043 edm::ValidityInterval& oInterval) { 00044 oInterval = edm::ValidityInterval::invalidInterval(); 00045 //if no intervals given, fail immediately 00046 if (setOfIOV_.size() == 0) { 00047 return; 00048 } 00049 00050 std::pair< std::set<edm::IOVSyncValue>::iterator, 00051 std::set<edm::IOVSyncValue>::iterator > itFound = setOfIOV_.equal_range(iTime); 00052 00053 //we have overshot 00054 if(itFound.first == itFound.second){ 00055 if(itFound.first == setOfIOV_.begin()){ 00056 //request is before first valid interval, so fail 00057 return; 00058 } 00059 //go back one step 00060 --itFound.first; 00061 } 00062 if (itFound.first == setOfIOV_.end()) { 00063 return; 00064 } 00065 00066 edm::IOVSyncValue endOfInterval = edm::IOVSyncValue::endOfTime(); 00067 00068 if(itFound.second != setOfIOV_.end()) { 00069 if(iovIsTime_) { 00070 endOfInterval = edm::IOVSyncValue(Timestamp(itFound.second->time().value()-1)); 00071 } else { 00072 endOfInterval = edm::IOVSyncValue(itFound.second->eventID().previousRunLastEvent()); 00073 } 00074 } 00075 oInterval = edm::ValidityInterval(*(itFound.first), endOfInterval); 00076 } 00077 00078 }