43 template <
typename InputIterator,
typename ForwardIterator,
typename Func>
45 transform_into(InputIterator
begin, InputIterator
end,
46 ForwardIterator
out, Func func) {
47 for (; begin !=
end; ++
begin, ++
out) func(*begin, *out);
55 template <
typename FROM,
typename TO,
typename FUNC>
57 fill_summary(FROM
const& from, TO&
to, FUNC func) {
58 if(to.size()!=from.size()) {
60 transform_into(from.begin(), from.end(),
temp.begin(), func);
63 transform_into(from.begin(), from.end(), to.begin(), func);
73 makeInserter(ExceptionToActionTable
const&
actions,
74 std::shared_ptr<ActivityRegistry>
areg,
75 std::shared_ptr<TriggerResultInserter> inserter) {
77 ptr->setActivityRegistry(areg);
83 ProductRegistry
const&
preg,
84 std::multimap<std::string,Worker*>& branchToReadingWorker)
87 auto vBranchesToDeleteEarly = opts.getUntrackedParameter<std::vector<std::string>>(
"canDeleteEarly",std::vector<std::string>());
88 if(not vBranchesToDeleteEarly.empty()) {
89 std::sort(vBranchesToDeleteEarly.begin(),vBranchesToDeleteEarly.end(),std::less<std::string>());
90 vBranchesToDeleteEarly.erase(std::unique(vBranchesToDeleteEarly.begin(),vBranchesToDeleteEarly.end()),
91 vBranchesToDeleteEarly.end());
94 auto allBranchNames =
preg.allBranchNames();
96 for(
auto &
b:allBranchNames) {
99 std::sort(allBranchNames.begin(),allBranchNames.end(),std::less<std::string>());
100 std::vector<std::string>
temp;
101 temp.reserve(vBranchesToDeleteEarly.size());
103 std::set_intersection(vBranchesToDeleteEarly.begin(),vBranchesToDeleteEarly.end(),
104 allBranchNames.begin(),allBranchNames.end(),
105 std::back_inserter(temp));
106 vBranchesToDeleteEarly.swap(temp);
107 if(temp.size() != vBranchesToDeleteEarly.size()) {
108 std::vector<std::string> missingProducts;
109 std::set_difference(temp.begin(),temp.end(),
110 vBranchesToDeleteEarly.begin(),vBranchesToDeleteEarly.end(),
111 std::back_inserter(missingProducts));
112 LogInfo
l(
"MissingProductsForCanDeleteEarly");
113 l<<
"The following products in the 'canDeleteEarly' list are not available in this job and will be ignored.";
114 for(
auto const&
n:missingProducts){
120 for(
auto const& branch:vBranchesToDeleteEarly) {
121 branchToReadingWorker.insert(std::make_pair(branch, static_cast<Worker*>(
nullptr)));
129 typedef std::vector<std::string>
vstring;
134 std::shared_ptr<ModuleRegistry> modReg,
141 std::shared_ptr<ActivityRegistry> areg,
143 bool allowEarlyDelete,
146 workerManager_(modReg,areg, actions),
148 trig_name_list_(tns.getTrigPaths()),
149 end_path_name_list_(tns.getEndPaths()),
156 number_of_unscheduled_modules_(0),
158 streamContext_(streamID_, processContext),
162 bool hasPath =
false;
168 fillTrigPath(proc_pset, preg, &prealloc, processConfiguration, trig_bitpos, trig_name,
results_, &labelsOnTriggerPaths);
185 fillEndPath(proc_pset, preg, &prealloc, processConfiguration, bitpos, end_path_name);
190 std::set<std::string> usedWorkerLabels;
192 usedWorkerLabels.insert(worker->description().moduleLabel());
194 std::vector<std::string> modulesInConfig(proc_pset.
getParameter<std::vector<std::string> >(
"@all_modules"));
195 std::set<std::string> modulesInConfigSet(modulesInConfig.begin(), modulesInConfig.end());
196 std::vector<std::string> unusedLabels;
197 set_difference(modulesInConfigSet.begin(), modulesInConfigSet.end(),
198 usedWorkerLabels.begin(), usedWorkerLabels.end(),
199 back_inserter(unusedLabels));
202 std::set<std::string> unscheduledLabels;
203 std::vector<std::string> shouldBeUsedLabels;
204 if (!unusedLabels.empty()) {
209 for (
auto const&
label : unusedLabels) {
210 if (allowUnscheduled) {
214 assert(modulePSet !=
nullptr);
218 shouldBeUsedLabels.push_back(
label);
221 if (!shouldBeUsedLabels.empty()) {
222 std::ostringstream unusedStream;
223 unusedStream <<
"'" << shouldBeUsedLabels.front() <<
"'";
224 for (std::vector<std::string>::iterator itLabel = shouldBeUsedLabels.begin() + 1,
225 itLabelEnd = shouldBeUsedLabels.end();
226 itLabel != itLabelEnd;
228 unusedStream <<
",'" << *itLabel <<
"'";
231 <<
"The following module labels are not assigned to any path:\n"
232 << unusedStream.str()
236 if (!unscheduledLabels.empty()) {
249 bool allowEarlyDelete) {
252 if(not allowEarlyDelete)
return;
256 std::multimap<std::string,Worker*> branchToReadingWorker;
257 initializeBranchToReadingWorker(opts,preg,branchToReadingWorker);
260 if(branchToReadingWorker.size()==0) {
263 const std::vector<std::string> kEmpty;
264 std::map<Worker*,unsigned int> reserveSizeForWorker;
265 unsigned int upperLimitOnReadingWorker =0;
266 unsigned int upperLimitOnIndicies = 0;
267 unsigned int nUniqueBranchesToDelete=branchToReadingWorker.size();
273 if(branchToReadingWorker.size()>0) {
277 for(
auto const& item: kept[
InEvent]) {
278 auto found = branchToReadingWorker.equal_range(item->branchName());
280 --nUniqueBranchesToDelete;
281 branchToReadingWorker.erase(
found.first,
found.second);
288 if(branchToReadingWorker.size()==0) {
296 auto branches = pset->getUntrackedParameter<std::vector<std::string>>(
"mightGet",kEmpty);
297 if(not branches.empty()) {
298 ++upperLimitOnReadingWorker;
300 for(
auto const& branch:branches){
301 auto found = branchToReadingWorker.equal_range(branch);
303 ++upperLimitOnIndicies;
304 ++reserveSizeForWorker[
w];
305 if(
nullptr ==
found.first->second) {
308 branchToReadingWorker.insert(make_pair(
found.first->first,
w));
315 auto it = branchToReadingWorker.begin();
316 std::vector<std::string> unusedBranches;
317 while(it !=branchToReadingWorker.end()) {
318 if(it->second ==
nullptr) {
319 unusedBranches.push_back(it->first);
323 branchToReadingWorker.erase(temp);
328 if(not unusedBranches.empty()) {
330 l<<
"The following products in the 'canDeleteEarly' list are not used in this job and will be ignored.\n"
331 " If possible, remove the producer from the job or add the product to the producer's own 'mightGet' list.";
332 for(
auto const&
n:unusedBranches){
337 if(0!=branchToReadingWorker.size()) {
341 std::map<const Worker*,EarlyDeleteHelper*> alreadySeenWorkers;
343 size_t nextOpenIndex = 0;
345 for(
auto& branchAndWorker:branchToReadingWorker) {
346 if(lastBranchName != branchAndWorker.first) {
348 BranchID bid(branchAndWorker.first+
".");
350 lastBranchName = branchAndWorker.first;
352 auto found = alreadySeenWorkers.find(branchAndWorker.second);
353 if(alreadySeenWorkers.end() ==
found) {
358 size_t index = nextOpenIndex;
359 size_t nIndices = reserveSizeForWorker[branchAndWorker.second];
362 beginAddress+index+1,
365 alreadySeenWorkers.insert(std::make_pair(branchAndWorker.second,&(
earlyDeleteHelpers_.back())));
366 nextOpenIndex +=nIndices;
376 if(itLast->end() != it->begin()) {
378 unsigned int delta = it->begin()- itLast->end();
379 it->shiftIndexPointers(delta);
382 (itLast->end()-beginAddress),
384 (it->begin()-beginAddress));
393 p.setEarlyDeleteHelpers(alreadySeenWorkers);
396 p.setEarlyDeleteHelpers(alreadySeenWorkers);
413 unsigned int placeInPath = 0;
414 for (
auto const& name : modnames) {
416 if (labelsOnPaths) labelsOnPaths->push_back(name);
433 "The unknown module label \"" << moduleLabel <<
434 "\" appears in " << pathType <<
" \"" << name <<
435 "\"\n please check spelling or remove that label from the path.";
448 <<
"The EDFilter '" << worker->
description().
moduleName() <<
"' with module label '" << moduleLabel <<
"' appears on EndPath '" << name <<
"'.\n"
449 <<
"The return value of the filter will be ignored.\n"
450 <<
"To suppress this warning, either remove the filter from the endpath,\n"
451 <<
"or explicitly ignore it in the configuration by using cms.ignore().\n";
454 tmpworkers.emplace_back(worker, filterAction, placeInPath);
458 out.swap(tmpworkers);
466 vstring* labelsOnTriggerPaths) {
467 using std::placeholders::_1;
470 fillWorkers(proc_pset, preg, prealloc, processConfiguration, name,
false, tmpworkers, labelsOnTriggerPaths);
472 for (PathWorkers::iterator wi(tmpworkers.begin()),
473 we(tmpworkers.end()); wi != we; ++wi) {
474 holder.push_back(wi->getWorker());
478 if (!tmpworkers.empty()) {
492 using std::placeholders::_1;
494 fillWorkers(proc_pset, preg, prealloc, processConfiguration, name,
true, tmpworkers, 0);
497 for (PathWorkers::iterator wi(tmpworkers.begin()), we(tmpworkers.end()); wi != we; ++wi) {
498 holder.push_back(wi->getWorker());
501 if (!tmpworkers.empty()) {
519 if (worker->description().moduleLabel() == iLabel) {
524 if (
nullptr == found) {
532 std::vector<ModuleDescription const*>
534 std::vector<ModuleDescription const*>
result;
549 std::back_inserter(oLabelsToFill),
550 std::bind(&
Path::name, std::placeholders::_1));
565 std::vector<std::string>& oLabelsToFill)
const {
566 TrigPaths::const_iterator itFound =
569 std::bind(std::equal_to<std::string>(),
571 std::bind(&
Path::name, std::placeholders::_1)));
573 oLabelsToFill.reserve(itFound->size());
574 for (
size_t i = 0;
i < itFound->size(); ++
i) {
575 oLabelsToFill.push_back(itFound->getWorker(
i)->description().moduleLabel());
582 std::vector<ModuleDescription const*>& descriptions,
583 unsigned int hint)
const {
584 descriptions.clear();
586 TrigPaths::const_iterator itFound;
590 if(itFound->name() == iPathLabel) found =
true;
596 std::bind(std::equal_to<std::string>(),
598 std::bind(&
Path::name, std::placeholders::_1)));
602 descriptions.reserve(itFound->size());
603 for (
size_t i = 0;
i < itFound->size(); ++
i) {
604 descriptions.push_back(itFound->getWorker(
i)->descPtr());
611 std::vector<ModuleDescription const*>& descriptions,
612 unsigned int hint)
const {
613 descriptions.clear();
615 TrigPaths::const_iterator itFound;
619 if(itFound->name() == iEndPathLabel) found =
true;
625 std::bind(std::equal_to<std::string>(),
627 std::bind(&
Path::name, std::placeholders::_1)));
628 if (itFound !=
end_paths_.end()) found =
true;
631 descriptions.reserve(itFound->size());
632 for (
size_t i = 0;
i < itFound->size(); ++
i) {
633 descriptions.push_back(itFound->getWorker(
i)->descPtr());
670 std::vector<ModuleInPathSummary>
temp(sz);
671 for (
size_t i = 0;
i != sz; ++
i) {
677 for (
size_t i = 0;
i != sz; ++
i) {
711 using std::placeholders::_1;
736 ++(earlyDeleteBranchToCount_[
index].second);
static void fillModuleInPathSummary(Path const &path, size_t which, ModuleInPathSummary &sum)
void triggerPaths(std::vector< std::string > &oLabelsToFill) const
void moduleDescriptionsInEndPath(std::string const &iEndPathLabel, std::vector< ModuleDescription const * > &descriptions, unsigned int hint) const
T getParameter(std::string const &) const
std::vector< PathSummary > endPathSummaries
T getUntrackedParameter(std::string const &, T const &) const
AllWorkers const & allWorkers() const
returns the collection of pointers to workers
std::vector< Worker * > Workers
ModuleDescription const & description() const
std::vector< int > empty_trig_paths_
void moduleDescriptionsInPath(std::string const &iPathLabel, std::vector< ModuleDescription const * > &descriptions, unsigned int hint) const
void endStream(StreamID iID, StreamContext &streamContext)
void fillEndPath(ParameterSet &proc_pset, ProductRegistry &preg, PreallocationConfiguration const *prealloc, std::shared_ptr< ProcessConfiguration const > processConfiguration, int bitpos, std::string const &name)
virtual void replaceModuleFor(Worker *) const =0
int totalEventsFailed() const
void initializeEarlyDelete(ModuleRegistry &modReg, edm::ParameterSet const &opts, edm::ProductRegistry const &preg, bool allowEarlyDelete)
std::shared_ptr< HLTGlobalStatus > TrigResPtr
void setOnDemandProducts(ProductRegistry &pregistry, std::set< std::string > const &unscheduledLabels) const
WorkersInPath::size_type size_type
std::vector< ModuleDescription const * > getAllModuleDescriptions() const
std::vector< std::pair< BranchID, unsigned int > > earlyDeleteBranchToCount_
void addToUnscheduledWorkers(ParameterSet &pset, ProductRegistry &preg, PreallocationConfiguration const *prealloc, std::shared_ptr< ProcessConfiguration > processConfiguration, std::string label, std::set< std::string > &unscheduledLabels, std::vector< std::string > &shouldBeUsedLabels)
volatile bool endpathsAreActive_
std::string const & moduleName() const
void addToAllWorkers(Worker *w)
vstring end_path_name_list_
ParameterSet getUntrackedParameterSet(std::string const &name, ParameterSet const &defaultValue) const
ExceptionToActionTable const & actionTable() const
returns the action table
void beginStream(StreamID id, StreamContext &streamContext)
std::shared_ptr< Worker > WorkerPtr
std::vector< WorkerSummary > workerSummaries
std::string const & moduleLabel() const
unsigned int number_of_unscheduled_modules_
WorkerManager workerManager_
std::shared_ptr< ActivityRegistry > actReg_
Func for_all(ForwardSequence &s, Func f)
wrapper for std::for_each
std::vector< WorkerInPath > PathWorkers
int totalEventsPassed() const
void getTriggerReport(TriggerReport &rep) const
std::vector< PathSummary > trigPathSummaries
EventSummary eventSummary
StreamSchedule(std::shared_ptr< TriggerResultInserter > inserter, std::shared_ptr< ModuleRegistry >, ParameterSet &proc_pset, service::TriggerNamesService &tns, PreallocationConfiguration const &prealloc, ProductRegistry &pregistry, BranchIDListHelper &branchIDListHelper, ExceptionToActionTable const &actions, std::shared_ptr< ActivityRegistry > areg, std::shared_ptr< ProcessConfiguration > processConfiguration, bool allowEarlyDelete, StreamID streamID, ProcessContext const *processContext)
void fillWorkers(ParameterSet &proc_pset, ProductRegistry &preg, PreallocationConfiguration const *prealloc, std::shared_ptr< ProcessConfiguration const > processConfiguration, std::string const &name, bool ignoreFilters, PathWorkers &out, vstring *labelsOnPaths)
StreamContext streamContext_
std::vector< std::string > vstring
static void fillPathSummary(Path const &path, PathSummary &sum)
bool getMapped(key_type const &k, value_type &result) const
vstring empty_trig_path_names_
static void fillWorkerSummaryAux(Worker const &w, WorkerSummary &sum)
virtual Types moduleType() const =0
void beginStream(StreamID iID, StreamContext &streamContext)
void clearCounters()
Clear all the counters in the trigger report.
WorkerPtr results_inserter_
unsigned int value() const
boost::array< SelectedProducts, NumBranchTypes > SelectedProductsForBranchType
std::vector< unsigned int > earlyDeleteHelperToBranchIndicies_
void forAllModuleHolders(F iFunc)
bool search_all(ForwardSequence const &s, Datum const &d)
int timesVisited(size_type i) const
virtual std::unique_ptr< OutputModuleCommunicator > createOutputModuleCommunicator()=0
static void fillWorkerSummary(Worker const *pw, WorkerSummary &sum)
bool endPathsEnabled() const
std::string const & name() const
void fillTrigPath(ParameterSet &proc_pset, ProductRegistry &preg, PreallocationConfiguration const *prealloc, std::shared_ptr< ProcessConfiguration const > processConfiguration, int bitpos, std::string const &name, TrigResPtr, vstring *labelsOnTriggerPaths)
Worker const * getWorker(size_type i) const
void replaceModule(maker::ModuleHolder *iMod, std::string const &iLabel)
clone the type of module with label iLabel but configure with iPSet.
void enableEndPaths(bool active)
std::vector< ModuleInPathSummary > moduleInPathSummaries
std::vector< std::string > vstring
tuple size
Write out results.
static Registry * instance()
Worker * getWorker(ParameterSet &pset, ProductRegistry &preg, PreallocationConfiguration const *prealloc, std::shared_ptr< ProcessConfiguration const > processConfiguration, std::string const &label)
void availablePaths(std::vector< std::string > &oLabelsToFill) const
adds to oLabelsToFill the labels for all paths in the process
std::vector< EarlyDeleteHelper > earlyDeleteHelpers_
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 addToAllWorkers(Worker *w)
void endPaths(std::vector< std::string > &oLabelsToFill) const
adds to oLabelsToFill the labels for all end paths in the process
ParameterSet * getPSetForUpdate(std::string const &name, bool &isTracked)