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 [&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);
414 auto aux = std::make_shared<RunAuxiliary>(principal.
aux());
418 processHistoryRegistry.registerProcessHistory(principal.
processHistory());
419 rpp->fillRunPrincipal(processHistoryRegistry, principal.
reader());
430 beginGlobalTransitionAsync<Traits>(
std::move(iHolder),
434 esp_->eventSetupForInstance(ts),
443 bool cleaningUpAfterException) {
449 endGlobalTransitionAsync<Traits>(
std::move(iHolder),
453 esp_->eventSetupForInstance(ts),
455 cleaningUpAfterException);
461 std::map<ProcessHistoryID, ProcessHistoryID>::const_iterator it =
parentToChildPhID_.find(parentPhID);
463 auto const& childPhID = it->second;
465 for_all(
subProcesses_, [&childPhID, runNumber](
auto& subProcess){ subProcess.writeRun(childPhID, runNumber); });
470 std::map<ProcessHistoryID, ProcessHistoryID>::const_iterator it =
parentToChildPhID_.find(parentPhID);
472 auto const& childPhID = it->second;
474 for_all(
subProcesses_, [&childPhID, runNumber](
auto& subProcess){ subProcess.deleteRunFromCache(childPhID, runNumber); });
481 auto aux = std::make_shared<LuminosityBlockAuxiliary>(principal.
aux());
485 processHistoryRegistry.registerProcessHistory(principal.
processHistory());
486 lbpp->fillLuminosityBlockPrincipal(processHistoryRegistry, principal.
reader());
492 beginGlobalTransitionAsync<Traits>(
std::move(iHolder),
496 esp_->eventSetupForInstance(ts),
507 endGlobalTransitionAsync<Traits>(
std::move(iHolder),
511 esp_->eventSetupForInstance(ts),
513 cleaningUpAfterException);
520 std::map<ProcessHistoryID, ProcessHistoryID>::const_iterator it =
parentToChildPhID_.find(parentPhID);
522 auto const& childPhID = it->second;
524 for_all(
subProcesses_, [&childPhID, runNumber, lumiNumber](
auto& subProcess){ subProcess.writeLumi(childPhID, runNumber, lumiNumber); });
529 std::map<ProcessHistoryID, ProcessHistoryID>::const_iterator it =
parentToChildPhID_.find(parentPhID);
531 auto const& childPhID = it->second;
533 for_all(
subProcesses_, [&childPhID, runNumber, lumiNumber](
auto& subProcess){ subProcess.deleteLumiFromCache(childPhID, runNumber, lumiNumber); });
559 beginStreamTransitionAsync<Traits>(
std::move(iHolder),
564 esp_->eventSetupForInstance(ts),
577 endStreamTransitionAsync<Traits>(
std::move(iHolder),
582 esp_->eventSetupForInstance(ts),
584 cleaningUpAfterException);
596 beginStreamTransitionAsync<Traits>(
std::move(iHolder),
601 esp_->eventSetupForInstance(ts),
614 endStreamTransitionAsync<Traits>(
std::move(iHolder),
619 esp_->eventSetupForInstance(ts),
621 cleaningUpAfterException);
628 for(
auto const& item : keptVector) {
631 if(parentProductResolver !=
nullptr) {
633 if(productResolver !=
nullptr) {
636 productResolver->
connectTo(*parentProductResolver, &parentPrincipal);
656 std::vector<ParameterSet>
658 std::vector<std::string> subProcesses = parameterSet.
getUntrackedParameter<std::vector<std::string>>(
"@all_subprocesses");
659 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)
BranchType const & branchType() const
std::vector< BranchIDList > BranchIDLists
ProcessHistoryID const & reducedProcessHistoryID() const
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 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)
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 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::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_
ServiceToken initServices(std::vector< ParameterSet > &servicePSets, ParameterSet &processPSet, ServiceToken const &iToken, serviceregistry::ServiceLegacy iLegacy, bool associate)
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
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_
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)
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)