26 #include "boost/graph/graph_traits.hpp"
27 #include "boost/graph/adjacency_list.hpp"
28 #include "boost/graph/depth_first_search.hpp"
29 #include "boost/graph/visitors.hpp"
44 using std::placeholders::_1;
46 bool binary_search_string(std::vector<std::string>
const&
v,
std::string const&
s) {
47 return std::binary_search(v.begin(), v.end(),
s);
53 std::shared_ptr<TriggerResultInserter>
55 PreallocationConfiguration
const& iPrealloc,
56 ProductRegistry&
preg,
57 ExceptionToActionTable
const&
actions,
58 std::shared_ptr<ActivityRegistry>
areg,
61 ParameterSet* trig_pset = proc_pset.getPSetForUpdate(
"@trigger_paths");
62 trig_pset->registerIt();
64 WorkerParams work_args(trig_pset, preg, &iPrealloc, processConfiguration, actions);
65 ModuleDescription
md(trig_pset->id(),
66 "TriggerResultInserter",
68 processConfiguration.get(),
71 areg->preModuleConstructionSignal_(
md);
72 bool postCalled =
false;
73 std::shared_ptr<TriggerResultInserter> returnValue;
75 maker::ModuleHolderT<TriggerResultInserter> holder(std::make_shared<TriggerResultInserter>(*trig_pset, iPrealloc.numberOfStreams()),static_cast<Maker const*>(
nullptr));
76 holder.setModuleDescription(
md);
77 holder.registerProductsAndCallbacks(&preg);
78 returnValue =holder.module();
81 areg->postModuleConstructionSignal_(
md);
86 areg->postModuleConstructionSignal_(
md);
99 checkAndInsertAlias(
std::string const& friendlyClassName,
105 ProductRegistry
const& preg,
106 std::multimap<BranchKey, BranchKey>& aliasMap,
107 std::map<BranchKey, BranchKey>& aliasKeys) {
110 BranchKey
key(friendlyClassName, moduleLabel, productInstanceName, processName);
111 if(preg.productList().find(
key) == preg.productList().end()) {
114 for(
auto const& product : preg.productList()) {
115 if(moduleLabel == product.first.moduleLabel() && processName == product.first.processName()) {
117 <<
"There are no products of type '" << friendlyClassName <<
"'\n"
118 <<
"with module label '" << moduleLabel <<
"' and instance name '" << productInstanceName <<
"'.\n";
123 std::string const& theInstanceAlias(instanceAlias == star ? productInstanceName : instanceAlias);
124 BranchKey aliasKey(friendlyClassName, alias, theInstanceAlias, processName);
125 if(preg.productList().find(aliasKey) != preg.productList().end()) {
127 <<
"A product of type '" << friendlyClassName <<
"'\n"
128 <<
"with module label '" << alias <<
"' and instance name '" << theInstanceAlias <<
"'\n"
129 <<
"already exists.\n";
131 auto iter = aliasKeys.find(aliasKey);
132 if(
iter != aliasKeys.end()) {
136 <<
"The module label alias '" << alias <<
"' and product instance alias '" << theInstanceAlias <<
"'\n"
137 <<
"are used for multiple products of type '" << friendlyClassName <<
"'\n"
138 <<
"One has module label '" << moduleLabel <<
"' and product instance name '" << productInstanceName <<
"',\n"
139 <<
"the other has module label '" <<
iter->second.moduleLabel() <<
"' and product instance name '" <<
iter->second.productInstanceName() <<
"'.\n";
142 auto prodIter = preg.productList().find(
key);
143 if(prodIter != preg.productList().end()) {
144 if (!prodIter->second.produced()) {
146 <<
"The module label alias '" << alias <<
"' and product instance alias '" << theInstanceAlias <<
"'\n"
147 <<
"are used for a product of type '" << friendlyClassName <<
"'\n"
148 <<
"with module label '" << moduleLabel <<
"' and product instance name '" << productInstanceName <<
"',\n"
149 <<
"An EDAlias can only be used for products produced in the current process. This one is not.\n";
151 aliasMap.insert(std::make_pair(
key, aliasKey));
152 aliasKeys.insert(std::make_pair(aliasKey,
key));
159 std::vector<std::string>
aliases = proc_pset.getParameter<std::vector<std::string> >(
"@all_aliases");
160 if(aliases.empty()) {
167 desc.add<
std::string>(
"fromProductInstance", star);
170 std::multimap<BranchKey, BranchKey> aliasMap;
172 std::map<BranchKey, BranchKey> aliasKeys;
176 ParameterSet const& aliasPSet = proc_pset.getParameterSet(alias);
177 std::vector<std::string> vPSetNames = aliasPSet.getParameterNamesForType<
VParameterSet>();
185 if(productInstanceName == star) {
187 BranchKey lowerBound(friendlyClassName, moduleLabel,
empty,
empty);
188 for(ProductRegistry::ProductList::const_iterator it = preg.productList().lower_bound(lowerBound);
189 it != preg.productList().end() && it->first.friendlyClassName() == friendlyClassName && it->first.moduleLabel() == moduleLabel;
196 checkAndInsertAlias(friendlyClassName, moduleLabel, it->first.productInstanceName(),
processName,
alias, instanceAlias,
preg, aliasMap, aliasKeys);
201 for(
auto const& product : preg.productList()) {
202 if(moduleLabel == product.first.moduleLabel() && processName == product.first.processName()) {
204 <<
"There are no products of type '" << friendlyClassName <<
"'\n"
205 <<
"with module label '" << moduleLabel <<
"'.\n";
210 checkAndInsertAlias(friendlyClassName, moduleLabel, productInstanceName, processName, alias, instanceAlias, preg, aliasMap, aliasKeys);
218 for(
auto const& aliasEntry : aliasMap) {
219 ProductRegistry::ProductList::const_iterator it = preg.productList().find(aliasEntry.first);
220 assert(it != preg.productList().end());
221 preg.addLabelAlias(it->second, aliasEntry.second.moduleLabel(), aliasEntry.second.productInstanceName());
226 typedef std::vector<std::string>
vstring;
229 vstring
const& end_path_name_list,
230 vstring& modulesInConfig,
231 std::set<std::string>
const& usedModuleLabels,
232 std::map<
std::string, std::vector<std::pair<std::string, int> > >& outputModulePathPositions) {
244 vstring outputModuleLabels;
246 std::string const moduleEdmType(
"@module_edm_type");
252 std::set<std::string> modulesInConfigSet(modulesInConfig.begin(), modulesInConfig.end());
256 vstring scheduledPaths = proc_pset.getParameter<vstring>(
"@paths");
257 std::set<std::string> modulesOnPaths;
259 std::set<std::string> noEndPaths(scheduledPaths.begin(),scheduledPaths.end());
260 for(
auto const&
endPath: end_path_name_list) {
265 for(
auto const&
path: noEndPaths) {
266 labels = proc_pset.getParameter<vstring>(
path);
267 modulesOnPaths.insert(labels.begin(),labels.end());
273 std::vector<std::string> labelsToBeDropped;
274 labelsToBeDropped.reserve(modulesInConfigSet.size());
275 std::set_difference(modulesInConfigSet.begin(),modulesInConfigSet.end(),
276 usedModuleLabels.begin(),usedModuleLabels.end(),
277 std::back_inserter(labelsToBeDropped));
279 const unsigned int sizeBeforeOutputModules = labelsToBeDropped.size();
280 for (
auto const& modLabel: usedModuleLabels) {
281 edmType = proc_pset.getParameterSet(modLabel).getParameter<
std::string>(moduleEdmType);
282 if (edmType == outputModule) {
283 outputModuleLabels.push_back(modLabel);
284 labelsToBeDropped.push_back(modLabel);
286 if(edmType == edAnalyzer) {
287 if(modulesOnPaths.end()==modulesOnPaths.find(modLabel)) {
288 labelsToBeDropped.push_back(modLabel);
293 std::inplace_merge(labelsToBeDropped.begin(),
294 labelsToBeDropped.begin()+sizeBeforeOutputModules,
295 labelsToBeDropped.end());
301 vstring::iterator endAfterRemove = std::remove_if(modulesInConfig.begin(), modulesInConfig.end(), std::bind(binary_search_string, std::ref(labelsToBeDropped), _1));
302 modulesInConfig.erase(endAfterRemove, modulesInConfig.end());
303 proc_pset.addParameter<vstring>(
std::string(
"@all_modules"), modulesInConfig);
306 vstring endPathsToBeDropped;
308 for (vstring::const_iterator iEndPath = end_path_name_list.begin(), endEndPath = end_path_name_list.end();
309 iEndPath != endEndPath;
311 labels = proc_pset.getParameter<vstring>(*iEndPath);
312 vstring::iterator iSave = labels.begin();
313 vstring::iterator iBegin = labels.begin();
315 for (vstring::iterator iLabel = labels.begin(), iEnd = labels.end();
316 iLabel != iEnd; ++iLabel) {
317 if (binary_search_string(labelsToBeDropped, *iLabel)) {
318 if (binary_search_string(outputModuleLabels, *iLabel)) {
319 outputModulePathPositions[*iLabel].emplace_back(*iEndPath, iSave - iBegin);
322 if (iSave != iLabel) {
323 iSave->swap(*iLabel);
328 labels.erase(iSave, labels.end());
329 if (labels.empty()) {
331 proc_pset.eraseSimpleParameter(*iEndPath);
332 endPathsToBeDropped.push_back(*iEndPath);
334 proc_pset.addParameter<vstring>(*iEndPath,
labels);
340 endAfterRemove = std::remove_if(scheduledPaths.begin(), scheduledPaths.end(), std::bind(binary_search_string, std::ref(endPathsToBeDropped), _1));
341 scheduledPaths.erase(endAfterRemove, scheduledPaths.end());
342 proc_pset.addParameter<vstring>(
std::string(
"@paths"), scheduledPaths);
345 vstring scheduledEndPaths = proc_pset.getParameter<vstring>(
"@end_paths");
346 endAfterRemove = std::remove_if(scheduledEndPaths.begin(), scheduledEndPaths.end(), std::bind(binary_search_string, std::ref(endPathsToBeDropped), _1));
347 scheduledEndPaths.erase(endAfterRemove, scheduledEndPaths.end());
348 proc_pset.addParameter<vstring>(
std::string(
"@end_paths"), scheduledEndPaths);
364 std::shared_ptr<ActivityRegistry> areg,
365 std::shared_ptr<ProcessConfiguration> processConfiguration,
370 resultsInserter_{tns.
getTrigPaths().empty()? std::shared_ptr<TriggerResultInserter>{} :makeInserter(proc_pset,prealloc,preg,actions,areg,processConfiguration)},
378 streamSchedules_.reserve(
prealloc.numberOfStreams());
379 for(
unsigned int i=0;
i<
prealloc.numberOfStreams();++
i) {
380 streamSchedules_.emplace_back(std::make_shared<StreamSchedule>(resultsInserter_,
moduleRegistry_,proc_pset,tns,
prealloc,preg,branchIDListHelper,actions,areg,processConfiguration,
nullptr==subProcPSet,
StreamID{
i},processContext));
385 const std::string kTriggerResults(
"TriggerResults");
386 std::vector<std::string> modulesToUse;
387 modulesToUse.reserve(streamSchedules_[0]->allWorkers().
size());
388 for(
auto const& worker : streamSchedules_[0]->allWorkers()) {
389 if(worker->description().moduleLabel() != kTriggerResults) {
390 modulesToUse.push_back(worker->description().moduleLabel());
394 unsigned int n = streamSchedules_[0]->numberOfUnscheduledModules();
396 std::vector<std::string>
temp;
397 temp.reserve(modulesToUse.size());
398 auto itBeginUnscheduled = modulesToUse.begin()+modulesToUse.size()-
n;
399 std::copy(itBeginUnscheduled,modulesToUse.end(),
400 std::back_inserter(temp));
401 std::copy(modulesToUse.begin(),itBeginUnscheduled,std::back_inserter(temp));
402 temp.swap(modulesToUse);
412 std::set<std::string> usedModuleLabels;
413 for(
auto const worker: allWorkers()) {
414 if(worker->description().moduleLabel() != kTriggerResults) {
415 usedModuleLabels.insert(worker->description().moduleLabel());
418 std::vector<std::string> modulesInConfig(proc_pset.getParameter<std::vector<std::string> >(
"@all_modules"));
419 std::map<std::string, std::vector<std::pair<std::string, int> > > outputModulePathPositions;
420 reduceParameterSet(proc_pset, tns.getEndPaths(), modulesInConfig, usedModuleLabels,
421 outputModulePathPositions);
422 processEDAliases(proc_pset, processConfiguration->processName(),
preg);
423 proc_pset.registerIt();
425 processConfiguration->setParameterSetID(proc_pset.id());
426 processConfiguration->setProcessConfigurationID();
430 size_t all_workers_count = allWorkers().size();
439 limitOutput(proc_pset, branchIDListHelper.branchIDLists());
445 assert (all_workers_count == allWorkers().
size());
447 branchIDListHelper.updateFromRegistry(preg);
451 for(
auto const& worker : streamSchedules_[0]->allWorkers()) {
452 worker->registerThinnedAssociations(preg, thinnedAssociationsHelper);
454 thinnedAssociationsHelper.sort();
457 c->setEventSelectionInfo(outputModulePathPositions, preg.anyProductProduced());
458 c->selectProducts(preg, thinnedAssociationsHelper);
462 std::vector<const ModuleDescription*> modDesc;
463 const auto& workers = allWorkers();
464 modDesc.reserve(workers.size());
467 std::back_inserter(modDesc),
469 return iWorker->descPtr();
475 auto timeKeeperPtr = summaryTimeKeeper_.get();
503 int maxEventSpecs = 0;
504 int maxEventsOut = -1;
511 std::vector<std::string> psetNamesE;
518 if (maxEventSpecs > 1) {
520 "\nAt most, one form of 'output' may appear in the 'maxEvents' parameter set";
525 if (vMaxEventsOut != 0 && !vMaxEventsOut->
empty()) {
526 std::string const& moduleLabel =
c->description().moduleLabel();
531 "\nNo entry in 'maxEvents' for output module label '" << moduleLabel <<
"'.\n";
543 if (!
c->limitReached()) {
548 LogInfo(
"SuccessfulTermination")
549 <<
"The job is terminating successfully because each output module\n"
550 <<
"has reached its configured limit.\n";
568 LogVerbatim(
"FwkSummary") <<
"TrigReport " <<
"---------- Event Summary ------------";
583 LogVerbatim(
"FwkSummary") <<
"TrigReport " <<
"---------- Path Summary ------------";
585 << std::right << std::setw(10) <<
"Trig Bit#" <<
" "
586 << std::right << std::setw(10) <<
"Executed" <<
" "
587 << std::right << std::setw(10) <<
"Passed" <<
" "
588 << std::right << std::setw(10) <<
"Failed" <<
" "
589 << std::right << std::setw(10) <<
"Error" <<
" "
593 << std::right << std::setw(5) << 1
594 << std::right << std::setw(5) <<
p.bitPosition <<
" "
595 << std::right << std::setw(10) <<
p.timesRun <<
" "
596 << std::right << std::setw(10) <<
p.timesPassed <<
" "
597 << std::right << std::setw(10) <<
p.timesFailed <<
" "
598 << std::right << std::setw(10) <<
p.timesExcept <<
" "
620 LogVerbatim(
"FwkSummary") <<
"TrigReport " <<
"-------End-Path Summary ------------";
622 << std::right << std::setw(10) <<
"Trig Bit#" <<
" "
623 << std::right << std::setw(10) <<
"Executed" <<
" "
624 << std::right << std::setw(10) <<
"Passed" <<
" "
625 << std::right << std::setw(10) <<
"Failed" <<
" "
626 << std::right << std::setw(10) <<
"Error" <<
" "
630 << std::right << std::setw(5) << 0
631 << std::right << std::setw(5) <<
p.bitPosition <<
" "
632 << std::right << std::setw(10) <<
p.timesRun <<
" "
633 << std::right << std::setw(10) <<
p.timesPassed <<
" "
634 << std::right << std::setw(10) <<
p.timesFailed <<
" "
635 << std::right << std::setw(10) <<
p.timesExcept <<
" "
641 LogVerbatim(
"FwkSummary") <<
"TrigReport " <<
"---------- Modules in Path: " <<
p.name <<
" ------------";
643 << std::right << std::setw(10) <<
"Trig Bit#" <<
" "
644 << std::right << std::setw(10) <<
"Visited" <<
" "
645 << std::right << std::setw(10) <<
"Passed" <<
" "
646 << std::right << std::setw(10) <<
"Failed" <<
" "
647 << std::right << std::setw(10) <<
"Error" <<
" "
650 unsigned int bitpos = 0;
651 for (
auto const&
mod:
p.moduleInPathSummaries) {
653 << std::right << std::setw(5) << 1
654 << std::right << std::setw(5) << bitpos <<
" "
655 << std::right << std::setw(10) <<
mod.timesVisited <<
" "
656 << std::right << std::setw(10) <<
mod.timesPassed <<
" "
657 << std::right << std::setw(10) <<
mod.timesFailed <<
" "
658 << std::right << std::setw(10) <<
mod.timesExcept <<
" "
659 <<
mod.moduleLabel <<
"";
666 LogVerbatim(
"FwkSummary") <<
"TrigReport " <<
"------ Modules in End-Path: " <<
p.name <<
" ------------";
668 << std::right << std::setw(10) <<
"Trig Bit#" <<
" "
669 << std::right << std::setw(10) <<
"Visited" <<
" "
670 << std::right << std::setw(10) <<
"Passed" <<
" "
671 << std::right << std::setw(10) <<
"Failed" <<
" "
672 << std::right << std::setw(10) <<
"Error" <<
" "
675 unsigned int bitpos=0;
676 for (
auto const&
mod:
p.moduleInPathSummaries) {
678 << std::right << std::setw(5) << 0
679 << std::right << std::setw(5) << bitpos <<
" "
680 << std::right << std::setw(10) <<
mod.timesVisited <<
" "
681 << std::right << std::setw(10) <<
mod.timesPassed <<
" "
682 << std::right << std::setw(10) <<
mod.timesFailed <<
" "
683 << std::right << std::setw(10) <<
mod.timesExcept <<
" "
684 <<
mod.moduleLabel <<
"";
690 LogVerbatim(
"FwkSummary") <<
"TrigReport " <<
"---------- Module Summary ------------";
692 << std::right << std::setw(10) <<
"Visited" <<
" "
693 << std::right << std::setw(10) <<
"Executed" <<
" "
694 << std::right << std::setw(10) <<
"Passed" <<
" "
695 << std::right << std::setw(10) <<
"Failed" <<
" "
696 << std::right << std::setw(10) <<
"Error" <<
" "
700 << std::right << std::setw(10) << worker.timesVisited <<
" "
701 << std::right << std::setw(10) << worker.timesRun <<
" "
702 << std::right << std::setw(10) << worker.timesPassed <<
" "
703 << std::right << std::setw(10) << worker.timesFailed <<
" "
704 << std::right << std::setw(10) << worker.timesExcept <<
" "
705 << worker.moduleLabel <<
"";
715 LogVerbatim(
"FwkSummary") <<
"TimeReport " <<
"---------- Event Summary ---[sec]----";
717 << std::setprecision(6) << std::fixed
720 << std::setprecision(6) << std::fixed
723 << std::setprecision(6) << std::fixed
726 << std::setprecision(6) << std::fixed
733 LogVerbatim(
"FwkSummary") <<
"TimeReport " <<
"---------- Path Summary ---[Real sec]----";
735 << std::right << std::setw(kColumn1Size) <<
"per event"<<
" "
736 << std::right << std::setw(kColumn2Size) <<
"per exec"
739 const int timesRun =
std::max(1,
p.timesRun);
741 << std::setprecision(6) << std::fixed
742 << std::right << std::setw(kColumn1Size) <<
p.realTime/totalEvents <<
" "
743 << std::right << std::setw(kColumn2Size) <<
p.realTime/timesRun <<
" "
747 << std::right << std::setw(kColumn1Size) <<
"per event"<<
" "
748 << std::right << std::setw(kColumn2Size) <<
"per exec"
752 LogVerbatim(
"FwkSummary") <<
"TimeReport " <<
"-------End-Path Summary ---[Real sec]----";
754 << std::right << std::setw(kColumn1Size) <<
"per event" <<
" "
755 << std::right << std::setw(kColumn2Size) <<
"per exec"
758 const int timesRun =
std::max(1,
p.timesRun);
761 << std::setprecision(6) << std::fixed
762 << std::right << std::setw(kColumn1Size) <<
p.realTime/totalEvents <<
" "
763 << std::right << std::setw(kColumn2Size) <<
p.realTime/timesRun <<
" "
767 << std::right << std::setw(kColumn1Size) <<
"per event" <<
" "
768 << std::right << std::setw(kColumn2Size) <<
"per exec"
773 LogVerbatim(
"FwkSummary") <<
"TimeReport " <<
"---------- Modules in Path: " <<
p.name <<
" ---[Real sec]----";
775 << std::right << std::setw(kColumn1Size) <<
"per event" <<
" "
776 << std::right << std::setw(kColumn2Size) <<
"per visit"
778 for (
auto const&
mod:
p.moduleInPathSummaries) {
780 << std::setprecision(6) << std::fixed
781 << std::right << std::setw(kColumn1Size) <<
mod.realTime/totalEvents <<
" "
782 << std::right << std::setw(kColumn2Size) <<
mod.realTime/
std::max(1,
mod.timesVisited) <<
" "
783 <<
mod.moduleLabel <<
"";
788 << std::right << std::setw(kColumn1Size) <<
"per event" <<
" "
789 << std::right << std::setw(kColumn2Size) <<
"per visit"
794 LogVerbatim(
"FwkSummary") <<
"TimeReport " <<
"------ Modules in End-Path: " <<
p.name <<
" ---[Real sec]----";
796 << std::right << std::setw(kColumn1Size) <<
"per event" <<
" "
797 << std::right << std::setw(kColumn2Size) <<
"per visit"
799 for (
auto const&
mod:
p.moduleInPathSummaries) {
801 << std::setprecision(6) << std::fixed
802 << std::right << std::setw(kColumn1Size) <<
mod.realTime/totalEvents <<
" "
803 << std::right << std::setw(kColumn2Size) <<
mod.realTime/
std::max(1,
mod.timesVisited) <<
" "
804 <<
mod.moduleLabel <<
"";
809 << std::right << std::setw(kColumn1Size) <<
"per event" <<
" "
810 << std::right << std::setw(kColumn2Size) <<
"per visit"
814 LogVerbatim(
"FwkSummary") <<
"TimeReport " <<
"---------- Module Summary ---[Real sec]----";
816 << std::right << std::setw(kColumn1Size) <<
"per event" <<
" "
817 << std::right << std::setw(kColumn2Size) <<
"per exec" <<
" "
818 << std::right << std::setw(kColumn3Size) <<
"per visit"
822 << std::setprecision(6) << std::fixed
823 << std::right << std::setw(kColumn1Size) << worker.realTime/totalEvents <<
" "
824 << std::right << std::setw(kColumn2Size) << worker.realTime/
std::max(1, worker.timesRun) <<
" "
825 << std::right << std::setw(kColumn3Size) << worker.realTime/
std::max(1, worker.timesVisited) <<
" "
826 << worker.moduleLabel <<
"";
829 << std::right << std::setw(kColumn1Size) <<
"per event" <<
" "
830 << std::right << std::setw(kColumn2Size) <<
"per exec" <<
" "
831 << std::right << std::setw(kColumn3Size) <<
"per visit"
835 LogVerbatim(
"FwkSummary") <<
"T---Report end!" <<
"";
840 using std::placeholders::_1;
845 using std::placeholders::_1;
850 using std::placeholders::_1;
855 using std::placeholders::_1;
860 using std::placeholders::_1;
865 using std::placeholders::_1;
873 using std::placeholders::_1;
878 using std::placeholders::_1;
899 using std::placeholders::_1;
903 using std::placeholders::_1;
912 if (worker->description().moduleLabel() == iLabel) {
917 if (
nullptr == found) {
926 s->replaceModule(newMod,iLabel);
942 std::vector<ModuleDescription const*>
944 std::vector<ModuleDescription const*>
result;
976 std::vector<std::string>& oLabelsToFill)
const {
982 std::vector<ModuleDescription const*>& descriptions,
983 unsigned int hint)
const {
984 streamSchedules_[0]->moduleDescriptionsInPath(iPathLabel, descriptions, hint);
989 std::vector<ModuleDescription const*>& descriptions,
990 unsigned int hint)
const {
991 streamSchedules_[0]->moduleDescriptionsInEndPath(iEndPathLabel, descriptions, hint);
996 std::vector<std::pair<unsigned int, unsigned int> >& moduleIDToIndex,
997 std::vector<std::vector<ModuleDescription const*> >& modulesWhoseProductsAreConsumedBy,
999 allModuleDescriptions.clear();
1000 moduleIDToIndex.clear();
1001 modulesWhoseProductsAreConsumedBy.clear();
1007 std::map<std::string, ModuleDescription const*> labelToDesc;
1011 allModuleDescriptions.push_back(p);
1012 moduleIDToIndex.push_back(std::pair<unsigned int, unsigned int>(p->
id(),
i));
1020 std::vector<ModuleDescription const*>&
modules = modulesWhoseProductsAreConsumedBy.at(i);
1021 worker->modulesWhoseProductsAreConsumed(modules, preg, labelToDesc);
1030 s->enableEndPaths(active);
1045 s->getTriggerReport(rep);
1059 int returnValue = 0;
1061 returnValue += s->totalEvents();
1068 int returnValue = 0;
1070 returnValue += s->totalEventsPassed();
1077 int returnValue = 0;
1079 returnValue += s->totalEventsFailed();
1134 typedef std::pair<unsigned int, unsigned int> SimpleEdge;
1135 typedef std::map<SimpleEdge, std::vector<unsigned int>> EdgeToPathMap;
1137 typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS> Graph;
1139 typedef boost::graph_traits<Graph>::edge_descriptor Edge;
1140 struct cycle_detector :
public boost::dfs_visitor<> {
1142 cycle_detector(EdgeToPathMap
const& iEdgeToPathMap,
1143 std::vector<std::string>
const& iPathNames,
1144 std::map<std::string,unsigned int>
const& iModuleNamesToIndex):
1145 m_edgeToPathMap(iEdgeToPathMap),
1146 m_pathNames(iPathNames),
1147 m_namesToIndex(iModuleNamesToIndex){}
1149 void tree_edge(Edge iEdge, Graph
const&) {
1150 m_stack.push_back(iEdge);
1153 void finish_edge(Edge iEdge, Graph
const& iGraph) {
1154 if(not m_stack.empty()) {
1155 if (iEdge == m_stack.back()) {
1162 void back_edge(Edge iEdge, Graph
const& iGraph) {
1167 IndexMap
const&
index =
get(boost::vertex_index, iGraph);
1169 unsigned int vertex = index[
target(iEdge,iGraph)];
1172 std::list<Edge>::iterator itFirst = m_stack.begin();
1174 bool seenVertex =
false;
1175 while(itFirst != m_stack.end()) {
1176 if(not seenVertex) {
1177 if(index[
source(*itFirst,iGraph)] == vertex) {
1181 if (index[
source(*itFirst,iGraph)] != vertex) {
1186 if(itFirst != m_stack.begin()) {
1193 std::vector<Edge> tempStack;
1194 tempStack.reserve(m_stack.size()+1);
1195 tempStack.insert(tempStack.end(),itFirst,m_stack.end());
1196 tempStack.emplace_back(iEdge);
1198 unsigned int nPathDependencyOnly =0;
1199 for(
auto const&
edge: tempStack) {
1203 auto iFound = m_edgeToPathMap.find(SimpleEdge(in,out));
1204 bool pathDependencyOnly =
true;
1205 for(
auto dependency : iFound->second) {
1207 pathDependencyOnly =
false;
1211 if (pathDependencyOnly) {
1212 ++nPathDependencyOnly;
1215 if(nPathDependencyOnly < 2) {
1216 reportError(tempStack,index,iGraph);
1221 return m_pathNames[iIndex];
1225 for(
auto const& item : m_namesToIndex) {
1226 if(item.second == iIndex) {
1234 reportError(std::vector<Edge>
const& iEdges,
1236 Graph
const& iGraph)
const {
1237 std::stringstream oStream;
1238 oStream <<
"Module run order problem found: \n";
1239 bool first_edge =
true;
1240 for(
auto const&
edge: iEdges) {
1241 unsigned int in =iIndex[
source(
edge,iGraph)];
1242 unsigned int out =iIndex[
target(
edge,iGraph)];
1251 auto iFound = m_edgeToPathMap.find(SimpleEdge(in,out));
1252 bool pathDependencyOnly =
true;
1253 for(
auto dependency : iFound->second) {
1255 pathDependencyOnly =
false;
1259 if (pathDependencyOnly) {
1265 oStream<<
"\n Running in the threaded framework would lead to indeterminate results."
1266 "\n Please change order of modules in mentioned Path(s) to avoid inconsistent module ordering.";
1268 LogError(
"UnrunnableSchedule")<<oStream.str();
1271 EdgeToPathMap
const& m_edgeToPathMap;
1272 std::vector<std::string>
const& m_pathNames;
1273 std::map<std::string,unsigned int> m_namesToIndex;
1275 std::list<Edge> m_stack;
1283 std::map<std::string,unsigned int> moduleNamesToIndex;
1285 moduleNamesToIndex.insert( std::make_pair(worker->description().moduleLabel(),
1286 worker->description().id()));
1290 EdgeToPathMap edgeToPathMap;
1293 std::vector<std::string> pathNames;
1297 std::vector<std::string> moduleNames;
1298 std::vector<std::string> reducedModuleNames;
1299 unsigned int pathIndex=0;
1300 for(
auto const&
path: pathNames) {
1301 moduleNames.clear();
1302 reducedModuleNames.clear();
1303 std::set<std::string> alreadySeenNames;
1307 unsigned int lastModuleIndex;
1308 for(
auto const&
name: moduleNames) {
1309 auto found = alreadySeenNames.insert(
name);
1312 unsigned int moduleIndex = moduleNamesToIndex[
name];
1313 if(not lastModuleName.empty() ) {
1314 edgeToPathMap[std::make_pair(moduleIndex,lastModuleIndex)].push_back(pathIndex);
1316 lastModuleName =
name;
1317 lastModuleIndex = moduleIndex;
1324 std::vector<const char*> dependentModules;
1327 dependentModules.clear();
1329 worker->modulesDependentUpon(dependentModules);
1330 auto found = moduleNamesToIndex.find(worker->description().moduleLabel());
1331 if (
found == moduleNamesToIndex.end()) {
1335 unsigned int moduleIndex =
found->second;
1336 for(
auto name: dependentModules) {
1342 std::vector<SimpleEdge> outList;
1343 outList.reserve(edgeToPathMap.size());
1344 for(
auto const& edgeInfo: edgeToPathMap) {
1345 outList.push_back(edgeInfo.first);
1348 Graph
g(outList.begin(),outList.end(), moduleNamesToIndex.size());
1350 cycle_detector detector(edgeToPathMap,pathNames,moduleNamesToIndex);
1351 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
tuple path
else: Piece not in the list, fine.
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_
void setProcessParameterSetID(ParameterSetID const &id)
Associated free functions.
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
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)