RootInput_source.cc
Go to the documentation of this file.
2 // vim: set sw=2:
3 
4 #include "TTreeCache.h"
16 
17 #include <cassert>
18 #include <memory>
19 #include <set>
20 
21 using namespace art;
22 
24 
25 void
27 {
28  state_ = state;
29 }
30 
31 void
33 {
34  lastReadEventID_ = eid;
35 }
36 
37 void
39 {
40  wantedEventID_ = eid;
41 }
42 
43 void
45 {
47 }
48 
52  desc.moduleDescription}
53  , catalog_{config().ifc_config}
54  , primaryFileSequence_{std::make_unique<RootInputFileSequence>(
55  config().rifs_config,
56  catalog_,
59  desc.productRegistry,
61  desc.parentageEnabled_,
62  desc.rangesEnabled_)}
63  , accessState_{}
64 {}
65 
66 void
68 {
69  primaryFileSequence_->endJob();
70 }
71 
72 void
74 {
75  primaryFileSequence_->closeFile_();
76 }
77 
78 void
80 {
81  // Rewind to before the first event that was read.
83  primaryFileSequence_->rewind_();
84 }
85 
88 {
89  return primaryFileSequence_->getNextItemType();
90 }
91 
92 void
94 {
95  primaryFileSequence_->finish();
96 }
97 
100 {
101  switch (accessState_.state()) {
105  return input::IsFile;
109  return input::IsRun;
111  // RunPrincipal has been handed off to the EventProcessor by this point.
112  // Used the cached pointer.
115  return input::IsSubRun;
117  auto const wantedEventID = accessState_.wantedEventID();
118  setEventPrincipal(primaryFileSequence_->readIt(wantedEventID, true));
119  accessState_.setLastReadEventID(wantedEventID);
121  primaryFileSequence_->rootFileForLastReadEvent());
122  return input::IsEvent;
123  }
124  default:
126  << "RootInputSource::nextItemType encountered an "
127  "unknown AccessState.\n";
128  }
129 }
130 
131 std::unique_ptr<FileBlock>
133 {
134  switch (accessState_.state()) {
139  return readFile_();
140  default:
142  << "RootInputSource::readFile encountered an "
143  "unknown or inappropriate AccessState.\n";
144  }
145 }
146 
147 std::unique_ptr<FileBlock>
149 {
150  return primaryFileSequence_->readFile_();
151 }
152 
153 std::unique_ptr<RunPrincipal>
155 {
156  switch (accessState_.state()) {
161  return runPrincipal();
162  default:
164  << "RootInputSource::readRun encountered an "
165  "unknown or inappropriate AccessState.\n";
166  }
167 }
168 
169 std::unique_ptr<RunPrincipal>
171 {
172  return primaryFileSequence_->readRun_();
173 }
174 
175 std::unique_ptr<RangeSetHandler>
177 {
178  return primaryFileSequence_->runRangeSetHandler();
179 }
180 
181 std::unique_ptr<SubRunPrincipal>
183 {
184  switch (accessState_.state()) {
189  return subRunPrincipal();
190  default:
192  << "RootInputSource::readSubRun encountered an "
193  "unknown or inappropriate AccessState.\n";
194  }
195 }
196 
197 std::unique_ptr<SubRunPrincipal>
199 {
200  return primaryFileSequence_->readSubRun_(runPrincipalExemptPtr());
201 }
202 
203 std::unique_ptr<RangeSetHandler>
205 {
206  return primaryFileSequence_->subRunRangeSetHandler();
207 }
208 
209 std::unique_ptr<EventPrincipal>
211 {
212  return readEvent_(srp);
213 }
214 
215 std::unique_ptr<EventPrincipal>
217 {
218  switch (accessState_.state()) {
223  return eventPrincipal();
224  default:
226  << "RootInputSource::readEvent encountered an "
227  "unknown or inappropriate AccessState.\n";
228  }
229 }
230 
231 std::unique_ptr<EventPrincipal>
233 {
234  std::unique_ptr<EventPrincipal> result;
235  if (!result.get()) {
236  result = primaryFileSequence_->readEvent_();
237  }
238  if (result.get()) {
239  accessState_.setLastReadEventID(result->id());
241  primaryFileSequence_->rootFileForLastReadEvent());
242  }
243  return result;
244 }
245 
State state() const
Definition: RootInput.h:69
RootInputFile * rootFileForLastReadEvent_
Definition: RootInput.h:101
void setEventPrincipal(std::unique_ptr< EventPrincipal > &&ep)
RunID const & runID() const
Definition: EventID.h:92
void rewind_() override
std::unique_ptr< EventPrincipal > readEvent(cet::exempt_ptr< SubRunPrincipal const > srp) override
EventID const & wantedEventID() const
Definition: RootInput.h:86
std::unique_ptr< SubRunPrincipal > readSubRun(cet::exempt_ptr< RunPrincipal const > rp) override
Read next subRun.
std::unique_ptr< SubRunPrincipal > readSubRun_() override
void setWantedEventID(EventID const &eid)
AccessState accessState_
Definition: RootInput.h:109
void finish() override
Definition: config.py:1
std::unique_ptr< FileBlock > readFile_() override
std::unique_ptr< RunPrincipal > readRun_() override
std::unique_ptr< RootInputFileSequence > primaryFileSequence_
Definition: RootInput.h:108
input::ItemType getNextItemType() override
input::ItemType nextItemType() override
std::unique_ptr< SubRunPrincipal > readSubRun(cet::exempt_ptr< RunPrincipal const >) override
Read next subRun.
void endJob() override
input::ItemType nextItemType() override
std::unique_ptr< RunPrincipal > readRun() override
Read next run.
std::unique_ptr< EventPrincipal > readEvent_() override
InputFileCatalog catalog_
Definition: RootInput.h:107
std::unique_ptr< FileBlock > readFile() override
Read next file.
SubRunID const & subRunID() const
Definition: EventID.h:104
void setSubRunPrincipal(std::unique_ptr< SubRunPrincipal > &&srp)
void setRunPrincipal(std::unique_ptr< RunPrincipal > &&rp)
auto const & processConfiguration() const
Definition: InputSource.h:64
void setLastReadEventID(EventID const &eid)
std::unique_ptr< RangeSetHandler > runRangeSetHandler() override
void setRootFileForLastReadEvent(RootInputFile *)
std::unique_ptr< EventPrincipal > readEvent(cet::exempt_ptr< SubRunPrincipal const >) override
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
std::unique_ptr< FileBlock > readFile() override
Read next file.
ModuleDescription const & moduleDescription
Service to store calibration data products (CDP) in the SQLite3 metadatabase of a file...
Definition: FillParentInfo.h:8
ProcessingMode processingMode() const
RunsSubRunsAndEvents (default), RunsAndSubRuns, or Runs.
RootInput(Parameters const &, InputSourceDescription &)
#define DEFINE_ART_INPUT_SOURCE(klass)
std::unique_ptr< RunPrincipal > readRun() override
Read next run.
void closeFile_() override
std::unique_ptr< RangeSetHandler > subRunRangeSetHandler() override