Macros | Functions
OpenRangeSetHandler_t.cc File Reference
#include "boost/test/unit_test.hpp"
#include "art/Framework/Principal/OpenRangeSetHandler.h"
#include "art/test/Framework/Principal/SimpleEvent.h"
#include "canvas/Persistency/Common/detail/aggregate.h"
#include "canvas/Persistency/Provenance/RangeSet.h"
#include <vector>

Go to the source code of this file.

Macros

#define BOOST_TEST_MODULE   (OpenRangeSetHandler_t)
 

Functions

 BOOST_AUTO_TEST_CASE (Simple)
 
 BOOST_AUTO_TEST_CASE (FileSwitchAfterEvent)
 
 BOOST_AUTO_TEST_CASE (FileSwitchAfterSubRun)
 

Macro Definition Documentation

#define BOOST_TEST_MODULE   (OpenRangeSetHandler_t)

Definition at line 3 of file OpenRangeSetHandler_t.cc.

Function Documentation

BOOST_AUTO_TEST_CASE ( Simple  )

Definition at line 55 of file OpenRangeSetHandler_t.cc.

56 {
57  // RangeSet reference
58 
59  // Process events
60  for (auto const& e : events) {
61  rHandler->update(e.id, e.lastInSubRun);
62  srHandler->update(e.id, e.lastInSubRun);
63  if (e.lastInSubRun) {
64  srHandler->flushRanges();
65  {
66  RangeSet subRunRS{1};
67  subRunRS.emplace_range(e.id.subRun(), 1, 4);
68  BOOST_TEST(srHandler->seenRanges() == subRunRS);
69  }
70  srHandler = make_unique<OpenRangeSetHandler>(1); // New subrun
71  }
72  }
73 
74  vector<EventRange> ranges;
75  for (unsigned sr{0}; sr != 3; ++sr) {
76  concatenate(ranges, eventRanges(sr));
77  }
78  RangeSet const runRS{1, ranges};
79  BOOST_TEST(rHandler->seenRanges() == runRS);
80 }
std::string concatenate(H const &h, T const &...t)
Definition: select.h:138
const double e
static constexpr double sr
Definition: Units.h:166
void emplace_range(ARGS &&...)
BOOST_AUTO_TEST_CASE ( FileSwitchAfterEvent  )

Definition at line 82 of file OpenRangeSetHandler_t.cc.

83 {
84  // Process 5 events
85  for (std::size_t i{0}; i != 5; ++i) {
86  auto const& e = events[i];
87  srHandler->update(e.id, e.lastInSubRun);
88  rHandler->update(e.id, e.lastInSubRun);
89  if (e.lastInSubRun) {
90  srHandler->flushRanges();
91  {
92  RangeSet subRunRS{1};
93  subRunRS.emplace_range(e.id.subRun(), 1, 4);
94  BOOST_TEST(srHandler->seenRanges() == subRunRS);
95  }
96  srHandler = make_unique<OpenRangeSetHandler>(1); // New subrun
97  }
98  }
99 
100  // Simulate file-switch
101  srHandler->maybeSplitRange();
102  rHandler->maybeSplitRange();
103  {
104  vector<EventRange> runRanges{EventRange{0, 1, 4}};
105  vector<EventRange> subRunRanges{EventRange{1, 1, 3}};
106  concatenate(runRanges, subRunRanges);
107  RangeSet const subRunRS{1, subRunRanges};
108  RangeSet const runRS{1, runRanges};
109  BOOST_TEST(srHandler->seenRanges() == subRunRS);
110  BOOST_TEST(rHandler->seenRanges() == runRS);
111  }
112  srHandler->rebase();
113  rHandler->rebase();
114 
115  // Process remaining events
116  // ... first do rest of SubRun 1
117  auto const& e = events[5];
118  srHandler->update(e.id, e.lastInSubRun);
119  rHandler->update(e.id, e.lastInSubRun);
120  srHandler->flushRanges();
121  {
122  RangeSet subRunRS{1};
123  subRunRS.emplace_range(1, 3, 4);
124  BOOST_TEST(srHandler->seenRanges() == subRunRS);
125  }
126  srHandler = make_unique<OpenRangeSetHandler>(1); // New subrun
127 
128  for (std::size_t i{6}; i != events.size(); ++i) {
129  auto const& e = events[i];
130  srHandler->update(e.id, e.lastInSubRun);
131  rHandler->update(e.id, e.lastInSubRun);
132  }
133 
134  // End job
135  srHandler->flushRanges();
136  rHandler->flushRanges();
137  {
138  vector<EventRange> runRanges{EventRange{1, 3, 4}};
139  vector<EventRange> subRunRanges{EventRange{2, 1, 4}};
140  concatenate(runRanges, subRunRanges);
141  RangeSet const subRunRS{1, subRunRanges};
142  RangeSet const runRS{1, runRanges};
143  BOOST_TEST(srHandler->seenRanges() == subRunRS);
144  BOOST_TEST(rHandler->seenRanges() == runRS);
145  }
146 }
std::string concatenate(H const &h, T const &...t)
Definition: select.h:138
const double e
void emplace_range(ARGS &&...)
BOOST_AUTO_TEST_CASE ( FileSwitchAfterSubRun  )

Definition at line 148 of file OpenRangeSetHandler_t.cc.

149 {
150  // Process 6 events
151  for (std::size_t i{0}; i != 6; ++i) {
152  auto const& e = events[i];
153  srHandler->update(e.id, e.lastInSubRun);
154  rHandler->update(e.id, e.lastInSubRun);
155  if (e.lastInSubRun) {
156  srHandler->flushRanges();
157  {
158  RangeSet subRunRS{1};
159  subRunRS.emplace_range(e.id.subRun(), 1, 4);
160  BOOST_TEST(srHandler->seenRanges() == subRunRS);
161  }
162  srHandler = make_unique<OpenRangeSetHandler>(1); // New subrun
163  }
164  }
165 
166  // Simulate file-switch
167  srHandler->maybeSplitRange();
168  rHandler->maybeSplitRange();
169  {
170  vector<EventRange> runRanges;
171  for (std::size_t i{0}; i != 2; ++i) {
172  concatenate(runRanges, eventRanges(i));
173  }
174  RangeSet const subRunRS{1, std::vector<EventRange>{}};
175  RangeSet const runRS{1, runRanges};
176  BOOST_TEST(srHandler->seenRanges() == subRunRS);
177  BOOST_TEST(rHandler->seenRanges() == runRS);
178  }
179  srHandler->rebase();
180  rHandler->rebase();
181 
182  for (std::size_t i{6}; i != events.size(); ++i) {
183  auto const& e = events[i];
184  srHandler->update(e.id, e.lastInSubRun);
185  rHandler->update(e.id, e.lastInSubRun);
186  }
187 
188  // End job
189  srHandler->flushRanges();
190  rHandler->flushRanges();
191  {
192  vector<EventRange> const ranges{EventRange{2, 1, 4}};
193  RangeSet const rs{1, ranges};
194  BOOST_TEST(srHandler->seenRanges() == rs);
195  BOOST_TEST(rHandler->seenRanges() == rs);
196  }
197 }
std::string concatenate(H const &h, T const &...t)
Definition: select.h:138
const double e
void emplace_range(ARGS &&...)