24 explicit SwitchPoint() =
default;
27 std::vector<std::uint32_t>
const& idNumbers)
30 if (filename_.empty()) {
32 <<
"Cannot create a valid SwitchPoint object with an empty filename.";
35 if (idNumbers.empty()) {
39 switch (idNumbers.size()) {
52 <<
"Specified too many id numbers.";
59 return filename_ !=
"";
65 return filename_ ==
fn;
71 return matches(fn) && r_ ==
id.run();
77 return matches(fn,
id.runID()) && sr_ ==
id.subRun();
83 return matches(fn,
id.subRunID()) && e_ ==
id.event();
94 #define OUTPUT_COMMENT \ 95 "To indicate where an output file should switch, one can\n" \ 96 "specify the switch points via:\n\n" \ 98 " [\"a.txt\", [1] ], # ==> Switch after Run 1 in file \"a.txt\"\n" \ 99 " [\"a.txt\", [] ], # ==> Switch after file \"a.txt\"\n" \ 100 " [\"b.txt\", [1,4] ], # ==> Switch after Run 1, SubRun 4 in file " \ 102 " [\"b.txt\", [2,3,7]] # ==> Switch after Run 2, SubRun 3, Event 7 in " \ 105 "Note that the switching behavior should be put in the order that\n" \ 106 "the switching is expected--e.g. it would be an error to\n" \ 107 "specify [\"a.txt\", []] as the first item since that would\n" \ 108 "tell the module to switch after the first file has been\n" \ 109 "processed, and then switch after Run 1 in file \"a.txt\". In\n" \ 110 "other words, no sorting is done of the specified switch points." 122 std::vector<SwitchPoint>{}};
129 , switchPoints_{
ps().switchAfter()}
131 if (!switchPoints_.empty()) {
132 activeSwitchPoint_ = switchPoints_.front();
140 currentInputFileName_ = fb.
fileName();
147 activeSwitchPoint_.matches(currentInputFileName_, ep.
eventID());
148 if (requestsFileClose_) {
149 updateSwitchPoints();
157 activeSwitchPoint_.matches(currentInputFileName_, srp.
subRunID());
158 if (requestsFileClose_) {
159 updateSwitchPoints();
167 activeSwitchPoint_.matches(currentInputFileName_, rp.
runID());
168 if (requestsFileClose_) {
169 updateSwitchPoints();
176 requestsFileClose_ = activeSwitchPoint_.matches(currentInputFileName_);
177 if (requestsFileClose_) {
178 updateSwitchPoints();
185 return requestsFileClose_;
197 assert(activeSwitchPoint_.valid());
198 if (switchPoints_.empty()) {
201 activeSwitchPoint_ = SwitchPoint{};
204 switchPoints_.erase(
cbegin(switchPoints_));
205 activeSwitchPoint_ = switchPoints_.front();
210 SwitchPoint activeSwitchPoint_{};
212 bool requestsFileClose_{
false};
216 #undef OUTPUT_COMMENT
EventID const & eventID() const
void write(EventPrincipal &ep) override
RunID const & runID() const
EventProcessorTestOutput(Parameters const &ps)
void updateSwitchPoints()
auto const & get_PSet() const
ChannelGroupService::Name Name
void writeSubRun(SubRunPrincipal &srp) override
void respondToOpenInputFile(FileBlock const &fb) override
bool requestsToCloseFile() const override
#define DEFINE_ART_MODULE(klass)
std::string const & fileName() const
SubRunID subRunID() const
IDNumber_t< Level::SubRun > SubRunNumber_t
Granularity fileGranularity() const override
static constexpr double ps
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
std::vector< SwitchPoint > switchPoints_
IDNumber_t< Level::Event > EventNumber_t
decltype(auto) constexpr cbegin(T &&obj)
ADL-aware version of std::cbegin.
void incrementInputFileNumber() override
void writeRun(RunPrincipal &rp) override
fhicl::TableFragment< OutputModule::Config > omConfig
IDNumber_t< Level::Run > RunNumber_t