1 #ifndef FWCore_Framework_StreamSchedule_h 2 #define FWCore_Framework_StreamSchedule_h 100 class BranchIDListHelper;
102 class ExceptionCollector;
103 class ExceptionToActionTable;
104 class OutputModuleCommunicator;
105 class ProcessContext;
108 class ModuleRegistry;
109 class TriggerResultInserter;
110 class PathStatusInserter;
111 class EndPathStatusInserter;
112 class PreallocationConfiguration;
116 class TriggerNamesService;
120 template <
typename T>
121 class StreamScheduleSignalSentry {
123 StreamScheduleSignalSentry(
ActivityRegistry*
a,
typename T::Context
const* context) :
124 a_(a), context_(context), allowThrow_(
false) {
125 if (a_) T::preScheduleSignal(a_, context_);
129 if (a_) { T::postScheduleSignal(a_, context_); }
131 if(allowThrow_) {
throw;}
142 typename T::Context
const* context_;
163 std::vector<
edm::propagate_const<std::shared_ptr<EndPathStatusInserter>>>& endPathStatusInserters,
164 std::shared_ptr<ModuleRegistry>,
171 std::shared_ptr<ActivityRegistry> areg,
172 std::shared_ptr<ProcessConfiguration> processConfiguration,
173 bool allowEarlyDelete,
184 template <
typename T>
185 void processOneStream(
typename T::MyPrincipal&
principal,
187 bool cleaningUpAfterException =
false);
189 template <
typename T>
193 bool cleaningUpAfterException =
false);
206 std::vector<ModuleDescription const*> getAllModuleDescriptions()
const;
209 void availablePaths(std::vector<std::string>& oLabelsToFill)
const;
213 std::vector<std::string>& oLabelsToFill)
const;
215 void moduleDescriptionsInPath(
std::string const& iPathLabel,
216 std::vector<ModuleDescription const*>& descriptions,
217 unsigned int hint)
const;
219 void moduleDescriptionsInEndPath(
std::string const& iEndPathLabel,
220 std::vector<ModuleDescription const*>& descriptions,
221 unsigned int hint)
const;
227 return total_events_;
233 return total_passed_;
239 return totalEvents() - totalEventsPassed();
244 void enableEndPaths(
bool active);
248 bool endPathsEnabled()
const;
255 void clearCounters();
262 return workerManager_.allWorkers();
266 return number_of_unscheduled_modules_;
295 return workerManager_.actionTable();
303 std::exception_ptr finishProcessOneEvent(std::exception_ptr);
305 template <
typename T>
306 bool runTriggerPaths(
typename T::MyPrincipal
const&,
EventSetup const&,
typename T::Context
const*);
308 template <
typename T>
309 void runEndPaths(
typename T::MyPrincipal
const&,
EventSetup const&,
typename T::Context
const*);
316 std::shared_ptr<ProcessConfiguration const> processConfiguration,
318 std::vector<std::string>
const& endPathNames);
322 std::shared_ptr<ProcessConfiguration const> processConfiguration,
324 std::vector<std::string>
const& endPathNames);
328 std::shared_ptr<ProcessConfiguration const> processConfiguration,
330 std::vector<std::string>
const& endPathNames);
332 void addToAllWorkers(
Worker*
w);
334 void resetEarlyDelete();
338 bool allowEarlyDelete);
343 void makePathStatusInserters(
345 std::vector<
edm::propagate_const<std::shared_ptr<EndPathStatusInserter>>>& endPathStatusInserters,
391 reportSvc->reportSkippedEvent(ep.
id().
run(), ep.
id().
event());
394 template <
typename T>
397 bool cleaningUpAfterException) {
400 T::setStreamContext(streamContext_, ep);
401 StreamScheduleSignalSentry<T> sentry(actReg_.get(), &streamContext_);
406 workerManager_.processOneOccurrence<
T>(ep, es, streamID_, &streamContext_, &streamContext_, cleaningUpAfterException);
410 runTriggerPaths<T>(ep, es, &streamContext_);
412 if (endpathsAreActive_) runEndPaths<T>(ep, es, &streamContext_);
423 terminationSentry.completedSuccessfully();
429 template <
typename T>
431 typename T::MyPrincipal& ep,
433 bool cleaningUpAfterException) {
436 T::setStreamContext(streamContext_, ep);
440 [
this,iHolder,
id,cleaningUpAfterException,token](std::exception_ptr
const* iPtr)
mutable 443 std::exception_ptr excpt;
449 std::rethrow_exception(excpt);
453 std::ostringstream ost;
455 ost<<
"Processing "<<T::transitionName()<<
" "<<
id;
458 excpt = std::current_exception();
465 T::postScheduleSignal(actReg_.get(), &streamContext_);
468 excpt = std::current_exception();
475 auto task =
make_functor_task(tbb::task::allocate_root(), [
this,doneTask,&ep,&es,cleaningUpAfterException,token] ()
mutable {
477 T::preScheduleSignal(actReg_.get(), &streamContext_);
480 workerManager_.resetAll();
481 for(
auto&
p : end_paths_) {
482 p.runAllModulesAsync<
T>(doneTask, ep, es, streamID_, &streamContext_);
485 for(
auto&
p : trig_paths_) {
486 p.runAllModulesAsync<
T>(doneTask, ep, es, streamID_, &streamContext_);
489 workerManager_.processOneOccurrenceAsync<
T>(doneTask,
490 ep, es, streamID_, &streamContext_, &streamContext_);
493 if(streamID_.value() == 0) {
497 tbb::task::spawn( *task);
499 tbb::task::enqueue( *task);
504 template <
typename T>
507 for(
auto&
p : trig_paths_) {
508 p.processOneOccurrence<
T>(ep, es, streamID_, context);
510 return results_->accept();
513 template <
typename T>
518 for(
auto&
p : end_paths_) {
519 p.processOneOccurrence<
T>(ep, es, streamID_, context);
EventNumber_t event() const
StreamContext const * context_
AllWorkers const & allWorkers() const
returns the collection of pointers to workers
std::shared_ptr< HLTGlobalStatus const > TrigResConstPtr
std::vector< Worker * > Workers
std::vector< int > empty_trig_paths_
roAction_t actions[nactions]
std::vector< edm::propagate_const< WorkerPtr > > pathStatusInserterWorkers_
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
int totalEventsFailed() const
unsigned int numberOfUnscheduledModules() const
std::vector< Path > NonTrigPaths
std::shared_ptr< HLTGlobalStatus > TrigResPtr
FunctorTask< F > * make_functor_task(ALLOC &&iAlloc, F f)
volatile bool endpathsAreActive_
std::vector< BranchToCount > earlyDeleteBranchToCount_
EventID const & id() const
void addContextAndPrintException(char const *context, cms::Exception &ex, bool disablePrint)
void reportSkipped(EventPrincipal const &ep) const
edm::propagate_const< WorkerPtr > results_inserter_
ExceptionToActionTable const & actionTable() const
returns the action table
std::shared_ptr< Worker > WorkerPtr
ServiceToken presentToken() const
void runEndPaths(typename T::MyPrincipal const &, EventSetup const &, typename T::Context const *)
unsigned int number_of_unscheduled_modules_
WorkerManager workerManager_
std::shared_ptr< ActivityRegistry > actReg_
std::vector< WorkerInPath > PathWorkers
int totalEventsPassed() const
std::vector< int > empty_end_paths_
void doneWaiting(std::exception_ptr iExcept)
StreamID streamID() const
SendTerminationSignalIfException(edm::ActivityRegistry *iReg, edm::StreamContext const *iContext)
StreamContext streamContext_
std::vector< std::string > vstring
std::list< std::string > const & context() const
static ServiceRegistry & instance()
std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
std::vector< Worker * > AllWorkers
std::vector< unsigned int > earlyDeleteHelperToBranchIndicies_
edm::propagate_const< TrigResPtr > results_
FunctorWaitingTask< F > * make_waiting_task(ALLOC &&iAlloc, F f)
void processOneStreamAsync(WaitingTaskHolder iTask, typename T::MyPrincipal &principal, EventSetup const &eventSetup, bool cleaningUpAfterException=false)
~SendTerminationSignalIfException()
std::atomic< bool > skippingEvent_
StreamContext const & context() const
std::vector< edm::propagate_const< WorkerPtr > > endPathStatusInserterWorkers_
auto wrap(F iFunc) -> decltype(iFunc())
bool runTriggerPaths(typename T::MyPrincipal const &, EventSetup const &, typename T::Context const *)
edm::ActivityRegistry * reg_
TrigResConstPtr results() const
std::vector< Path > TrigPaths
void processOneStream(typename T::MyPrincipal &principal, EventSetup const &eventSetup, bool cleaningUpAfterException=false)
std::vector< EarlyDeleteHelper > earlyDeleteHelpers_
void completedSuccessfully()