LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
ClosedRangeSetHandler.h
Go to the documentation of this file.
1 #ifndef art_Framework_Principal_ClosedRangeSetHandler_h
2 #define art_Framework_Principal_ClosedRangeSetHandler_h
3 
4 // ====================================================================
5 // ClosedRangeSetHandler
6 //
7 // This class is used to track AND MANIPULATE RangeSets as inherited
8 // from another source, such as RootInput. The RangeSets are closed
9 // in that the span of events/subruns encapsulated by a given RangeSet
10 // can never grow. The individual ranges, however, can be split if
11 // necessitated by an output-file switch. The 'rsIter_' member keeps
12 // track of the current EventRange.
13 //
14 // N.B. Event-filtering does not affect the calculation of the
15 // RangeSet since the RangeSet tracks all processed events, even
16 // those that were rejected due to failing a filter criterion.
17 //
18 // In the case of an output-file-switch, one of the RangeSet's
19 // EventRanges might be "split" so as to ensure unique RangeSets
20 // per output file for a given output module. For example,
21 // suppose the inherited RangeSet looks like:
22 //
23 // Run: 1 SubRun: 0 Event range: [1,6)
24 //
25 // but there are only two events in the file for that RangeSet --
26 // e.g. 2 and 4. If there is an output file switch after event 2
27 // is processed, the RangeSets for the output files will be:
28 //
29 // File A RangeSet = Run: 1 SubRun: 0 Event range: [1,3)
30 // File B RangeSet = Run: 1 SubRun: 0 Event range: [3,6)
31 //
32 // even though file A will contain only event 2 and file B will
33 // contain only event 4. In this way, the inherited RangeSet is
34 // preserved across files.
35 // ====================================================================
36 
41 
42 #include <string>
43 #include <vector>
44 
45 namespace art {
46 
48  public:
49  explicit ClosedRangeSetHandler(RangeSet const& inputRangeSet);
50 
51  // This class contains an iterator as a member.
52  // It should not be copied!
55 
58 
59  private:
60  auto
61  begin() const
62  {
63  return ranges_.begin();
64  }
65  auto
66  end() const
67  {
68  return ranges_.end();
69  }
71 
72  RangeSet do_getSeenRanges() const override;
73 
74  void do_update(EventID const&, bool lastInSubRun) override;
75 
76  void do_flushRanges() override;
77  void do_maybeSplitRange() override;
78  void do_rebase() override;
79 
80  struct EventInfo {
81  void
82  set(EventID const& eid, bool const last)
83  {
84  id = eid;
85  lastInSubRun = last;
86  }
88  bool lastInSubRun{false};
89  };
90 
94  };
95 }
96 #endif /* art_Framework_Principal_ClosedRangeSetHandler_h */
97 
98 // Local Variables:
99 // mode: c++
100 // End:
static constexpr EventID invalidEvent()
Definition: EventID.h:203
RangeSet::const_iterator rsIter_
std::vector< EventRange >::const_iterator const_iterator
Definition: RangeSet.h:33
auto begin() const
Definition: RangeSet.h:70
ClosedRangeSetHandler(RangeSet const &inputRangeSet)
auto end() const
Definition: RangeSet.h:75
RangeSet do_getSeenRanges() const override
RangeSet::const_iterator next_subrun_or_end() const
void do_update(EventID const &, bool lastInSubRun) override
static RangeSet invalid()
Definition: RangeSet.cc:46
HLT enums.
ClosedRangeSetHandler & operator=(ClosedRangeSetHandler const &)=delete