Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-07-19 01:44:05

0001 /*----------------------------------------------------------------------
0002 ----------------------------------------------------------------------*/
0003 
0004 #include "FWCore/Sources/interface/RawInputSource.h"
0005 
0006 #include "DataFormats/Provenance/interface/EventAuxiliary.h"
0007 #include "DataFormats/Provenance/interface/LuminosityBlockAuxiliary.h"
0008 #include "DataFormats/Provenance/interface/RunAuxiliary.h"
0009 #include "DataFormats/Provenance/interface/Timestamp.h"
0010 #include "DataFormats/Provenance/interface/ProcessHistoryRegistry.h"
0011 #include "FWCore/Framework/interface/EventPrincipal.h"
0012 #include "FWCore/Framework/interface/FileBlock.h"
0013 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0014 
0015 namespace edm {
0016 
0017   RawInputSource::RawInputSource(ParameterSet const& pset, InputSourceDescription const& desc)
0018       : InputSource(pset, desc),
0019         // The default value for the following parameter get defined in at least one derived class
0020         // where it has a different default value.
0021         inputFileTransitionsEachEvent_(pset.getUntrackedParameter<bool>("inputFileTransitionsEachEvent", false)),
0022         fakeInputFileTransition_(false) {
0023     setTimestamp(Timestamp::beginOfTime());
0024   }
0025 
0026   RawInputSource::~RawInputSource() {}
0027 
0028   std::shared_ptr<RunAuxiliary> RawInputSource::readRunAuxiliary_() {
0029     assert(newRun());
0030     assert(runAuxiliary());
0031     resetNewRun();
0032     return runAuxiliary();
0033   }
0034 
0035   std::shared_ptr<LuminosityBlockAuxiliary> RawInputSource::readLuminosityBlockAuxiliary_() {
0036     assert(!newRun());
0037     assert(newLumi());
0038     assert(luminosityBlockAuxiliary());
0039     resetNewLumi();
0040     return luminosityBlockAuxiliary();
0041   }
0042 
0043   void RawInputSource::readEvent_(EventPrincipal& eventPrincipal) {
0044     assert(!newRun());
0045     assert(!newLumi());
0046     assert(eventCached());
0047     resetEventCached();
0048     read(eventPrincipal);
0049   }
0050 
0051   void RawInputSource::makeEvent(EventPrincipal& eventPrincipal, EventAuxiliary const& eventAuxiliary) {
0052     auto history = processHistoryRegistry().getMapped(eventAuxiliary.processHistoryID());
0053     eventPrincipal.fillEventPrincipal(eventAuxiliary, history);
0054   }
0055 
0056   InputSource::ItemType RawInputSource::getNextItemType() {
0057     if (state() == IsInvalid) {
0058       return IsFile;
0059     }
0060     if (newRun() && runAuxiliary()) {
0061       return IsRun;
0062     }
0063     if (newLumi() && luminosityBlockAuxiliary()) {
0064       return IsLumi;
0065     }
0066     if (eventCached()) {
0067       return IsEvent;
0068     }
0069     if (inputFileTransitionsEachEvent_) {
0070       // The following two lines are here because after a source
0071       // tells the state machine the next ItemType is IsFile,
0072       // the source should then always follow that with IsRun
0073       // and then IsLumi. These two lines will cause that to happen.
0074       resetRunAuxiliary(newRun());
0075       resetLuminosityBlockAuxiliary(newLumi());
0076     }
0077     Next another = checkNext();
0078     if (another == Next::kStop) {
0079       return IsStop;
0080     } else if (another == Next::kEvent and inputFileTransitionsEachEvent_) {
0081       fakeInputFileTransition_ = true;
0082       return IsFile;
0083     } else if (another == Next::kFile) {
0084       setNewRun();
0085       setNewLumi();
0086       resetEventCached();
0087       return IsFile;
0088     }
0089     if (newRun()) {
0090       return IsRun;
0091     } else if (newLumi()) {
0092       return IsLumi;
0093     }
0094     return IsEvent;
0095   }
0096 
0097   void RawInputSource::reset_() {
0098     throw Exception(errors::LogicError) << "RawInputSource::reset()\n"
0099                                         << "Forking is not implemented for this type of RawInputSource\n"
0100                                         << "Contact a Framework Developer\n";
0101   }
0102 
0103   void RawInputSource::rewind_() { reset_(); }
0104 
0105   void RawInputSource::fillDescription(ParameterSetDescription& description) {
0106     // The default value for "inputFileTransitionsEachEvent" gets defined in the derived class
0107     // as it depends on the derived class. So, we cannot redefine it here.
0108     InputSource::fillDescription(description);
0109   }
0110 
0111   void RawInputSource::closeFile_() {
0112     if (!fakeInputFileTransition_) {
0113       genuineCloseFile();
0114     }
0115   }
0116 
0117   std::shared_ptr<edm::FileBlock> RawInputSource::readFile_() {
0118     if (!fakeInputFileTransition_) {
0119       genuineReadFile();
0120     }
0121     fakeInputFileTransition_ = false;
0122     return std::make_shared<FileBlock>();
0123   }
0124 
0125 }  // namespace edm