35 #include "boost/range/adaptor/reversed.hpp" 45 std::shared_ptr<ProductRegistry const> parentProductRegistry,
46 std::shared_ptr<BranchIDListHelper const> parentBranchIDListHelper,
57 parentPreg_(parentProductRegistry),
59 branchIDListHelper_(),
61 processConfiguration_(),
62 historyLumiOffset_(preallocConfig.numberOfStreams()),
63 historyRunOffset_(historyLumiOffset_+preallocConfig.numberOfLuminosityBlocks()),
64 processHistoryRegistries_(historyRunOffset_+ preallocConfig.numberOfRuns()),
65 historyAppenders_(historyRunOffset_+preallocConfig.numberOfRuns()),
71 processParameterSet_(),
72 productSelectorRules_(parameterSet,
"outputCommands",
"OutputModule"),
74 wantAllEvents_(
true) {
84 tns->getProcessName(),
88 std::map<std::string, std::vector<std::pair<std::string, int> > > outputModulePathPositions;
91 outputModulePathPositions,
92 parentProductRegistry->anyProductProduced());
94 std::map<BranchID, bool> keepAssociation;
95 selectProducts(*parentProductRegistry, parentThinnedAssociationsHelper, keepAssociation);
112 if(topLevelParameterSet.
exists(maxEvents)) {
115 if(topLevelParameterSet.
exists(maxLumis)) {
121 bool hasSubProcesses = subProcessVParameterSet.size() != 0
ull;
177 auto ep = std::make_shared<EventPrincipal>(
preg_,
188 for(
auto& subProcessPSet : subProcessVParameterSet) {
190 topLevelParameterSet,
193 *thinnedAssociationsHelper_,
240 ExceptionCollector c(
"Multiple exceptions were thrown while executing endJob. An exception message follows for each.");
243 c.
call([&subProcess](){ subProcess.doEndJob();});
253 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);
294 std::map<BranchID, BranchDescription const*>& trueBranchIDToKeptBranchDesc,
295 std::set<BranchID>& keptProductsInEvent) {
298 trueBranchIDToKeptBranchDesc);
304 keptProductsInEvent.insert(desc.
branchID());
322 std::map<BranchID::value_type, BranchID::value_type>::const_iterator iter = droppedBranchIDToKeptBranchID.find(branchID);
323 if(iter != droppedBranchIDToKeptBranchID.end()) {
324 branchID = iter->second;
328 for_all(
subProcesses_, [&droppedBranchIDToKeptBranchID](
auto& subProcess){ subProcess.fixBranchIDListsForEDAliases(droppedBranchIDToKeptBranchID); });
360 processHistoryRegistry.registerProcessHistory(principal.
processHistory());
363 bool deepCopyRetriever =
false;
365 processHistoryRegistry,
375 [
this,&ep,iHolder](std::exception_ptr
const* iPtr)
mutable 388 afterProcessTask =
std::move(finalizeEventTask);
392 [
this,&ep,finalizeEventTask] (std::exception_ptr
const* iPtr)
mutable{
395 subProcess.doEventAsync(finalizeEventTask,ep);
416 auto aux = std::make_shared<RunAuxiliary>(principal.
aux());
420 processHistoryRegistry.registerProcessHistory(principal.
processHistory());
421 rpp->fillRunPrincipal(processHistoryRegistry, principal.
reader());
432 schedule_->processOneGlobal<Traits>(rp,
esp_->eventSetupForInstance(ts));
439 endRun(principal,ts,cleaningUpAfterException);
448 schedule_->processOneGlobal<Traits>(rp,
esp_->eventSetupForInstance(ts), cleaningUpAfterException);
449 for_all(
subProcesses_, [&rp, &ts, cleaningUpAfterException](
auto& subProcess){ subProcess.doEndRun(rp, ts, cleaningUpAfterException); });
455 std::map<ProcessHistoryID, ProcessHistoryID>::const_iterator it =
parentToChildPhID_.find(parentPhID);
457 auto const& childPhID = it->second;
459 for_all(
subProcesses_, [&childPhID, runNumber](
auto& subProcess){ subProcess.writeRun(childPhID, runNumber); });
464 std::map<ProcessHistoryID, ProcessHistoryID>::const_iterator it =
parentToChildPhID_.find(parentPhID);
466 auto const& childPhID = it->second;
468 for_all(
subProcesses_, [&childPhID, runNumber](
auto& subProcess){ subProcess.deleteRunFromCache(childPhID, runNumber); });
479 auto aux = std::make_shared<LuminosityBlockAuxiliary>(principal.
aux());
483 processHistoryRegistry.registerProcessHistory(principal.
processHistory());
484 lbpp->fillLuminosityBlockPrincipal(processHistoryRegistry, principal.
reader());
490 schedule_->processOneGlobal<Traits>(lbp,
esp_->eventSetupForInstance(ts));
491 for_all(
subProcesses_, [&lbp, &ts](
auto& subProcess){ subProcess.doBeginLuminosityBlock(lbp, ts); });
506 schedule_->processOneGlobal<Traits>(lbp,
esp_->eventSetupForInstance(ts), cleaningUpAfterException);
507 for_all(
subProcesses_, [&lbp, &ts, cleaningUpAfterException](
auto& subProcess){ subProcess.doEndLuminosityBlock(lbp, ts, cleaningUpAfterException); });
513 std::map<ProcessHistoryID, ProcessHistoryID>::const_iterator it =
parentToChildPhID_.find(parentPhID);
515 auto const& childPhID = it->second;
517 for_all(
subProcesses_, [&childPhID, runNumber, lumiNumber](
auto& subProcess){ subProcess.writeLumi(childPhID, runNumber, lumiNumber); });
522 std::map<ProcessHistoryID, ProcessHistoryID>::const_iterator it =
parentToChildPhID_.find(parentPhID);
524 auto const& childPhID = it->second;
526 for_all(
subProcesses_, [&childPhID, runNumber, lumiNumber](
auto& subProcess){ subProcess.deleteLumiFromCache(childPhID, runNumber, lumiNumber); });
549 schedule_->processOneStream<Traits>(
id,rp,
esp_->eventSetupForInstance(ts));
550 for_all(
subProcesses_, [
id, &rp, &ts](
auto& subProcess){ subProcess.doStreamBeginRun(
id,rp, ts); });
562 beginStreamTransitionAsync<Traits>(
std::move(iHolder),
567 esp_->eventSetupForInstance(ts),
579 schedule_->processOneStream<Traits>(
id,rp,
esp_->eventSetupForInstance(ts),cleaningUpAfterException);
580 for_all(
subProcesses_, [
id, &rp, &ts, cleaningUpAfterException](
auto& subProcess){ subProcess.doStreamEndRun(
id,rp, ts,cleaningUpAfterException); });
591 endStreamTransitionAsync<Traits>(
std::move(iHolder),
596 esp_->eventSetupForInstance(ts),
598 cleaningUpAfterException);
607 schedule_->processOneStream<Traits>(
id,lbp,
esp_->eventSetupForInstance(ts));
608 for_all(
subProcesses_, [
id, &lbp, &ts](
auto& subProcess){ subProcess.doStreamBeginLuminosityBlock(
id,lbp, ts); });
620 beginStreamTransitionAsync<Traits>(
std::move(iHolder),
625 esp_->eventSetupForInstance(ts),
637 schedule_->processOneStream<Traits>(
id,lbp,
esp_->eventSetupForInstance(ts),cleaningUpAfterException);
638 for_all(
subProcesses_, [
id, &lbp, &ts, cleaningUpAfterException](
auto& subProcess){ subProcess.doStreamEndLuminosityBlock(
id,lbp, ts,cleaningUpAfterException); });
649 endStreamTransitionAsync<Traits>(
std::move(iHolder),
654 esp_->eventSetupForInstance(ts),
656 cleaningUpAfterException);
663 for(
auto const& item : keptVector) {
666 if(parentProductResolver !=
nullptr) {
668 if(productResolver !=
nullptr) {
671 productResolver->
connectTo(*parentProductResolver, &parentPrincipal);
691 std::vector<ParameterSet>
693 std::vector<std::string> subProcesses = parameterSet.
getUntrackedParameter<std::vector<std::string>>(
"@all_subprocesses");
694 if(!subProcesses.empty()) {
unsigned int historyRunOffset_
unsigned int historyLumiOffset_
ParameterSetID selector_config_id_
std::shared_ptr< ActivityRegistry > actReg_
void insert(std::shared_ptr< RunPrincipal > rp)
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)
std::shared_ptr< EventSetupProvider > makeProvider(ParameterSet &)
void setLuminosityBlockPrincipal(std::shared_ptr< LuminosityBlockPrincipal > const &lbp)
EventSelectionIDVector const & eventSelectionIDs() const
void respondToOpenInputFile(FileBlock const &fb)
void doStreamEndLuminosityBlock(unsigned int iID, LuminosityBlockPrincipal const &principal, IOVSyncValue const &ts, bool cleaningUpAfterException)
BranchType const & branchType() const
std::vector< BranchIDList > BranchIDLists
ProcessHistoryID const & reducedProcessHistoryID() const
void doBeginRun(RunPrincipal const &principal, IOVSyncValue const &ts)
void deleteLumi(ProcessHistoryID const &phid, RunNumber_t run, LuminosityBlockNumber_t lumi)
void writeLumi(ProcessHistoryID const &parentPhID, int runNumber, int lumiNumber)
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::unique_ptr< ExceptionToActionTable const > act_table_
std::shared_ptr< BranchIDListHelper const > branchIDListHelper() const
std::shared_ptr< ThinnedAssociationsHelper const > thinnedAssociationsHelper() 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 beginRun(RunPrincipal const &r, IOVSyncValue const &ts)
void doStreamEndRunAsync(WaitingTaskHolder iHolder, unsigned int iID, RunPrincipal const &principal, IOVSyncValue const &ts, bool cleaningUpAfterException)
PathsAndConsumesOfModules pathsAndConsumesOfModules_
LuminosityBlockPrincipal & lumiPrincipal(ProcessHistoryID const &phid, RunNumber_t run, LuminosityBlockNumber_t lumi) const
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)
void setParentProcessContext(ProcessContext const *parentProcessContext)
void doBeginLuminosityBlock(LuminosityBlockPrincipal const &principal, IOVSyncValue const &ts)
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
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)
void processAsync(WaitingTaskHolder iHolder, EventPrincipal const &e)
std::string const & moduleLabel() const
std::string const & productInstanceName() const
ProcessHistoryID const & processHistoryID() const
std::shared_ptr< CommonParams > initMisc(ParameterSet ¶meterSet)
std::shared_ptr< SubProcessParentageHelper > & subProcessParentageHelper()
SelectedProductsForBranchType keptProducts_
void selectProducts(ProductRegistry const &preg, ThinnedAssociationsHelper const &parentThinnedAssociationsHelper, std::map< BranchID, bool > &keepAssociation)
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
static void setThrowAnException(bool v)
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_
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)
ProductProvenanceRetriever const * productProvenanceRetrieverPtr() const
void beginLuminosityBlock(LuminosityBlockPrincipal const &lb, IOVSyncValue const &ts)
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
void doEndRun(RunPrincipal const &principal, IOVSyncValue const &ts, bool cleaningUpAfterException)
std::shared_ptr< ProcessConfiguration const > processConfiguration() const
std::map< BranchID::value_type, BranchID::value_type > droppedBranchIDToKeptBranchID_
ProductSelector productSelector_
unsigned int value() const
void checkForModuleDependencyCorrectness(edm::PathsAndConsumesOfModulesBase const &iPnC, bool iPrintDependencies)
detail::TriggerResultsBasedEventSelector selectors_
void doStreamBeginLuminosityBlock(unsigned int iID, LuminosityBlockPrincipal const &principal, IOVSyncValue const &ts)
ServiceToken initServices(std::vector< ParameterSet > &servicePSets, ParameterSet &processPSet, ServiceToken const &iToken, serviceregistry::ServiceLegacy iLegacy, bool associate)
void doStreamEndRun(unsigned int iID, RunPrincipal const &principal, IOVSyncValue const &ts, bool cleaningUpAfterException)
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)
void deleteLumiFromCache(ProcessHistoryID const &parentPhID, int runNumber, int lumiNumber)
ServiceToken addCPRandTNS(ParameterSet const ¶meterSet, ServiceToken const &token)
edm::propagate_const< std::shared_ptr< BranchIDListHelper > > branchIDListHelper_
std::shared_ptr< RunPrincipal > const & runPrincipalPtr(ProcessHistoryID const &phid, RunNumber_t run) const
void endRun(RunPrincipal const &r, IOVSyncValue const &ts, bool cleaningUpAfterException)
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)
void endLuminosityBlock(LuminosityBlockPrincipal const &lb, IOVSyncValue const &ts, bool cleaningUpAfterException)
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_
std::shared_ptr< SignallingProductRegistry const > preg() const
std::shared_ptr< LuminosityBlockPrincipal > const & lumiPrincipalPtr(ProcessHistoryID const &phid, RunNumber_t run, LuminosityBlockNumber_t lumi) const
ConstProductResolverPtr getProductResolver(BranchID const &oid) const
void fixBranchIDListsForEDAliases(std::map< BranchID::value_type, BranchID::value_type > const &droppedBranchIDToKeptBranchID)
ProcessContext processContext_
void writeRun(ProcessHistoryID const &parentPhID, int runNumber)
BranchID const & originalBranchID() const
void call(std::function< void(void)>)
std::shared_ptr< BranchIDListHelper const > branchIDListHelper() const
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
std::unique_ptr< Schedule > initSchedule(ParameterSet ¶meterSet, bool hasSubprocesses, PreallocationConfiguration const &iAllocConfig, ProcessContext const *)
ParameterSet const & registerIt()
std::shared_ptr< ProductRegistry const > preg_
PrincipalCache principalCache_
ParameterSet const & parameterSet(Provenance const &provenance)
void doStreamBeginRun(unsigned int iID, RunPrincipal const &principal, IOVSyncValue const &ts)
edm::propagate_const< std::shared_ptr< SubProcessParentageHelper > > subProcessParentageHelper_
void doEndLuminosityBlock(LuminosityBlockPrincipal const &principal, IOVSyncValue const &ts, bool cleaningUpAfterException)
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)