From a0d61031d6cba0e26fac7a5b3a4316db405b8ece Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Fri, 26 Jul 2013 10:38:41 -0500 Subject: [PATCH 1/6] Minor code cleanup based on actual use --- FWCore/Framework/interface/CachedProducts.h | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/FWCore/Framework/interface/CachedProducts.h b/FWCore/Framework/interface/CachedProducts.h index 0bafb70274aa9..42dc1817b4e34 100644 --- a/FWCore/Framework/interface/CachedProducts.h +++ b/FWCore/Framework/interface/CachedProducts.h @@ -76,10 +76,6 @@ namespace edm bool wantEvent(Event const& e); - // Get all TriggerResults objects for the process names we're - // interested in. - size_type fill(Event const& ev); - handle_t getOneTriggerResults(Event const& e); // Clear the cache @@ -88,9 +84,10 @@ namespace edm private: typedef selectors_t::iterator iter; - // Return the number of cached TriggerResult handles - //size_type size() const { return numberFound_; } - + // Get all TriggerResults objects for the process names we're + // interested in. + size_type fill(Event const& ev); + // If we have only one handle cached, return it; otherwise throw. handle_t returnOneHandleOrThrow(); From 2c3844672c293b4e726db961e24a4b00bc6e6053 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Fri, 26 Jul 2013 10:49:07 -0500 Subject: [PATCH 2/6] Renamed CachedProducts to TriggerResultsBasedEventSelector which better describes its purpose --- ...s.h => TriggerResultsBasedEventSelector.h} | 10 +++---- ...cc => TriggerResultsBasedEventSelector.cc} | 28 +++++++++---------- 2 files changed, 19 insertions(+), 19 deletions(-) rename FWCore/Framework/interface/{CachedProducts.h => TriggerResultsBasedEventSelector.h} (88%) rename FWCore/Framework/src/{CachedProducts.cc => TriggerResultsBasedEventSelector.cc} (80%) diff --git a/FWCore/Framework/interface/CachedProducts.h b/FWCore/Framework/interface/TriggerResultsBasedEventSelector.h similarity index 88% rename from FWCore/Framework/interface/CachedProducts.h rename to FWCore/Framework/interface/TriggerResultsBasedEventSelector.h index 42dc1817b4e34..e9bbb83872923 100644 --- a/FWCore/Framework/interface/CachedProducts.h +++ b/FWCore/Framework/interface/TriggerResultsBasedEventSelector.h @@ -1,9 +1,9 @@ -#ifndef Framework_CachedProducts_h -#define Framework_CachedProducts_h +#ifndef FWCore_Framework_TriggerResultsBasedEventSelector_h +#define FWCore_Framework_TriggerResultsBasedEventSelector_h // ------------------------------------------------------------------- // -// CachedProducts: This class is used by OutputModule to interact with +// TriggerResultsBasedEventSelector: This class is used by OutputModule to interact with // the TriggerResults objects upon which the decision to write out an // event is made. // @@ -59,10 +59,10 @@ namespace edm }; - class CachedProducts + class TriggerResultsBasedEventSelector { public: - CachedProducts(); + TriggerResultsBasedEventSelector(); typedef detail::handle_t handle_t; typedef std::vector selectors_t; typedef selectors_t::size_type size_type; diff --git a/FWCore/Framework/src/CachedProducts.cc b/FWCore/Framework/src/TriggerResultsBasedEventSelector.cc similarity index 80% rename from FWCore/Framework/src/CachedProducts.cc rename to FWCore/Framework/src/TriggerResultsBasedEventSelector.cc index 93675c28952e1..7aa588e2bec93 100644 --- a/FWCore/Framework/src/CachedProducts.cc +++ b/FWCore/Framework/src/TriggerResultsBasedEventSelector.cc @@ -2,7 +2,7 @@ #include "boost/bind.hpp" -#include "FWCore/Framework/interface/CachedProducts.h" +#include "FWCore/Framework/interface/TriggerResultsBasedEventSelector.h" #include "FWCore/Utilities/interface/Algorithms.h" namespace edm @@ -12,14 +12,14 @@ namespace edm typedef detail::NamedEventSelector NES; - CachedProducts::CachedProducts() : + TriggerResultsBasedEventSelector::TriggerResultsBasedEventSelector() : fillDone_(false), numberFound_(0), selectors_() { } void - CachedProducts::setupDefault(std::vector const& triggernames) + TriggerResultsBasedEventSelector::setupDefault(std::vector const& triggernames) { // Set up one NamedEventSelector, with default configuration @@ -30,7 +30,7 @@ namespace edm } void - CachedProducts::setup(std::vector const& path_specs, + TriggerResultsBasedEventSelector::setup(std::vector const& path_specs, std::vector const& triggernames, const std::string& process_name) { @@ -74,15 +74,15 @@ namespace edm } } - CachedProducts::handle_t - CachedProducts::getOneTriggerResults(Event const& ev) + TriggerResultsBasedEventSelector::handle_t + TriggerResultsBasedEventSelector::getOneTriggerResults(Event const& ev) { fill(ev); return returnOneHandleOrThrow(); } bool - CachedProducts::wantEvent(Event const& ev) + TriggerResultsBasedEventSelector::wantEvent(Event const& ev) { // We have to get all the TriggerResults objects before we test // any for a match, because we have to deal with the possibility @@ -106,15 +106,15 @@ namespace edm return match_found; } - CachedProducts::handle_t - CachedProducts::returnOneHandleOrThrow() + TriggerResultsBasedEventSelector::handle_t + TriggerResultsBasedEventSelector::returnOneHandleOrThrow() { switch (numberFound_) { case 0: throw edm::Exception(edm::errors::ProductNotFound, "TooFewProducts") - << "CachedProducts::returnOneHandleOrThrow: " + << "TriggerResultsBasedEventSelector::returnOneHandleOrThrow: " << " too few products found, " << "exepcted one, got zero\n"; case 1: @@ -123,15 +123,15 @@ namespace edm default: throw edm::Exception(edm::errors::ProductNotFound, "TooManyMatches") - << "CachedProducts::returnOneHandleOrThrow: " + << "TriggerResultsBasedEventSelector::returnOneHandleOrThrow: " << "too many products found, " << "expected one, got " << numberFound_ << '\n'; } return selectors_[0].product(); } - CachedProducts::size_type - CachedProducts::fill(Event const& ev) + TriggerResultsBasedEventSelector::size_type + TriggerResultsBasedEventSelector::fill(Event const& ev) { if (!fillDone_) { @@ -147,7 +147,7 @@ namespace edm } void - CachedProducts::clear() + TriggerResultsBasedEventSelector::clear() { for_all(selectors_, boost::bind(&NamedEventSelector::clear, _1)); fillDone_ = false; From 7f048f53cd54229ec0bde22c0acdd7308d6e7bc9 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Fri, 26 Jul 2013 13:24:25 -0500 Subject: [PATCH 3/6] TriggerResultsBasedEventSelector now uses EventPrincipal directly so we do not have to make a temporary edm::Event --- FWCore/Framework/interface/OutputModule.h | 13 ++------ .../TriggerResultsBasedEventSelector.h | 13 +++----- FWCore/Framework/src/OutputModule.cc | 31 +++++-------------- .../src/TriggerResultsBasedEventSelector.cc | 16 ++++++++-- 4 files changed, 28 insertions(+), 45 deletions(-) diff --git a/FWCore/Framework/interface/OutputModule.h b/FWCore/Framework/interface/OutputModule.h index 856ae79e64ce8..f13d0f82c2664 100644 --- a/FWCore/Framework/interface/OutputModule.h +++ b/FWCore/Framework/interface/OutputModule.h @@ -15,7 +15,7 @@ output stream. #include "DataFormats/Provenance/interface/ModuleDescription.h" #include "DataFormats/Provenance/interface/Selections.h" -#include "FWCore/Framework/interface/CachedProducts.h" +#include "FWCore/Framework/interface/TriggerResultsBasedEventSelector.h" #include "FWCore/Framework/interface/Frameworkfwd.h" #include "FWCore/Framework/interface/ProductSelectorRules.h" #include "FWCore/Framework/interface/ProductSelector.h" @@ -29,7 +29,7 @@ output stream. namespace edm { - typedef detail::CachedProducts::handle_t Trig; + typedef detail::TriggerResultsBasedEventSelector::handle_t Trig; std::vector const& getAllTriggerNames(); @@ -74,9 +74,6 @@ namespace edm { protected: - //Trig const& getTriggerResults(Event const& ep) const; - Trig getTriggerResults(Event const& ep) const; - // This function is needed for compatibility with older code. We // need to clean up the use of Event and EventPrincipal, to avoid // creation of multiple Event objects when handling a single @@ -148,12 +145,8 @@ namespace edm { // We do not own the pointed-to CurrentProcessingContext. CurrentProcessingContext const* current_context_; - //This will store TriggerResults objects for the current event. - // mutable std::vector prods_; - mutable bool prodsValid_; - bool wantAllEvents_; - mutable detail::CachedProducts selectors_; + mutable detail::TriggerResultsBasedEventSelector selectors_; // ID of the ParameterSet that configured the event selector // subsystem. ParameterSetID selector_config_id_; diff --git a/FWCore/Framework/interface/TriggerResultsBasedEventSelector.h b/FWCore/Framework/interface/TriggerResultsBasedEventSelector.h index e9bbb83872923..75ccadec7d301 100644 --- a/FWCore/Framework/interface/TriggerResultsBasedEventSelector.h +++ b/FWCore/Framework/interface/TriggerResultsBasedEventSelector.h @@ -12,7 +12,7 @@ #include #include -#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventPrincipal.h" #include "FWCore/Framework/interface/EventSelector.h" #include "DataFormats/Common/interface/Handle.h" #include "FWCore/Utilities/interface/InputTag.h" @@ -32,10 +32,7 @@ namespace edm product_() { } - void fill(Event const& e) - { - e.getByLabel(inputTag_, product_); - } + void fill(EventPrincipal const& e); bool match() { @@ -74,9 +71,9 @@ namespace edm std::vector const& triggernames, const std::string& process_name); - bool wantEvent(Event const& e); + bool wantEvent(EventPrincipal const& e); - handle_t getOneTriggerResults(Event const& e); + handle_t getOneTriggerResults(EventPrincipal const& e); // Clear the cache void clear(); @@ -86,7 +83,7 @@ namespace edm // Get all TriggerResults objects for the process names we're // interested in. - size_type fill(Event const& ev); + size_type fill(EventPrincipal const& ev); // If we have only one handle cached, return it; otherwise throw. handle_t returnOneHandleOrThrow(); diff --git a/FWCore/Framework/src/OutputModule.cc b/FWCore/Framework/src/OutputModule.cc index f0dcca59896d0..e02b357d1c507 100644 --- a/FWCore/Framework/src/OutputModule.cc +++ b/FWCore/Framework/src/OutputModule.cc @@ -112,7 +112,6 @@ namespace edm { productSelector_(), moduleDescription_(), current_context_(nullptr), - prodsValid_(false), wantAllEvents_(false), selectors_(), selector_config_id_(), @@ -266,34 +265,21 @@ namespace edm { } - Trig OutputModule::getTriggerResults(Event const& ev) const { - return selectors_.getOneTriggerResults(ev); - } - Trig OutputModule::getTriggerResults(EventPrincipal const& ep) const { - // This is bad, because we're returning handles into an Event that - // is destructed before the return. It might not fail, because the - // actual EventPrincipal is not destroyed, but it still needs to - // be cleaned up. - Event ev(const_cast(ep), - *current_context_->moduleDescription()); - return getTriggerResults(ev); - } + return selectors_.getOneTriggerResults(ep); } namespace { class PVSentry { public: - PVSentry(detail::CachedProducts& prods, bool& valid) : p(prods), v(valid) {} + PVSentry(detail::TriggerResultsBasedEventSelector& prods) : p(prods) {} ~PVSentry() { p.clear(); - v = false; } private: - detail::CachedProducts& p; - bool& v; + detail::TriggerResultsBasedEventSelector& p; - PVSentry(PVSentry const&); // not implemented - PVSentry& operator=(PVSentry const&); // not implemented + PVSentry(PVSentry const&) = delete; + PVSentry& operator=(PVSentry const&) = delete; }; } @@ -302,15 +288,12 @@ namespace edm { EventSetup const&, CurrentProcessingContext const* cpc) { detail::CPCSentry sentry(current_context_, cpc); - PVSentry products_sentry(selectors_, prodsValid_); + PVSentry products_sentry(selectors_); FDEBUG(2) << "writeEvent called\n"; if(!wantAllEvents_) { - // use module description and const_cast unless interface to - // event is changed to just take a const EventPrincipal - Event e(const_cast(ep), moduleDescription_); - if(!selectors_.wantEvent(e)) { + if(!selectors_.wantEvent(ep)) { return true; } } diff --git a/FWCore/Framework/src/TriggerResultsBasedEventSelector.cc b/FWCore/Framework/src/TriggerResultsBasedEventSelector.cc index 7aa588e2bec93..db9640f6a8383 100644 --- a/FWCore/Framework/src/TriggerResultsBasedEventSelector.cc +++ b/FWCore/Framework/src/TriggerResultsBasedEventSelector.cc @@ -5,10 +5,20 @@ #include "FWCore/Framework/interface/TriggerResultsBasedEventSelector.h" #include "FWCore/Utilities/interface/Algorithms.h" +static const edm::TypeID s_TrigResultsType(typeid(edm::TriggerResults)); + namespace edm { namespace detail { + void NamedEventSelector::fill(EventPrincipal const& e) { + edm::BasicHandle h = e.getByLabel(PRODUCT_TYPE, + s_TrigResultsType, + inputTag_, + nullptr); + convert_handle(h,product_); + } + typedef detail::NamedEventSelector NES; @@ -75,14 +85,14 @@ namespace edm } TriggerResultsBasedEventSelector::handle_t - TriggerResultsBasedEventSelector::getOneTriggerResults(Event const& ev) + TriggerResultsBasedEventSelector::getOneTriggerResults(EventPrincipal const& ev) { fill(ev); return returnOneHandleOrThrow(); } bool - TriggerResultsBasedEventSelector::wantEvent(Event const& ev) + TriggerResultsBasedEventSelector::wantEvent(EventPrincipal const& ev) { // We have to get all the TriggerResults objects before we test // any for a match, because we have to deal with the possibility @@ -131,7 +141,7 @@ namespace edm } TriggerResultsBasedEventSelector::size_type - TriggerResultsBasedEventSelector::fill(Event const& ev) + TriggerResultsBasedEventSelector::fill(EventPrincipal const& ev) { if (!fillDone_) { From 2c7b1f0e435ac7d2c630d6e8542720c9adbd7433 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Fri, 26 Jul 2013 17:11:53 -0500 Subject: [PATCH 4/6] Moved function out of OutputModule header and source files in order to reuse elsewhere. --- .../Framework/interface/getAllTriggerNames.h | 31 +++++++++++++++++++ FWCore/Framework/src/getAllTriggerNames.cc | 28 +++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 FWCore/Framework/interface/getAllTriggerNames.h create mode 100644 FWCore/Framework/src/getAllTriggerNames.cc diff --git a/FWCore/Framework/interface/getAllTriggerNames.h b/FWCore/Framework/interface/getAllTriggerNames.h new file mode 100644 index 0000000000000..1c957ee5498b1 --- /dev/null +++ b/FWCore/Framework/interface/getAllTriggerNames.h @@ -0,0 +1,31 @@ +#ifndef FWCore_Framework_getAllTriggerNames_h +#define FWCore_Framework_getAllTriggerNames_h +// -*- C++ -*- +// +// Package: Framework +// Class : getAllTriggerNames +// +/**\function getAllTriggerNames getAllTriggerNames.h "FWCore/Framework/interface/getAllTriggerNames.h" + + Description: Returns a list of all the trigger names in the current process + Usage: + + +*/ +// +// Original Author: Chris Jones +// Created: Fri, 26 Jul 2013 20:40:50 GMT +// $Id$ +// + +// system include files +#include +#include + +// user include files + +// forward declarations +namespace edm { + std::vector const& getAllTriggerNames(); +} +#endif diff --git a/FWCore/Framework/src/getAllTriggerNames.cc b/FWCore/Framework/src/getAllTriggerNames.cc new file mode 100644 index 0000000000000..50fe28ea3e415 --- /dev/null +++ b/FWCore/Framework/src/getAllTriggerNames.cc @@ -0,0 +1,28 @@ +// -*- C++ -*- +// +// Package: Package +// Class : getAllTriggerNames +// +// Implementation: +// [Notes on implementation] +// +// Original Author: Chris Jones +// Created: Fri, 26 Jul 2013 20:43:45 GMT +// $Id$ +// + +// system include files + +// user include files +#include "FWCore/Framework/interface/getAllTriggerNames.h" +#include "FWCore/ServiceRegistry/interface/Service.h" +#include "FWCore/Framework/interface/TriggerNamesService.h" + + +namespace edm { + + std::vector const& getAllTriggerNames() { + Service tns; + return tns->getTrigPaths(); + } +} From 914ff0f03eb1feb59d203c7d377188ebd587cf34 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Fri, 26 Jul 2013 17:13:52 -0500 Subject: [PATCH 5/6] Made SubProcess no longer inherit from edm::OutputModule. This was accomplished by moving common code to different class files --- FWCore/Framework/interface/OutputModule.h | 3 +- FWCore/Framework/interface/ScheduleItems.h | 4 +- FWCore/Framework/interface/SubProcess.h | 61 ++++--- .../TriggerResultsBasedEventSelector.h | 32 +++- FWCore/Framework/src/OutputModule.cc | 153 ++---------------- FWCore/Framework/src/ScheduleItems.cc | 4 +- FWCore/Framework/src/SubProcess.cc | 134 ++++++++++++--- .../src/TriggerResultsBasedEventSelector.cc | 138 ++++++++++++++++ 8 files changed, 340 insertions(+), 189 deletions(-) diff --git a/FWCore/Framework/interface/OutputModule.h b/FWCore/Framework/interface/OutputModule.h index f13d0f82c2664..d69d31369373e 100644 --- a/FWCore/Framework/interface/OutputModule.h +++ b/FWCore/Framework/interface/OutputModule.h @@ -20,6 +20,7 @@ output stream. #include "FWCore/Framework/interface/ProductSelectorRules.h" #include "FWCore/Framework/interface/ProductSelector.h" #include "FWCore/Framework/interface/EDConsumerBase.h" +#include "FWCore/Framework/interface/getAllTriggerNames.h" #include "FWCore/ParameterSet/interface/ParameterSetfwd.h" #include @@ -31,8 +32,6 @@ namespace edm { typedef detail::TriggerResultsBasedEventSelector::handle_t Trig; - std::vector const& getAllTriggerNames(); - class OutputModule : public EDConsumerBase { public: template friend class WorkerT; diff --git a/FWCore/Framework/interface/ScheduleItems.h b/FWCore/Framework/interface/ScheduleItems.h index 83b9da25761b0..bfa85e0430c3f 100644 --- a/FWCore/Framework/interface/ScheduleItems.h +++ b/FWCore/Framework/interface/ScheduleItems.h @@ -14,7 +14,7 @@ namespace edm { class ActivityRegistry; class BranchIDListHelper; class CommonParams; - class OutputModule; + class SubProcess; class ParameterSet; class ProcessConfiguration; class ProductRegistry; @@ -25,7 +25,7 @@ namespace edm { struct ScheduleItems { ScheduleItems(); - ScheduleItems(ProductRegistry const& preg, BranchIDListHelper const& branchIDListHelper, OutputModule const& om); + ScheduleItems(ProductRegistry const& preg, BranchIDListHelper const& branchIDListHelper, SubProcess const& om); ScheduleItems(ScheduleItems const&) = delete; // Disallow copying and moving ScheduleItems& operator=(ScheduleItems const&) = delete; // Disallow copying and moving diff --git a/FWCore/Framework/interface/SubProcess.h b/FWCore/Framework/interface/SubProcess.h index d11eb265b0865..8e35b57db7b40 100644 --- a/FWCore/Framework/interface/SubProcess.h +++ b/FWCore/Framework/interface/SubProcess.h @@ -2,14 +2,18 @@ #define FWCore_Framework_SubProcess_h #include "FWCore/Framework/interface/EventSetupProvider.h" -#include "FWCore/Framework/interface/OutputModule.h" #include "FWCore/Framework/src/PrincipalCache.h" #include "FWCore/Framework/interface/ScheduleItems.h" #include "FWCore/Framework/interface/Schedule.h" +#include "FWCore/Framework/interface/TriggerResultsBasedEventSelector.h" +#include "FWCore/Framework/interface/ProductSelectorRules.h" +#include "FWCore/Framework/interface/ProductSelector.h" #include "FWCore/ServiceRegistry/interface/ServiceLegacy.h" #include "FWCore/ServiceRegistry/interface/ServiceToken.h" #include "FWCore/Utilities/interface/BranchType.h" +#include "DataFormats/Provenance/interface/Selections.h" + #include "boost/shared_ptr.hpp" #include @@ -25,7 +29,7 @@ namespace edm { namespace eventsetup { class EventSetupsController; } - class SubProcess : public OutputModule { + class SubProcess { public: SubProcess(ParameterSet& parameterSet, ParameterSet const& topLevelParameterSet, @@ -37,14 +41,13 @@ namespace edm { serviceregistry::ServiceLegacy iLegacy); virtual ~SubProcess(); + + //From OutputModule + void selectProducts(ProductRegistry const& preg); + SelectionsArray const& keptProducts() const {return keptProducts_;} - using OutputModule::doBeginJob; - using OutputModule::doEndJob; - using OutputModule::doBeginRun; - using OutputModule::doEndRun; - using OutputModule::doBeginLuminosityBlock; - using OutputModule::doEndLuminosityBlock; - using OutputModule::doEvent; + void doBeginJob(); + void doEndJob(); void doEvent(EventPrincipal const& principal, IOVSyncValue const& ts); @@ -210,19 +213,22 @@ namespace edm { EventSetup const& es_; }; - virtual void beginJob(); - virtual void endJob(); - virtual void write(EventPrincipal const& e); - virtual void beginRun(RunPrincipal const& r); - virtual void endRun(RunPrincipal const& r); - virtual void beginLuminosityBlock(LuminosityBlockPrincipal const& lb); - virtual void endLuminosityBlock(LuminosityBlockPrincipal const& lb); - virtual void writeRun(RunPrincipal const&) { throw 0; } - virtual void writeLuminosityBlock(LuminosityBlockPrincipal const&) { throw 0; } + void beginJob(); + void endJob(); + void process(EventPrincipal const& e); + void beginRun(RunPrincipal const& r); + void endRun(RunPrincipal const& r); + void beginLuminosityBlock(LuminosityBlockPrincipal const& lb); + void endLuminosityBlock(LuminosityBlockPrincipal const& lb); void propagateProducts(BranchType type, Principal const& parentPrincipal, Principal& principal) const; void fixBranchIDListsForEDAliases(std::map const& droppedBranchIDToKeptBranchID); + std::map const& droppedBranchIDToKeptBranchID() { + return droppedBranchIDToKeptBranchID_; + } + + ServiceToken serviceToken_; boost::shared_ptr parentPreg_; boost::shared_ptr preg_; @@ -238,6 +244,25 @@ namespace edm { std::auto_ptr subProcess_; bool cleaningUpAfterException_; std::unique_ptr processParameterSet_; + + // keptProducts_ are pointers to the BranchDescription objects describing + // the branches we are to write. + // + // We do not own the BranchDescriptions to which we point. + SelectionsArray keptProducts_; + ProductSelectorRules productSelectorRules_; + ProductSelector productSelector_; + + + //EventSelection + bool wantAllEvents_; + ParameterSetID selector_config_id_; + mutable detail::TriggerResultsBasedEventSelector selectors_; + + // needed because of possible EDAliases. + // filled in only if key and value are different. + std::map droppedBranchIDToKeptBranchID_; + }; // free function diff --git a/FWCore/Framework/interface/TriggerResultsBasedEventSelector.h b/FWCore/Framework/interface/TriggerResultsBasedEventSelector.h index 75ccadec7d301..79f33de73dbd7 100644 --- a/FWCore/Framework/interface/TriggerResultsBasedEventSelector.h +++ b/FWCore/Framework/interface/TriggerResultsBasedEventSelector.h @@ -11,6 +11,7 @@ #include #include #include +#include #include "FWCore/Framework/interface/EventPrincipal.h" #include "FWCore/Framework/interface/EventSelector.h" @@ -55,7 +56,6 @@ namespace edm handle_t product_; }; - class TriggerResultsBasedEventSelector { public: @@ -93,6 +93,36 @@ namespace edm size_type numberFound_; selectors_t selectors_; }; + + class TRBESSentry { + public: + TRBESSentry(detail::TriggerResultsBasedEventSelector& prods) : p(prods) {} + ~TRBESSentry() { + p.clear(); + } + private: + detail::TriggerResultsBasedEventSelector& p; + + TRBESSentry(TRBESSentry const&) = delete; + TRBESSentry& operator=(TRBESSentry const&) = delete; + }; + + + /** Handles the final initialization of the TriggerResutsBasedEventSelector + \return true if all events will be selected + */ + bool configureEventSelector(edm::ParameterSet const& iPSet, + std::string const& iProcessName, + std::vector const& iAllTriggerNames, + edm::detail::TriggerResultsBasedEventSelector& oSelector); + /** Takes the user specified SelectEvents PSet and creates a new one + which conforms to the canonical format required for provenance + */ + ParameterSetID registerProperSelectionInfo(edm::ParameterSet const& iInitial, + std::string const& iLabel, + std::map > > const& outputModulePathPositions, + bool anyProductProduced); + } } diff --git a/FWCore/Framework/src/OutputModule.cc b/FWCore/Framework/src/OutputModule.cc index e02b357d1c507..fe9c455726421 100644 --- a/FWCore/Framework/src/OutputModule.cc +++ b/FWCore/Framework/src/OutputModule.cc @@ -25,82 +25,6 @@ namespace edm { - std::vector const& getAllTriggerNames() { - Service tns; - return tns->getTrigPaths(); - } -} - -namespace { - //-------------------------------------------------------- - // Remove whitespace (spaces and tabs) from a std::string. - void remove_whitespace(std::string& s) { - s.erase(std::remove(s.begin(), s.end(), ' '), s.end()); - s.erase(std::remove(s.begin(), s.end(), '\t'), s.end()); - } - - void test_remove_whitespace() { - std::string a("noblanks"); - std::string b("\t no blanks \t"); - - remove_whitespace(b); - assert(a == b); - } - - //-------------------------------------------------------- - // Given a path-spec (std::string of the form "a:b", where the ":b" is - // optional), return a parsed_path_spec_t containing "a" and "b". - - typedef std::pair parsed_path_spec_t; - void parse_path_spec(std::string const& path_spec, - parsed_path_spec_t& output) { - std::string trimmed_path_spec(path_spec); - remove_whitespace(trimmed_path_spec); - - std::string::size_type colon = trimmed_path_spec.find(":"); - if(colon == std::string::npos) { - output.first = trimmed_path_spec; - } else { - output.first = trimmed_path_spec.substr(0, colon); - output.second = trimmed_path_spec.substr(colon + 1, - trimmed_path_spec.size()); - } - } - - void test_parse_path_spec() { - std::vector paths; - paths.push_back("a:p1"); - paths.push_back("b:p2"); - paths.push_back(" c"); - paths.push_back("ddd\t:p3"); - paths.push_back("eee: p4 "); - - std::vector parsed(paths.size()); - for(size_t i = 0; i < paths.size(); ++i) { - parse_path_spec(paths[i], parsed[i]); - } - - assert(parsed[0].first == "a"); - assert(parsed[0].second == "p1"); - assert(parsed[1].first == "b"); - assert(parsed[1].second == "p2"); - assert(parsed[2].first == "c"); - assert(parsed[2].second == ""); - assert(parsed[3].first == "ddd"); - assert(parsed[3].second == "p3"); - assert(parsed[4].first == "eee"); - assert(parsed[4].second == "p4"); - } -} - -namespace edm { - namespace test { - void run_all_output_module_tests() { - test_remove_whitespace(); - test_parse_path_spec(); - } - } - // ------------------------------------------------------- OutputModule::OutputModule(ParameterSet const& pset) : maxEvents_(-1), @@ -133,32 +57,10 @@ namespace edm { selectevents.registerIt(); // Just in case this PSet is not registered selector_config_id_ = selectevents.id(); - // If selectevents is an emtpy ParameterSet, then we are to write - // all events, or one which contains a vstrig 'SelectEvents' that - // is empty, we are to write all events. We have no need for any - // EventSelectors. - if(selectevents.empty()) { - wantAllEvents_ = true; - selectors_.setupDefault(getAllTriggerNames()); - return; - } - - std::vector path_specs = - selectevents.getParameter >("SelectEvents"); - - if(path_specs.empty()) { - wantAllEvents_ = true; - selectors_.setupDefault(getAllTriggerNames()); - return; - } - - // If we get here, we have the possibility of having to deal with - // path_specs that look at more than one process. - std::vector parsed_paths(path_specs.size()); - for(size_t i = 0; i < path_specs.size(); ++i) { - parse_path_spec(path_specs[i], parsed_paths[i]); - } - selectors_.setup(parsed_paths, getAllTriggerNames(), process_name_); + wantAllEvents_ = detail::configureEventSelector(selectevents, + process_name_, + getAllTriggerNames(), + selectors_); } void OutputModule::configure(OutputModuleDescription const& desc) { @@ -269,18 +171,6 @@ namespace edm { return selectors_.getOneTriggerResults(ep); } namespace { - class PVSentry { - public: - PVSentry(detail::TriggerResultsBasedEventSelector& prods) : p(prods) {} - ~PVSentry() { - p.clear(); - } - private: - detail::TriggerResultsBasedEventSelector& p; - - PVSentry(PVSentry const&) = delete; - PVSentry& operator=(PVSentry const&) = delete; - }; } bool @@ -288,7 +178,7 @@ namespace edm { EventSetup const&, CurrentProcessingContext const* cpc) { detail::CPCSentry sentry(current_context_, cpc); - PVSentry products_sentry(selectors_); + detail::TRBESSentry products_sentry(selectors_); FDEBUG(2) << "writeEvent called\n"; @@ -492,37 +382,14 @@ namespace edm { OutputModule::baseType() { return kBaseType; } - + void OutputModule::setEventSelectionInfo(std::map > > const& outputModulePathPositions, bool anyProductProduced) { - - ParameterSet selectEventsInfo; - selectEventsInfo.copyForModify(getParameterSet(selector_config_id_)); - selectEventsInfo.addParameter("InProcessHistory", anyProductProduced); - std::string const& label = description().moduleLabel(); - std::vector endPaths; - std::vector endPathPositions; - - // The label will be empty if and only if this is a SubProcess - // SubProcess's do not appear on any end path - if (!label.empty()) { - std::map > >::const_iterator iter = outputModulePathPositions.find(label); - assert(iter != outputModulePathPositions.end()); - for (std::vector >::const_iterator i = iter->second.begin(), e = iter->second.end(); - i != e; ++i) { - endPaths.push_back(i->first); - endPathPositions.push_back(i->second); - } - } - selectEventsInfo.addParameter >("EndPaths", endPaths); - selectEventsInfo.addParameter >("EndPathPositions", endPathPositions); - if (!selectEventsInfo.exists("SelectEvents")) { - selectEventsInfo.addParameter >("SelectEvents", std::vector()); - } - selectEventsInfo.registerIt(); - - selector_config_id_ = selectEventsInfo.id(); + selector_config_id_ = detail::registerProperSelectionInfo(getParameterSet(selector_config_id_), + description().moduleLabel(), + outputModulePathPositions, + anyProductProduced); } void diff --git a/FWCore/Framework/src/ScheduleItems.cc b/FWCore/Framework/src/ScheduleItems.cc index f12eb80bc4bf3..775a841d577b2 100644 --- a/FWCore/Framework/src/ScheduleItems.cc +++ b/FWCore/Framework/src/ScheduleItems.cc @@ -7,7 +7,7 @@ #include "FWCore/Framework/interface/Actions.h" #include "FWCore/Framework/interface/CommonParams.h" #include "FWCore/Framework/interface/ConstProductRegistry.h" -#include "FWCore/Framework/interface/OutputModule.h" +#include "FWCore/Framework/interface/SubProcess.h" #include "FWCore/Framework/interface/Schedule.h" #include "FWCore/Framework/interface/TriggerNamesService.h" #include "FWCore/Framework/src/SignallingProductRegistry.h" @@ -29,7 +29,7 @@ namespace edm { processConfiguration_() { } - ScheduleItems::ScheduleItems(ProductRegistry const& preg, BranchIDListHelper const& branchIDListHelper, OutputModule const& om) : + ScheduleItems::ScheduleItems(ProductRegistry const& preg, BranchIDListHelper const& branchIDListHelper, SubProcess const& om) : actReg_(new ActivityRegistry), preg_(new SignallingProductRegistry(preg)), branchIDListHelper_(new BranchIDListHelper(branchIDListHelper)), diff --git a/FWCore/Framework/src/SubProcess.cc b/FWCore/Framework/src/SubProcess.cc index 8a5bcf8aafa16..8abb009e4cf8d 100644 --- a/FWCore/Framework/src/SubProcess.cc +++ b/FWCore/Framework/src/SubProcess.cc @@ -18,6 +18,8 @@ #include "FWCore/Framework/interface/OccurrenceTraits.h" #include "FWCore/Framework/interface/OutputModuleDescription.h" #include "FWCore/Framework/interface/RunPrincipal.h" +#include "FWCore/Framework/interface/getAllTriggerNames.h" +#include "FWCore/Framework/interface/TriggerNamesService.h" #include "FWCore/Framework/src/EventSetupsController.h" #include "FWCore/Framework/src/SignallingProductRegistry.h" #include "FWCore/ParameterSet/interface/IllegalParameters.h" @@ -38,7 +40,6 @@ namespace edm { ActivityRegistry& parentActReg, ServiceToken const& token, serviceregistry::ServiceLegacy iLegacy) : - OutputModule(parameterSet), serviceToken_(), parentPreg_(parentProductRegistry), preg_(), @@ -53,8 +54,28 @@ namespace edm { esInfo_(nullptr), subProcess_(), cleaningUpAfterException_(false), - processParameterSet_() { - + processParameterSet_(), + productSelectorRules_(parameterSet, "outputCommands", "OutputModule"), + productSelector_(), + wantAllEvents_(true) { + + //Setup the event selection + Service tns; + + ParameterSet selectevents = + parameterSet.getUntrackedParameterSet("SelectEvents", ParameterSet()); + + selectevents.registerIt(); // Just in case this PSet is not registered + wantAllEvents_ = detail::configureEventSelector(selectevents, + tns->getProcessName(), + getAllTriggerNames(), + selectors_); + std::map > > outputModulePathPositions; + selector_config_id_ = detail::registerProperSelectionInfo(selectevents, + "", + outputModulePathPositions, + parentProductRegistry->anyProductProduced()); + selectProducts(*parentProductRegistry); std::string const maxEvents("maxEvents"); @@ -116,12 +137,6 @@ namespace edm { branchIDListHelper_ = items.branchIDListHelper_; processConfiguration_ = items.processConfiguration_; - OutputModuleDescription desc(branchIDListHelper_->branchIDLists()); - configure(desc); - - std::map > > outputModulePathPositions; - setEventSelectionInfo(outputModulePathPositions, parentProductRegistry->anyProductProduced()); - boost::shared_ptr ep(new EventPrincipal(preg_, branchIDListHelper_, *processConfiguration_, historyAppender_.get(), StreamID::invalidStreamID())); principalCache_.insert(ep); @@ -133,6 +148,17 @@ namespace edm { SubProcess::~SubProcess() {} + void + SubProcess::doBeginJob() { + this->beginJob(); + } + + void + SubProcess::doEndJob() { + endJob(); + } + + void SubProcess::beginJob() { if(!droppedBranchIDToKeptBranchID().empty()) { @@ -154,6 +180,61 @@ namespace edm { } } + void + SubProcess::selectProducts(ProductRegistry const& preg) { + if(productSelector_.initialized()) return; + productSelector_.initialize(productSelectorRules_, preg.allBranchDescriptions()); + + // TODO: See if we can collapse keptProducts_ and productSelector_ into a + // single object. See the notes in the header for ProductSelector + // for more information. + + std::map trueBranchIDToKeptBranchDesc; + + for(auto const& it : preg.productList()) { + BranchDescription const& desc = it.second; + if(desc.transient()) { + // if the class of the branch is marked transient, output nothing + } else if(!desc.present() && !desc.produced()) { + // else if the branch containing the product has been previously dropped, + // output nothing + } else if(productSelector_.selected(desc)) { + // else if the branch has been selected, put it in the list of selected branches. + if(desc.produced()) { + // First we check if an equivalent branch has already been selected due to an EDAlias. + // We only need the check for products produced in this process. + BranchID const& trueBranchID = desc.originalBranchID(); + std::map::const_iterator iter = trueBranchIDToKeptBranchDesc.find(trueBranchID); + if(iter != trueBranchIDToKeptBranchDesc.end()) { + throw edm::Exception(errors::Configuration, "Duplicate Output Selection") + << "Two (or more) equivalent branches have been selected for output.\n" + << "#1: " << BranchKey(desc) << "\n" + << "#2: " << BranchKey(*iter->second) << "\n" + << "Please drop at least one of them.\n"; + } + trueBranchIDToKeptBranchDesc.insert(std::make_pair(trueBranchID, &desc)); + } + // Now put it in the list of selected branches. + keptProducts_[desc.branchType()].push_back(&desc); + } + } + // Now fill in a mapping needed in the case that a branch was dropped while its EDAlias was kept. + for(auto const& it : preg.productList()) { + BranchDescription const& desc = it.second; + if(!desc.produced() || desc.isAlias()) continue; + BranchID const& branchID = desc.branchID(); + std::map::const_iterator iter = trueBranchIDToKeptBranchDesc.find(branchID); + if(iter != trueBranchIDToKeptBranchDesc.end()) { + // This branch, produced in this process, or an alias of it, was persisted. + BranchID const& keptBranchID = iter->second->branchID(); + if(keptBranchID != branchID) { + // An EDAlias branch was persisted. + droppedBranchIDToKeptBranchID_.insert(std::make_pair(branchID.id(), keptBranchID.id())); + } + } + } + } + void SubProcess::fixBranchIDListsForEDAliases(std::map const& droppedBranchIDToKeptBranchID) { // Check for branches dropped while an EDAlias was kept. @@ -175,23 +256,36 @@ namespace edm { } void - SubProcess::doEvent(EventPrincipal const& principal, IOVSyncValue const& ts) { + SubProcess::doEvent(EventPrincipal const& ep, IOVSyncValue const& ts) { ServiceRegistry::Operate operate(serviceToken_); esInfo_.reset(new ESInfo(ts, *esp_)); - CurrentProcessingContext cpc; - doEvent(principal, esInfo_->es_, &cpc); + /* BEGIN relevant bits from OutputModule::doEvent */ + detail::TRBESSentry products_sentry(selectors_); + + + if(!wantAllEvents_) { + // use module description and const_cast unless interface to + // event is changed to just take a const EventPrincipal + if(!selectors_.wantEvent(ep)) { + return; + } + } + process(ep); + /* END relevant bits from OutputModule::doEvent */ + + //doEvent(principal, esInfo_->es_, &cpc); esInfo_.reset(); } void - SubProcess::write(EventPrincipal const& principal) { + SubProcess::process(EventPrincipal const& principal) { EventAuxiliary aux(principal.aux()); aux.setProcessHistoryID(principal.processHistoryID()); boost::shared_ptr esids(new EventSelectionIDVector); *esids = principal.eventSelectionIDs(); - if (principal.productRegistry().anyProductProduced() || !wantAllEvents()) { - esids->push_back(selectorConfig()); + if (principal.productRegistry().anyProductProduced() || !wantAllEvents_) { + esids->push_back(selector_config_id_); } EventPrincipal& ep = principalCache_.eventPrincipal(); @@ -214,7 +308,7 @@ namespace edm { ServiceRegistry::Operate operate(serviceToken_); esInfo_.reset(new ESInfo(ts, *esp_)); CurrentProcessingContext cpc; - doBeginRun(principal, esInfo_->es_, &cpc); + beginRun(principal); esInfo_.reset(); } @@ -244,8 +338,7 @@ namespace edm { cleaningUpAfterException_ = cleaningUpAfterException; ServiceRegistry::Operate operate(serviceToken_); esInfo_.reset(new ESInfo(ts, *esp_)); - CurrentProcessingContext cpc; - doEndRun(principal, esInfo_->es_, &cpc); + endRun(principal); esInfo_.reset(); } @@ -279,8 +372,7 @@ namespace edm { SubProcess::doBeginLuminosityBlock(LuminosityBlockPrincipal const& principal, IOVSyncValue const& ts) { ServiceRegistry::Operate operate(serviceToken_); esInfo_.reset(new ESInfo(ts, *esp_)); - CurrentProcessingContext cpc; - doBeginLuminosityBlock(principal, esInfo_->es_, &cpc); + beginLuminosityBlock(principal); esInfo_.reset(); } @@ -305,7 +397,7 @@ namespace edm { ServiceRegistry::Operate operate(serviceToken_); esInfo_.reset(new ESInfo(ts, *esp_)); CurrentProcessingContext cpc; - doEndLuminosityBlock(principal, esInfo_->es_, &cpc); + endLuminosityBlock(principal); esInfo_.reset(); } diff --git a/FWCore/Framework/src/TriggerResultsBasedEventSelector.cc b/FWCore/Framework/src/TriggerResultsBasedEventSelector.cc index db9640f6a8383..18707f8517378 100644 --- a/FWCore/Framework/src/TriggerResultsBasedEventSelector.cc +++ b/FWCore/Framework/src/TriggerResultsBasedEventSelector.cc @@ -3,14 +3,118 @@ #include "boost/bind.hpp" #include "FWCore/Framework/interface/TriggerResultsBasedEventSelector.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Utilities/interface/Algorithms.h" static const edm::TypeID s_TrigResultsType(typeid(edm::TriggerResults)); +namespace { + //-------------------------------------------------------- + // Remove whitespace (spaces and tabs) from a std::string. + void remove_whitespace(std::string& s) { + s.erase(std::remove(s.begin(), s.end(), ' '), s.end()); + s.erase(std::remove(s.begin(), s.end(), '\t'), s.end()); + } + + void test_remove_whitespace() { + std::string a("noblanks"); + std::string b("\t no blanks \t"); + + remove_whitespace(b); + assert(a == b); + } + + //-------------------------------------------------------- + // Given a path-spec (std::string of the form "a:b", where the ":b" is + // optional), return a parsed_path_spec_t containing "a" and "b". + + typedef std::pair parsed_path_spec_t; + void parse_path_spec(std::string const& path_spec, + parsed_path_spec_t& output) { + std::string trimmed_path_spec(path_spec); + remove_whitespace(trimmed_path_spec); + + std::string::size_type colon = trimmed_path_spec.find(":"); + if(colon == std::string::npos) { + output.first = trimmed_path_spec; + } else { + output.first = trimmed_path_spec.substr(0, colon); + output.second = trimmed_path_spec.substr(colon + 1, + trimmed_path_spec.size()); + } + } + + void test_parse_path_spec() { + std::vector paths; + paths.push_back("a:p1"); + paths.push_back("b:p2"); + paths.push_back(" c"); + paths.push_back("ddd\t:p3"); + paths.push_back("eee: p4 "); + + std::vector parsed(paths.size()); + for(size_t i = 0; i < paths.size(); ++i) { + parse_path_spec(paths[i], parsed[i]); + } + + assert(parsed[0].first == "a"); + assert(parsed[0].second == "p1"); + assert(parsed[1].first == "b"); + assert(parsed[1].second == "p2"); + assert(parsed[2].first == "c"); + assert(parsed[2].second == ""); + assert(parsed[3].first == "ddd"); + assert(parsed[3].second == "p3"); + assert(parsed[4].first == "eee"); + assert(parsed[4].second == "p4"); + } +} + namespace edm { + namespace test { + void run_all_output_module_tests() { + test_remove_whitespace(); + test_parse_path_spec(); + } + } + namespace detail { + + bool configureEventSelector(edm::ParameterSet const& iPSet, + std::string const& iProcessName, + std::vector const& iAllTriggerNames, + edm::detail::TriggerResultsBasedEventSelector& oSelector) { + // If selectevents is an emtpy ParameterSet, then we are to write + // all events, or one which contains a vstrig 'SelectEvents' that + // is empty, we are to write all events. We have no need for any + // EventSelectors. + if(iPSet.empty()) { + oSelector.setupDefault(iAllTriggerNames); + return true; + } + + std::vector path_specs = + iPSet.getParameter >("SelectEvents"); + + if(path_specs.empty()) { + oSelector.setupDefault(iAllTriggerNames); + return true; + } + + // If we get here, we have the possibility of having to deal with + // path_specs that look at more than one process. + std::vector parsed_paths(path_specs.size()); + for(size_t i = 0; i < path_specs.size(); ++i) { + parse_path_spec(path_specs[i], parsed_paths[i]); + } + oSelector.setup(parsed_paths, iAllTriggerNames, iProcessName); + + return false; + } + + void NamedEventSelector::fill(EventPrincipal const& e) { edm::BasicHandle h = e.getByLabel(PRODUCT_TYPE, s_TrigResultsType, @@ -165,5 +269,39 @@ namespace edm } + + ParameterSetID + registerProperSelectionInfo(edm::ParameterSet const& iInitial, + std::string const& iLabel, + std::map > > const& outputModulePathPositions, + bool anyProductProduced) { + ParameterSet selectEventsInfo; + selectEventsInfo.copyForModify(iInitial); + selectEventsInfo.addParameter("InProcessHistory", anyProductProduced); + std::vector endPaths; + std::vector endPathPositions; + + // The label will be empty if and only if this is a SubProcess + // SubProcess's do not appear on any end path + if (!iLabel.empty()) { + std::map > >::const_iterator iter = outputModulePathPositions.find(iLabel); + assert(iter != outputModulePathPositions.end()); + for (std::vector >::const_iterator i = iter->second.begin(), e = iter->second.end(); + i != e; ++i) { + endPaths.push_back(i->first); + endPathPositions.push_back(i->second); + } + } + selectEventsInfo.addParameter >("EndPaths", endPaths); + selectEventsInfo.addParameter >("EndPathPositions", endPathPositions); + if (!selectEventsInfo.exists("SelectEvents")) { + selectEventsInfo.addParameter >("SelectEvents", std::vector()); + } + selectEventsInfo.registerIt(); + + return selectEventsInfo.id(); + } + + } // namespace detail } // namespace edm From 1904ed3ab46f2a79c630a92194669347480400b0 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Sat, 27 Jul 2013 18:02:52 -0500 Subject: [PATCH 6/6] Completed the Stream based transitions. Removed further remnants of when SubProcess inherited from OutputModule. --- FWCore/Framework/interface/SubProcess.h | 18 ++-- FWCore/Framework/src/SubProcess.cc | 104 +++++++++++++----------- 2 files changed, 61 insertions(+), 61 deletions(-) diff --git a/FWCore/Framework/interface/SubProcess.h b/FWCore/Framework/interface/SubProcess.h index 8e35b57db7b40..d51f0f24d7ab5 100644 --- a/FWCore/Framework/interface/SubProcess.h +++ b/FWCore/Framework/interface/SubProcess.h @@ -207,19 +207,13 @@ namespace edm { } private: - struct ESInfo { - ESInfo(IOVSyncValue const& ts, eventsetup::EventSetupProvider& esp); - IOVSyncValue const& ts_; - EventSetup const& es_; - }; - void beginJob(); void endJob(); - void process(EventPrincipal const& e); - void beginRun(RunPrincipal const& r); - void endRun(RunPrincipal const& r); - void beginLuminosityBlock(LuminosityBlockPrincipal const& lb); - void endLuminosityBlock(LuminosityBlockPrincipal const& lb); + void process(EventPrincipal const& e, IOVSyncValue const& ts); + void beginRun(RunPrincipal const& r, IOVSyncValue const& ts); + void endRun(RunPrincipal const& r, IOVSyncValue const& ts, bool cleaningUpAfterException); + void beginLuminosityBlock(LuminosityBlockPrincipal const& lb, IOVSyncValue const& ts); + void endLuminosityBlock(LuminosityBlockPrincipal const& lb, IOVSyncValue const& ts, bool cleaningUpAfterException); void propagateProducts(BranchType type, Principal const& parentPrincipal, Principal& principal) const; void fixBranchIDListsForEDAliases(std::map const& droppedBranchIDToKeptBranchID); @@ -240,9 +234,7 @@ namespace edm { std::auto_ptr schedule_; std::map parentToChildPhID_; std::unique_ptr historyAppender_; - std::auto_ptr esInfo_; std::auto_ptr subProcess_; - bool cleaningUpAfterException_; std::unique_ptr processParameterSet_; // keptProducts_ are pointers to the BranchDescription objects describing diff --git a/FWCore/Framework/src/SubProcess.cc b/FWCore/Framework/src/SubProcess.cc index 8abb009e4cf8d..0e9ea68e074ad 100644 --- a/FWCore/Framework/src/SubProcess.cc +++ b/FWCore/Framework/src/SubProcess.cc @@ -51,9 +51,7 @@ namespace edm { schedule_(), parentToChildPhID_(), historyAppender_(new HistoryAppender), - esInfo_(nullptr), subProcess_(), - cleaningUpAfterException_(false), processParameterSet_(), productSelectorRules_(parameterSet, "outputCommands", "OutputModule"), productSelector_(), @@ -250,15 +248,9 @@ namespace edm { if(subProcess_.get()) subProcess_->fixBranchIDListsForEDAliases(droppedBranchIDToKeptBranchID); } - SubProcess::ESInfo::ESInfo(IOVSyncValue const& ts, eventsetup::EventSetupProvider& esp) : - ts_(ts), - es_(esp.eventSetupForInstance(ts)) { - } - void SubProcess::doEvent(EventPrincipal const& ep, IOVSyncValue const& ts) { ServiceRegistry::Operate operate(serviceToken_); - esInfo_.reset(new ESInfo(ts, *esp_)); /* BEGIN relevant bits from OutputModule::doEvent */ detail::TRBESSentry products_sentry(selectors_); @@ -270,15 +262,12 @@ namespace edm { return; } } - process(ep); + process(ep,ts); /* END relevant bits from OutputModule::doEvent */ - - //doEvent(principal, esInfo_->es_, &cpc); - esInfo_.reset(); } void - SubProcess::process(EventPrincipal const& principal) { + SubProcess::process(EventPrincipal const& principal, IOVSyncValue const& ts) { EventAuxiliary aux(principal.aux()); aux.setProcessHistoryID(principal.processHistoryID()); @@ -298,22 +287,19 @@ namespace edm { ep.setLuminosityBlockPrincipal(principalCache_.lumiPrincipalPtr()); propagateProducts(InEvent, principal, ep); typedef OccurrenceTraits Traits; - schedule_->processOneOccurrence(ep, esInfo_->es_); - if(subProcess_.get()) subProcess_->doEvent(ep, esInfo_->ts_); + schedule_->processOneOccurrence(ep, esp_->eventSetupForInstance(ts)); + if(subProcess_.get()) subProcess_->doEvent(ep, ts); ep.clearEventPrincipal(); } void SubProcess::doBeginRun(RunPrincipal const& principal, IOVSyncValue const& ts) { ServiceRegistry::Operate operate(serviceToken_); - esInfo_.reset(new ESInfo(ts, *esp_)); - CurrentProcessingContext cpc; - beginRun(principal); - esInfo_.reset(); + beginRun(principal,ts); } void - SubProcess::beginRun(RunPrincipal const& principal) { + SubProcess::beginRun(RunPrincipal const& principal, IOVSyncValue const& ts) { boost::shared_ptr aux(new RunAuxiliary(principal.aux())); aux->setProcessHistoryID(principal.processHistoryID()); boost::shared_ptr rpp(new RunPrincipal(aux, preg_, *processConfiguration_, historyAppender_.get(),principal.index())); @@ -329,26 +315,23 @@ namespace edm { RunPrincipal& rp = *principalCache_.runPrincipalPtr(); propagateProducts(InRun, principal, rp); typedef OccurrenceTraits Traits; - schedule_->processOneOccurrence(rp, esInfo_->es_); - if(subProcess_.get()) subProcess_->doBeginRun(rp, esInfo_->ts_); + schedule_->processOneOccurrence(rp, esp_->eventSetupForInstance(ts)); + if(subProcess_.get()) subProcess_->doBeginRun(rp, ts); } void SubProcess::doEndRun(RunPrincipal const& principal, IOVSyncValue const& ts, bool cleaningUpAfterException) { - cleaningUpAfterException_ = cleaningUpAfterException; ServiceRegistry::Operate operate(serviceToken_); - esInfo_.reset(new ESInfo(ts, *esp_)); - endRun(principal); - esInfo_.reset(); + endRun(principal,ts,cleaningUpAfterException); } void - SubProcess::endRun(RunPrincipal const& principal) { + SubProcess::endRun(RunPrincipal const& principal, IOVSyncValue const& ts, bool cleaningUpAfterException) { RunPrincipal& rp = *principalCache_.runPrincipalPtr(); propagateProducts(InRun, principal, rp); typedef OccurrenceTraits Traits; - schedule_->processOneOccurrence(rp, esInfo_->es_, cleaningUpAfterException_); - if(subProcess_.get()) subProcess_->doEndRun(rp, esInfo_->ts_, cleaningUpAfterException_); + schedule_->processOneOccurrence(rp, esp_->eventSetupForInstance(ts), cleaningUpAfterException); + if(subProcess_.get()) subProcess_->doEndRun(rp, ts, cleaningUpAfterException); } void @@ -371,13 +354,11 @@ namespace edm { void SubProcess::doBeginLuminosityBlock(LuminosityBlockPrincipal const& principal, IOVSyncValue const& ts) { ServiceRegistry::Operate operate(serviceToken_); - esInfo_.reset(new ESInfo(ts, *esp_)); - beginLuminosityBlock(principal); - esInfo_.reset(); + beginLuminosityBlock(principal,ts); } void - SubProcess::beginLuminosityBlock(LuminosityBlockPrincipal const& principal) { + SubProcess::beginLuminosityBlock(LuminosityBlockPrincipal const& principal, IOVSyncValue const& ts) { boost::shared_ptr aux(new LuminosityBlockAuxiliary(principal.aux())); aux->setProcessHistoryID(principal.processHistoryID()); boost::shared_ptr lbpp(new LuminosityBlockPrincipal(aux, preg_, *processConfiguration_, historyAppender_.get(),principal.index())); @@ -387,27 +368,23 @@ namespace edm { LuminosityBlockPrincipal& lbp = *principalCache_.lumiPrincipalPtr(); propagateProducts(InLumi, principal, lbp); typedef OccurrenceTraits Traits; - schedule_->processOneOccurrence(lbp, esInfo_->es_); - if(subProcess_.get()) subProcess_->doBeginLuminosityBlock(lbp, esInfo_->ts_); + schedule_->processOneOccurrence(lbp, esp_->eventSetupForInstance(ts)); + if(subProcess_.get()) subProcess_->doBeginLuminosityBlock(lbp, ts); } void SubProcess::doEndLuminosityBlock(LuminosityBlockPrincipal const& principal, IOVSyncValue const& ts, bool cleaningUpAfterException) { - cleaningUpAfterException_ = cleaningUpAfterException; ServiceRegistry::Operate operate(serviceToken_); - esInfo_.reset(new ESInfo(ts, *esp_)); - CurrentProcessingContext cpc; - endLuminosityBlock(principal); - esInfo_.reset(); + endLuminosityBlock(principal,ts,cleaningUpAfterException); } void - SubProcess::endLuminosityBlock(LuminosityBlockPrincipal const& principal) { + SubProcess::endLuminosityBlock(LuminosityBlockPrincipal const& principal, IOVSyncValue const& ts, bool cleaningUpAfterException) { LuminosityBlockPrincipal& lbp = *principalCache_.lumiPrincipalPtr(); propagateProducts(InLumi, principal, lbp); typedef OccurrenceTraits Traits; - schedule_->processOneOccurrence(lbp, esInfo_->es_, cleaningUpAfterException_); - if(subProcess_.get()) subProcess_->doEndLuminosityBlock(lbp, esInfo_->ts_, cleaningUpAfterException_); + schedule_->processOneOccurrence(lbp, esp_->eventSetupForInstance(ts), cleaningUpAfterException); + if(subProcess_.get()) subProcess_->doEndLuminosityBlock(lbp, ts, cleaningUpAfterException); } void @@ -443,18 +420,49 @@ namespace edm { if(subProcess_.get()) subProcess_->doEndStream(iID); } - //Dummies until SubProcess inherits from new interface void - SubProcess::doStreamBeginRun(StreamID, RunPrincipal const& principal, IOVSyncValue const& ts) {} + SubProcess::doStreamBeginRun(StreamID id, RunPrincipal const& principal, IOVSyncValue const& ts) { + ServiceRegistry::Operate operate(serviceToken_); + { + RunPrincipal& rp = *principalCache_.runPrincipalPtr(); + typedef OccurrenceTraits Traits; + schedule_->processOneOccurrence(rp, esp_->eventSetupForInstance(ts)); + if(subProcess_.get()) subProcess_->doStreamBeginRun(id,rp, ts); + } + } void - SubProcess::doStreamEndRun(StreamID, RunPrincipal const& principal, IOVSyncValue const& ts, bool cleaningUpAfterException) {} + SubProcess::doStreamEndRun(StreamID id, RunPrincipal const& principal, IOVSyncValue const& ts, bool cleaningUpAfterException) { + ServiceRegistry::Operate operate(serviceToken_); + { + RunPrincipal& rp = *principalCache_.runPrincipalPtr(); + typedef OccurrenceTraits Traits; + schedule_->processOneOccurrence(rp, esp_->eventSetupForInstance(ts),cleaningUpAfterException); + if(subProcess_.get()) subProcess_->doStreamEndRun(id,rp, ts,cleaningUpAfterException); + } + } void - SubProcess::doStreamBeginLuminosityBlock(StreamID, LuminosityBlockPrincipal const& principal, IOVSyncValue const& ts) {} + SubProcess::doStreamBeginLuminosityBlock(StreamID id, LuminosityBlockPrincipal const& principal, IOVSyncValue const& ts) { + ServiceRegistry::Operate operate(serviceToken_); + { + LuminosityBlockPrincipal& lbp = *principalCache_.lumiPrincipalPtr(); + typedef OccurrenceTraits Traits; + schedule_->processOneOccurrence(lbp, esp_->eventSetupForInstance(ts)); + if(subProcess_.get()) subProcess_->doStreamBeginLuminosityBlock(id,lbp, ts); + } + } void - SubProcess::doStreamEndLuminosityBlock(StreamID, LuminosityBlockPrincipal const& principal, IOVSyncValue const& ts, bool cleaningUpAfterException) {} + SubProcess::doStreamEndLuminosityBlock(StreamID id, LuminosityBlockPrincipal const& principal, IOVSyncValue const& ts, bool cleaningUpAfterException) { + ServiceRegistry::Operate operate(serviceToken_); + { + LuminosityBlockPrincipal& lbp = *principalCache_.lumiPrincipalPtr(); + typedef OccurrenceTraits Traits; + schedule_->processOneOccurrence(lbp, esp_->eventSetupForInstance(ts),cleaningUpAfterException); + if(subProcess_.get()) subProcess_->doStreamEndLuminosityBlock(id,lbp, ts,cleaningUpAfterException); + } + } void