ClosedRangeSetHandler.h
Go to the documentation of this file.
1 #ifndef art_Framework_Principal_ClosedRangeSetHandler_h
2 #define art_Framework_Principal_ClosedRangeSetHandler_h
3 // vim: set sw=2 expandtab :
4 
5 //
6 // ClosedRangeSetHandler
7 //
8 // This class is used to track AND MANIPULATE RangeSets as inherited
9 // from another source, such as RootInput. The RangeSets are closed
10 // in that the span of events/subruns encapsulated by a given RangeSet
11 // can never grow. The individual ranges, however, can be split if
12 // necessitated by an output-file switch. The 'idx_' member keeps
13 // track of the current EventRange.
14 //
15 // N.B. Event-filtering does not affect the calculation of the
16 // RangeSet since the RangeSet tracks all processed events, even
17 // those that were rejected due to failing a filter criterion.
18 //
19 // In the case of an output-file-switch, one of the RangeSet's
20 // EventRanges might be "split" so as to ensure unique RangeSets
21 // per output file for a given output module. For example,
22 // suppose the inherited RangeSet looks like:
23 //
24 // Run: 1 SubRun: 0 Event range: [1,6)
25 //
26 // but there are only two events in the file for that RangeSet --
27 // e.g. 2 and 4. If there is an output file switch after event 2
28 // is processed, the RangeSets for the output files will be:
29 //
30 // File A RangeSet = Run: 1 SubRun: 0 Event range: [1,3)
31 // File B RangeSet = Run: 1 SubRun: 0 Event range: [3,6)
32 //
33 // even though file A will contain only event 2 and file B will
34 // contain only event 4. In this way, the inherited RangeSet is
35 // preserved across files.
36 //
37 
41 
42 namespace art {
43 
44  class ClosedRangeSetHandler final : public RangeSetHandler {
45 
46  public: // TYPES
47  class EventInfo {
48 
49  public: // MEMBER FUNCTIONS -- Special Member Functions
50  ~EventInfo() noexcept;
51  EventInfo() noexcept;
52  EventInfo(EventInfo const&) noexcept;
53  EventInfo(EventInfo&&) noexcept;
56 
57  public: // MEMBER FUNCTIONS -- API for the user
58  EventID const& id() const;
59  bool lastInSubRun() const;
60  void set(EventID const& eid, bool const last);
61 
62  private: // MEMBER DATA
64  bool lastInSubRun_{false};
65  };
66 
67  public: // MEMBER FUNCTIONS -- Special Member Functions
68  virtual ~ClosedRangeSetHandler();
69  explicit ClosedRangeSetHandler(RangeSet const& inputRangeSet);
74 
75  public: // MEMBER FUNCTIONS -- API for the user
76  EventInfo const& eventInfo() const;
77 
78  private: // MEMBER FUNCTIONS -- Implementation details
79  std::size_t begin_idx() const;
80  std::size_t end_idx() const;
81 
82  private: // MEMBER FUNCTIONS -- API required by RangeSetHandler
83  HandlerType do_type() const override;
84  RangeSet do_getSeenRanges() const override;
85  void do_update(EventID const&, bool lastInSubRun) override;
86  void do_flushRanges() override;
87  void do_maybeSplitRange() override;
88  void do_rebase() override;
89  RangeSetHandler* do_clone() const override;
90 
91  private: // MEMBER DATA
93  std::size_t idx_{0};
95  };
96 
97 } // namespace art
98 
99 #endif /* art_Framework_Principal_ClosedRangeSetHandler_h */
100 
101 // Local Variables:
102 // mode: c++
103 // End:
HandlerType do_type() const override
ClosedRangeSetHandler(RangeSet const &inputRangeSet)
RangeSet do_getSeenRanges() const override
EventInfo const & eventInfo() const
void do_update(EventID const &, bool lastInSubRun) override
ClosedRangeSetHandler::EventInfo & operator=(EventInfo const &) noexcept
static RangeSet invalid()
Definition: RangeSet.cc:45
static constexpr EventID invalidEvent() noexcept
Definition: EventID.h:202
RangeSetHandler * do_clone() const override