LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
art::ClosedRangeSetHandler Class Referencefinal

#include "ClosedRangeSetHandler.h"

Inheritance diagram for art::ClosedRangeSetHandler:
art::RangeSetHandler

Classes

class  EventInfo
 

Public Types

enum  HandlerType { HandlerType::Open = 1, HandlerType::Closed = 2 }
 

Public Member Functions

virtual ~ClosedRangeSetHandler ()
 
 ClosedRangeSetHandler (RangeSet const &inputRangeSet)
 
 ClosedRangeSetHandler (ClosedRangeSetHandler const &)
 
 ClosedRangeSetHandler (ClosedRangeSetHandler &&)
 
ClosedRangeSetHandleroperator= (ClosedRangeSetHandler const &)
 
ClosedRangeSetHandleroperator= (ClosedRangeSetHandler &&)
 
EventInfo const & eventInfo () const
 
HandlerType type () const
 
RangeSet seenRanges () const
 
void update (EventID const &id, bool const lastInSubRun)
 
void flushRanges ()
 
void maybeSplitRange ()
 
void rebase ()
 
RangeSetHandlerclone () const
 

Private Member Functions

std::size_t begin_idx () const
 
std::size_t end_idx () const
 
HandlerType do_type () const override
 
RangeSet do_getSeenRanges () const override
 
void do_update (EventID const &, bool lastInSubRun) override
 
void do_flushRanges () override
 
void do_maybeSplitRange () override
 
void do_rebase () override
 
RangeSetHandlerdo_clone () const override
 

Private Attributes

RangeSet ranges_ {RangeSet::invalid()}
 
std::size_t idx_ {0}
 
EventInfo eventInfo_ {}
 

Detailed Description

Definition at line 44 of file ClosedRangeSetHandler.h.

Member Enumeration Documentation

enum art::RangeSetHandler::HandlerType
stronginherited
Enumerator
Open 
Closed 

Definition at line 14 of file RangeSetHandler.h.

Constructor & Destructor Documentation

art::ClosedRangeSetHandler::~ClosedRangeSetHandler ( )
virtualdefault
art::ClosedRangeSetHandler::ClosedRangeSetHandler ( RangeSet const &  inputRangeSet)
explicit

Definition at line 58 of file ClosedRangeSetHandler.cc.

References eventInfo_, idx_, and operator=().

art::ClosedRangeSetHandler::ClosedRangeSetHandler ( ClosedRangeSetHandler const &  )
default
art::ClosedRangeSetHandler::ClosedRangeSetHandler ( ClosedRangeSetHandler &&  )
default

Member Function Documentation

size_t art::ClosedRangeSetHandler::begin_idx ( ) const
private

Definition at line 90 of file ClosedRangeSetHandler.cc.

References art::RangeSet::begin_idx(), and ranges_.

Referenced by do_getSeenRanges().

91  {
92  return ranges_.begin_idx();
93  }
std::size_t begin_idx() const
Definition: RangeSet.cc:189
RangeSetHandler * art::RangeSetHandler::clone ( ) const
inherited
RangeSetHandler * art::ClosedRangeSetHandler::do_clone ( ) const
overrideprivatevirtual

Implements art::RangeSetHandler.

Definition at line 173 of file ClosedRangeSetHandler.cc.

174  {
175  return new ClosedRangeSetHandler{*this};
176  }
ClosedRangeSetHandler(RangeSet const &inputRangeSet)
void art::ClosedRangeSetHandler::do_flushRanges ( )
overrideprivatevirtual

Implements art::RangeSetHandler.

Definition at line 130 of file ClosedRangeSetHandler.cc.

References end_idx(), and idx_.

131  {
132  idx_ = end_idx();
133  }
RangeSet art::ClosedRangeSetHandler::do_getSeenRanges ( ) const
overrideprivatevirtual

Implements art::RangeSetHandler.

Definition at line 108 of file ClosedRangeSetHandler.cc.

References begin_idx(), idx_, ranges_, art::RangeSet::run(), and tmp.

109  {
110  RangeSet tmp{ranges_.run()};
111  tmp.assign_ranges(ranges_, begin_idx(), idx_);
112  return tmp;
113  }
Float_t tmp
Definition: plot.C:35
RunNumber_t run() const
Definition: RangeSet.cc:89
void art::ClosedRangeSetHandler::do_maybeSplitRange ( )
overrideprivatevirtual

Implements art::RangeSetHandler.

Definition at line 136 of file ClosedRangeSetHandler.cc.

References end_idx(), art::EventID::event(), eventInfo_, art::ClosedRangeSetHandler::EventInfo::id(), idx_, art::EventID::isFlush(), art::EventID::isValid(), art::ClosedRangeSetHandler::EventInfo::lastInSubRun(), art::EventID::next(), ranges_, art::RangeSet::split_range(), and art::EventID::subRun().

137  {
138  if (eventInfo_.lastInSubRun()) {
139  // No need to split.
140  return;
141  }
142  if (!eventInfo_.id().isValid()) {
143  // Have not read any events yet.
144  return;
145  }
146  if (eventInfo_.id().isFlush()) {
147  // Should not happen, be careful anyway.
148  return;
149  }
150  if (idx_ == end_idx()) {
151  // No need to split.
152  return;
153  }
154  auto split_range = ranges_.split_range(eventInfo_.id().subRun(),
155  eventInfo_.id().next().event());
156  if (split_range.second) {
157  // The split did happen, update our idx to the right-hand
158  // side of the split (our ranges has already been updated).
159  idx_ = split_range.first;
160  }
161  }
bool isValid() const
Definition: EventID.h:122
EventID next() const
Definition: EventID.h:134
std::pair< std::size_t, bool > split_range(SubRunNumber_t, EventNumber_t)
Definition: RangeSet.cc:345
bool isFlush() const
Definition: EventID.h:128
EventNumber_t event() const
Definition: EventID.h:116
SubRunNumber_t subRun() const
Definition: EventID.h:110
void art::ClosedRangeSetHandler::do_rebase ( )
overrideprivatevirtual

Implements art::RangeSetHandler.

Definition at line 164 of file ClosedRangeSetHandler.cc.

References end_idx(), art::RangeSet::extract_ranges(), idx_, ranges_, art::RangeSet::run(), and tmp.

165  {
166  auto rebasedRanges = ranges_.extract_ranges(idx_, end_idx());
167  RangeSet tmpRS{ranges_.run(), rebasedRanges};
168  ClosedRangeSetHandler tmp{tmpRS};
169  std::swap(*this, tmp);
170  }
Float_t tmp
Definition: plot.C:35
ClosedRangeSetHandler(RangeSet const &inputRangeSet)
RunNumber_t run() const
Definition: RangeSet.cc:89
std::vector< EventRange > extract_ranges(std::size_t const b, std::size_t const e)
Definition: RangeSet.cc:252
void swap(lar::deep_const_fwd_iterator_nested< CITER, INNERCONTEXTRACT > &a, lar::deep_const_fwd_iterator_nested< CITER, INNERCONTEXTRACT > &b)
RangeSetHandler::HandlerType art::ClosedRangeSetHandler::do_type ( ) const
overrideprivatevirtual
void art::ClosedRangeSetHandler::do_update ( EventID const &  id,
bool  lastInSubRun 
)
overrideprivatevirtual

Implements art::RangeSetHandler.

Definition at line 116 of file ClosedRangeSetHandler.cc.

References art::RangeSet::at(), art::EventRange::contains(), end_idx(), eventInfo_, idx_, art::RangeSet::next_subrun_or_end(), ranges_, and art::ClosedRangeSetHandler::EventInfo::set().

117  {
118  eventInfo_.set(id, lastInSubRun);
119  if (lastInSubRun) {
121  return;
122  }
123  while (idx_ != end_idx() &&
124  !ranges_.at(idx_).contains(id.subRun(), id.event())) {
125  ++idx_;
126  }
127  }
bool contains(SubRunNumber_t s, EventNumber_t e) const noexcept
Definition: EventRange.cc:136
void set(EventID const &eid, bool const last)
std::size_t next_subrun_or_end(std::size_t const b) const
Definition: RangeSet.cc:220
EventRange & at(std::size_t)
Definition: RangeSet.cc:246
Event finding and building.
size_t art::ClosedRangeSetHandler::end_idx ( ) const
private

Definition at line 96 of file ClosedRangeSetHandler.cc.

References art::RangeSet::end_idx(), and ranges_.

Referenced by do_flushRanges(), do_maybeSplitRange(), do_rebase(), and do_update().

97  {
98  return ranges_.end_idx();
99  }
std::size_t end_idx() const
Definition: RangeSet.cc:195
ClosedRangeSetHandler::EventInfo const & art::ClosedRangeSetHandler::eventInfo ( ) const

Definition at line 84 of file ClosedRangeSetHandler.cc.

References eventInfo_.

Referenced by art::EventProcessor::setSubRunAuxiliaryRangeSetID().

85  {
86  return eventInfo_;
87  }
void art::RangeSetHandler::flushRanges ( )
inherited

Definition at line 27 of file RangeSetHandler.cc.

References art::RangeSetHandler::do_flushRanges().

Referenced by art::EventProcessor::setRunAuxiliaryRangeSetID().

28  {
30  }
virtual void do_flushRanges()=0
void art::RangeSetHandler::maybeSplitRange ( )
inherited

Definition at line 33 of file RangeSetHandler.cc.

References art::RangeSetHandler::do_maybeSplitRange().

Referenced by art::EventProcessor::setSubRunAuxiliaryRangeSetID().

34  {
36  }
virtual void do_maybeSplitRange()=0
ClosedRangeSetHandler & art::ClosedRangeSetHandler::operator= ( ClosedRangeSetHandler const &  )
default

Referenced by ClosedRangeSetHandler().

ClosedRangeSetHandler & art::ClosedRangeSetHandler::operator= ( ClosedRangeSetHandler &&  )
default
void art::RangeSetHandler::rebase ( )
inherited

Definition at line 39 of file RangeSetHandler.cc.

References art::RangeSetHandler::do_rebase().

40  {
41  do_rebase();
42  }
virtual void do_rebase()=0
RangeSet art::RangeSetHandler::seenRanges ( ) const
inherited
RangeSetHandler::HandlerType art::RangeSetHandler::type ( ) const
inherited

Definition at line 9 of file RangeSetHandler.cc.

References art::RangeSetHandler::do_type().

10  {
11  return do_type();
12  }
virtual HandlerType do_type() const =0
void art::RangeSetHandler::update ( EventID const &  id,
bool const  lastInSubRun 
)
inherited

Definition at line 21 of file RangeSetHandler.cc.

References art::RangeSetHandler::do_update().

22  {
23  do_update(id, lastInSubRun);
24  }
virtual void do_update(EventID const &, bool lastInSubRun)=0

Member Data Documentation

EventInfo art::ClosedRangeSetHandler::eventInfo_ {}
private
std::size_t art::ClosedRangeSetHandler::idx_ {0}
private
RangeSet art::ClosedRangeSetHandler::ranges_ {RangeSet::invalid()}
private

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