Classes | Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
art::RootInput Class Referencefinal

#include <RootInput.h>

Inheritance diagram for art::RootInput:
art::DecrepitRelicInputSourceImplementation art::InputSource

Classes

class  AccessState
 
struct  Config
 

Public Types

using Parameters = fhicl::WrappedTable< Config, Config::KeysToIgnore >
 
- Public Types inherited from art::InputSource
enum  ProcessingMode { Runs, RunsAndSubRuns, RunsSubRunsAndEvents }
 

Public Member Functions

 ~RootInput ()
 
 RootInput (Parameters const &, InputSourceDescription &)
 
 RootInput (RootInput const &)=delete
 
 RootInput (RootInput &&)=delete
 
RootInputoperator= (RootInput const &)=delete
 
RootInputoperator= (RootInput &&)=delete
 
template<typename T >
bool seekToEvent (T eventSpec, bool exact=false)
 
- Public Member Functions inherited from art::DecrepitRelicInputSourceImplementation
 DecrepitRelicInputSourceImplementation (fhicl::TableFragment< Config > const &, ModuleDescription const &)
 
virtual ~DecrepitRelicInputSourceImplementation () noexcept=0
 
 DecrepitRelicInputSourceImplementation (DecrepitRelicInputSourceImplementation &&)=delete
 
DecrepitRelicInputSourceImplementationoperator= (DecrepitRelicInputSourceImplementation const &)=delete
 
DecrepitRelicInputSourceImplementationoperator= (DecrepitRelicInputSourceImplementation &&)=delete
 
virtual void closeFile () override
 
virtual void doBeginJob () override
 
virtual void doEndJob () override
 
virtual std::unique_ptr< EventPrincipalreadEvent (EventID const &) override
 
virtual void skipEvents (int offset) override
 
virtual void rewind () override
 
ProcessingMode processingMode () const
 
int maxEvents () const
 
int remainingEvents () const
 
int maxSubRuns () const
 
int remainingSubRuns () const
 
void repeat_ ()
 
void issueReports (EventID const &eventID)
 
- Public Member Functions inherited from art::InputSource
virtual ~InputSource () noexcept
 
 InputSource (ModuleDescription const &)
 
 InputSource (InputSource const &)=delete
 
 InputSource (InputSource &&)=delete
 
InputSourceoperator= (InputSource const &)=delete
 
InputSourceoperator= (InputSource &&)=delete
 
ModuleDescription const & moduleDescription () const
 
ProcessConfiguration const & processConfiguration () const
 

Private Types

typedef input::EntryNumber EntryNumber
 

Private Member Functions

void finish () override
 
virtual input::ItemType nextItemType () override
 
virtual std::unique_ptr< FileBlockreadFile () override
 Read next file. More...
 
virtual std::unique_ptr< RunPrincipalreadRun () override
 
virtual std::unique_ptr< SubRunPrincipalreadSubRun (cet::exempt_ptr< RunPrincipal const >) override
 
virtual std::unique_ptr< EventPrincipalreadEvent (cet::exempt_ptr< SubRunPrincipal const >) override
 
virtual std::unique_ptr< RangeSetHandlerrunRangeSetHandler () override
 
virtual std::unique_ptr< RangeSetHandlersubRunRangeSetHandler () override
 
virtual void endJob () override
 
virtual input::ItemType getNextItemType () override
 
virtual std::unique_ptr< RunPrincipalreadRun_ () override
 
virtual std::unique_ptr< SubRunPrincipalreadSubRun_ (cet::exempt_ptr< RunPrincipal const >) override
 
virtual std::unique_ptr< EventPrincipalreadEvent_ () override
 
virtual std::unique_ptr< FileBlockreadFile_ () override
 
virtual void closeFile_ () override
 
virtual void rewind_ () override
 
std::unique_ptr< EventPrincipalreadEvent_ (cet::exempt_ptr< SubRunPrincipal const >)
 
template<typename T >
std::enable_if_t< std::is_convertible< T, off_t >::value, EventIDpostSeekChecks (EventID const &foundID, T eventSpec)
 
template<typename T >
std::enable_if_t<!std::is_convertible< T, off_t >::value, EventIDpostSeekChecks (EventID const &foundID, T eventSpec)
 

Private Attributes

InputFileCatalog catalog_
 
std::unique_ptr< RootInputFileSequenceprimaryFileSequence_
 
AccessState accessState_ {}
 

Additional Inherited Members

- Protected Member Functions inherited from art::DecrepitRelicInputSourceImplementation
input::ItemType state () const
 
void setState (input::ItemType)
 
void reset ()
 

Detailed Description

Definition at line 27 of file RootInput.h.

Member Typedef Documentation

Definition at line 91 of file RootInput.h.

Definition at line 47 of file RootInput.h.

Constructor & Destructor Documentation

RootInput::~RootInput ( )

Definition at line 89 of file RootInput_source.cc.

89 {}
RootInput::RootInput ( RootInput::Parameters const &  config,
InputSourceDescription desc 
)

Definition at line 91 of file RootInput_source.cc.

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 {}
UpdateOutputCallbacks & productRegistry
std::unique_ptr< RootInputFileSequence > primaryFileSequence_
Definition: RootInput.h:197
exempt_ptr< E > make_exempt_ptr(E *) noexcept
InputFileCatalog catalog_
Definition: RootInput.h:196
ProcessConfiguration const & processConfiguration() const
Definition: InputSource.cc:18
ModuleDescription const & moduleDescription
art::RootInput::RootInput ( RootInput const &  )
delete
art::RootInput::RootInput ( RootInput &&  )
delete

Member Function Documentation

void RootInput::closeFile_ ( )
overrideprivatevirtual

Reimplemented from art::DecrepitRelicInputSourceImplementation.

Definition at line 112 of file RootInput_source.cc.

113 {
114  primaryFileSequence_->closeFile_();
115 }
std::unique_ptr< RootInputFileSequence > primaryFileSequence_
Definition: RootInput.h:197
void RootInput::endJob ( )
overrideprivatevirtual

Reimplemented from art::DecrepitRelicInputSourceImplementation.

Definition at line 106 of file RootInput_source.cc.

107 {
108  primaryFileSequence_->endJob();
109 }
std::unique_ptr< RootInputFileSequence > primaryFileSequence_
Definition: RootInput.h:197
void RootInput::finish ( )
overrideprivatevirtual

Reimplemented from art::DecrepitRelicInputSourceImplementation.

Definition at line 132 of file RootInput_source.cc.

133 {
134  primaryFileSequence_->finish();
135 }
std::unique_ptr< RootInputFileSequence > primaryFileSequence_
Definition: RootInput.h:197
input::ItemType RootInput::getNextItemType ( )
overrideprivatevirtual

Implements art::DecrepitRelicInputSourceImplementation.

Definition at line 126 of file RootInput_source.cc.

127 {
128  return primaryFileSequence_->getNextItemType();
129 }
std::unique_ptr< RootInputFileSequence > primaryFileSequence_
Definition: RootInput.h:197
input::ItemType RootInput::nextItemType ( )
overrideprivatevirtual

Reimplemented from art::DecrepitRelicInputSourceImplementation.

Definition at line 138 of file RootInput_source.cc.

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 }
void setRootFileForLastReadEvent(std::shared_ptr< RootInputFile > const &)
RunID const & runID() const
Definition: EventID.h:93
SubRunID const & subRunID() const
Definition: EventID.h:105
AccessState accessState_
Definition: RootInput.h:198
std::unique_ptr< RootInputFileSequence > primaryFileSequence_
Definition: RootInput.h:197
EventID const & wantedEventID() const
void setLastReadEventID(EventID const &)
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
RootInput& art::RootInput::operator= ( RootInput const &  )
delete
RootInput& art::RootInput::operator= ( RootInput &&  )
delete
template<typename T >
std::enable_if_t< std::is_convertible< T, off_t >::value, EventID > art::RootInput::postSeekChecks ( EventID const &  foundID,
eventSpec 
)
private

Definition at line 233 of file RootInput.h.

234  {
235  if (eventspec == 0 && foundID == accessState_.lastReadEventID()) {
236  // We're supposed to be reading the, "next" event but it's a
237  // duplicate of the current one: skip it.
238  mf::LogWarning("DuplicateEvent")
239  << "Duplicate Events found: "
240  << "both events were " << foundID << ".\n"
241  << "The duplicate will be skipped.\n";
242  return primaryFileSequence_->seekToEvent(1, false);
243  }
244  return foundID;
245  }
AccessState accessState_
Definition: RootInput.h:198
EventID const & lastReadEventID() const
std::unique_ptr< RootInputFileSequence > primaryFileSequence_
Definition: RootInput.h:197
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
template<typename T >
std::enable_if_t<!std::is_convertible< T, off_t >::value, EventID > art::RootInput::postSeekChecks ( EventID const &  foundID,
eventSpec 
)
private

Definition at line 249 of file RootInput.h.

250  {
251  // Default implementation is NOP.
252  return foundID;
253  }
unique_ptr< EventPrincipal > RootInput::readEvent ( cet::exempt_ptr< SubRunPrincipal const >  srp)
overrideprivatevirtual

Reimplemented from art::DecrepitRelicInputSourceImplementation.

Definition at line 247 of file RootInput_source.cc.

248 {
249  return readEvent_(srp);
250 }
virtual std::unique_ptr< EventPrincipal > readEvent_() override
unique_ptr< EventPrincipal > RootInput::readEvent_ ( )
overrideprivatevirtual

Implements art::DecrepitRelicInputSourceImplementation.

Definition at line 270 of file RootInput_source.cc.

271 {
272  unique_ptr<EventPrincipal> result = primaryFileSequence_->readEvent_();
273  if (result.get()) {
276  primaryFileSequence_->rootFileForLastReadEvent());
277  }
278  return result;
279 }
void setRootFileForLastReadEvent(std::shared_ptr< RootInputFile > const &)
EventID const & eventID() const
Definition: Principal.cc:1186
AccessState accessState_
Definition: RootInput.h:198
std::unique_ptr< RootInputFileSequence > primaryFileSequence_
Definition: RootInput.h:197
void setLastReadEventID(EventID const &)
unique_ptr< EventPrincipal > RootInput::readEvent_ ( cet::exempt_ptr< SubRunPrincipal const >  srp)
private

Definition at line 253 of file RootInput_source.cc.

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 }
AccessState accessState_
Definition: RootInput.h:198
virtual std::unique_ptr< EventPrincipal > readEvent(cet::exempt_ptr< SubRunPrincipal const >) override
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
unique_ptr< FileBlock > RootInput::readFile ( )
overrideprivatevirtual

Read next file.

Reimplemented from art::DecrepitRelicInputSourceImplementation.

Definition at line 166 of file RootInput_source.cc.

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 }
AccessState accessState_
Definition: RootInput.h:198
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
std::unique_ptr< FileBlock > readFile() override
Read next file.
unique_ptr< FileBlock > RootInput::readFile_ ( )
overrideprivatevirtual

Reimplemented from art::DecrepitRelicInputSourceImplementation.

Definition at line 183 of file RootInput_source.cc.

184 {
185  return primaryFileSequence_->readFile_();
186 }
std::unique_ptr< RootInputFileSequence > primaryFileSequence_
Definition: RootInput.h:197
unique_ptr< RunPrincipal > RootInput::readRun ( )
overrideprivatevirtual

Reimplemented from art::DecrepitRelicInputSourceImplementation.

Definition at line 189 of file RootInput_source.cc.

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 }
virtual std::unique_ptr< RunPrincipal > readRun() override
AccessState accessState_
Definition: RootInput.h:198
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
unique_ptr< RunPrincipal > RootInput::readRun_ ( )
overrideprivatevirtual

Implements art::DecrepitRelicInputSourceImplementation.

Definition at line 206 of file RootInput_source.cc.

207 {
208  return primaryFileSequence_->readRun_();
209 }
std::unique_ptr< RootInputFileSequence > primaryFileSequence_
Definition: RootInput.h:197
unique_ptr< SubRunPrincipal > RootInput::readSubRun ( cet::exempt_ptr< RunPrincipal const >  rp)
overrideprivatevirtual

Reimplemented from art::DecrepitRelicInputSourceImplementation.

Definition at line 218 of file RootInput_source.cc.

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 }
AccessState accessState_
Definition: RootInput.h:198
virtual std::unique_ptr< SubRunPrincipal > readSubRun(cet::exempt_ptr< RunPrincipal const >) override
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
unique_ptr< SubRunPrincipal > RootInput::readSubRun_ ( cet::exempt_ptr< RunPrincipal const >  rp)
overrideprivatevirtual

Implements art::DecrepitRelicInputSourceImplementation.

Definition at line 235 of file RootInput_source.cc.

236 {
237  return primaryFileSequence_->readSubRun_(rp);
238 }
std::unique_ptr< RootInputFileSequence > primaryFileSequence_
Definition: RootInput.h:197
void RootInput::rewind_ ( )
overrideprivatevirtual

Reimplemented from art::DecrepitRelicInputSourceImplementation.

Definition at line 118 of file RootInput_source.cc.

119 {
120  // Rewind to before the first event that was read.
122  primaryFileSequence_->rewind_();
123 }
AccessState accessState_
Definition: RootInput.h:198
std::unique_ptr< RootInputFileSequence > primaryFileSequence_
Definition: RootInput.h:197
unique_ptr< RangeSetHandler > RootInput::runRangeSetHandler ( )
overrideprivatevirtual

Implements art::InputSource.

Definition at line 212 of file RootInput_source.cc.

213 {
214  return primaryFileSequence_->runRangeSetHandler();
215 }
std::unique_ptr< RootInputFileSequence > primaryFileSequence_
Definition: RootInput.h:197
template<typename T >
bool art::RootInput::seekToEvent ( eventSpec,
bool  exact = false 
)

Definition at line 203 of file RootInput.h.

204  {
205  if (accessState_.state()) {
207  << "Attempted to initiate a random access seek "
208  << "with one already in progress at state = " << accessState_.state()
209  << ".\n";
210  }
211  EventID foundID = primaryFileSequence_->seekToEvent(eventSpec, exact);
212  if (!foundID.isValid()) {
213  return false;
214  }
215  foundID = postSeekChecks(foundID, eventSpec);
217  if (primaryFileSequence_->rootFile() !=
220  } else if (foundID.runID() != accessState_.lastReadEventID().runID()) {
222  } else if (foundID.subRunID() !=
225  } else {
227  }
228  return true;
229  }
RunID const & runID() const
Definition: EventID.h:93
SubRunID const & subRunID() const
Definition: EventID.h:105
AccessState accessState_
Definition: RootInput.h:198
void setWantedEventID(EventID const &)
EventID const & lastReadEventID() const
std::shared_ptr< RootInputFile > rootFileForLastReadEvent() const
std::unique_ptr< RootInputFileSequence > primaryFileSequence_
Definition: RootInput.h:197
std::enable_if_t< std::is_convertible< T, off_t >::value, EventID > postSeekChecks(EventID const &foundID, T eventSpec)
Definition: RootInput.h:233
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
unique_ptr< RangeSetHandler > RootInput::subRunRangeSetHandler ( )
overrideprivatevirtual

Implements art::InputSource.

Definition at line 241 of file RootInput_source.cc.

242 {
243  return primaryFileSequence_->subRunRangeSetHandler();
244 }
std::unique_ptr< RootInputFileSequence > primaryFileSequence_
Definition: RootInput.h:197

Member Data Documentation

AccessState art::RootInput::accessState_ {}
private

Definition at line 198 of file RootInput.h.

InputFileCatalog art::RootInput::catalog_
private

Definition at line 196 of file RootInput.h.

std::unique_ptr<RootInputFileSequence> art::RootInput::primaryFileSequence_
private

Definition at line 197 of file RootInput.h.


The documentation for this class was generated from the following files: