38 #include "boost/range/adaptor/reversed.hpp" 48 std::shared_ptr<ProductRegistry const> parentProductRegistry,
49 std::shared_ptr<BranchIDListHelper const> parentBranchIDListHelper,
60 parentPreg_(parentProductRegistry),
62 branchIDListHelper_(),
64 processConfiguration_(),
65 historyLumiOffset_(preallocConfig.numberOfStreams()),
66 historyRunOffset_(historyLumiOffset_ + preallocConfig.numberOfLuminosityBlocks()),
67 processHistoryRegistries_(historyRunOffset_ + preallocConfig.numberOfRuns()),
68 historyAppenders_(historyRunOffset_ + preallocConfig.numberOfRuns()),
74 processParameterSet_(),
75 productSelectorRules_(parameterSet,
"outputCommands",
"OutputModule"),
77 wantAllEvents_(
true) {
86 std::map<std::string, std::vector<std::pair<std::string, int>>> outputModulePathPositions;
88 selectevents,
"", outputModulePathPositions, parentProductRegistry->anyProductProduced());
90 std::map<BranchID, bool> keepAssociation;
91 selectProducts(*parentProductRegistry, parentThinnedAssociationsHelper, keepAssociation);
109 if (topLevelParameterSet.
exists(maxEvents)) {
113 if (topLevelParameterSet.
exists(maxLumis)) {
120 bool hasSubProcesses = subProcessVParameterSet.size() != 0ull;
153 thinnedAssociationsHelper_->updateFromParentProcess(
161 preg_ = items.preg();
177 auto ep = std::make_shared<EventPrincipal>(
preg_,
187 auto lbpp = std::make_unique<LuminosityBlockPrincipal>(
195 for (
auto& subProcessPSet : subProcessVParameterSet) {
197 topLevelParameterSet,
200 *thinnedAssociationsHelper_,
240 "Multiple exceptions were thrown while executing endJob. An exception message follows for each.");
243 c.
call([&subProcess]() { subProcess.doEndJob(); });
252 std::map<BranchID, bool>& keepAssociation) {
261 std::map<BranchID, BranchDescription const*> trueBranchIDToKeptBranchDesc;
262 std::vector<BranchDescription const*> associationDescriptions;
263 std::set<BranchID> keptProductsInEvent;
273 associationDescriptions.push_back(&desc);
275 keepThisBranch(desc, trueBranchIDToKeptBranchDesc, keptProductsInEvent);
280 associationDescriptions, keptProductsInEvent, keepAssociation);
293 std::map<BranchID, BranchDescription const*>& trueBranchIDToKeptBranchDesc,
294 std::set<BranchID>& keptProductsInEvent) {
301 keptProductsInEvent.insert(desc.
branchID());
317 std::map<BranchID::value_type, BranchID::value_type>::const_iterator iter =
318 droppedBranchIDToKeptBranchID.find(branchID);
319 if (iter != droppedBranchIDToKeptBranchID.end()) {
320 branchID = iter->second;
325 subProcess.fixBranchIDListsForEDAliases(droppedBranchIDToKeptBranchID);
354 processHistoryRegistry.registerProcessHistory(principal.
processHistory());
357 bool deepCopyRetriever =
false;
360 processHistoryRegistry,
370 make_waiting_task(tbb::task::allocate_root(), [&ep, iHolder](std::exception_ptr
const* iPtr)
mutable {
380 afterProcessTask =
std::move(finalizeEventTask);
383 tbb::task::allocate_root(), [
this, &ep, finalizeEventTask](std::exception_ptr
const* iPtr)
mutable {
386 subProcess.doEventAsync(finalizeEventTask, ep);
401 auto aux = std::make_shared<RunAuxiliary>(principal.
aux());
403 auto rpp = std::make_shared<RunPrincipal>(
aux,
410 processHistoryRegistry.registerProcessHistory(principal.
processHistory());
411 rpp->fillRunPrincipal(processHistoryRegistry, principal.
reader());
422 beginGlobalTransitionAsync<Traits>(
429 bool cleaningUpAfterException) {
433 endGlobalTransitionAsync<Traits>(
std::move(iHolder),
440 cleaningUpAfterException);
448 std::map<ProcessHistoryID, ProcessHistoryID>::const_iterator it =
parentToChildPhID_.find(parentPhID);
450 auto const& childPhID = it->second;
453 tbb::task::allocate_root(),
454 [
this, childPhID, runNumber, task, mergeableRunProductMetadata](std::exception_ptr
const* iExcept)
mutable {
460 s.writeRunAsync(task, childPhID, runNumber, mergeableRunProductMetadata);
468 mergeableRunProductMetadata);
472 std::map<ProcessHistoryID, ProcessHistoryID>::const_iterator it =
parentToChildPhID_.find(parentPhID);
474 auto const& childPhID = it->second;
477 [&childPhID, runNumber](
auto& subProcess) { subProcess.deleteRunFromCache(childPhID, runNumber); });
485 auto aux = principal.
aux();
491 processHistoryRegistry.registerProcessHistory(principal.
processHistory());
492 lbpp->fillLuminosityBlockPrincipal(processHistoryRegistry, principal.
reader());
497 beginGlobalTransitionAsync<Traits>(
504 bool cleaningUpAfterException) {
508 endGlobalTransitionAsync<Traits>(
std::move(iHolder),
515 cleaningUpAfterException);
523 edm::make_waiting_task(tbb::task::allocate_root(), [
this,
l, task](std::exception_ptr
const* iExcept)
mutable {
529 s.writeLumiAsync(task, *
l);
540 s.deleteLumiFromCache(*lb);
542 lb->clearPrincipal();
565 beginStreamTransitionAsync<Traits>(
573 bool cleaningUpAfterException) {
577 endStreamTransitionAsync<Traits>(
std::move(iHolder),
585 cleaningUpAfterException);
596 beginStreamTransitionAsync<Traits>(
604 bool cleaningUpAfterException) {
607 endStreamTransitionAsync<Traits>(
std::move(iHolder),
615 cleaningUpAfterException);
620 for (
auto const& item : keptVector) {
623 if (parentProductResolver !=
nullptr) {
625 if (productResolver !=
nullptr) {
628 productResolver->
connectTo(*parentProductResolver, &parentPrincipal);
637 [
this](
auto& subProcess) { subProcess.updateBranchIDListHelper(
branchIDListHelper_->branchIDLists()); });
649 std::vector<std::string> subProcesses =
651 if (!subProcesses.empty()) {
unsigned int historyRunOffset_
unsigned int historyLumiOffset_
ParameterSetID selector_config_id_
void insert(std::shared_ptr< RunPrincipal > rp)
void setLuminosityBlockPrincipal(LuminosityBlockPrincipal *lbp)
ProductRegistry const & productRegistry() const
ProductResolverBase * getModifiableProductResolver(BranchID const &oid)
void doEventAsync(WaitingTaskHolder iHolder, EventPrincipal const &principal)
T getUntrackedParameter(std::string const &, T const &) const
bool selected(BranchDescription const &desc) const
bool wantEvent(EventForOutput const &e)
EventSelectionIDVector const & eventSelectionIDs() const
void respondToOpenInputFile(FileBlock const &fb)
BranchType const & branchType() const
std::vector< BranchIDList > BranchIDLists
ProcessHistoryID const & reducedProcessHistoryID() const
void doStreamBeginRunAsync(WaitingTaskHolder iHolder, unsigned int iID, RunPrincipal const &principal, IOVSyncValue const &ts)
std::unique_ptr< ParameterSet > popParameterSet(std::string const &name)
static void fillDroppedToKept(ProductRegistry const &preg, std::map< BranchID, BranchDescription const * > const &trueBranchIDToKeptBranchDesc, std::map< BranchID::value_type, BranchID::value_type > &droppedBranchIDToKeptBranchID_)
void setNumberOfConcurrentPrincipals(PreallocationConfiguration const &)
std::shared_ptr< BranchIDListHelper const > branchIDListHelper() const
std::vector< ProcessHistoryRegistry > processHistoryRegistries_
edm::propagate_const< std::shared_ptr< ThinnedAssociationsHelper > > thinnedAssociationsHelper_
std::vector< SubProcess > subProcesses_
void updateLookup(BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
void doStreamEndRunAsync(WaitingTaskHolder iHolder, unsigned int iID, RunPrincipal const &principal, IOVSyncValue const &ts, bool cleaningUpAfterException)
PathsAndConsumesOfModules pathsAndConsumesOfModules_
bool exists(std::string const ¶meterName) const
checks if a parameter exists
void updateBranchIDListHelper(BranchIDLists const &)
LuminosityBlockAuxiliary const & aux() const
SelectedProductsForBranchType const & keptProducts() const
std::string const & processName() const
LuminosityBlockIndex index() const
void doEndStream(unsigned int)
ParameterSet getUntrackedParameterSet(std::string const &name, ParameterSet const &defaultValue) const
void doStreamEndLuminosityBlockAsync(WaitingTaskHolder iHolder, unsigned int iID, LuminosityBlockPrincipal const &principal, IOVSyncValue const &ts, bool cleaningUpAfterException)
std::shared_ptr< EventSetupProvider > makeProvider(ParameterSet &, ActivityRegistry *)
void setParentProcessContext(ProcessContext const *parentProcessContext)
std::map< BranchID::value_type, BranchID::value_type > const & droppedBranchIDToKeptBranchID()
BranchListIndexes const & branchListIndexes() const
edm::propagate_const< std::unique_ptr< Schedule > > schedule_
ProcessHistory const & processHistory() const
std::vector< EventSelectionID > EventSelectionIDVector
void validateTopLevelParameterSets(ParameterSet *processParameterSet)
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
std::vector< std::pair< BranchDescription const *, EDGetToken > > SelectedProducts
Func for_all(ForwardSequence &s, Func f)
wrapper for std::for_each
ProductList const & productList() const
void selectAssociationProducts(std::vector< BranchDescription const * > const &associationDescriptions, std::set< BranchID > const &keptProductsInEvent, std::map< BranchID, bool > &keepAssociation) const
void initialize(Schedule const *, std::shared_ptr< ProductRegistry const >)
virtual void connectTo(ProductResolverBase const &, Principal const *)=0
ServiceToken serviceToken_
void deleteRunFromCache(ProcessHistoryID const &parentPhID, int runNumber)
std::vector< BranchListIndex > BranchListIndexes
void doneWaiting(std::exception_ptr iExcept)
std::vector< std::shared_ptr< LuminosityBlockPrincipal > > inUseLumiPrincipals_
void processAsync(WaitingTaskHolder iHolder, EventPrincipal const &e)
void doEndRunAsync(WaitingTaskHolder iHolder, RunPrincipal const &principal, IOVSyncValue const &ts, bool cleaningUpAfterException)
std::string const & moduleLabel() const
void doBeginLuminosityBlockAsync(WaitingTaskHolder iHolder, LuminosityBlockPrincipal const &principal, IOVSyncValue const &ts)
std::string const & productInstanceName() const
ProcessHistoryID const & processHistoryID() const
SelectedProductsForBranchType keptProducts_
LuminosityBlockPrincipal const & luminosityBlockPrincipal() const
void selectProducts(ProductRegistry const &preg, ThinnedAssociationsHelper const &parentThinnedAssociationsHelper, std::map< BranchID, bool > &keepAssociation)
void doBeginRunAsync(WaitingTaskHolder iHolder, RunPrincipal const &principal, IOVSyncValue const &ts)
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
void deleteLumiFromCache(LuminosityBlockPrincipal &)
ProductSelectorRules productSelectorRules_
StreamID streamID() const
TypeID unwrappedTypeID() const
edm::propagate_const< std::shared_ptr< eventsetup::EventSetupProvider > > esp_
std::vector< BranchDescription const * > allBranchDescriptions() const
edm::propagate_const< std::unique_ptr< ParameterSet > > processParameterSet_
void doEndLuminosityBlockAsync(WaitingTaskHolder iHolder, LuminosityBlockPrincipal const &principal, IOVSyncValue const &ts, bool cleaningUpAfterException)
bool configureEventSelector(edm::ParameterSet const &iPSet, std::string const &iProcessName, std::vector< std::string > const &iAllTriggerNames, edm::detail::TriggerResultsBasedEventSelector &oSelector, ConsumesCollector &&iC)
BranchID const & branchID() const
TypeWithDict const & unwrappedType() const
RunAuxiliary const & aux() const
void keepThisBranch(BranchDescription const &desc, std::map< BranchID, BranchDescription const * > &trueBranchIDToKeptBranchDesc, std::set< BranchID > &keptProductsInEvent)
unsigned int numberOfLuminosityBlocks() const
ProductProvenanceRetriever const * productProvenanceRetrieverPtr() const
void setProcessConfiguration(ProcessConfiguration const *processConfiguration)
EventPrincipal & eventPrincipal(unsigned int iStreamIndex) const
void doStreamBeginLuminosityBlockAsync(WaitingTaskHolder iHolder, unsigned int iID, LuminosityBlockPrincipal const &principal, IOVSyncValue const &ts)
std::unique_ptr< ExceptionToActionTable const > act_table_
std::vector< ParameterSet > popSubProcessVParameterSet(ParameterSet ¶meterSet)
void setProcessHistoryRegistry(ProcessHistoryRegistry const &phr)
DelayedReader * reader() const
std::map< BranchID::value_type, BranchID::value_type > droppedBranchIDToKeptBranchID_
void writeRunAsync(WaitingTaskHolder, ProcessHistoryID const &parentPhID, int runNumber, MergeableRunProductMetadata const *)
ProductSelector productSelector_
unsigned int value() const
void checkForModuleDependencyCorrectness(edm::PathsAndConsumesOfModulesBase const &iPnC, bool iPrintDependencies)
detail::TriggerResultsBasedEventSelector selectors_
void clearEventPrincipal()
void connectToSubProcess(ActivityRegistry &iOther)
std::map< ProcessHistoryID, ProcessHistoryID > parentToChildPhID_
FunctorWaitingTask< F > * make_waiting_task(ALLOC &&iAlloc, F f)
void deleteRun(ProcessHistoryID const &phid, RunNumber_t run)
std::shared_ptr< ActivityRegistry > actReg_
SubProcess(ParameterSet ¶meterSet, ParameterSet const &topLevelParameterSet, std::shared_ptr< ProductRegistry const > parentProductRegistry, std::shared_ptr< BranchIDListHelper const > parentBranchIDListHelper, ThinnedAssociationsHelper const &parentThinnedAssociationsHelper, SubProcessParentageHelper const &parentSubProcessParentageHelper, eventsetup::EventSetupsController &esController, ActivityRegistry &parentActReg, ServiceToken const &token, serviceregistry::ServiceLegacy iLegacy, PreallocationConfiguration const &preallocConfig, ProcessContext const *parentProcessContext)
edm::propagate_const< std::shared_ptr< BranchIDListHelper > > branchIDListHelper_
std::shared_ptr< RunPrincipal > const & runPrincipalPtr(ProcessHistoryID const &phid, RunNumber_t run) const
bool anyProductProduced() const
std::vector< HistoryAppender > historyAppenders_
std::vector< BranchID::value_type > BranchIDList
std::vector< ParameterSet > popVParameterSet(std::string const &name)
void fillEventPrincipal(EventAuxiliary const &aux, ProcessHistoryRegistry const &processHistoryRegistry, DelayedReader *reader=0)
std::vector< std::string > const & getAllTriggerNames()
void initialize(ProductSelectorRules const &rules, std::vector< BranchDescription const * > const &branchDescriptions)
void propagateProducts(BranchType type, Principal const &parentPrincipal, Principal &principal) const
void doBeginStream(unsigned int)
unsigned int numberOfStreams() const
void setConsumer(EDConsumerBase const *iConsumer)
std::shared_ptr< ProductRegistry const > parentPreg_
ConstProductResolverPtr getProductResolver(BranchID const &oid) const
void fixBranchIDListsForEDAliases(std::map< BranchID::value_type, BranchID::value_type > const &droppedBranchIDToKeptBranchID)
ProcessContext processContext_
std::shared_ptr< LuminosityBlockPrincipal > getAvailableLumiPrincipalPtr()
BranchID const & originalBranchID() const
void call(std::function< void(void)>)
ParameterSetID registerProperSelectionInfo(edm::ParameterSet const &iInitial, std::string const &iLabel, std::map< std::string, std::vector< std::pair< std::string, int > > > const &outputModulePathPositions, bool anyProductProduced)
std::shared_ptr< ThinnedAssociationsHelper const > thinnedAssociationsHelper() const
EventAuxiliary const & aux() const
ParameterSet const & registerIt()
void writeLumiAsync(WaitingTaskHolder, LuminosityBlockPrincipal &)
std::shared_ptr< ProductRegistry const > preg_
PrincipalCache principalCache_
ParameterSet const & parameterSet(Provenance const &provenance)
edm::propagate_const< std::shared_ptr< SubProcessParentageHelper > > subProcessParentageHelper_
static void checkForDuplicateKeptBranch(BranchDescription const &desc, std::map< BranchID, BranchDescription const * > &trueBranchIDToKeptBranchDesc)
std::shared_ptr< ProcessConfiguration const > processConfiguration_
RunPrincipal & runPrincipal(ProcessHistoryID const &phid, RunNumber_t run) const
def operate(timelog, memlog, json_f, num)