25 #include "boost/graph/graph_traits.hpp"
26 #include "boost/graph/adjacency_list.hpp"
27 #include "boost/graph/depth_first_search.hpp"
28 #include "boost/graph/visitors.hpp"
43 using std::placeholders::_1;
45 bool binary_search_string(std::vector<std::string>
const&
v,
std::string const&
s) {
46 return std::binary_search(v.begin(), v.end(),
s);
52 std::shared_ptr<TriggerResultInserter>
54 PreallocationConfiguration
const& iPrealloc,
55 ProductRegistry&
preg,
56 ExceptionToActionTable
const&
actions,
57 std::shared_ptr<ActivityRegistry>
areg,
60 ParameterSet* trig_pset = proc_pset.getPSetForUpdate(
"@trigger_paths");
61 trig_pset->registerIt();
63 WorkerParams work_args(trig_pset, preg, &iPrealloc, processConfiguration, actions);
64 ModuleDescription
md(trig_pset->id(),
65 "TriggerResultInserter",
67 processConfiguration.get(),
70 areg->preModuleConstructionSignal_(
md);
71 bool postCalled =
false;
72 std::shared_ptr<TriggerResultInserter> returnValue;
74 maker::ModuleHolderT<TriggerResultInserter> holder(std::make_shared<TriggerResultInserter>(*trig_pset, iPrealloc.numberOfStreams()),static_cast<Maker const*>(
nullptr));
75 holder.setModuleDescription(
md);
76 holder.registerProductsAndCallbacks(&preg);
77 returnValue =holder.module();
80 areg->postModuleConstructionSignal_(
md);
85 areg->postModuleConstructionSignal_(
md);
98 checkAndInsertAlias(
std::string const& friendlyClassName,
104 ProductRegistry
const& preg,
105 std::multimap<BranchKey, BranchKey>& aliasMap,
106 std::map<BranchKey, BranchKey>& aliasKeys) {
109 BranchKey
key(friendlyClassName, moduleLabel, productInstanceName, processName);
110 if(preg.productList().find(
key) == preg.productList().end()) {
113 for(
auto const& product : preg.productList()) {
114 if(moduleLabel == product.first.moduleLabel() && processName == product.first.processName()) {
116 <<
"There are no products of type '" << friendlyClassName <<
"'\n"
117 <<
"with module label '" << moduleLabel <<
"' and instance name '" << productInstanceName <<
"'.\n";
122 std::string const& theInstanceAlias(instanceAlias == star ? productInstanceName : instanceAlias);
123 BranchKey aliasKey(friendlyClassName, alias, theInstanceAlias, processName);
124 if(preg.productList().find(aliasKey) != preg.productList().end()) {
126 <<
"A product of type '" << friendlyClassName <<
"'\n"
127 <<
"with module label '" << alias <<
"' and instance name '" << theInstanceAlias <<
"'\n"
128 <<
"already exists.\n";
130 auto iter = aliasKeys.find(aliasKey);
131 if(iter != aliasKeys.end()) {
133 if(iter->second !=
key) {
135 <<
"The module label alias '" << alias <<
"' and product instance alias '" << theInstanceAlias <<
"'\n"
136 <<
"are used for multiple products of type '" << friendlyClassName <<
"'\n"
137 <<
"One has module label '" << moduleLabel <<
"' and product instance name '" << productInstanceName <<
"',\n"
138 <<
"the other has module label '" << iter->second.moduleLabel() <<
"' and product instance name '" << iter->second.productInstanceName() <<
"'.\n";
141 auto prodIter = preg.productList().find(
key);
142 if(prodIter != preg.productList().end()) {
143 if (!prodIter->second.produced()) {
145 <<
"The module label alias '" << alias <<
"' and product instance alias '" << theInstanceAlias <<
"'\n"
146 <<
"are used for a product of type '" << friendlyClassName <<
"'\n"
147 <<
"with module label '" << moduleLabel <<
"' and product instance name '" << productInstanceName <<
"',\n"
148 <<
"An EDAlias can only be used for products produced in the current process. This one is not.\n";
150 aliasMap.insert(std::make_pair(
key, aliasKey));
151 aliasKeys.insert(std::make_pair(aliasKey,
key));
158 std::vector<std::string>
aliases = proc_pset.getParameter<std::vector<std::string> >(
"@all_aliases");
159 if(aliases.empty()) {
166 desc.add<
std::string>(
"fromProductInstance", star);
169 std::multimap<BranchKey, BranchKey> aliasMap;
171 std::map<BranchKey, BranchKey> aliasKeys;
175 ParameterSet const& aliasPSet = proc_pset.getParameterSet(alias);
176 std::vector<std::string> vPSetNames = aliasPSet.getParameterNamesForType<
VParameterSet>();
184 if(productInstanceName == star) {
186 BranchKey lowerBound(friendlyClassName, moduleLabel,
empty,
empty);
187 for(ProductRegistry::ProductList::const_iterator it = preg.productList().lower_bound(lowerBound);
188 it != preg.productList().end() && it->first.friendlyClassName() == friendlyClassName && it->first.moduleLabel() == moduleLabel;
195 checkAndInsertAlias(friendlyClassName, moduleLabel, it->first.productInstanceName(),
processName,
alias, instanceAlias,
preg, aliasMap, aliasKeys);
200 for(
auto const& product : preg.productList()) {
201 if(moduleLabel == product.first.moduleLabel() && processName == product.first.processName()) {
203 <<
"There are no products of type '" << friendlyClassName <<
"'\n"
204 <<
"with module label '" << moduleLabel <<
"'.\n";
209 checkAndInsertAlias(friendlyClassName, moduleLabel, productInstanceName, processName, alias, instanceAlias, preg, aliasMap, aliasKeys);
217 for(
auto const& aliasEntry : aliasMap) {
218 ProductRegistry::ProductList::const_iterator it = preg.productList().find(aliasEntry.first);
219 assert(it != preg.productList().end());
220 preg.addLabelAlias(it->second, aliasEntry.second.moduleLabel(), aliasEntry.second.productInstanceName());
225 typedef std::vector<std::string>
vstring;
228 vstring
const& end_path_name_list,
229 vstring& modulesInConfig,
230 std::set<std::string>
const& usedModuleLabels,
231 std::map<
std::string, std::vector<std::pair<std::string, int> > >& outputModulePathPositions) {
243 vstring outputModuleLabels;
245 std::string const moduleEdmType(
"@module_edm_type");
251 std::set<std::string> modulesInConfigSet(modulesInConfig.begin(), modulesInConfig.end());
255 vstring scheduledPaths = proc_pset.getParameter<vstring>(
"@paths");
256 std::set<std::string> modulesOnPaths;
258 std::set<std::string> noEndPaths(scheduledPaths.begin(),scheduledPaths.end());
259 for(
auto const&
endPath: end_path_name_list) {
264 for(
auto const&
path: noEndPaths) {
265 labels = proc_pset.getParameter<vstring>(
path);
266 modulesOnPaths.insert(labels.begin(),labels.end());
272 std::vector<std::string> labelsToBeDropped;
273 labelsToBeDropped.reserve(modulesInConfigSet.size());
274 std::set_difference(modulesInConfigSet.begin(),modulesInConfigSet.end(),
275 usedModuleLabels.begin(),usedModuleLabels.end(),
276 std::back_inserter(labelsToBeDropped));
278 const unsigned int sizeBeforeOutputModules = labelsToBeDropped.size();
279 for (
auto const& modLabel: usedModuleLabels) {
280 edmType = proc_pset.getParameterSet(modLabel).getParameter<
std::string>(moduleEdmType);
281 if (edmType == outputModule) {
282 outputModuleLabels.push_back(modLabel);
283 labelsToBeDropped.push_back(modLabel);
285 if(edmType == edAnalyzer) {
286 if(modulesOnPaths.end()==modulesOnPaths.find(modLabel)) {
287 labelsToBeDropped.push_back(modLabel);
292 std::inplace_merge(labelsToBeDropped.begin(),
293 labelsToBeDropped.begin()+sizeBeforeOutputModules,
294 labelsToBeDropped.end());
300 vstring::iterator endAfterRemove = std::remove_if(modulesInConfig.begin(), modulesInConfig.end(), std::bind(binary_search_string, std::ref(labelsToBeDropped), _1));
301 modulesInConfig.erase(endAfterRemove, modulesInConfig.end());
302 proc_pset.addParameter<vstring>(
std::string(
"@all_modules"), modulesInConfig);
305 vstring endPathsToBeDropped;
307 for (vstring::const_iterator iEndPath = end_path_name_list.begin(), endEndPath = end_path_name_list.end();
308 iEndPath != endEndPath;
310 labels = proc_pset.getParameter<vstring>(*iEndPath);
311 vstring::iterator iSave = labels.begin();
312 vstring::iterator iBegin = labels.begin();
314 for (vstring::iterator iLabel = labels.begin(), iEnd = labels.end();
315 iLabel != iEnd; ++iLabel) {
316 if (binary_search_string(labelsToBeDropped, *iLabel)) {
317 if (binary_search_string(outputModuleLabels, *iLabel)) {
318 outputModulePathPositions[*iLabel].emplace_back(*iEndPath, iSave - iBegin);
321 if (iSave != iLabel) {
322 iSave->swap(*iLabel);
327 labels.erase(iSave, labels.end());
328 if (labels.empty()) {
330 proc_pset.eraseSimpleParameter(*iEndPath);
331 endPathsToBeDropped.push_back(*iEndPath);
333 proc_pset.addParameter<vstring>(*iEndPath,
labels);
339 endAfterRemove = std::remove_if(scheduledPaths.begin(), scheduledPaths.end(), std::bind(binary_search_string, std::ref(endPathsToBeDropped), _1));
340 scheduledPaths.erase(endAfterRemove, scheduledPaths.end());
341 proc_pset.addParameter<vstring>(
std::string(
"@paths"), scheduledPaths);
344 vstring scheduledEndPaths = proc_pset.getParameter<vstring>(
"@end_paths");
345 endAfterRemove = std::remove_if(scheduledEndPaths.begin(), scheduledEndPaths.end(), std::bind(binary_search_string, std::ref(endPathsToBeDropped), _1));
346 scheduledEndPaths.erase(endAfterRemove, scheduledEndPaths.end());
347 proc_pset.addParameter<vstring>(
std::string(
"@end_paths"), scheduledEndPaths);
363 std::shared_ptr<ActivityRegistry> areg,
364 std::shared_ptr<ProcessConfiguration> processConfiguration,
369 resultsInserter_{tns.
getTrigPaths().empty()? std::shared_ptr<TriggerResultInserter>{} :makeInserter(proc_pset,prealloc,preg,actions,areg,processConfiguration)},
377 streamSchedules_.reserve(
prealloc.numberOfStreams());
378 for(
unsigned int i=0;
i<
prealloc.numberOfStreams();++
i) {
379 streamSchedules_.emplace_back(std::make_shared<StreamSchedule>(resultsInserter_,
moduleRegistry_,proc_pset,tns,
prealloc,preg,branchIDListHelper,actions,areg,processConfiguration,
nullptr==subProcPSet,
StreamID{
i},processContext));
384 const std::string kTriggerResults(
"TriggerResults");
385 std::vector<std::string> modulesToUse;
386 modulesToUse.reserve(streamSchedules_[0]->allWorkers().
size());
387 for(
auto const& worker : streamSchedules_[0]->allWorkers()) {
388 if(worker->description().moduleLabel() != kTriggerResults) {
389 modulesToUse.push_back(worker->description().moduleLabel());
393 unsigned int n = streamSchedules_[0]->numberOfUnscheduledModules();
395 std::vector<std::string>
temp;
396 temp.reserve(modulesToUse.size());
397 auto itBeginUnscheduled = modulesToUse.begin()+modulesToUse.size()-
n;
398 std::copy(itBeginUnscheduled,modulesToUse.end(),
399 std::back_inserter(temp));
400 std::copy(modulesToUse.begin(),itBeginUnscheduled,std::back_inserter(temp));
401 temp.swap(modulesToUse);
411 std::set<std::string> usedModuleLabels;
412 for(
auto const worker: allWorkers()) {
413 if(worker->description().moduleLabel() != kTriggerResults) {
414 usedModuleLabels.insert(worker->description().moduleLabel());
417 std::vector<std::string> modulesInConfig(proc_pset.getParameter<std::vector<std::string> >(
"@all_modules"));
418 std::map<std::string, std::vector<std::pair<std::string, int> > > outputModulePathPositions;
419 reduceParameterSet(proc_pset, tns.getEndPaths(), modulesInConfig, usedModuleLabels,
420 outputModulePathPositions);
421 processEDAliases(proc_pset, processConfiguration->processName(),
preg);
422 proc_pset.registerIt();
423 processConfiguration->setParameterSetID(proc_pset.id());
424 processConfiguration->setProcessConfigurationID();
428 size_t all_workers_count = allWorkers().size();
437 limitOutput(proc_pset, branchIDListHelper.branchIDLists());
443 assert (all_workers_count == allWorkers().
size());
445 branchIDListHelper.updateFromRegistry(preg);
449 for(
auto const& worker : streamSchedules_[0]->allWorkers()) {
450 worker->registerThinnedAssociations(preg, thinnedAssociationsHelper);
452 thinnedAssociationsHelper.sort();
455 c->setEventSelectionInfo(outputModulePathPositions, preg.anyProductProduced());
456 c->selectProducts(preg, thinnedAssociationsHelper);
460 std::vector<const ModuleDescription*> modDesc;
461 const auto& workers = allWorkers();
462 modDesc.reserve(workers.size());
465 std::back_inserter(modDesc),
467 return iWorker->descPtr();
473 auto timeKeeperPtr = summaryTimeKeeper_.get();
501 int maxEventSpecs = 0;
502 int maxEventsOut = -1;
509 std::vector<std::string> psetNamesE;
516 if (maxEventSpecs > 1) {
518 "\nAt most, one form of 'output' may appear in the 'maxEvents' parameter set";
523 if (vMaxEventsOut != 0 && !vMaxEventsOut->
empty()) {
524 std::string const& moduleLabel =
c->description().moduleLabel();
529 "\nNo entry in 'maxEvents' for output module label '" << moduleLabel <<
"'.\n";
541 if (!
c->limitReached()) {
546 LogInfo(
"SuccessfulTermination")
547 <<
"The job is terminating successfully because each output module\n"
548 <<
"has reached its configured limit.\n";
566 LogVerbatim(
"FwkSummary") <<
"TrigReport " <<
"---------- Event Summary ------------";
581 LogVerbatim(
"FwkSummary") <<
"TrigReport " <<
"---------- Path Summary ------------";
583 << std::right << std::setw(10) <<
"Trig Bit#" <<
" "
584 << std::right << std::setw(10) <<
"Executed" <<
" "
585 << std::right << std::setw(10) <<
"Passed" <<
" "
586 << std::right << std::setw(10) <<
"Failed" <<
" "
587 << std::right << std::setw(10) <<
"Error" <<
" "
591 << std::right << std::setw(5) << 1
592 << std::right << std::setw(5) <<
p.bitPosition <<
" "
593 << std::right << std::setw(10) <<
p.timesRun <<
" "
594 << std::right << std::setw(10) <<
p.timesPassed <<
" "
595 << std::right << std::setw(10) <<
p.timesFailed <<
" "
596 << std::right << std::setw(10) <<
p.timesExcept <<
" "
618 LogVerbatim(
"FwkSummary") <<
"TrigReport " <<
"-------End-Path Summary ------------";
620 << std::right << std::setw(10) <<
"Trig Bit#" <<
" "
621 << std::right << std::setw(10) <<
"Executed" <<
" "
622 << std::right << std::setw(10) <<
"Passed" <<
" "
623 << std::right << std::setw(10) <<
"Failed" <<
" "
624 << std::right << std::setw(10) <<
"Error" <<
" "
628 << std::right << std::setw(5) << 0
629 << std::right << std::setw(5) <<
p.bitPosition <<
" "
630 << std::right << std::setw(10) <<
p.timesRun <<
" "
631 << std::right << std::setw(10) <<
p.timesPassed <<
" "
632 << std::right << std::setw(10) <<
p.timesFailed <<
" "
633 << std::right << std::setw(10) <<
p.timesExcept <<
" "
639 LogVerbatim(
"FwkSummary") <<
"TrigReport " <<
"---------- Modules in Path: " <<
p.name <<
" ------------";
641 << std::right << std::setw(10) <<
"Trig Bit#" <<
" "
642 << std::right << std::setw(10) <<
"Visited" <<
" "
643 << std::right << std::setw(10) <<
"Passed" <<
" "
644 << std::right << std::setw(10) <<
"Failed" <<
" "
645 << std::right << std::setw(10) <<
"Error" <<
" "
648 unsigned int bitpos = 0;
649 for (
auto const&
mod:
p.moduleInPathSummaries) {
651 << std::right << std::setw(5) << 1
652 << std::right << std::setw(5) << bitpos <<
" "
653 << std::right << std::setw(10) <<
mod.timesVisited <<
" "
654 << std::right << std::setw(10) <<
mod.timesPassed <<
" "
655 << std::right << std::setw(10) <<
mod.timesFailed <<
" "
656 << std::right << std::setw(10) <<
mod.timesExcept <<
" "
657 <<
mod.moduleLabel <<
"";
664 LogVerbatim(
"FwkSummary") <<
"TrigReport " <<
"------ Modules in End-Path: " <<
p.name <<
" ------------";
666 << std::right << std::setw(10) <<
"Trig Bit#" <<
" "
667 << std::right << std::setw(10) <<
"Visited" <<
" "
668 << std::right << std::setw(10) <<
"Passed" <<
" "
669 << std::right << std::setw(10) <<
"Failed" <<
" "
670 << std::right << std::setw(10) <<
"Error" <<
" "
673 unsigned int bitpos=0;
674 for (
auto const&
mod:
p.moduleInPathSummaries) {
676 << std::right << std::setw(5) << 0
677 << std::right << std::setw(5) << bitpos <<
" "
678 << std::right << std::setw(10) <<
mod.timesVisited <<
" "
679 << std::right << std::setw(10) <<
mod.timesPassed <<
" "
680 << std::right << std::setw(10) <<
mod.timesFailed <<
" "
681 << std::right << std::setw(10) <<
mod.timesExcept <<
" "
682 <<
mod.moduleLabel <<
"";
688 LogVerbatim(
"FwkSummary") <<
"TrigReport " <<
"---------- Module Summary ------------";
690 << std::right << std::setw(10) <<
"Visited" <<
" "
691 << std::right << std::setw(10) <<
"Executed" <<
" "
692 << std::right << std::setw(10) <<
"Passed" <<
" "
693 << std::right << std::setw(10) <<
"Failed" <<
" "
694 << std::right << std::setw(10) <<
"Error" <<
" "
698 << std::right << std::setw(10) << worker.timesVisited <<
" "
699 << std::right << std::setw(10) << worker.timesRun <<
" "
700 << std::right << std::setw(10) << worker.timesPassed <<
" "
701 << std::right << std::setw(10) << worker.timesFailed <<
" "
702 << std::right << std::setw(10) << worker.timesExcept <<
" "
703 << worker.moduleLabel <<
"";
713 LogVerbatim(
"FwkSummary") <<
"TimeReport " <<
"---------- Event Summary ---[sec]----";
715 << std::setprecision(6) << std::fixed
718 << std::setprecision(6) << std::fixed
721 << std::setprecision(6) << std::fixed
724 << std::setprecision(6) << std::fixed
731 LogVerbatim(
"FwkSummary") <<
"TimeReport " <<
"---------- Path Summary ---[Real sec]----";
733 << std::right << std::setw(kColumn1Size) <<
"per event"<<
" "
734 << std::right << std::setw(kColumn2Size) <<
"per exec"
737 const int timesRun =
std::max(1,
p.timesRun);
739 << std::setprecision(6) << std::fixed
740 << std::right << std::setw(kColumn1Size) <<
p.realTime/totalEvents <<
" "
741 << std::right << std::setw(kColumn2Size) <<
p.realTime/timesRun <<
" "
745 << std::right << std::setw(kColumn1Size) <<
"per event"<<
" "
746 << std::right << std::setw(kColumn2Size) <<
"per exec"
750 LogVerbatim(
"FwkSummary") <<
"TimeReport " <<
"-------End-Path Summary ---[Real sec]----";
752 << std::right << std::setw(kColumn1Size) <<
"per event" <<
" "
753 << std::right << std::setw(kColumn2Size) <<
"per exec"
756 const int timesRun =
std::max(1,
p.timesRun);
759 << std::setprecision(6) << std::fixed
760 << std::right << std::setw(kColumn1Size) <<
p.realTime/totalEvents <<
" "
761 << std::right << std::setw(kColumn2Size) <<
p.realTime/timesRun <<
" "
765 << std::right << std::setw(kColumn1Size) <<
"per event" <<
" "
766 << std::right << std::setw(kColumn2Size) <<
"per exec"
771 LogVerbatim(
"FwkSummary") <<
"TimeReport " <<
"---------- Modules in Path: " <<
p.name <<
" ---[Real sec]----";
773 << std::right << std::setw(kColumn1Size) <<
"per event" <<
" "
774 << std::right << std::setw(kColumn2Size) <<
"per visit"
776 for (
auto const&
mod:
p.moduleInPathSummaries) {
778 << std::setprecision(6) << std::fixed
779 << std::right << std::setw(kColumn1Size) <<
mod.realTime/totalEvents <<
" "
780 << std::right << std::setw(kColumn2Size) <<
mod.realTime/
std::max(1,
mod.timesVisited) <<
" "
781 <<
mod.moduleLabel <<
"";
786 << std::right << std::setw(kColumn1Size) <<
"per event" <<
" "
787 << std::right << std::setw(kColumn2Size) <<
"per visit"
792 LogVerbatim(
"FwkSummary") <<
"TimeReport " <<
"------ Modules in End-Path: " <<
p.name <<
" ---[Real sec]----";
794 << std::right << std::setw(kColumn1Size) <<
"per event" <<
" "
795 << std::right << std::setw(kColumn2Size) <<
"per visit"
797 for (
auto const&
mod:
p.moduleInPathSummaries) {
799 << std::setprecision(6) << std::fixed
800 << std::right << std::setw(kColumn1Size) <<
mod.realTime/totalEvents <<
" "
801 << std::right << std::setw(kColumn2Size) <<
mod.realTime/
std::max(1,
mod.timesVisited) <<
" "
802 <<
mod.moduleLabel <<
"";
807 << std::right << std::setw(kColumn1Size) <<
"per event" <<
" "
808 << std::right << std::setw(kColumn2Size) <<
"per visit"
812 LogVerbatim(
"FwkSummary") <<
"TimeReport " <<
"---------- Module Summary ---[Real sec]----";
814 << std::right << std::setw(kColumn1Size) <<
"per event" <<
" "
815 << std::right << std::setw(kColumn2Size) <<
"per exec" <<
" "
816 << std::right << std::setw(kColumn3Size) <<
"per visit"
820 << std::setprecision(6) << std::fixed
821 << std::right << std::setw(kColumn1Size) << worker.realTime/totalEvents <<
" "
822 << std::right << std::setw(kColumn2Size) << worker.realTime/
std::max(1, worker.timesRun) <<
" "
823 << std::right << std::setw(kColumn3Size) << worker.realTime/
std::max(1, worker.timesVisited) <<
" "
824 << worker.moduleLabel <<
"";
827 << std::right << std::setw(kColumn1Size) <<
"per event" <<
" "
828 << std::right << std::setw(kColumn2Size) <<
"per exec" <<
" "
829 << std::right << std::setw(kColumn3Size) <<
"per visit"
833 LogVerbatim(
"FwkSummary") <<
"T---Report end!" <<
"";
838 using std::placeholders::_1;
843 using std::placeholders::_1;
848 using std::placeholders::_1;
853 using std::placeholders::_1;
858 using std::placeholders::_1;
863 using std::placeholders::_1;
871 using std::placeholders::_1;
876 using std::placeholders::_1;
897 using std::placeholders::_1;
901 using std::placeholders::_1;
910 if (worker->description().moduleLabel() == iLabel) {
915 if (
nullptr == found) {
924 s->replaceModule(newMod,iLabel);
940 std::vector<ModuleDescription const*>
942 std::vector<ModuleDescription const*>
result;
974 std::vector<std::string>& oLabelsToFill)
const {
980 std::vector<ModuleDescription const*>& descriptions,
981 unsigned int hint)
const {
982 streamSchedules_[0]->moduleDescriptionsInPath(iPathLabel, descriptions, hint);
987 std::vector<ModuleDescription const*>& descriptions,
988 unsigned int hint)
const {
989 streamSchedules_[0]->moduleDescriptionsInEndPath(iEndPathLabel, descriptions, hint);
994 std::vector<std::pair<unsigned int, unsigned int> >& moduleIDToIndex,
995 std::vector<std::vector<ModuleDescription const*> >& modulesWhoseProductsAreConsumedBy,
997 allModuleDescriptions.clear();
998 moduleIDToIndex.clear();
999 modulesWhoseProductsAreConsumedBy.clear();
1005 std::map<std::string, ModuleDescription const*> labelToDesc;
1009 allModuleDescriptions.push_back(p);
1010 moduleIDToIndex.push_back(std::pair<unsigned int, unsigned int>(p->
id(),
i));
1018 std::vector<ModuleDescription const*>&
modules = modulesWhoseProductsAreConsumedBy.at(i);
1019 worker->modulesWhoseProductsAreConsumed(modules, preg, labelToDesc);
1028 s->enableEndPaths(active);
1043 s->getTriggerReport(rep);
1057 int returnValue = 0;
1059 returnValue += s->totalEvents();
1066 int returnValue = 0;
1068 returnValue += s->totalEventsPassed();
1075 int returnValue = 0;
1077 returnValue += s->totalEventsFailed();
1132 typedef std::pair<unsigned int, unsigned int> SimpleEdge;
1133 typedef std::map<SimpleEdge, std::vector<unsigned int>> EdgeToPathMap;
1135 typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS> Graph;
1137 typedef boost::graph_traits<Graph>::edge_descriptor Edge;
1138 struct cycle_detector :
public boost::dfs_visitor<> {
1140 cycle_detector(EdgeToPathMap
const& iEdgeToPathMap,
1141 std::vector<std::string>
const& iPathNames,
1142 std::map<std::string,unsigned int>
const& iModuleNamesToIndex):
1143 m_edgeToPathMap(iEdgeToPathMap),
1144 m_pathNames(iPathNames),
1145 m_namesToIndex(iModuleNamesToIndex){}
1147 void tree_edge(Edge iEdge, Graph
const&) {
1148 m_stack.push_back(iEdge);
1151 void finish_edge(Edge iEdge, Graph
const& iGraph) {
1152 if(not m_stack.empty()) {
1153 if (iEdge == m_stack.back()) {
1160 void back_edge(Edge iEdge, Graph
const& iGraph) {
1165 IndexMap
const&
index =
get(boost::vertex_index, iGraph);
1167 unsigned int vertex = index[
target(iEdge,iGraph)];
1170 std::list<Edge>::iterator itFirst = m_stack.begin();
1172 bool seenVertex =
false;
1173 while(itFirst != m_stack.end()) {
1174 if(not seenVertex) {
1175 if(index[
source(*itFirst,iGraph)] == vertex) {
1179 if (index[
source(*itFirst,iGraph)] != vertex) {
1184 if(itFirst != m_stack.begin()) {
1191 std::vector<Edge> tempStack;
1192 tempStack.reserve(m_stack.size()+1);
1193 tempStack.insert(tempStack.end(),itFirst,m_stack.end());
1194 tempStack.emplace_back(iEdge);
1196 unsigned int nPathDependencyOnly =0;
1197 for(
auto const&
edge: tempStack) {
1201 auto iFound = m_edgeToPathMap.find(SimpleEdge(in,out));
1202 bool pathDependencyOnly =
true;
1203 for(
auto dependency : iFound->second) {
1205 pathDependencyOnly =
false;
1209 if (pathDependencyOnly) {
1210 ++nPathDependencyOnly;
1213 if(nPathDependencyOnly < 2) {
1214 reportError(tempStack,index,iGraph);
1219 return m_pathNames[iIndex];
1223 for(
auto const& item : m_namesToIndex) {
1224 if(item.second == iIndex) {
1232 reportError(std::vector<Edge>
const& iEdges,
1234 Graph
const& iGraph)
const {
1235 std::stringstream oStream;
1236 oStream <<
"Module run order problem found: \n";
1237 bool first_edge =
true;
1238 for(
auto const&
edge: iEdges) {
1239 unsigned int in =iIndex[
source(
edge,iGraph)];
1240 unsigned int out =iIndex[
target(
edge,iGraph)];
1249 auto iFound = m_edgeToPathMap.find(SimpleEdge(in,out));
1250 bool pathDependencyOnly =
true;
1251 for(
auto dependency : iFound->second) {
1253 pathDependencyOnly =
false;
1257 if (pathDependencyOnly) {
1263 oStream<<
"\n Running in the threaded framework would lead to indeterminate results."
1264 "\n Please change order of modules in mentioned Path(s) to avoid inconsistent module ordering.";
1266 LogError(
"UnrunnableSchedule")<<oStream.str();
1269 EdgeToPathMap
const& m_edgeToPathMap;
1270 std::vector<std::string>
const& m_pathNames;
1271 std::map<std::string,unsigned int> m_namesToIndex;
1273 std::list<Edge> m_stack;
1281 std::map<std::string,unsigned int> moduleNamesToIndex;
1283 moduleNamesToIndex.insert( std::make_pair(worker->description().moduleLabel(),
1284 worker->description().id()));
1288 EdgeToPathMap edgeToPathMap;
1291 std::vector<std::string> pathNames;
1295 std::vector<std::string> moduleNames;
1296 std::vector<std::string> reducedModuleNames;
1297 unsigned int pathIndex=0;
1298 for(
auto const&
path: pathNames) {
1299 moduleNames.clear();
1300 reducedModuleNames.clear();
1301 std::set<std::string> alreadySeenNames;
1305 unsigned int lastModuleIndex;
1306 for(
auto const&
name: moduleNames) {
1307 auto found = alreadySeenNames.insert(
name);
1310 unsigned int moduleIndex = moduleNamesToIndex[
name];
1311 if(not lastModuleName.empty() ) {
1312 edgeToPathMap[std::make_pair(moduleIndex,lastModuleIndex)].push_back(pathIndex);
1314 lastModuleName =
name;
1315 lastModuleIndex = moduleIndex;
1322 std::vector<const char*> dependentModules;
1325 dependentModules.clear();
1327 worker->modulesDependentUpon(dependentModules);
1328 auto found = moduleNamesToIndex.find(worker->description().moduleLabel());
1329 if (
found == moduleNamesToIndex.end()) {
1333 unsigned int moduleIndex =
found->second;
1334 for(
auto name: dependentModules) {
1340 std::vector<SimpleEdge> outList;
1341 outList.reserve(edgeToPathMap.size());
1342 for(
auto const& edgeInfo: edgeToPathMap) {
1343 outList.push_back(edgeInfo.first);
1346 Graph
g(outList.begin(),outList.end(), moduleNamesToIndex.size());
1348 cycle_detector detector(edgeToPathMap,pathNames,moduleNamesToIndex);
1349 boost::depth_first_search(
g,boost::visitor(detector));
std::vector< PathSummary > endPathSummaries
T getUntrackedParameter(std::string const &, T const &) const
std::vector< PathTimingSummary > endPathSummaries
void checkForCorrectness() const
Check that the schedule is actually runable.
void stopEvent(StreamContext const &)
void startProcessingLoop()
std::vector< BranchIDList > BranchIDLists
void fillModuleAndConsumesInfo(std::vector< ModuleDescription const * > &allModuleDescriptions, std::vector< std::pair< unsigned int, unsigned int > > &moduleIDToIndex, std::vector< std::vector< ModuleDescription const * > > &modulesWhoseProductsAreConsumedBy, ProductRegistry const &preg) const
virtual void openFile(FileBlock const &fb)=0
AllWorkers const & allWorkers() const
returns the collection of pointers to workers
void availablePaths(std::vector< std::string > &oLabelsToFill) const
adds to oLabelsToFill the labels for all paths in the process
static std::string const source("source")
virtual void writeRun(RunPrincipal const &rp, ProcessContext const *)=0
preallocConfig_(prealloc)
void restartModuleEvent(StreamContext const &, ModuleCallingContext const &)
bool endPathsEnabled() const
all_output_communicators_()
void respondToCloseInputFile(FileBlock const &fb)
void startModuleEvent(StreamContext const &, ModuleCallingContext const &)
std::vector< Worker * > AllWorkers
std::vector< ParameterSet > VParameterSet
void writeRun(RunPrincipal const &rp, ProcessContext const *)
void endStream(unsigned int)
void writeLumi(LuminosityBlockPrincipal const &lbp, ProcessContext const *)
void enableEndPaths(bool active)
std::shared_ptr< ProductHolderIndexHelper > const & productLookup(BranchType branchType) const
unsigned int numberOfThreads() const
ParameterSet getUntrackedParameterSet(std::string const &name, ParameterSet const &defaultValue) const
std::shared_ptr< ModuleRegistry > moduleRegistry_
void moduleDescriptionsInEndPath(std::string const &iEndPathLabel, std::vector< ModuleDescription const * > &descriptions, unsigned int hint) const
std::vector< WorkerSummary > workerSummaries
std::string const & moduleLabel() const
void stopProcessingLoop()
void startEvent(StreamID)
static unsigned int getUniqueID()
Returns a unique id each time called. Intended to be passed to ModuleDescription's constructor's modI...
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
int totalEventsFailed() const
bool changeModule(std::string const &iLabel, ParameterSet const &iPSet, const ProductRegistry &iRegistry)
void eraseOrSetUntrackedParameterSet(std::string const &name)
Func for_all(ForwardSequence &s, Func f)
wrapper for std::for_each
std::vector< std::string > getParameterNamesForType(bool trackiness=true) const
int totalEventsPassed() const
void triggerPaths(std::vector< std::string > &oLabelsToFill) const
std::string moduleName(Provenance const &provenance)
virtual void updateLookup(BranchType iBranchType, ProductHolderIndexHelper const &)=0
std::vector< PathSummary > trigPathSummaries
EventSummary eventSummary
void limitOutput(ParameterSet const &proc_pset, BranchIDLists const &branchIDLists)
wantSummary_(tns.wantSummary())
virtual void openNewFileIfNeeded()=0
EventTimingSummary eventSummary
Schedule(ParameterSet &proc_pset, service::TriggerNamesService &tns, ProductRegistry &pregistry, BranchIDListHelper &branchIDListHelper, ThinnedAssociationsHelper &thinnedAssociationsHelper, ExceptionToActionTable const &actions, std::shared_ptr< ActivityRegistry > areg, std::shared_ptr< ProcessConfiguration > processConfiguration, const ParameterSet *subProcPSet, PreallocationConfiguration const &config, ProcessContext const *processContext)
void clearCounters()
Clear all the counters in the trigger report.
std::vector< PathTimingSummary > trigPathSummaries
std::vector< std::shared_ptr< StreamSchedule > > streamSchedules_
bool terminate() const
Return whether each output module has reached its maximum count.
void respondToOpenInputFile(FileBlock const &fb)
virtual void writeLumi(LuminosityBlockPrincipal const &lbp, ProcessContext const *)=0
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
void stopPath(StreamContext const &, PathContext const &, HLTPathStatus const &)
void stopModuleEvent(StreamContext const &, ModuleCallingContext const &)
void postForkReacquireResources(unsigned int iChildIndex, unsigned int iNumberOfChildren)
void getTriggerReport(TriggerReport &rep) const
virtual bool shouldWeCloseFile() const =0
PreallocationConfiguration preallocConfig_
moduleRegistry_(new ModuleRegistry())
void sort_all(RandomAccessSequence &s)
wrappers for std::sort
volatile bool endpathsAreActive_
void respondToOpenInputFile(FileBlock const &fb)
void startPath(StreamContext const &, PathContext const &)
bool search_all(ForwardSequence const &s, Datum const &d)
std::unique_ptr< SystemTimeKeeper > summaryTimeKeeper_
virtual std::unique_ptr< OutputModuleCommunicator > createOutputModuleCommunicator()=0
AllOutputModuleCommunicators all_output_communicators_
void loadMissingDictionaries()
void modulesInPath(std::string const &iPathLabel, std::vector< std::string > &oLabelsToFill) const
adds to oLabelsToFill in execution order the labels of all modules in path iPathLabel ...
void pauseModuleEvent(StreamContext const &, ModuleCallingContext const &)
void beginStream(unsigned int)
void respondToCloseInputFile(FileBlock const &fb)
void preForkReleaseResources()
void postForkReacquireResources(unsigned int iChildIndex, unsigned int iNumberOfChildren)
std::vector< ModuleDescription const * > getAllModuleDescriptions() const
Strings const & getTrigPaths() const
std::unique_ptr< GlobalSchedule > globalSchedule_
void beginJob(ProductRegistry const &)
virtual void closeFile()=0
void openNewOutputFilesIfNeeded()
size_t getParameterSetNames(std::vector< std::string > &output, bool trackiness=true) const
void preForkReleaseResources()
void openOutputFiles(FileBlock &fb)
std::vector< WorkerTimingSummary > workerSummaries
T mod(const T &a, const T &b)
void endJob(ExceptionCollector &collector)
void getTriggerTimingReport(TriggerTimingReport &rep) const
bool shouldWeCloseOutput() const
std::vector< std::string > vstring
tuple size
Write out results.
void endPaths(std::vector< std::string > &oLabelsToFill) const
adds to oLabelsToFill the labels for all end paths in the process
void moduleDescriptionsInPath(std::string const &iPathLabel, std::vector< ModuleDescription const * > &descriptions, unsigned int hint) const
std::string match(BranchDescription const &a, BranchDescription const &b, std::string const &fileName)