![]() |
![]() |
00001 /*---------------------------------------------------------------------- 00002 ----------------------------------------------------------------------*/ 00003 00004 #include "FWCore/Sources/interface/RawInputSource.h" 00005 00006 #include "DataFormats/Provenance/interface/EventAuxiliary.h" 00007 #include "DataFormats/Provenance/interface/LuminosityBlockAuxiliary.h" 00008 #include "DataFormats/Provenance/interface/RunAuxiliary.h" 00009 #include "DataFormats/Provenance/interface/Timestamp.h" 00010 #include "FWCore/Framework/interface/EventPrincipal.h" 00011 #include "FWCore/ParameterSet/interface/ParameterSet.h" 00012 00013 namespace edm { 00014 00015 RawInputSource::RawInputSource(ParameterSet const& pset, InputSourceDescription const& desc) : 00016 InputSource(pset, desc), 00017 // The default value for the following parameter get defined in at least one derived class 00018 // where it has a different default value. 00019 inputFileTransitionsEachEvent_(pset.getUntrackedParameter<bool>("inputFileTransitionsEachEvent", false)) { 00020 setTimestamp(Timestamp::beginOfTime()); 00021 } 00022 00023 RawInputSource::~RawInputSource() { 00024 } 00025 00026 boost::shared_ptr<RunAuxiliary> 00027 RawInputSource::readRunAuxiliary_() { 00028 assert(newRun()); 00029 assert(runAuxiliary()); 00030 resetNewRun(); 00031 return runAuxiliary(); 00032 } 00033 00034 boost::shared_ptr<LuminosityBlockAuxiliary> 00035 RawInputSource::readLuminosityBlockAuxiliary_() { 00036 assert(!newRun()); 00037 assert(newLumi()); 00038 assert(luminosityBlockAuxiliary()); 00039 resetNewLumi(); 00040 return luminosityBlockAuxiliary(); 00041 } 00042 00043 EventPrincipal* 00044 RawInputSource::readEvent_(EventPrincipal& eventPrincipal) { 00045 assert(!newRun()); 00046 assert(!newLumi()); 00047 assert(eventCached()); 00048 resetEventCached(); 00049 return read(eventPrincipal); 00050 } 00051 00052 EventPrincipal* 00053 RawInputSource::makeEvent(EventPrincipal& eventPrincipal, EventAuxiliary const& eventAuxiliary) { 00054 EventSourceSentry sentry(*this); 00055 eventPrincipal.fillEventPrincipal(eventAuxiliary); 00056 return &eventPrincipal; 00057 } 00058 00059 void 00060 RawInputSource::preForkReleaseResources() { 00061 closeFile(nullptr, false); 00062 } 00063 00064 InputSource::ItemType 00065 RawInputSource::getNextItemType() { 00066 if(state() == IsInvalid) { 00067 return IsFile; 00068 } 00069 if(newRun() && runAuxiliary()) { 00070 return IsRun; 00071 } 00072 if(newLumi() && luminosityBlockAuxiliary()) { 00073 return IsLumi; 00074 } 00075 if(eventCached()) { 00076 return IsEvent; 00077 } 00078 if (inputFileTransitionsEachEvent_) { 00079 resetRunAuxiliary(newRun()); 00080 resetLuminosityBlockAuxiliary(newLumi()); 00081 } 00082 bool another = checkNextEvent(); 00083 if(!another || (!newLumi() && !eventCached())) { 00084 return IsStop; 00085 } else if(inputFileTransitionsEachEvent_) { 00086 return IsFile; 00087 } 00088 if(newRun()) { 00089 return IsRun; 00090 } else if(newLumi()) { 00091 return IsLumi; 00092 } 00093 return IsEvent; 00094 } 00095 00096 void 00097 RawInputSource::reset_() { 00098 throw Exception(errors::LogicError) 00099 << "RawInputSource::reset()\n" 00100 << "Forking is not implemented for this type of RawInputSource\n" 00101 << "Contact a Framework Developer\n"; 00102 } 00103 00104 void 00105 RawInputSource::rewind_() { 00106 reset_(); 00107 } 00108 00109 void 00110 RawInputSource:: fillDescription(ParameterSetDescription& description) { 00111 // The default value for "inputFileTransitionsEachEvent" gets defined in the derived class 00112 // as it depends on the derived class. So, we cannot redefine it here. 00113 InputSource::fillDescription(description); 00114 } 00115 }