1 #ifndef art_Framework_Modules_MixFilter_h 2 #define art_Framework_Modules_MixFilter_h 145 #include "cetlib/metaprogramming.h" 148 #include <functional> 149 #include <type_traits> 157 using cet::enable_if_function_exists_t;
161 template <
typename T,
typename =
void>
165 template <
typename T>
168 enable_if_function_exists_t<void (T::*)(), &T::startEvent>>
172 template <
typename T>
178 static bool need_warning =
true;
181 <<
"Mixing driver function has signature startEvent(), which is " 183 <<
"Please update your code to define startEvent(Event const &).\n" 184 <<
"In a future version of ART the old method will no longer be " 186 need_warning =
false;
192 template <
typename T>
199 template <
typename T>
209 maybe_call_old_startEvent;
210 maybe_call_old_startEvent(t);
217 template <
typename T,
typename =
void>
221 template <
typename T>
224 enable_if_function_exists_t<void (T::*)(Event const&), &T::startEvent>>
228 template <
typename T>
247 template <
typename T,
typename =
void>
251 template <
typename T>
254 enable_if_function_exists_t<size_t (T::*)(), &T::eventsToSkip>>
258 template <
typename T>
261 enable_if_function_exists_t<size_t (T::*)() const, &T::eventsToSkip>>
265 template <
typename T>
270 template <
typename T>
274 return t.eventsToSkip();
277 template <
typename T>
282 std::bind(&detail::call_eventsToSkip<T>, std::ref(t)));
292 template <
typename T,
typename =
void>
296 template <
typename T>
299 enable_if_function_exists_t<void (T::*)(EventIDSequence const&),
300 &T::processEventIDs>> : std::true_type {
303 template <
typename T>
310 template <
typename T>
315 t.processEventIDs(seq);
325 template <
typename T,
typename =
void>
329 template <
typename T>
332 enable_if_function_exists_t<void (T::*)(EventAuxiliarySequence const&),
333 &T::processEventAuxiliaries>>
337 template <
typename T>
344 template <
typename T>
353 auxseq.reserve(nSecondaries);
355 t.processEventAuxiliaries(auxseq);
363 template <
typename T,
typename =
void>
367 template <
typename T>
370 enable_if_function_exists_t<void (T::*)(Event&), &T::finalizeEvent>>
374 template <
typename T>
381 template <
typename T>
394 template <
typename T,
typename =
void>
398 template <
typename T>
401 enable_if_function_exists_t<void (T::*)(SubRun const&), &T::beginSubRun>>
405 template <
typename T>
412 template <
typename T>
425 template <
typename T,
typename =
void>
429 template <
typename T>
432 enable_if_function_exists_t<void (T::*)(SubRun&), &T::endSubRun>>
436 template <
typename T>
443 template <
typename T>
456 template <
typename T,
typename =
void>
460 template <
typename T>
463 enable_if_function_exists_t<void (T::*)(Run const&), &T::beginRun>>
467 template <
typename T>
474 template <
typename T>
487 template <
typename T,
typename =
void>
491 template <
typename T>
494 enable_if_function_exists_t<void (T::*)(Run&), &T::endRun>>
498 template <
typename T>
505 template <
typename T>
518 template <
typename T>
521 template <
typename T, respond_to_file<T>>
524 template <
typename T>
529 template <
typename T>
533 t.respondToOpenInputFile(fb);
537 template <
typename T>
541 t.respondToCloseInputFile(fb);
545 template <
typename T>
549 t.respondToOpenOutputFiles(fb);
553 template <
typename T>
557 t.respondToCloseOutputFiles(fb);
562 template <
typename T,
typename =
void>
566 template <
typename T>
570 &T::respondToOpenInputFile>>
575 template <
typename T,
typename =
void>
579 template <
typename T>
583 &T::respondToCloseInputFile>>
588 template <
typename T,
typename =
void>
592 template <
typename T>
596 &T::respondToOpenOutputFiles>>
601 template <
typename T,
typename =
void>
605 template <
typename T>
609 &T::respondToCloseOutputFiles>>
626 void respondToOpenInputFile(
FileBlock const&
fb)
override;
627 void respondToCloseInputFile(
FileBlock const&
fb)
override;
628 void respondToOpenOutputFiles(
FileBlock const&
fb)
override;
629 void respondToCloseOutputFiles(
FileBlock const&
fb)
override;
631 bool beginSubRun(
SubRun& sr)
override;
632 bool endSubRun(
SubRun& sr)
override;
633 bool beginRun(
Run& r)
override;
634 bool endRun(
Run& r)
override;
644 : helper_(initEngine_(p), *this)
710 maybe_call_startEvent(e);
711 maybe_call_startEvent(
detail_);
713 size_t nSecondaries =
detail_.nSecondaries();
717 enSeq.reserve(nSecondaries);
718 eIDseq.reserve(nSecondaries);
721 <<
"Insufficient secondary events available to mix.\n";
727 maybe_call_processEventIDs;
728 maybe_call_processEventIDs(
detail_, eIDseq);
733 maybe_call_processEventAuxiliaries;
734 maybe_call_processEventAuxiliaries(
detail_,
helper_, enSeq, nSecondaries);
742 maybe_call_finalizeEvent;
743 maybe_call_finalizeEvent(
detail_, e);
754 maybe_call_beginSubRun;
755 maybe_call_beginSubRun(
detail_, sr);
766 maybe_call_endSubRun;
767 maybe_call_endSubRun(
detail_, sr);
779 maybe_call_beginRun(
detail_, r);
801 if (ServiceRegistry::isAvailable<RandomNumberGenerator>()) {
seed_t get_seed_value(fhicl::ParameterSet const &pset, char const key[]="seed", seed_t const implicit_seed=-1)
void operator()(T &t, SubRun &sr)
std::vector< EventAuxiliary > EventAuxiliarySequence
std::vector< EventID > EventIDSequence
fhicl::ParameterSet const & initEngine_(fhicl::ParameterSet const &p)
void mixAndPut(EntryNumberSequence const &enSeq, EventIDSequence const &eIDseq, Event &e)
void setEventsToSkipFunction(std::function< size_t()> eventsToSkip)
void operator()(T &, SubRun const &)
void operator()(T &t, Run &r)
void operator()(T &, MixHelper &, EntryNumberSequence const &, size_t)
void operator()(T &, Run const &)
void operator()(T &t, SubRun const &sr)
void respondToOpenInputFile(FileBlock const &fb) override
void operator()(T &t, EventIDSequence const &seq)
bool generateEventSequence(size_t nSecondaries, EntryNumberSequence &enSeq, EventIDSequence &eIDseq)
do_not_call_respondToXXX(T &, FileBlock const &)
base_engine_t & createEngine(seed_t seed)
void operator()(T &t, Event &e)
do_not_setup_eventsToSkip(MixHelper &, T &)
void respondToCloseOutputFiles(FileBlock const &fb) override
void respondToOpenOutputFiles(FileBlock const &fb) override
void generateEventAuxiliarySequence(EntryNumberSequence const &, EventAuxiliarySequence &)
void operator()(T &, SubRun &)
call_startEvent(Event const &e)
std::vector< FileIndex::EntryNumber_t > EntryNumberSequence
void(T::*)(FileBlock const &) respond_to_file
bool beginSubRun(SubRun &sr) override
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
bool filter(Event &e) override
void respondToCloseInputFile(FileBlock const &fb) override
void operator()(T &, Event &)
call_respondToOpenOutputFiles(T &t, FileBlock const &fb)
std::string value(boost::any const &)
MixFilter(fhicl::ParameterSet const &p)
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
void operator()(T &t, MixHelper &h, EntryNumberSequence const &enseq, size_t nSecondaries)
do_not_call_startEvent(Event const &)
void operator()(T &, EventIDSequence const &)
void operator()(T &t, Run const &r)
bool beginRun(Run &r) override
bool endRun(Run &r) override
void operator()(T &, Run &)
size_t call_eventsToSkip(T &t)
bool endSubRun(SubRun &sr) override
setup_eventsToSkip(MixHelper &helper, T &t)
call_respondToCloseOutputFiles(T &t, FileBlock const &fb)