1 #ifndef art_Framework_Modules_MixFilter_h 2 #define art_Framework_Modules_MixFilter_h 146 #include "cetlib/metaprogramming.h" 149 #include <functional> 151 #include <type_traits> 154 template <
typename T,
typename IOPolicy>
157 template <
typename T>
174 using cet::enable_if_function_exists_t;
179 template <
typename T,
typename =
void>
182 template <
typename T>
185 enable_if_function_exists_t<void (T::*)(Event const&), &T::startEvent>>
193 template <
typename T,
typename =
void>
196 template <
typename T>
199 enable_if_function_exists_t<size_t (T::*)(), &T::eventsToSkip>>
202 template <
typename T>
205 enable_if_function_exists_t<size_t (T::*)() const, &T::eventsToSkip>>
213 template <
typename T,
typename =
void>
216 template <
typename T>
219 enable_if_function_exists_t<void (T::*)(EventIDSequence const&),
220 &T::processEventIDs>> : std::true_type {};
228 template <
typename T,
typename =
void>
231 template <
typename T>
234 enable_if_function_exists_t<void (T::*)(EventAuxiliarySequence const&),
235 &T::processEventAuxiliaries>>
242 template <
typename T,
typename =
void>
245 template <
typename T>
248 enable_if_function_exists_t<void (T::*)(Event&), &T::finalizeEvent>>
255 template <
typename T,
typename =
void>
258 template <
typename T>
261 enable_if_function_exists_t<void (T::*)(SubRun const&), &T::beginSubRun>>
268 template <
typename T,
typename =
void>
271 template <
typename T>
274 enable_if_function_exists_t<void (T::*)(SubRun&), &T::endSubRun>>
281 template <
typename T,
typename =
void>
284 template <
typename T>
287 enable_if_function_exists_t<void (T::*)(Run const&), &T::beginRun>>
294 template <
typename T,
typename =
void>
297 template <
typename T>
300 enable_if_function_exists_t<void (T::*)(Run&), &T::endRun>>
307 template <
typename T>
310 template <
typename T, respond_to_file<T>>
314 template <
typename T,
typename =
void>
317 template <
typename T>
321 &T::respondToOpenInputFile>>
325 template <
typename T,
typename =
void>
328 template <
typename T>
332 &T::respondToCloseInputFile>>
336 template <
typename T,
typename =
void>
339 template <
typename T>
343 &T::respondToOpenOutputFiles>>
347 template <
typename T,
typename =
void>
350 template <
typename T>
354 &T::respondToCloseOutputFiles>>
361 template <
typename T,
typename =
void>
366 template <
typename T>
381 template <
typename T,
typename IOPolicy>
388 template <
typename U = Parameters>
389 explicit MixFilter(std::enable_if_t<std::is_same_v<U, fhicl::ParameterSet>,
391 template <
typename U = Parameters>
393 std::enable_if_t<!std::is_same_v<U, fhicl::ParameterSet>, U>
const& p);
396 void respondToOpenInputFile(
FileBlock const&
fb)
override;
397 void respondToCloseInputFile(
FileBlock const&
fb)
override;
398 void respondToOpenOutputFiles(
FileBlock const&
fb)
override;
399 void respondToCloseOutputFiles(
FileBlock const&
fb)
override;
401 bool beginSubRun(
SubRun& sr)
override;
402 bool endSubRun(
SubRun& sr)
override;
403 bool beginRun(
Run&
r)
override;
404 bool endRun(
Run&
r)
override;
410 template <
typename T,
typename IOPolicy>
411 template <
typename U>
413 std::enable_if_t<std::is_same_v<U, fhicl::ParameterSet>,
417 p.template get<std::string>(
"module_label"),
419 std::make_unique<IOPolicy>()}
427 template <
typename T,
typename IOPolicy>
428 template <
typename U>
430 std::enable_if_t<!std::is_same_v<U, fhicl::ParameterSet>, U>
const& p)
433 p.get_PSet().template get<std::string>(
"module_label"),
435 std::make_unique<IOPolicy>()}
443 template <
typename T,
typename IOPolicy>
448 detail_.respondToOpenInputFile(fb);
452 template <
typename T,
typename IOPolicy>
457 detail_.respondToCloseInputFile(fb);
461 template <
typename T,
typename IOPolicy>
466 detail_.respondToOpenOutputFiles(fb);
470 template <
typename T,
typename IOPolicy>
475 detail_.respondToCloseOutputFiles(fb);
479 template <
typename T,
typename IOPolicy>
489 size_t const nSecondaries =
detail_.nSecondaries();
495 enSeq.reserve(nSecondaries);
496 eIDseq.reserve(nSecondaries);
499 <<
"Insufficient secondary events available to mix.\n";
504 detail_.processEventIDs(eIDseq);
510 detail_.processEventAuxiliaries(auxseq);
524 template <
typename T,
typename IOPolicy>
534 template <
typename T,
typename IOPolicy>
544 template <
typename T,
typename IOPolicy>
554 template <
typename T,
typename IOPolicy>
typename T::Parameters user_config_t
std::vector< EventID > EventIDSequence
void mixAndPut(EntryNumberSequence const &enSeq, EventIDSequence const &eIDseq, Event &e)
void setEventsToSkipFunction(std::function< size_t()> eventsToSkip)
typename detail::maybe_has_Parameters< T >::Parameters Parameters
bool beginRun(Run &r) override
void respondToOpenInputFile(FileBlock const &fb) override
void respondToCloseInputFile(FileBlock const &fb) override
bool endRun(Run &r) override
bool generateEventSequence(size_t nSecondaries, EntryNumberSequence &enSeq, EventIDSequence &eIDseq)
void respondToCloseOutputFiles(FileBlock const &fb) override
fhicl::TableFragment< MixHelper::Config > mixHelper
void respondToOpenOutputFiles(FileBlock const &fb) override
bool filter(Event &e) override
std::vector< FileIndex::EntryNumber_t > EntryNumberSequence
bool endSubRun(SubRun &sr) override
MixFilter(std::enable_if_t< std::is_same_v< U, fhicl::ParameterSet >, fhicl::ParameterSet > const &p)
void(T::*)(FileBlock const &) respond_to_file
ProducesCollector & producesCollector() noexcept
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
bool beginSubRun(SubRun &sr) override
EventAuxiliarySequence generateEventAuxiliarySequence(EntryNumberSequence const &)
auto const & operator()() const
fhicl::TableFragment< T > fragment_