36 #include "boost/range/adaptor/reversed.hpp" 46 std::shared_ptr<ProductRegistry const> parentProductRegistry,
47 std::shared_ptr<BranchIDListHelper const> parentBranchIDListHelper,
58 parentPreg_(parentProductRegistry),
60 branchIDListHelper_(),
62 processConfiguration_(),
63 historyLumiOffset_(preallocConfig.numberOfStreams()),
64 historyRunOffset_(historyLumiOffset_+preallocConfig.numberOfLuminosityBlocks()),
65 processHistoryRegistries_(historyRunOffset_+ preallocConfig.numberOfRuns()),
66 historyAppenders_(historyRunOffset_+preallocConfig.numberOfRuns()),
72 processParameterSet_(),
73 productSelectorRules_(parameterSet,
"outputCommands",
"OutputModule"),
75 wantAllEvents_(
true) {
85 tns->getProcessName(),
89 std::map<std::string, std::vector<std::pair<std::string, int> > > outputModulePathPositions;
92 outputModulePathPositions,
93 parentProductRegistry->anyProductProduced());
95 std::map<BranchID, bool> keepAssociation;
96 selectProducts(*parentProductRegistry, parentThinnedAssociationsHelper, keepAssociation);
113 if(topLevelParameterSet.
exists(maxEvents)) {
116 if(topLevelParameterSet.
exists(maxLumis)) {
122 bool hasSubProcesses = subProcessVParameterSet.size() != 0ull;
178 auto ep = std::make_shared<EventPrincipal>(
preg_,
189 for(
auto& subProcessPSet : subProcessVParameterSet) {
191 topLevelParameterSet,
194 *thinnedAssociationsHelper_,
242 ExceptionCollector c(
"Multiple exceptions were thrown while executing endJob. An exception message follows for each.");
245 c.
call([&subProcess](){ subProcess.doEndJob();});
255 std::map<BranchID, bool>& keepAssociation) {
263 std::map<BranchID, BranchDescription const*> trueBranchIDToKeptBranchDesc;
264 std::vector<BranchDescription const*> associationDescriptions;
265 std::set<BranchID> keptProductsInEvent;
275 associationDescriptions.push_back(&desc);
277 keepThisBranch(desc, trueBranchIDToKeptBranchDesc, keptProductsInEvent);
296 std::map<BranchID, BranchDescription const*>& trueBranchIDToKeptBranchDesc,
297 std::set<BranchID>& keptProductsInEvent) {
300 trueBranchIDToKeptBranchDesc);
306 keptProductsInEvent.insert(desc.
branchID());
324 std::map<BranchID::value_type, BranchID::value_type>::const_iterator iter = droppedBranchIDToKeptBranchID.find(branchID);
325 if(iter != droppedBranchIDToKeptBranchID.end()) {
326 branchID = iter->second;
330 for_all(
subProcesses_, [&droppedBranchIDToKeptBranchID](
auto& subProcess){ subProcess.fixBranchIDListsForEDAliases(droppedBranchIDToKeptBranchID); });
362 processHistoryRegistry.registerProcessHistory(principal.
processHistory());
365 bool deepCopyRetriever =
false;
367 processHistoryRegistry,
377 [
this,&ep,iHolder](std::exception_ptr
const* iPtr)
mutable 390 afterProcessTask =
std::move(finalizeEventTask);
394 [
this,&ep,finalizeEventTask] (std::exception_ptr
const* iPtr)
mutable{
397 subProcess.doEventAsync(finalizeEventTask,ep);
418 auto aux = std::make_shared<RunAuxiliary>(principal.
aux());
422 processHistoryRegistry.registerProcessHistory(principal.
processHistory());
423 rpp->fillRunPrincipal(processHistoryRegistry, principal.
reader());
434 schedule_->processOneGlobal<Traits>(rp,
esp_->eventSetupForInstance(ts));
442 auto aux = std::make_shared<RunAuxiliary>(principal.
aux());
446 processHistoryRegistry.registerProcessHistory(principal.
processHistory());
447 rpp->fillRunPrincipal(processHistoryRegistry, principal.
reader());
458 beginGlobalTransitionAsync<Traits>(
std::move(iHolder),
462 esp_->eventSetupForInstance(ts),
470 endRun(principal,ts,cleaningUpAfterException);
480 schedule_->processOneGlobal<Traits>(rp,
esp_->eventSetupForInstance(ts), cleaningUpAfterException);
481 for_all(
subProcesses_, [&rp, &ts, cleaningUpAfterException](
auto& subProcess){ subProcess.doEndRun(rp, ts, cleaningUpAfterException); });
488 bool cleaningUpAfterException) {
494 endGlobalTransitionAsync<Traits>(
std::move(iHolder),
498 esp_->eventSetupForInstance(ts),
500 cleaningUpAfterException);
506 std::map<ProcessHistoryID, ProcessHistoryID>::const_iterator it =
parentToChildPhID_.find(parentPhID);
508 auto const& childPhID = it->second;
510 for_all(
subProcesses_, [&childPhID, runNumber](
auto& subProcess){ subProcess.writeRun(childPhID, runNumber); });
515 std::map<ProcessHistoryID, ProcessHistoryID>::const_iterator it =
parentToChildPhID_.find(parentPhID);
517 auto const& childPhID = it->second;
519 for_all(
subProcesses_, [&childPhID, runNumber](
auto& subProcess){ subProcess.deleteRunFromCache(childPhID, runNumber); });
530 auto aux = std::make_shared<LuminosityBlockAuxiliary>(principal.
aux());
534 processHistoryRegistry.registerProcessHistory(principal.
processHistory());
535 lbpp->fillLuminosityBlockPrincipal(processHistoryRegistry, principal.
reader());
541 schedule_->processOneGlobal<Traits>(lbp,
esp_->eventSetupForInstance(ts));
542 for_all(
subProcesses_, [&lbp, &ts](
auto& subProcess){ subProcess.doBeginLuminosityBlock(lbp, ts); });
549 auto aux = std::make_shared<LuminosityBlockAuxiliary>(principal.
aux());
553 processHistoryRegistry.registerProcessHistory(principal.
processHistory());
554 lbpp->fillLuminosityBlockPrincipal(processHistoryRegistry, principal.
reader());
560 beginGlobalTransitionAsync<Traits>(
std::move(iHolder),
564 esp_->eventSetupForInstance(ts),
581 schedule_->processOneGlobal<Traits>(lbp,
esp_->eventSetupForInstance(ts), cleaningUpAfterException);
582 for_all(
subProcesses_, [&lbp, &ts, cleaningUpAfterException](
auto& subProcess){ subProcess.doEndLuminosityBlock(lbp, ts, cleaningUpAfterException); });
592 endGlobalTransitionAsync<Traits>(
std::move(iHolder),
596 esp_->eventSetupForInstance(ts),
598 cleaningUpAfterException);
605 std::map<ProcessHistoryID, ProcessHistoryID>::const_iterator it =
parentToChildPhID_.find(parentPhID);
607 auto const& childPhID = it->second;
609 for_all(
subProcesses_, [&childPhID, runNumber, lumiNumber](
auto& subProcess){ subProcess.writeLumi(childPhID, runNumber, lumiNumber); });
614 std::map<ProcessHistoryID, ProcessHistoryID>::const_iterator it =
parentToChildPhID_.find(parentPhID);
616 auto const& childPhID = it->second;
618 for_all(
subProcesses_, [&childPhID, runNumber, lumiNumber](
auto& subProcess){ subProcess.deleteLumiFromCache(childPhID, runNumber, lumiNumber); });
641 schedule_->processOneStream<Traits>(
id,rp,
esp_->eventSetupForInstance(ts));
642 for_all(
subProcesses_, [
id, &rp, &ts](
auto& subProcess){ subProcess.doStreamBeginRun(
id,rp, ts); });
654 beginStreamTransitionAsync<Traits>(
std::move(iHolder),
659 esp_->eventSetupForInstance(ts),
671 schedule_->processOneStream<Traits>(
id,rp,
esp_->eventSetupForInstance(ts),cleaningUpAfterException);
672 for_all(
subProcesses_, [
id, &rp, &ts, cleaningUpAfterException](
auto& subProcess){ subProcess.doStreamEndRun(
id,rp, ts,cleaningUpAfterException); });
683 endStreamTransitionAsync<Traits>(
std::move(iHolder),
688 esp_->eventSetupForInstance(ts),
690 cleaningUpAfterException);
699 schedule_->processOneStream<Traits>(
id,lbp,
esp_->eventSetupForInstance(ts));
700 for_all(
subProcesses_, [
id, &lbp, &ts](
auto& subProcess){ subProcess.doStreamBeginLuminosityBlock(
id,lbp, ts); });
712 beginStreamTransitionAsync<Traits>(
std::move(iHolder),
717 esp_->eventSetupForInstance(ts),
729 schedule_->processOneStream<Traits>(
id,lbp,
esp_->eventSetupForInstance(ts),cleaningUpAfterException);
730 for_all(
subProcesses_, [
id, &lbp, &ts, cleaningUpAfterException](
auto& subProcess){ subProcess.doStreamEndLuminosityBlock(
id,lbp, ts,cleaningUpAfterException); });
741 endStreamTransitionAsync<Traits>(
std::move(iHolder),
746 esp_->eventSetupForInstance(ts),
748 cleaningUpAfterException);
755 for(
auto const& item : keptVector) {
758 if(parentProductResolver !=
nullptr) {
760 if(productResolver !=
nullptr) {
763 productResolver->
connectTo(*parentProductResolver, &parentPrincipal);
783 std::vector<ParameterSet>
785 std::vector<std::string> subProcesses = parameterSet.
getUntrackedParameter<std::vector<std::string>>(
"@all_subprocesses");
786 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 setAtEndTransition(bool iAtEnd)
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)
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
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)
void doBeginRunAsync(WaitingTaskHolder iHolder, RunPrincipal const &principal, IOVSyncValue const &ts)
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_
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)
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)