CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
RawInputSource.cc
Go to the documentation of this file.
1 /*----------------------------------------------------------------------
2 ----------------------------------------------------------------------*/
3 
5 
14 
15 namespace edm {
16 
18  : InputSource(pset, desc),
19  // The default value for the following parameter get defined in at least one derived class
20  // where it has a different default value.
21  inputFileTransitionsEachEvent_(pset.getUntrackedParameter<bool>("inputFileTransitionsEachEvent", false)),
22  fakeInputFileTransition_(false) {
24  }
25 
27 
28  std::shared_ptr<RunAuxiliary> RawInputSource::readRunAuxiliary_() {
29  assert(newRun());
31  resetNewRun();
32  return runAuxiliary();
33  }
34 
35  std::shared_ptr<LuminosityBlockAuxiliary> RawInputSource::readLuminosityBlockAuxiliary_() {
36  assert(!newRun());
37  assert(newLumi());
39  resetNewLumi();
40  return luminosityBlockAuxiliary();
41  }
42 
44  assert(!newRun());
45  assert(!newLumi());
48  read(eventPrincipal);
49  }
50 
51  void RawInputSource::makeEvent(EventPrincipal& eventPrincipal, EventAuxiliary const& eventAuxiliary) {
52  auto history = processHistoryRegistry().getMapped(eventAuxiliary.processHistoryID());
53  eventPrincipal.fillEventPrincipal(eventAuxiliary, history);
54  }
55 
57  if (state() == IsInvalid) {
58  return IsFile;
59  }
60  if (newRun() && runAuxiliary()) {
61  return IsRun;
62  }
63  if (newLumi() && luminosityBlockAuxiliary()) {
64  return IsLumi;
65  }
66  if (eventCached()) {
67  return IsEvent;
68  }
70  // The following two lines are here because after a source
71  // tells the state machine the next ItemType is IsFile,
72  // the source should then always follow that with IsRun
73  // and then IsLumi. These two lines will cause that to happen.
76  }
77  Next another = checkNext();
78  if (another == Next::kStop) {
79  return IsStop;
80  } else if (another == Next::kEvent and inputFileTransitionsEachEvent_) {
82  return IsFile;
83  } else if (another == Next::kFile) {
84  setNewRun();
85  setNewLumi();
87  return IsFile;
88  }
89  if (newRun()) {
90  return IsRun;
91  } else if (newLumi()) {
92  return IsLumi;
93  }
94  return IsEvent;
95  }
96 
98  throw Exception(errors::LogicError) << "RawInputSource::reset()\n"
99  << "Forking is not implemented for this type of RawInputSource\n"
100  << "Contact a Framework Developer\n";
101  }
102 
104 
106  // The default value for "inputFileTransitionsEachEvent" gets defined in the derived class
107  // as it depends on the derived class. So, we cannot redefine it here.
108  InputSource::fillDescription(description);
109  }
110 
114  }
115  }
116 
117  std::shared_ptr<edm::FileBlock> RawInputSource::readFile_() {
119  genuineReadFile();
120  }
121  fakeInputFileTransition_ = false;
122  return std::make_shared<FileBlock>();
123  }
124 
125 } // namespace edm
virtual void genuineCloseFile()
ProcessHistoryRegistry const & processHistoryRegistry() const
Accessors for process history registry.
Definition: InputSource.h:140
void readEvent_(EventPrincipal &eventPrincipal) override
virtual void genuineReadFile()
std::shared_ptr< LuminosityBlockAuxiliary > readLuminosityBlockAuxiliary_() override
bool getMapped(ProcessHistoryID const &key, ProcessHistory &value) const
void closeFile_() final
bool newLumi() const
Definition: InputSource.h:355
void resetRunAuxiliary(bool isNewRun=true) const
Definition: InputSource.h:339
void setTimestamp(Timestamp const &theTime)
To set the current time, as seen by the input source.
Definition: InputSource.h:326
RawInputSource(ParameterSet const &pset, InputSourceDescription const &desc)
assert(be >=bs)
~RawInputSource() override
virtual Next checkNext()=0
static Timestamp beginOfTime()
Definition: Timestamp.h:84
bool inputFileTransitionsEachEvent_
virtual void read(EventPrincipal &eventPrincipal)=0
std::shared_ptr< FileBlock > readFile_() final
bool newRun() const
Definition: InputSource.h:352
std::shared_ptr< RunAuxiliary > readRunAuxiliary_() override
void rewind_() override
ItemType getNextItemType() override
ItemType state() const
Definition: InputSource.h:330
void resetEventCached()
Definition: InputSource.h:361
virtual void reset_()
std::shared_ptr< RunAuxiliary > runAuxiliary() const
Called by the framework to merge or insert run in principal cache.
Definition: InputSource.h:230
void resetLuminosityBlockAuxiliary(bool isNewLumi=true) const
Definition: InputSource.h:343
ProcessHistoryID const & processHistoryID() const
void fillEventPrincipal(EventAuxiliary const &aux, ProcessHistory const *processHistory, DelayedReader *reader=nullptr)
void makeEvent(EventPrincipal &eventPrincipal, EventAuxiliary const &eventAuxiliary)
static void fillDescription(ParameterSetDescription &desc)
Definition: InputSource.cc:117
std::shared_ptr< LuminosityBlockAuxiliary > luminosityBlockAuxiliary() const
Called by the framework to merge or insert lumi in principal cache.
Definition: InputSource.h:233
static void fillDescription(ParameterSetDescription &description)
bool eventCached() const
Definition: InputSource.h:358