39 std::shared_ptr<ProductRegistry const> parentProductRegistry,
40 std::shared_ptr<BranchIDListHelper const> parentBranchIDListHelper,
49 parentPreg_(parentProductRegistry),
51 branchIDListHelper_(),
53 processConfiguration_(),
54 historyLumiOffset_(preallocConfig.numberOfStreams()),
55 historyRunOffset_(historyLumiOffset_+preallocConfig.numberOfLuminosityBlocks()),
56 processHistoryRegistries_(historyRunOffset_+ preallocConfig.numberOfRuns()),
57 historyAppenders_(historyRunOffset_+preallocConfig.numberOfRuns()),
63 processParameterSet_(),
64 productSelectorRules_(parameterSet,
"outputCommands",
"OutputModule"),
66 wantAllEvents_(
true) {
76 tns->getProcessName(),
79 std::map<std::string, std::vector<std::pair<std::string, int> > > outputModulePathPositions;
82 outputModulePathPositions,
83 parentProductRegistry->anyProductProduced());
85 std::map<BranchID, bool> keepAssociation;
86 selectProducts(*parentProductRegistry, parentThinnedAssociationsHelper, keepAssociation);
102 if(topLevelParameterSet.
exists(maxEvents)) {
105 if(topLevelParameterSet.
exists(maxLumis)) {
150 preg_.reset(items.preg_.release());
164 ep->preModuleDelayedGetSignal_.connect(std::cref(items.actReg_->preModuleEventDelayedGetSignal_));
165 ep->postModuleDelayedGetSignal_.connect(std::cref(items.actReg_->postModuleEventDelayedGetSignal_));
168 if(subProcessParameterSet) {
170 topLevelParameterSet,
173 *thinnedAssociationsHelper_,
211 ExceptionCollector c(
"Multiple exceptions were thrown while executing endJob. An exception message follows for each.");
213 if(
subProcess_.get()) c.
call([
this](){ this->subProcess_->doEndJob();});
222 std::map<BranchID, bool>& keepAssociation) {
223 if(productSelector_.initialized())
return;
230 std::map<BranchID, BranchDescription const*> trueBranchIDToKeptBranchDesc;
231 std::vector<BranchDescription const*> associationDescriptions;
232 std::set<BranchID> keptProductsInEvent;
242 associationDescriptions.push_back(&desc);
243 }
else if(productSelector_.selected(desc)) {
244 keepThisBranch(desc, trueBranchIDToKeptBranchDesc, keptProductsInEvent);
252 for(
auto association : associationDescriptions) {
253 if(keepAssociation[association->branchID()]) {
254 keepThisBranch(*association, trueBranchIDToKeptBranchDesc, keptProductsInEvent);
259 ProductSelector::fillDroppedToKept(preg, trueBranchIDToKeptBranchDesc, droppedBranchIDToKeptBranchID_);
263 std::map<BranchID, BranchDescription const*>& trueBranchIDToKeptBranchDesc,
264 std::set<BranchID>& keptProductsInEvent) {
266 ProductSelector::checkForDuplicateKeptBranch(desc,
267 trueBranchIDToKeptBranchDesc);
273 keptProductsInEvent.insert(desc.
branchID());
277 keptProducts_[desc.
branchType()].push_back(&desc);
281 SubProcess::fixBranchIDListsForEDAliases(std::map<BranchID::value_type, BranchID::value_type>
const& droppedBranchIDToKeptBranchID) {
284 for(
BranchIDList& branchIDList : branchIDListHelper_->mutableBranchIDLists()) {
286 std::map<BranchID::value_type, BranchID::value_type>::const_iterator
iter = droppedBranchIDToKeptBranchID.find(branchID);
287 if(iter != droppedBranchIDToKeptBranchID.end()) {
288 branchID = iter->second;
292 if(subProcess_.get()) subProcess_->fixBranchIDListsForEDAliases(droppedBranchIDToKeptBranchID);
302 if(!wantAllEvents_) {
305 if(!selectors_.wantEvent(ep,
nullptr)) {
320 esids.push_back(selector_config_id_);
324 auto & processHistoryRegistry = processHistoryRegistries_[principal.
streamID().
value()];
325 processHistoryRegistry.registerProcessHistory(principal.
processHistory());
327 branchIDListHelper_->fixBranchListIndexes(bli);
329 processHistoryRegistry,
335 propagateProducts(
InEvent, principal, ep);
337 schedule_->processOneEvent<Traits>(ep.
streamID().
value(),ep, esp_->eventSetup());
338 if(subProcess_.get()) subProcess_->doEvent(ep);
345 beginRun(principal,ts);
350 auto aux = std::make_shared<RunAuxiliary>(principal.
aux());
352 auto rpp = std::make_shared<RunPrincipal>(
aux, preg_, *processConfiguration_, &(historyAppenders_[historyRunOffset_+principal.
index()]),principal.
index());
353 auto & processHistoryRegistry = processHistoryRegistries_[historyRunOffset_+principal.
index()];
354 processHistoryRegistry.registerProcessHistory(principal.
processHistory());
355 rpp->fillRunPrincipal(processHistoryRegistry, principal.
reader());
356 principalCache_.insert(rpp);
361 parentToChildPhID_.insert(std::make_pair(parentInputReducedPHID,inputReducedPHID));
364 propagateProducts(
InRun, principal, rp);
366 schedule_->processOneGlobal<Traits>(rp, esp_->eventSetupForInstance(ts));
367 if(subProcess_.get()) subProcess_->doBeginRun(rp, ts);
373 endRun(principal,ts,cleaningUpAfterException);
379 propagateProducts(
InRun, principal, rp);
381 schedule_->processOneGlobal<Traits>(rp, esp_->eventSetupForInstance(ts), cleaningUpAfterException);
382 if(subProcess_.get()) subProcess_->doEndRun(rp, ts, cleaningUpAfterException);
388 std::map<ProcessHistoryID, ProcessHistoryID>::const_iterator it = parentToChildPhID_.find(parentPhID);
389 assert(it != parentToChildPhID_.end());
390 schedule_->writeRun(principalCache_.runPrincipal(it->second, runNumber), &processContext_);
391 if(subProcess_.get()) subProcess_->writeRun(it->second, runNumber);
396 std::map<ProcessHistoryID, ProcessHistoryID>::const_iterator it = parentToChildPhID_.find(parentPhID);
397 assert(it != parentToChildPhID_.end());
398 principalCache_.deleteRun(it->second, runNumber);
399 if(subProcess_.get()) subProcess_->deleteRunFromCache(it->second, runNumber);
405 beginLuminosityBlock(principal,ts);
410 auto aux = std::make_shared<LuminosityBlockAuxiliary>(principal.
aux());
412 auto lbpp = std::make_shared<LuminosityBlockPrincipal>(
aux, preg_, *processConfiguration_, &(historyAppenders_[historyLumiOffset_+principal.
index()]),principal.
index());
413 auto & processHistoryRegistry = processHistoryRegistries_[historyLumiOffset_+principal.
index()];
414 processHistoryRegistry.registerProcessHistory(principal.
processHistory());
415 lbpp->fillLuminosityBlockPrincipal(processHistoryRegistry, principal.
reader());
416 lbpp->setRunPrincipal(principalCache_.runPrincipalPtr());
417 principalCache_.insert(lbpp);
419 propagateProducts(
InLumi, principal, lbp);
421 schedule_->processOneGlobal<Traits>(lbp, esp_->eventSetupForInstance(ts));
422 if(subProcess_.get()) subProcess_->doBeginLuminosityBlock(lbp, ts);
428 endLuminosityBlock(principal,ts,cleaningUpAfterException);
434 propagateProducts(
InLumi, principal, lbp);
436 schedule_->processOneGlobal<Traits>(lbp, esp_->eventSetupForInstance(ts), cleaningUpAfterException);
437 if(subProcess_.get()) subProcess_->doEndLuminosityBlock(lbp, ts, cleaningUpAfterException);
443 std::map<ProcessHistoryID, ProcessHistoryID>::const_iterator it = parentToChildPhID_.find(parentPhID);
444 assert(it != parentToChildPhID_.end());
445 schedule_->writeLumi(principalCache_.lumiPrincipal(it->second, runNumber, lumiNumber), &processContext_);
446 if(subProcess_.get()) subProcess_->writeLumi(it->second, runNumber, lumiNumber);
451 std::map<ProcessHistoryID, ProcessHistoryID>::const_iterator it = parentToChildPhID_.find(parentPhID);
452 assert(it != parentToChildPhID_.end());
453 principalCache_.deleteLumi(it->second, runNumber, lumiNumber);
454 if(subProcess_.get()) subProcess_->deleteLumiFromCache(it->second, runNumber, lumiNumber);
458 SubProcess::doBeginStream(
unsigned int iID) {
460 schedule_->beginStream(iID);
461 if(subProcess_.get()) subProcess_->doBeginStream(iID);
465 SubProcess::doEndStream(
unsigned int iID) {
467 schedule_->endStream(iID);
468 if(subProcess_.get()) subProcess_->doEndStream(iID);
477 schedule_->processOneStream<Traits>(id,rp, esp_->eventSetupForInstance(ts));
478 if(subProcess_.get()) subProcess_->doStreamBeginRun(
id,rp, ts);
488 schedule_->processOneStream<Traits>(id,rp, esp_->eventSetupForInstance(ts),cleaningUpAfterException);
489 if(subProcess_.get()) subProcess_->doStreamEndRun(
id,rp, ts,cleaningUpAfterException);
499 schedule_->processOneStream<Traits>(id,lbp, esp_->eventSetupForInstance(ts));
500 if(subProcess_.get()) subProcess_->doStreamBeginLuminosityBlock(
id,lbp, ts);
510 schedule_->processOneStream<Traits>(id,lbp, esp_->eventSetupForInstance(ts),cleaningUpAfterException);
511 if(subProcess_.get()) subProcess_->doStreamEndLuminosityBlock(
id,lbp, ts,cleaningUpAfterException);
519 for(
auto const& item : keptVector) {
521 if(parentProductHolder !=
nullptr) {
524 if(productHolder !=
nullptr) {
547 void SubProcess::updateBranchIDListHelper(
BranchIDLists const& branchIDLists) {
548 branchIDListHelper_->updateFromParent(branchIDLists);
549 if(subProcess_.get()) {
550 subProcess_->updateBranchIDListHelper(branchIDListHelper_->branchIDLists());
558 schedule_->respondToOpenInputFile(fb);
559 if(subProcess_.get()) subProcess_->respondToOpenInputFile(fb);
563 std::auto_ptr<ParameterSet>
565 std::vector<std::string> subProcesses = parameterSet.
getUntrackedParameter<std::vector<std::string> >(
"@all_subprocesses");
566 if(!subProcesses.empty()) {
567 assert(subProcesses.size() == 1U);
568 assert(subProcesses[0] ==
"@sub_process");
571 return std::auto_ptr<ParameterSet>(
nullptr);
unsigned int historyRunOffset_
ParameterSetID selector_config_id_
void insert(std::shared_ptr< RunPrincipal > rp)
bool productProvenanceValid() const
ProductRegistry const & productRegistry() const
T getUntrackedParameter(std::string const &, T const &) const
void setLuminosityBlockPrincipal(std::shared_ptr< LuminosityBlockPrincipal > const &lbp)
EventSelectionIDVector const & eventSelectionIDs() const
BranchType const & branchType() const
std::vector< BranchIDList > BranchIDLists
ProcessHistoryID const & reducedProcessHistoryID() const
ConstProductHolderPtr getProductHolder(BranchID const &oid) const
void setNumberOfConcurrentPrincipals(PreallocationConfiguration const &)
std::vector< ProcessHistoryRegistry > processHistoryRegistries_
std::auto_ptr< ParameterSet > popSubProcessParameterSet(ParameterSet ¶meterSet)
boost::shared_ptr< eventsetup::EventSetupProvider > esp_
PathsAndConsumesOfModules pathsAndConsumesOfModules_
bool exists(std::string const ¶meterName) const
checks if a parameter exists
void updateBranchIDListHelper(BranchIDLists const &)
ProductProvenance * productProvenance() const
LuminosityBlockAuxiliary const & aux() const
LuminosityBlockIndex index() const
ParameterSet getUntrackedParameterSet(std::string const &name, ParameterSet const &defaultValue) const
void setParentProcessContext(ProcessContext const *parentProcessContext)
std::map< BranchID::value_type, BranchID::value_type > const & droppedBranchIDToKeptBranchID()
BranchListIndexes const & branchListIndexes() const
void resetProductProvenance() const
ProcessHistory const & processHistory() const
std::vector< EventSelectionID > EventSelectionIDVector
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 >)
ServiceToken serviceToken_
std::vector< BranchListIndex > BranchListIndexes
ProcessHistoryID const & processHistoryID() const
std::shared_ptr< ProductProvenanceRetriever > productProvenanceRetrieverPtr() const
void selectProducts(ProductRegistry const &preg, ThinnedAssociationsHelper const &parentThinnedAssociationsHelper, std::map< BranchID, bool > &keepAssociation)
ProcessHistory const & processHistory() const
static void setThrowAnException(bool v)
std::shared_ptr< ProductProvenanceRetriever > const & store() const
StreamID streamID() const
std::shared_ptr< WrapperBase > wrapper_
std::vector< BranchDescription const * > allBranchDescriptions() const
std::auto_ptr< ParameterSet > popParameterSet(std::string const &name)
BranchID const & branchID() const
TypeWithDict const & unwrappedType() const
RunAuxiliary const & aux() const
ProductData const & productData() const
std::shared_ptr< BranchIDListHelper > branchIDListHelper_
void setProcessConfiguration(ProcessConfiguration const *processConfiguration)
std::unique_ptr< ExceptionToActionTable const > act_table_
void setProcessHistoryRegistry(ProcessHistoryRegistry const &phr)
DelayedReader * reader() const
std::map< BranchID::value_type, BranchID::value_type > droppedBranchIDToKeptBranchID_
unsigned int value() const
detail::TriggerResultsBasedEventSelector selectors_
boost::shared_ptr< EventSetupProvider > makeProvider(ParameterSet &)
std::auto_ptr< Schedule > schedule_
void clearEventPrincipal()
void connectToSubProcess(ActivityRegistry &iOther)
std::shared_ptr< ActivityRegistry > actReg_
bool anyProductProduced() const
void setProductID(ProductID const &pid)
std::vector< HistoryAppender > historyAppenders_
std::shared_ptr< ThinnedAssociationsHelper > thinnedAssociationsHelper_
std::vector< BranchID::value_type > BranchIDList
void setStore(std::shared_ptr< ProductProvenanceRetriever > store) const
void fillEventPrincipal(EventAuxiliary const &aux, ProcessHistoryRegistry const &processHistoryRegistry, DelayedReader *reader=0)
std::unique_ptr< ParameterSet > processParameterSet_
std::vector< std::string > const & getAllTriggerNames()
void setProcessHistory(ProcessHistory const &ph)
std::vector< BranchDescription const * > SelectedProducts
unsigned int numberOfStreams() const
void fixBranchIDListsForEDAliases(std::map< BranchID::value_type, BranchID::value_type > const &droppedBranchIDToKeptBranchID)
void setProductProvenance(ProductProvenance const &prov) const
ProcessContext processContext_
BranchID const & originalBranchID() const
ProductID const & productID() 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)
SubProcess(ParameterSet ¶meterSet, ParameterSet const &topLevelParameterSet, std::shared_ptr< ProductRegistry const > parentProductRegistry, std::shared_ptr< BranchIDListHelper const > parentBranchIDListHelper, ThinnedAssociationsHelper const &parentThinnedAssociationsHelper, eventsetup::EventSetupsController &esController, ActivityRegistry &parentActReg, ServiceToken const &token, serviceregistry::ServiceLegacy iLegacy, PreallocationConfiguration const &preallocConfig, ProcessContext const *parentProcessContext)
std::auto_ptr< SubProcess > subProcess_
EventAuxiliary const & aux() const
bool configureEventSelector(edm::ParameterSet const &iPSet, std::string const &iProcessName, std::vector< std::string > const &iAllTriggerNames, edm::detail::TriggerResultsBasedEventSelector &oSelector)
ParameterSet const & registerIt()
std::shared_ptr< ProductRegistry const > preg_
PrincipalCache principalCache_
ParameterSet const & parameterSet(Provenance const &provenance)
std::shared_ptr< ProcessConfiguration const > processConfiguration_
bool productUnavailable() const