24 #include "boost/graph/graph_traits.hpp"
25 #include "boost/graph/adjacency_list.hpp"
26 #include "boost/graph/depth_first_search.hpp"
27 #include "boost/graph/visitors.hpp"
42 using std::placeholders::_1;
44 bool binary_search_string(std::vector<std::string>
const&
v,
std::string const&
s) {
45 return std::binary_search(v.begin(), v.end(),
s);
51 std::shared_ptr<TriggerResultInserter>
53 PreallocationConfiguration
const& iPrealloc,
54 ProductRegistry&
preg,
55 ExceptionToActionTable
const&
actions,
56 std::shared_ptr<ActivityRegistry>
areg,
59 ParameterSet* trig_pset = proc_pset.getPSetForUpdate(
"@trigger_paths");
60 trig_pset->registerIt();
62 WorkerParams work_args(trig_pset, preg, &iPrealloc, processConfiguration, actions);
63 ModuleDescription md(trig_pset->id(),
64 "TriggerResultInserter",
66 processConfiguration.get(),
69 areg->preModuleConstructionSignal_(md);
70 bool postCalled =
false;
71 std::shared_ptr<TriggerResultInserter> returnValue;
73 maker::ModuleHolderT<TriggerResultInserter> holder(std::make_shared<TriggerResultInserter>(*trig_pset, iPrealloc.numberOfStreams()),static_cast<Maker const*>(
nullptr));
74 holder.setModuleDescription(md);
75 holder.registerProductsAndCallbacks(&preg);
76 returnValue =holder.module();
79 areg->postModuleConstructionSignal_(md);
84 areg->postModuleConstructionSignal_(md);
97 checkAndInsertAlias(
std::string const& friendlyClassName,
103 ProductRegistry
const& preg,
104 std::multimap<BranchKey, BranchKey>& aliasMap,
105 std::map<BranchKey, BranchKey>& aliasKeys) {
108 BranchKey
key(friendlyClassName, moduleLabel, productInstanceName, processName);
109 if(preg.productList().find(
key) == preg.productList().end()) {
112 for(
auto const& product : preg.productList()) {
113 if(moduleLabel == product.first.moduleLabel() && processName == product.first.processName()) {
115 <<
"There are no products of type '" << friendlyClassName <<
"'\n"
116 <<
"with module label '" << moduleLabel <<
"' and instance name '" << productInstanceName <<
"'.\n";
121 std::string const& theInstanceAlias(instanceAlias == star ? productInstanceName : instanceAlias);
122 BranchKey aliasKey(friendlyClassName, alias, theInstanceAlias, processName);
123 if(preg.productList().find(aliasKey) != preg.productList().end()) {
125 <<
"A product of type '" << friendlyClassName <<
"'\n"
126 <<
"with module label '" << alias <<
"' and instance name '" << theInstanceAlias <<
"'\n"
127 <<
"already exists.\n";
129 auto iter = aliasKeys.find(aliasKey);
130 if(iter != aliasKeys.end()) {
132 if(iter->second !=
key) {
134 <<
"The module label alias '" << alias <<
"' and product instance alias '" << theInstanceAlias <<
"'\n"
135 <<
"are used for multiple products of type '" << friendlyClassName <<
"'\n"
136 <<
"One has module label '" << moduleLabel <<
"' and product instance name '" << productInstanceName <<
"',\n"
137 <<
"the other has module label '" << iter->second.moduleLabel() <<
"' and product instance name '" << iter->second.productInstanceName() <<
"'.\n";
140 auto prodIter = preg.productList().find(
key);
141 if(prodIter != preg.productList().end()) {
142 if (!prodIter->second.produced()) {
144 <<
"The module label alias '" << alias <<
"' and product instance alias '" << theInstanceAlias <<
"'\n"
145 <<
"are used for a product of type '" << friendlyClassName <<
"'\n"
146 <<
"with module label '" << moduleLabel <<
"' and product instance name '" << productInstanceName <<
"',\n"
147 <<
"An EDAlias can only be used for products produced in the current process. This one is not.\n";
149 aliasMap.insert(std::make_pair(
key, aliasKey));
150 aliasKeys.insert(std::make_pair(aliasKey,
key));
157 std::vector<std::string>
aliases = proc_pset.getParameter<std::vector<std::string> >(
"@all_aliases");
158 if(aliases.empty()) {
165 desc.add<
std::string>(
"fromProductInstance", star);
168 std::multimap<BranchKey, BranchKey> aliasMap;
170 std::map<BranchKey, BranchKey> aliasKeys;
174 ParameterSet const& aliasPSet = proc_pset.getParameterSet(alias);
175 std::vector<std::string> vPSetNames = aliasPSet.getParameterNamesForType<
VParameterSet>();
183 if(productInstanceName == star) {
185 BranchKey lowerBound(friendlyClassName, moduleLabel,
empty,
empty);
186 for(ProductRegistry::ProductList::const_iterator it = preg.productList().lower_bound(lowerBound);
187 it != preg.productList().end() && it->first.friendlyClassName() == friendlyClassName && it->first.moduleLabel() == moduleLabel;
194 checkAndInsertAlias(friendlyClassName, moduleLabel, it->first.productInstanceName(),
processName,
alias, instanceAlias,
preg, aliasMap, aliasKeys);
199 for(
auto const& product : preg.productList()) {
200 if(moduleLabel == product.first.moduleLabel() && processName == product.first.processName()) {
202 <<
"There are no products of type '" << friendlyClassName <<
"'\n"
203 <<
"with module label '" << moduleLabel <<
"'.\n";
208 checkAndInsertAlias(friendlyClassName, moduleLabel, productInstanceName, processName, alias, instanceAlias, preg, aliasMap, aliasKeys);
216 for(
auto const& aliasEntry : aliasMap) {
217 ProductRegistry::ProductList::const_iterator it = preg.productList().find(aliasEntry.first);
218 assert(it != preg.productList().end());
219 preg.addLabelAlias(it->second, aliasEntry.second.moduleLabel(), aliasEntry.second.productInstanceName());
224 typedef std::vector<std::string>
vstring;
227 vstring
const& end_path_name_list,
228 vstring& modulesInConfig,
229 std::set<std::string>
const& usedModuleLabels,
230 std::map<
std::string, std::vector<std::pair<std::string, int> > >& outputModulePathPositions) {
242 vstring outputModuleLabels;
244 std::string const moduleEdmType(
"@module_edm_type");
250 std::set<std::string> modulesInConfigSet(modulesInConfig.begin(), modulesInConfig.end());
254 vstring scheduledPaths = proc_pset.getParameter<vstring>(
"@paths");
255 std::set<std::string> modulesOnPaths;
257 std::set<std::string> noEndPaths(scheduledPaths.begin(),scheduledPaths.end());
258 for(
auto const&
endPath: end_path_name_list) {
263 for(
auto const&
path: noEndPaths) {
264 labels = proc_pset.getParameter<vstring>(
path);
265 modulesOnPaths.insert(labels.begin(),labels.end());
271 std::vector<std::string> labelsToBeDropped;
272 labelsToBeDropped.reserve(modulesInConfigSet.size());
273 std::set_difference(modulesInConfigSet.begin(),modulesInConfigSet.end(),
274 usedModuleLabels.begin(),usedModuleLabels.end(),
275 std::back_inserter(labelsToBeDropped));
277 const unsigned int sizeBeforeOutputModules = labelsToBeDropped.size();
278 for (
auto const& modLabel: usedModuleLabels) {
279 edmType = proc_pset.getParameterSet(modLabel).getParameter<
std::string>(moduleEdmType);
280 if (edmType == outputModule) {
281 outputModuleLabels.push_back(modLabel);
282 labelsToBeDropped.push_back(modLabel);
284 if(edmType == edAnalyzer) {
285 if(modulesOnPaths.end()==modulesOnPaths.find(modLabel)) {
286 labelsToBeDropped.push_back(modLabel);
291 std::inplace_merge(labelsToBeDropped.begin(),
292 labelsToBeDropped.begin()+sizeBeforeOutputModules,
293 labelsToBeDropped.end());
299 vstring::iterator endAfterRemove = std::remove_if(modulesInConfig.begin(), modulesInConfig.end(), std::bind(binary_search_string, std::ref(labelsToBeDropped), _1));
300 modulesInConfig.erase(endAfterRemove, modulesInConfig.end());
301 proc_pset.addParameter<vstring>(
std::string(
"@all_modules"), modulesInConfig);
304 vstring endPathsToBeDropped;
306 for (vstring::const_iterator iEndPath = end_path_name_list.begin(), endEndPath = end_path_name_list.end();
307 iEndPath != endEndPath;
309 labels = proc_pset.getParameter<vstring>(*iEndPath);
310 vstring::iterator iSave = labels.begin();
311 vstring::iterator iBegin = labels.begin();
313 for (vstring::iterator iLabel = labels.begin(), iEnd = labels.end();
314 iLabel != iEnd; ++iLabel) {
315 if (binary_search_string(labelsToBeDropped, *iLabel)) {
316 if (binary_search_string(outputModuleLabels, *iLabel)) {
317 outputModulePathPositions[*iLabel].emplace_back(*iEndPath, iSave - iBegin);
320 if (iSave != iLabel) {
321 iSave->swap(*iLabel);
326 labels.erase(iSave, labels.end());
327 if (labels.empty()) {
329 proc_pset.eraseSimpleParameter(*iEndPath);
330 endPathsToBeDropped.push_back(*iEndPath);
332 proc_pset.addParameter<vstring>(*iEndPath,
labels);
338 endAfterRemove = std::remove_if(scheduledPaths.begin(), scheduledPaths.end(), std::bind(binary_search_string, std::ref(endPathsToBeDropped), _1));
339 scheduledPaths.erase(endAfterRemove, scheduledPaths.end());
340 proc_pset.addParameter<vstring>(
std::string(
"@paths"), scheduledPaths);
343 vstring scheduledEndPaths = proc_pset.getParameter<vstring>(
"@end_paths");
344 endAfterRemove = std::remove_if(scheduledEndPaths.begin(), scheduledEndPaths.end(), std::bind(binary_search_string, std::ref(endPathsToBeDropped), _1));
345 scheduledEndPaths.erase(endAfterRemove, scheduledEndPaths.end());
346 proc_pset.addParameter<vstring>(
std::string(
"@end_paths"), scheduledEndPaths);
352 ParameterSet const&
opts = pset.getUntrackedParameterSet(
"options", defopts);
353 return opts.getUntrackedParameter(
"printDependencies",
false);
368 std::shared_ptr<ActivityRegistry> areg,
369 std::shared_ptr<ProcessConfiguration> processConfiguration,
370 bool hasSubprocesses,
374 resultsInserter_{tns.
getTrigPaths().empty()? std::shared_ptr<TriggerResultInserter>{} :makeInserter(proc_pset,prealloc,preg,actions,areg,processConfiguration)},
383 streamSchedules_.reserve(
prealloc.numberOfStreams());
384 for(
unsigned int i=0;
i<
prealloc.numberOfStreams();++
i) {
385 streamSchedules_.emplace_back(std::make_shared<StreamSchedule>(
389 branchIDListHelper,actions,
390 areg,processConfiguration,
398 const std::string kTriggerResults(
"TriggerResults");
399 std::vector<std::string> modulesToUse;
400 modulesToUse.reserve(streamSchedules_[0]->allWorkers().
size());
401 for(
auto const& worker : streamSchedules_[0]->allWorkers()) {
402 if(worker->description().moduleLabel() != kTriggerResults) {
403 modulesToUse.push_back(worker->description().moduleLabel());
407 unsigned int n = streamSchedules_[0]->numberOfUnscheduledModules();
409 std::vector<std::string>
temp;
410 temp.reserve(modulesToUse.size());
411 auto itBeginUnscheduled = modulesToUse.begin()+modulesToUse.size()-
n;
412 std::copy(itBeginUnscheduled,modulesToUse.end(),
413 std::back_inserter(temp));
414 std::copy(modulesToUse.begin(),itBeginUnscheduled,std::back_inserter(temp));
415 temp.swap(modulesToUse);
419 globalSchedule_ = std::make_unique<GlobalSchedule>(
428 std::set<std::string> usedModuleLabels;
429 for(
auto const& worker: allWorkers()) {
430 if(worker->description().moduleLabel() != kTriggerResults) {
431 usedModuleLabels.insert(worker->description().moduleLabel());
434 std::vector<std::string> modulesInConfig(proc_pset.getParameter<std::vector<std::string> >(
"@all_modules"));
435 std::map<std::string, std::vector<std::pair<std::string, int> > > outputModulePathPositions;
436 reduceParameterSet(proc_pset, tns.getEndPaths(), modulesInConfig, usedModuleLabels,
437 outputModulePathPositions);
438 processEDAliases(proc_pset, processConfiguration->processName(),
preg);
439 proc_pset.registerIt();
440 processConfiguration->setParameterSetID(proc_pset.id());
441 processConfiguration->setProcessConfigurationID();
445 size_t all_workers_count = allWorkers().size();
454 limitOutput(proc_pset, branchIDListHelper.branchIDLists());
458 assert (all_workers_count == allWorkers().
size());
460 branchIDListHelper.updateFromRegistry(preg);
464 for(
auto const& worker : streamSchedules_[0]->allWorkers()) {
465 worker->registerThinnedAssociations(preg, thinnedAssociationsHelper);
467 thinnedAssociationsHelper.sort();
470 c->setEventSelectionInfo(outputModulePathPositions, preg.anyProductProduced());
471 c->selectProducts(preg, thinnedAssociationsHelper);
475 std::vector<const ModuleDescription*> modDesc;
476 const auto& workers = allWorkers();
477 modDesc.reserve(workers.size());
480 std::back_inserter(modDesc),
482 return iWorker->descPtr();
486 summaryTimeKeeper_ = std::make_unique<SystemTimeKeeper>(
487 prealloc.numberOfStreams(),
490 auto timeKeeperPtr = summaryTimeKeeper_.get();
518 int maxEventSpecs = 0;
519 int maxEventsOut = -1;
526 std::vector<std::string> psetNamesE;
533 if (maxEventSpecs > 1) {
535 "\nAt most, one form of 'output' may appear in the 'maxEvents' parameter set";
540 if (vMaxEventsOut != 0 && !vMaxEventsOut->
empty()) {
541 std::string const& moduleLabel =
c->description().moduleLabel();
546 "\nNo entry in 'maxEvents' for output module label '" << moduleLabel <<
"'.\n";
558 if (!
c->limitReached()) {
563 LogInfo(
"SuccessfulTermination")
564 <<
"The job is terminating successfully because each output module\n"
565 <<
"has reached its configured limit.\n";
583 LogVerbatim(
"FwkSummary") <<
"TrigReport " <<
"---------- Event Summary ------------";
598 LogVerbatim(
"FwkSummary") <<
"TrigReport " <<
"---------- Path Summary ------------";
600 << std::right << std::setw(10) <<
"Trig Bit#" <<
" "
601 << std::right << std::setw(10) <<
"Executed" <<
" "
602 << std::right << std::setw(10) <<
"Passed" <<
" "
603 << std::right << std::setw(10) <<
"Failed" <<
" "
604 << std::right << std::setw(10) <<
"Error" <<
" "
608 << std::right << std::setw(5) << 1
609 << std::right << std::setw(5) <<
p.bitPosition <<
" "
610 << std::right << std::setw(10) <<
p.timesRun <<
" "
611 << std::right << std::setw(10) <<
p.timesPassed <<
" "
612 << std::right << std::setw(10) <<
p.timesFailed <<
" "
613 << std::right << std::setw(10) <<
p.timesExcept <<
" "
635 LogVerbatim(
"FwkSummary") <<
"TrigReport " <<
"-------End-Path Summary ------------";
637 << std::right << std::setw(10) <<
"Trig Bit#" <<
" "
638 << std::right << std::setw(10) <<
"Executed" <<
" "
639 << std::right << std::setw(10) <<
"Passed" <<
" "
640 << std::right << std::setw(10) <<
"Failed" <<
" "
641 << std::right << std::setw(10) <<
"Error" <<
" "
645 << std::right << std::setw(5) << 0
646 << std::right << std::setw(5) <<
p.bitPosition <<
" "
647 << std::right << std::setw(10) <<
p.timesRun <<
" "
648 << std::right << std::setw(10) <<
p.timesPassed <<
" "
649 << std::right << std::setw(10) <<
p.timesFailed <<
" "
650 << std::right << std::setw(10) <<
p.timesExcept <<
" "
656 LogVerbatim(
"FwkSummary") <<
"TrigReport " <<
"---------- Modules in Path: " <<
p.name <<
" ------------";
658 << std::right << std::setw(10) <<
"Trig Bit#" <<
" "
659 << std::right << std::setw(10) <<
"Visited" <<
" "
660 << std::right << std::setw(10) <<
"Passed" <<
" "
661 << std::right << std::setw(10) <<
"Failed" <<
" "
662 << std::right << std::setw(10) <<
"Error" <<
" "
665 unsigned int bitpos = 0;
666 for (
auto const&
mod:
p.moduleInPathSummaries) {
668 << std::right << std::setw(5) << 1
669 << std::right << std::setw(5) << bitpos <<
" "
670 << std::right << std::setw(10) <<
mod.timesVisited <<
" "
671 << std::right << std::setw(10) <<
mod.timesPassed <<
" "
672 << std::right << std::setw(10) <<
mod.timesFailed <<
" "
673 << std::right << std::setw(10) <<
mod.timesExcept <<
" "
674 <<
mod.moduleLabel <<
"";
681 LogVerbatim(
"FwkSummary") <<
"TrigReport " <<
"------ Modules in End-Path: " <<
p.name <<
" ------------";
683 << std::right << std::setw(10) <<
"Trig Bit#" <<
" "
684 << std::right << std::setw(10) <<
"Visited" <<
" "
685 << std::right << std::setw(10) <<
"Passed" <<
" "
686 << std::right << std::setw(10) <<
"Failed" <<
" "
687 << std::right << std::setw(10) <<
"Error" <<
" "
690 unsigned int bitpos=0;
691 for (
auto const&
mod:
p.moduleInPathSummaries) {
693 << std::right << std::setw(5) << 0
694 << std::right << std::setw(5) << bitpos <<
" "
695 << std::right << std::setw(10) <<
mod.timesVisited <<
" "
696 << std::right << std::setw(10) <<
mod.timesPassed <<
" "
697 << std::right << std::setw(10) <<
mod.timesFailed <<
" "
698 << std::right << std::setw(10) <<
mod.timesExcept <<
" "
699 <<
mod.moduleLabel <<
"";
705 LogVerbatim(
"FwkSummary") <<
"TrigReport " <<
"---------- Module Summary ------------";
707 << std::right << std::setw(10) <<
"Visited" <<
" "
708 << std::right << std::setw(10) <<
"Executed" <<
" "
709 << std::right << std::setw(10) <<
"Passed" <<
" "
710 << std::right << std::setw(10) <<
"Failed" <<
" "
711 << std::right << std::setw(10) <<
"Error" <<
" "
715 << std::right << std::setw(10) << worker.timesVisited <<
" "
716 << std::right << std::setw(10) << worker.timesRun <<
" "
717 << std::right << std::setw(10) << worker.timesPassed <<
" "
718 << std::right << std::setw(10) << worker.timesFailed <<
" "
719 << std::right << std::setw(10) << worker.timesExcept <<
" "
720 << worker.moduleLabel <<
"";
730 LogVerbatim(
"FwkSummary") <<
"TimeReport " <<
"---------- Event Summary ---[sec]----";
732 << std::setprecision(6) << std::fixed
735 << std::setprecision(6) << std::fixed
738 << std::setprecision(6) << std::fixed
741 << std::setprecision(6) << std::fixed
748 LogVerbatim(
"FwkSummary") <<
"TimeReport " <<
"---------- Path Summary ---[Real sec]----";
750 << std::right << std::setw(kColumn1Size) <<
"per event"<<
" "
751 << std::right << std::setw(kColumn2Size) <<
"per exec"
754 const int timesRun =
std::max(1,
p.timesRun);
756 << std::setprecision(6) << std::fixed
757 << std::right << std::setw(kColumn1Size) <<
p.realTime/totalEvents <<
" "
758 << std::right << std::setw(kColumn2Size) <<
p.realTime/timesRun <<
" "
762 << std::right << std::setw(kColumn1Size) <<
"per event"<<
" "
763 << std::right << std::setw(kColumn2Size) <<
"per exec"
767 LogVerbatim(
"FwkSummary") <<
"TimeReport " <<
"-------End-Path Summary ---[Real sec]----";
769 << std::right << std::setw(kColumn1Size) <<
"per event" <<
" "
770 << std::right << std::setw(kColumn2Size) <<
"per exec"
773 const int timesRun =
std::max(1,
p.timesRun);
776 << std::setprecision(6) << std::fixed
777 << std::right << std::setw(kColumn1Size) <<
p.realTime/totalEvents <<
" "
778 << std::right << std::setw(kColumn2Size) <<
p.realTime/timesRun <<
" "
782 << std::right << std::setw(kColumn1Size) <<
"per event" <<
" "
783 << std::right << std::setw(kColumn2Size) <<
"per exec"
788 LogVerbatim(
"FwkSummary") <<
"TimeReport " <<
"---------- Modules in Path: " <<
p.name <<
" ---[Real sec]----";
790 << std::right << std::setw(kColumn1Size) <<
"per event" <<
" "
791 << std::right << std::setw(kColumn2Size) <<
"per visit"
793 for (
auto const&
mod:
p.moduleInPathSummaries) {
795 << std::setprecision(6) << std::fixed
796 << std::right << std::setw(kColumn1Size) <<
mod.realTime/totalEvents <<
" "
797 << std::right << std::setw(kColumn2Size) <<
mod.realTime/
std::max(1,
mod.timesVisited) <<
" "
798 <<
mod.moduleLabel <<
"";
803 << std::right << std::setw(kColumn1Size) <<
"per event" <<
" "
804 << std::right << std::setw(kColumn2Size) <<
"per visit"
809 LogVerbatim(
"FwkSummary") <<
"TimeReport " <<
"------ Modules in End-Path: " <<
p.name <<
" ---[Real sec]----";
811 << std::right << std::setw(kColumn1Size) <<
"per event" <<
" "
812 << std::right << std::setw(kColumn2Size) <<
"per visit"
814 for (
auto const&
mod:
p.moduleInPathSummaries) {
816 << std::setprecision(6) << std::fixed
817 << std::right << std::setw(kColumn1Size) <<
mod.realTime/totalEvents <<
" "
818 << std::right << std::setw(kColumn2Size) <<
mod.realTime/
std::max(1,
mod.timesVisited) <<
" "
819 <<
mod.moduleLabel <<
"";
824 << std::right << std::setw(kColumn1Size) <<
"per event" <<
" "
825 << std::right << std::setw(kColumn2Size) <<
"per visit"
829 LogVerbatim(
"FwkSummary") <<
"TimeReport " <<
"---------- Module Summary ---[Real sec]----";
831 << std::right << std::setw(kColumn1Size) <<
"per event" <<
" "
832 << std::right << std::setw(kColumn2Size) <<
"per exec" <<
" "
833 << std::right << std::setw(kColumn3Size) <<
"per visit"
837 << std::setprecision(6) << std::fixed
838 << std::right << std::setw(kColumn1Size) << worker.realTime/totalEvents <<
" "
839 << std::right << std::setw(kColumn2Size) << worker.realTime/
std::max(1, worker.timesRun) <<
" "
840 << std::right << std::setw(kColumn3Size) << worker.realTime/
std::max(1, worker.timesVisited) <<
" "
841 << worker.moduleLabel <<
"";
844 << std::right << std::setw(kColumn1Size) <<
"per event" <<
" "
845 << std::right << std::setw(kColumn2Size) <<
"per exec" <<
" "
846 << std::right << std::setw(kColumn3Size) <<
"per visit"
850 LogVerbatim(
"FwkSummary") <<
"T---Report end!" <<
"";
855 using std::placeholders::_1;
860 using std::placeholders::_1;
865 using std::placeholders::_1;
870 using std::placeholders::_1;
875 using std::placeholders::_1;
880 using std::placeholders::_1;
888 using std::placeholders::_1;
893 using std::placeholders::_1;
914 using std::placeholders::_1;
918 using std::placeholders::_1;
927 if (worker->description().moduleLabel() == iLabel) {
932 if (
nullptr == found) {
941 s->replaceModule(newMod,iLabel);
957 std::vector<ModuleDescription const*>
959 std::vector<ModuleDescription const*>
result;
991 std::vector<std::string>& oLabelsToFill)
const {
997 std::vector<ModuleDescription const*>& descriptions,
998 unsigned int hint)
const {
999 streamSchedules_[0]->moduleDescriptionsInPath(iPathLabel, descriptions, hint);
1004 std::vector<ModuleDescription const*>& descriptions,
1005 unsigned int hint)
const {
1006 streamSchedules_[0]->moduleDescriptionsInEndPath(iEndPathLabel, descriptions, hint);
1011 std::vector<std::pair<unsigned int, unsigned int> >& moduleIDToIndex,
1012 std::vector<std::vector<ModuleDescription const*> >& modulesWhoseProductsAreConsumedBy,
1014 allModuleDescriptions.clear();
1015 moduleIDToIndex.clear();
1016 modulesWhoseProductsAreConsumedBy.clear();
1022 std::map<std::string, ModuleDescription const*> labelToDesc;
1026 allModuleDescriptions.push_back(p);
1027 moduleIDToIndex.push_back(std::pair<unsigned int, unsigned int>(p->
id(),
i));
1035 std::vector<ModuleDescription const*>&
modules = modulesWhoseProductsAreConsumedBy.at(i);
1036 worker->modulesWhoseProductsAreConsumed(modules, preg, labelToDesc);
1045 s->enableEndPaths(active);
1060 s->getTriggerReport(rep);
1074 int returnValue = 0;
1076 returnValue += s->totalEvents();
1083 int returnValue = 0;
1085 returnValue += s->totalEventsPassed();
1092 int returnValue = 0;
1094 returnValue += s->totalEventsFailed();
1149 typedef std::pair<unsigned int, unsigned int> SimpleEdge;
1150 typedef std::map<SimpleEdge, std::vector<unsigned int>> EdgeToPathMap;
1152 typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS> Graph;
1154 typedef boost::graph_traits<Graph>::edge_descriptor Edge;
1155 struct cycle_detector :
public boost::dfs_visitor<> {
1157 cycle_detector(EdgeToPathMap
const& iEdgeToPathMap,
1158 std::vector<std::string>
const& iPathNames,
1159 std::map<std::string,unsigned int>
const& iModuleNamesToIndex):
1160 m_edgeToPathMap(iEdgeToPathMap),
1161 m_pathNames(iPathNames),
1162 m_namesToIndex(iModuleNamesToIndex){}
1164 void tree_edge(Edge iEdge, Graph
const&) {
1165 m_stack.push_back(iEdge);
1168 void finish_edge(Edge iEdge, Graph
const& iGraph) {
1169 if(not m_stack.empty()) {
1170 if (iEdge == m_stack.back()) {
1177 void back_edge(Edge iEdge, Graph
const& iGraph) {
1182 IndexMap
const&
index =
get(boost::vertex_index, iGraph);
1184 unsigned int vertex = index[
target(iEdge,iGraph)];
1187 std::list<Edge>::iterator itFirst = m_stack.begin();
1189 bool seenVertex =
false;
1190 while(itFirst != m_stack.end()) {
1191 if(not seenVertex) {
1192 if(index[
source(*itFirst,iGraph)] == vertex) {
1196 if (index[
source(*itFirst,iGraph)] != vertex) {
1201 if(itFirst != m_stack.begin()) {
1208 std::vector<Edge> tempStack;
1209 tempStack.reserve(m_stack.size()+1);
1210 tempStack.insert(tempStack.end(),itFirst,m_stack.end());
1211 tempStack.emplace_back(iEdge);
1213 unsigned int nPathDependencyOnly =0;
1214 for(
auto const& edge: tempStack) {
1215 unsigned int in =index[
source(edge,iGraph)];
1216 unsigned int out =index[
target(edge,iGraph)];
1218 auto iFound = m_edgeToPathMap.find(SimpleEdge(in,out));
1219 bool pathDependencyOnly =
true;
1220 for(
auto dependency : iFound->second) {
1222 pathDependencyOnly =
false;
1226 if (pathDependencyOnly) {
1227 ++nPathDependencyOnly;
1230 if(nPathDependencyOnly < 2) {
1231 throwOnError(tempStack,index,iGraph);
1236 return m_pathNames[iIndex];
1240 for(
auto const& item : m_namesToIndex) {
1241 if(item.second == iIndex) {
1249 throwOnError(std::vector<Edge>
const& iEdges,
1251 Graph
const& iGraph)
const {
1252 std::stringstream oStream;
1253 oStream <<
"Module run order problem found: \n";
1254 bool first_edge =
true;
1255 for(
auto const& edge: iEdges) {
1256 unsigned int in =iIndex[
source(edge,iGraph)];
1257 unsigned int out =iIndex[
target(edge,iGraph)];
1266 auto iFound = m_edgeToPathMap.find(SimpleEdge(in,out));
1267 bool pathDependencyOnly =
true;
1268 for(
auto dependency : iFound->second) {
1270 pathDependencyOnly =
false;
1274 if (pathDependencyOnly) {
1280 oStream<<
"\n Running in the threaded framework would lead to indeterminate results."
1281 "\n Please change order of modules in mentioned Path(s) to avoid inconsistent module ordering.";
1284 << oStream.str() <<
"\n";
1287 EdgeToPathMap
const& m_edgeToPathMap;
1288 std::vector<std::string>
const& m_pathNames;
1289 std::map<std::string,unsigned int> m_namesToIndex;
1291 std::list<Edge> m_stack;
1299 std::map<std::string,unsigned int> moduleNamesToIndex;
1301 moduleNamesToIndex.insert(std::make_pair(worker->description().moduleLabel(),
1302 worker->description().id()));
1306 EdgeToPathMap edgeToPathMap;
1309 std::vector<std::string> pathNames;
1313 std::vector<std::string> moduleNames;
1314 std::vector<std::string> reducedModuleNames;
1315 unsigned int pathIndex=0;
1316 for(
auto const&
path: pathNames) {
1317 moduleNames.clear();
1318 reducedModuleNames.clear();
1319 std::set<std::string> alreadySeenNames;
1323 unsigned int lastModuleIndex;
1324 for(
auto const&
name: moduleNames) {
1325 auto found = alreadySeenNames.insert(
name);
1328 unsigned int const moduleIndex = moduleNamesToIndex[
name];
1329 if(not lastModuleName.empty()) {
1330 edgeToPathMap[std::make_pair(moduleIndex,lastModuleIndex)].push_back(pathIndex);
1332 lastModuleName =
name;
1333 lastModuleIndex = moduleIndex;
1340 std::vector<const char*> dependentModules;
1343 dependentModules.clear();
1346 auto found = moduleNamesToIndex.find(worker->description().moduleLabel());
1347 if (
found == moduleNamesToIndex.end()) {
1351 unsigned int const moduleIndex =
found->second;
1352 for(
auto const&
name: dependentModules) {
1358 std::vector<SimpleEdge> outList;
1359 outList.reserve(edgeToPathMap.size());
1360 for(
auto const& edgeInfo: edgeToPathMap) {
1361 outList.push_back(edgeInfo.first);
1364 Graph
g(outList.begin(),outList.end(), moduleNamesToIndex.size());
1366 cycle_detector detector(edgeToPathMap,pathNames,moduleNamesToIndex);
1367 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)
unsigned int numberOfThreads() const
ParameterSet getUntrackedParameterSet(std::string const &name, ParameterSet const &defaultValue) const
std::shared_ptr< ProductHolderIndexHelper const > productLookup(BranchType branchType) const
void moduleDescriptionsInEndPath(std::string const &iEndPathLabel, std::vector< ModuleDescription const * > &descriptions, unsigned int hint) const
std::vector< WorkerSummary > workerSummaries
edm::propagate_const< std::unique_ptr< SystemTimeKeeper > > summaryTimeKeeper_
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
edm::propagate_const< std::unique_ptr< GlobalSchedule > > globalSchedule_
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
void clearCounters()
Clear all the counters in the trigger report.
std::vector< PathTimingSummary > trigPathSummaries
bool terminate() const
Return whether each output module has reached its maximum count.
void respondToOpenInputFile(FileBlock const &fb)
edm::propagate_const< std::shared_ptr< ModuleRegistry > > moduleRegistry_
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())
std::vector< edm::propagate_const< std::shared_ptr< StreamSchedule > > > streamSchedules_
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)
virtual std::unique_ptr< OutputModuleCommunicator > createOutputModuleCommunicator()=0
AllOutputModuleCommunicators all_output_communicators_
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
void beginJob(ProductRegistry const &)
printDependencies_(printDependencies(proc_pset))
virtual void closeFile()=0
void openNewOutputFilesIfNeeded()
size_t getParameterSetNames(std::vector< std::string > &output, bool trackiness=true) const
void preForkReleaseResources()
void openOutputFiles(FileBlock &fb)
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, bool hasSubprocesses, PreallocationConfiguration const &config, ProcessContext const *processContext)
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)