RootInput_source.cc
Go to the documentation of this file.
2 // vim: set sw=2 expandtab :
3 
15 
16 #include "TTreeCache.h"
17 
18 #include <cassert>
19 #include <memory>
20 #include <set>
21 
22 using namespace art;
23 using namespace std;
24 
26 
28  : state_(SEQUENTIAL)
29  , lastReadEventID_()
30  , rootFileForLastReadEvent_()
31  , wantedEventID_()
32 {}
33 
36 {
37  return state_;
38 }
39 
40 void
42 {
44 }
45 
46 EventID const&
48 {
49  return lastReadEventID_;
50 }
51 
52 EventID const&
54 {
55  return wantedEventID_;
56 }
57 
58 shared_ptr<RootInputFile>
60 {
62 }
63 
64 void
66 {
67  state_ = state;
68 }
69 
70 void
72 {
73  lastReadEventID_ = eid;
74 }
75 
76 void
78 {
79  wantedEventID_ = eid;
80 }
81 
82 void
84  shared_ptr<RootInputFile> const& ptr)
85 {
87 }
88 
90 
94  desc.moduleDescription}
95  , catalog_{config().ifc_config}
96  , primaryFileSequence_{std::make_unique<RootInputFileSequence>(
97  config().rifs_config,
98  catalog_,
100  processingMode(),
101  desc.productRegistry,
103 {}
104 
105 void
107 {
108  primaryFileSequence_->endJob();
109 }
110 
111 void
113 {
114  primaryFileSequence_->closeFile_();
115 }
116 
117 void
119 {
120  // Rewind to before the first event that was read.
122  primaryFileSequence_->rewind_();
123 }
124 
127 {
128  return primaryFileSequence_->getNextItemType();
129 }
130 
131 void
133 {
134  primaryFileSequence_->finish();
135 }
136 
139 {
140  switch (accessState_.state()) {
144  return input::IsFile;
147  return input::IsRun;
150  return input::IsSubRun;
155  primaryFileSequence_->rootFileForLastReadEvent());
156  return input::IsEvent;
157  }
158  default:
159  throw Exception(errors::LogicError) << "RootInputSource::nextItemType "
160  "encountered an unknown "
161  "AccessState.\n";
162  }
163 }
164 
165 unique_ptr<FileBlock>
167 {
168  switch (accessState_.state()) {
175  default:
176  throw Exception(errors::LogicError) << "RootInputSource::readFile "
177  "encountered an unknown or "
178  "inappropriate AccessState.\n";
179  }
180 }
181 
182 unique_ptr<FileBlock>
184 {
185  return primaryFileSequence_->readFile_();
186 }
187 
188 unique_ptr<RunPrincipal>
190 {
191  switch (accessState_.state()) {
198  default:
199  throw Exception(errors::LogicError) << "RootInputSource::readRun "
200  "encountered an unknown or "
201  "inappropriate AccessState.\n";
202  }
203 }
204 
205 unique_ptr<RunPrincipal>
207 {
208  return primaryFileSequence_->readRun_();
209 }
210 
211 unique_ptr<RangeSetHandler>
213 {
214  return primaryFileSequence_->runRangeSetHandler();
215 }
216 
217 unique_ptr<SubRunPrincipal>
219 {
220  switch (accessState_.state()) {
227  default:
228  throw Exception(errors::LogicError) << "RootInputSource::readSubRun "
229  "encountered an unknown or "
230  "inappropriate AccessState.\n";
231  }
232 }
233 
234 unique_ptr<SubRunPrincipal>
236 {
237  return primaryFileSequence_->readSubRun_(rp);
238 }
239 
240 unique_ptr<RangeSetHandler>
242 {
243  return primaryFileSequence_->subRunRangeSetHandler();
244 }
245 
246 unique_ptr<EventPrincipal>
248 {
249  return readEvent_(srp);
250 }
251 
252 unique_ptr<EventPrincipal>
254 {
255  switch (accessState_.state()) {
262  default:
263  throw Exception(errors::LogicError) << "RootInputSource::readEvent "
264  "encountered an unknown or "
265  "inappropriate AccessState.\n";
266  }
267 }
268 
269 unique_ptr<EventPrincipal>
271 {
272  unique_ptr<EventPrincipal> result = primaryFileSequence_->readEvent_();
273  if (result.get()) {
276  primaryFileSequence_->rootFileForLastReadEvent());
277  }
278  return result;
279 }
280 
void setRootFileForLastReadEvent(std::shared_ptr< RootInputFile > const &)
RunID const & runID() const
Definition: EventID.h:93
SubRunID const & subRunID() const
Definition: EventID.h:105
std::shared_ptr< RootInputFile > rootFileForLastReadEvent_
Definition: RootInput.h:87
EventID const & eventID() const
Definition: Principal.cc:1186
virtual std::unique_ptr< RangeSetHandler > runRangeSetHandler() override
virtual void rewind_() override
virtual std::unique_ptr< EventPrincipal > readEvent(cet::exempt_ptr< SubRunPrincipal const >) override
virtual std::unique_ptr< RunPrincipal > readRun() override
AccessState accessState_
Definition: RootInput.h:198
void setWantedEventID(EventID const &)
void finish() override
STL namespace.
EventID const & lastReadEventID() const
std::shared_ptr< RootInputFile > rootFileForLastReadEvent() const
std::unique_ptr< RootInputFileSequence > primaryFileSequence_
Definition: RootInput.h:197
virtual input::ItemType getNextItemType() override
virtual void endJob() override
virtual input::ItemType nextItemType() override
virtual std::unique_ptr< SubRunPrincipal > readSubRun(cet::exempt_ptr< RunPrincipal const >) override
EventID const & wantedEventID() const
exempt_ptr< E > make_exempt_ptr(E *) noexcept
InputFileCatalog catalog_
Definition: RootInput.h:196
void setLastReadEventID(EventID const &)
virtual std::unique_ptr< FileBlock > readFile_() override
virtual std::unique_ptr< EventPrincipal > readEvent(cet::exempt_ptr< SubRunPrincipal const >) override
virtual std::unique_ptr< FileBlock > readFile() override
Read next file.
virtual std::unique_ptr< SubRunPrincipal > readSubRun(cet::exempt_ptr< RunPrincipal const >) override
virtual std::unique_ptr< SubRunPrincipal > readSubRun_(cet::exempt_ptr< RunPrincipal const >) override
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
virtual std::unique_ptr< RunPrincipal > readRun() override
ProcessConfiguration const & processConfiguration() const
Definition: InputSource.cc:18
ModuleDescription const & moduleDescription
virtual std::unique_ptr< RangeSetHandler > subRunRangeSetHandler() override
RootInput(Parameters const &, InputSourceDescription &)
std::unique_ptr< FileBlock > readFile() override
Read next file.
virtual std::unique_ptr< EventPrincipal > readEvent_() override
#define DEFINE_ART_INPUT_SOURCE(klass)
virtual std::unique_ptr< RunPrincipal > readRun_() override
virtual void closeFile_() override