From 9fe2ce83a85e5207aa180f3c7161d2bee85e2e68 Mon Sep 17 00:00:00 2001 From: Srecko Morovic Date: Thu, 3 Sep 2015 10:31:25 +0200 Subject: [PATCH 1/5] port of StreamerOutputModuleBase to one::OutputModule base class Backports parts of this commit from 76X branch: https://github.com/cms-sw/cmssw/commit/a4b465d661a0ae5d6bc9e8fb176a1e349b69d302 --- .../plugins/RecoEventOutputModuleForFU.h | 9 ++++---- .../Streamer/interface/StreamerOutputModule.h | 4 +++- .../interface/StreamerOutputModuleBase.h | 13 +++++++----- .../Streamer/src/StreamerOutputModuleBase.cc | 21 +++++++++++++++---- 4 files changed, 33 insertions(+), 14 deletions(-) diff --git a/EventFilter/Utilities/plugins/RecoEventOutputModuleForFU.h b/EventFilter/Utilities/plugins/RecoEventOutputModuleForFU.h index ea64ef6d2b7d3..d5f97517bf22f 100644 --- a/EventFilter/Utilities/plugins/RecoEventOutputModuleForFU.h +++ b/EventFilter/Utilities/plugins/RecoEventOutputModuleForFU.h @@ -44,8 +44,8 @@ namespace evf { virtual void doOutputEvent(EventMsgBuilder const& msg) const; //virtual void beginRun(edm::RunPrincipal const&, edm::ModuleCallingContext const*); virtual void beginJob(); - virtual void beginLuminosityBlock(edm::LuminosityBlockPrincipal const&, edm::ModuleCallingContext const*); - virtual void endLuminosityBlock(edm::LuminosityBlockPrincipal const&, edm::ModuleCallingContext const*); + virtual void doBeginLuminosityBlock_(edm::LuminosityBlockPrincipal const&, edm::ModuleCallingContext const*); + virtual void doEndLuminosityBlock_(edm::LuminosityBlockPrincipal const&, edm::ModuleCallingContext const*); private: std::auto_ptr c_; @@ -72,6 +72,7 @@ namespace evf { template RecoEventOutputModuleForFU::RecoEventOutputModuleForFU(edm::ParameterSet const& ps) : + edm::one::OutputModuleBase::OutputModuleBase(ps), edm::StreamerOutputModuleBase(ps), c_(new Consumer(ps)), stream_label_(ps.getParameter("@module_label")), @@ -243,7 +244,7 @@ namespace evf { template - void RecoEventOutputModuleForFU::beginLuminosityBlock(edm::LuminosityBlockPrincipal const &ls, edm::ModuleCallingContext const*) + void RecoEventOutputModuleForFU::doBeginLuminosityBlock_(edm::LuminosityBlockPrincipal const &ls, edm::ModuleCallingContext const*) { //edm::LogInfo("RecoEventOutputModuleForFU") << "begin lumi"; openDatFilePath_ = edm::Service()->getOpenDatFilePath(ls.luminosityBlock(),stream_label_); @@ -253,7 +254,7 @@ namespace evf { } template - void RecoEventOutputModuleForFU::endLuminosityBlock(edm::LuminosityBlockPrincipal const &ls, edm::ModuleCallingContext const*) + void RecoEventOutputModuleForFU::doEndLuminosityBlock_(edm::LuminosityBlockPrincipal const &ls, edm::ModuleCallingContext const*) { //edm::LogInfo("RecoEventOutputModuleForFU") << "end lumi"; long filesize=0; diff --git a/IOPool/Streamer/interface/StreamerOutputModule.h b/IOPool/Streamer/interface/StreamerOutputModule.h index caceb9a50ba55..599423678ffab 100644 --- a/IOPool/Streamer/interface/StreamerOutputModule.h +++ b/IOPool/Streamer/interface/StreamerOutputModule.h @@ -33,8 +33,10 @@ namespace edm { template StreamerOutputModule::StreamerOutputModule(ParameterSet const& ps) : + edm::one::OutputModuleBase::OutputModuleBase(ps), StreamerOutputModuleBase(ps), - c_(new Consumer(ps)) { + c_(new Consumer(ps)) + { } template diff --git a/IOPool/Streamer/interface/StreamerOutputModuleBase.h b/IOPool/Streamer/interface/StreamerOutputModuleBase.h index b6a18206dfc4e..7e1b7857253f9 100644 --- a/IOPool/Streamer/interface/StreamerOutputModuleBase.h +++ b/IOPool/Streamer/interface/StreamerOutputModuleBase.h @@ -1,7 +1,7 @@ #ifndef IOPool_Streamer_StreamerOutputModuleBase_h #define IOPool_Streamer_StreamerOutputModuleBase_h -#include "FWCore/Framework/interface/OutputModule.h" +#include "FWCore/Framework/interface/one/OutputModule.h" #include "FWCore/Utilities/interface/EDGetToken.h" #include "IOPool/Streamer/interface/MsgTools.h" #include "IOPool/Streamer/interface/StreamSerializer.h" @@ -14,15 +14,17 @@ namespace edm { class ModuleCallingContext; class ParameterSetDescription; - class StreamerOutputModuleBase : public OutputModule { + typedef detail::TriggerResultsBasedEventSelector::handle_t Trig; + + class StreamerOutputModuleBase : public one::OutputModule<> { public: - explicit StreamerOutputModuleBase(ParameterSet const& ps); + explicit StreamerOutputModuleBase(ParameterSet const& ps); virtual ~StreamerOutputModuleBase(); static void fillDescription(ParameterSetDescription & desc); private: - virtual void beginRun(RunPrincipal const&, ModuleCallingContext const*) override; - virtual void endRun(RunPrincipal const&, ModuleCallingContext const*) override; + virtual void doBeginRun_(RunPrincipal const&, ModuleCallingContext const*) override; + virtual void doEndRun_(RunPrincipal const&, ModuleCallingContext const*) override; virtual void beginJob() override; virtual void endJob() override; virtual void writeRun(RunPrincipal const&, ModuleCallingContext const*) override; @@ -36,6 +38,7 @@ namespace edm { std::auto_ptr serializeRegistry(); std::auto_ptr serializeEvent(EventPrincipal const& e, ModuleCallingContext const* mcc); + Trig getTriggerResults(EDGetTokenT const& token, EventPrincipal const& ep, ModuleCallingContext const*) const; void setHltMask(EventPrincipal const& e, ModuleCallingContext const*); void setLumiSection(); diff --git a/IOPool/Streamer/src/StreamerOutputModuleBase.cc b/IOPool/Streamer/src/StreamerOutputModuleBase.cc index a8829acbdd2f8..331ec7321ff72 100644 --- a/IOPool/Streamer/src/StreamerOutputModuleBase.cc +++ b/IOPool/Streamer/src/StreamerOutputModuleBase.cc @@ -9,6 +9,7 @@ #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/ParameterSet/interface/ParameterSetDescription.h" #include "FWCore/Utilities/interface/DebugMacros.h" +#include "FWCore/Framework/interface/PrincipalGetAdapter.h" //#include "FWCore/Utilities/interface/Digest.h" #include "FWCore/Version/interface/GetReleaseVersion.h" #include "DataFormats/Common/interface/TriggerResults.h" @@ -55,7 +56,8 @@ namespace { namespace edm { StreamerOutputModuleBase::StreamerOutputModuleBase(ParameterSet const& ps) : - OutputModule(ps), + one::OutputModuleBase::OutputModuleBase(ps), + one::OutputModule<>(ps), selections_(&keptProducts()[InEvent]), maxEventSize_(ps.getUntrackedParameter("max_event_size")), useCompression_(ps.getUntrackedParameter("use_compression")), @@ -105,14 +107,14 @@ namespace edm { StreamerOutputModuleBase::~StreamerOutputModuleBase() {} void - StreamerOutputModuleBase::beginRun(RunPrincipal const&, ModuleCallingContext const*) { + StreamerOutputModuleBase::doBeginRun_(RunPrincipal const&, ModuleCallingContext const*) { start(); std::auto_ptr init_message = serializeRegistry(); doOutputHeader(*init_message); } void - StreamerOutputModuleBase::endRun(RunPrincipal const&, ModuleCallingContext const*) { + StreamerOutputModuleBase::doEndRun_(RunPrincipal const&, ModuleCallingContext const*) { stop(); } @@ -194,12 +196,23 @@ namespace edm { return init_message; } + Trig + StreamerOutputModuleBase::getTriggerResults(EDGetTokenT const& token, EventPrincipal const& ep, ModuleCallingContext const* mcc) const { + //This cast is safe since we only call const functions of the EventPrincipal after this point + PrincipalGetAdapter adapter(const_cast(ep), moduleDescription()); + adapter.setConsumer(this); + Trig result; + auto bh = adapter.getByToken_(TypeID(typeid(TriggerResults)),PRODUCT_TYPE, token, mcc); + convert_handle(std::move(bh), result); + return result; + } + void StreamerOutputModuleBase::setHltMask(EventPrincipal const& e, ModuleCallingContext const* mcc) { hltbits_.clear(); // If there was something left over from last event - Handle const& prod = getTriggerResults(trToken_,e, mcc); + Handle const& prod = getTriggerResults(trToken_, e, mcc); //Trig const& prod = getTrigMask(e); std::vector vHltState; From d9043fef2d8a3834c5707062ea221a0707c3115c Mon Sep 17 00:00:00 2001 From: Srecko Morovic Date: Thu, 3 Sep 2015 21:35:58 +0200 Subject: [PATCH 2/5] changes suggested by Dr15Jones: more appropriate one::OutputModule template, and adding override --- .../Utilities/plugins/RecoEventOutputModuleForFU.h | 8 ++++---- IOPool/Streamer/interface/StreamerOutputModuleBase.h | 6 +++--- IOPool/Streamer/src/StreamerOutputModuleBase.cc | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/EventFilter/Utilities/plugins/RecoEventOutputModuleForFU.h b/EventFilter/Utilities/plugins/RecoEventOutputModuleForFU.h index d5f97517bf22f..603a91a21df2f 100644 --- a/EventFilter/Utilities/plugins/RecoEventOutputModuleForFU.h +++ b/EventFilter/Utilities/plugins/RecoEventOutputModuleForFU.h @@ -44,8 +44,8 @@ namespace evf { virtual void doOutputEvent(EventMsgBuilder const& msg) const; //virtual void beginRun(edm::RunPrincipal const&, edm::ModuleCallingContext const*); virtual void beginJob(); - virtual void doBeginLuminosityBlock_(edm::LuminosityBlockPrincipal const&, edm::ModuleCallingContext const*); - virtual void doEndLuminosityBlock_(edm::LuminosityBlockPrincipal const&, edm::ModuleCallingContext const*); + virtual void beginLuminosityBlock(edm::LuminosityBlockPrincipal const&, edm::ModuleCallingContext const*) override; + virtual void endLuminosityBlock(edm::LuminosityBlockPrincipal const&, edm::ModuleCallingContext const*) override; private: std::auto_ptr c_; @@ -244,7 +244,7 @@ namespace evf { template - void RecoEventOutputModuleForFU::doBeginLuminosityBlock_(edm::LuminosityBlockPrincipal const &ls, edm::ModuleCallingContext const*) + void RecoEventOutputModuleForFU::beginLuminosityBlock(edm::LuminosityBlockPrincipal const &ls, edm::ModuleCallingContext const*) { //edm::LogInfo("RecoEventOutputModuleForFU") << "begin lumi"; openDatFilePath_ = edm::Service()->getOpenDatFilePath(ls.luminosityBlock(),stream_label_); @@ -254,7 +254,7 @@ namespace evf { } template - void RecoEventOutputModuleForFU::doEndLuminosityBlock_(edm::LuminosityBlockPrincipal const &ls, edm::ModuleCallingContext const*) + void RecoEventOutputModuleForFU::endLuminosityBlock(edm::LuminosityBlockPrincipal const &ls, edm::ModuleCallingContext const*) { //edm::LogInfo("RecoEventOutputModuleForFU") << "end lumi"; long filesize=0; diff --git a/IOPool/Streamer/interface/StreamerOutputModuleBase.h b/IOPool/Streamer/interface/StreamerOutputModuleBase.h index 7e1b7857253f9..bc36358693208 100644 --- a/IOPool/Streamer/interface/StreamerOutputModuleBase.h +++ b/IOPool/Streamer/interface/StreamerOutputModuleBase.h @@ -16,15 +16,15 @@ namespace edm { typedef detail::TriggerResultsBasedEventSelector::handle_t Trig; - class StreamerOutputModuleBase : public one::OutputModule<> { + class StreamerOutputModuleBase : public one::OutputModule { public: explicit StreamerOutputModuleBase(ParameterSet const& ps); virtual ~StreamerOutputModuleBase(); static void fillDescription(ParameterSetDescription & desc); private: - virtual void doBeginRun_(RunPrincipal const&, ModuleCallingContext const*) override; - virtual void doEndRun_(RunPrincipal const&, ModuleCallingContext const*) override; + virtual void beginRun(RunPrincipal const&, ModuleCallingContext const*) override; + virtual void endRun(RunPrincipal const&, ModuleCallingContext const*) override; virtual void beginJob() override; virtual void endJob() override; virtual void writeRun(RunPrincipal const&, ModuleCallingContext const*) override; diff --git a/IOPool/Streamer/src/StreamerOutputModuleBase.cc b/IOPool/Streamer/src/StreamerOutputModuleBase.cc index 331ec7321ff72..1b6ada37277cf 100644 --- a/IOPool/Streamer/src/StreamerOutputModuleBase.cc +++ b/IOPool/Streamer/src/StreamerOutputModuleBase.cc @@ -57,7 +57,7 @@ namespace { namespace edm { StreamerOutputModuleBase::StreamerOutputModuleBase(ParameterSet const& ps) : one::OutputModuleBase::OutputModuleBase(ps), - one::OutputModule<>(ps), + one::OutputModule(ps), selections_(&keptProducts()[InEvent]), maxEventSize_(ps.getUntrackedParameter("max_event_size")), useCompression_(ps.getUntrackedParameter("use_compression")), From e9508a81cadc170d81ad9cc08a61b3a9a4fcb7e9 Mon Sep 17 00:00:00 2001 From: Srecko Morovic Date: Thu, 3 Sep 2015 22:43:41 +0200 Subject: [PATCH 3/5] *using template in form one::OutputModule is needed to compile (in analogy to PoolOutputModule) *streamer output module now also needs beginLumi and endLumi handlers --- IOPool/Streamer/interface/StreamerOutputModule.h | 10 ++++++++++ IOPool/Streamer/interface/StreamerOutputModuleBase.h | 2 +- IOPool/Streamer/src/StreamerOutputModuleBase.cc | 6 +++--- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/IOPool/Streamer/interface/StreamerOutputModule.h b/IOPool/Streamer/interface/StreamerOutputModule.h index 599423678ffab..97c409d3a77f1 100644 --- a/IOPool/Streamer/interface/StreamerOutputModule.h +++ b/IOPool/Streamer/interface/StreamerOutputModule.h @@ -26,6 +26,8 @@ namespace edm { virtual void stop() const; virtual void doOutputHeader(InitMsgBuilder const& init_message) const; virtual void doOutputEvent(EventMsgBuilder const& msg) const; + virtual void beginLuminosityBlock(edm::LuminosityBlockPrincipal const&, edm::ModuleCallingContext const*) override; + virtual void endLuminosityBlock(edm::LuminosityBlockPrincipal const&, edm::ModuleCallingContext const*) override; private: std::auto_ptr c_; @@ -67,6 +69,14 @@ namespace edm { c_->doOutputEvent(msg); // You can't use msg in StreamerOutputModule after this point } + template + void + StreamerOutputModule::beginLuminosityBlock(edm::LuminosityBlockPrincipal const&, edm::ModuleCallingContext const*) {} + + template + void + StreamerOutputModule::endLuminosityBlock(edm::LuminosityBlockPrincipal const&, edm::ModuleCallingContext const*) {} + template void StreamerOutputModule::fillDescriptions(ConfigurationDescriptions& descriptions) { diff --git a/IOPool/Streamer/interface/StreamerOutputModuleBase.h b/IOPool/Streamer/interface/StreamerOutputModuleBase.h index bc36358693208..1a8e29f199174 100644 --- a/IOPool/Streamer/interface/StreamerOutputModuleBase.h +++ b/IOPool/Streamer/interface/StreamerOutputModuleBase.h @@ -16,7 +16,7 @@ namespace edm { typedef detail::TriggerResultsBasedEventSelector::handle_t Trig; - class StreamerOutputModuleBase : public one::OutputModule { + class StreamerOutputModuleBase : public one::OutputModule { public: explicit StreamerOutputModuleBase(ParameterSet const& ps); virtual ~StreamerOutputModuleBase(); diff --git a/IOPool/Streamer/src/StreamerOutputModuleBase.cc b/IOPool/Streamer/src/StreamerOutputModuleBase.cc index 1b6ada37277cf..de31a2f33eb1d 100644 --- a/IOPool/Streamer/src/StreamerOutputModuleBase.cc +++ b/IOPool/Streamer/src/StreamerOutputModuleBase.cc @@ -57,7 +57,7 @@ namespace { namespace edm { StreamerOutputModuleBase::StreamerOutputModuleBase(ParameterSet const& ps) : one::OutputModuleBase::OutputModuleBase(ps), - one::OutputModule(ps), + one::OutputModule(ps), selections_(&keptProducts()[InEvent]), maxEventSize_(ps.getUntrackedParameter("max_event_size")), useCompression_(ps.getUntrackedParameter("use_compression")), @@ -107,14 +107,14 @@ namespace edm { StreamerOutputModuleBase::~StreamerOutputModuleBase() {} void - StreamerOutputModuleBase::doBeginRun_(RunPrincipal const&, ModuleCallingContext const*) { + StreamerOutputModuleBase::beginRun(RunPrincipal const&, ModuleCallingContext const*) { start(); std::auto_ptr init_message = serializeRegistry(); doOutputHeader(*init_message); } void - StreamerOutputModuleBase::doEndRun_(RunPrincipal const&, ModuleCallingContext const*) { + StreamerOutputModuleBase::endRun(RunPrincipal const&, ModuleCallingContext const*) { stop(); } From 92a89d5d6ef302f13f19cbed13cffd9aa0e2689f Mon Sep 17 00:00:00 2001 From: Srecko Morovic Date: Fri, 4 Sep 2015 00:16:53 +0200 Subject: [PATCH 4/5] override beginJob --- EventFilter/Utilities/plugins/RecoEventOutputModuleForFU.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EventFilter/Utilities/plugins/RecoEventOutputModuleForFU.h b/EventFilter/Utilities/plugins/RecoEventOutputModuleForFU.h index 603a91a21df2f..f8608e5af9d81 100644 --- a/EventFilter/Utilities/plugins/RecoEventOutputModuleForFU.h +++ b/EventFilter/Utilities/plugins/RecoEventOutputModuleForFU.h @@ -43,7 +43,7 @@ namespace evf { virtual void doOutputHeader(InitMsgBuilder const& init_message) const; virtual void doOutputEvent(EventMsgBuilder const& msg) const; //virtual void beginRun(edm::RunPrincipal const&, edm::ModuleCallingContext const*); - virtual void beginJob(); + virtual void beginJob() override; virtual void beginLuminosityBlock(edm::LuminosityBlockPrincipal const&, edm::ModuleCallingContext const*) override; virtual void endLuminosityBlock(edm::LuminosityBlockPrincipal const&, edm::ModuleCallingContext const*) override; From 8916c518009baf76695b9464d1b21dbce83c51e8 Mon Sep 17 00:00:00 2001 From: Srecko Morovic Date: Fri, 4 Sep 2015 00:21:49 +0200 Subject: [PATCH 5/5] fix compilation of DQMStreamerOutputModules, update to one::OutputModule --- DQMServices/StreamerIO/test/DQMStreamerOutputModule.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/DQMServices/StreamerIO/test/DQMStreamerOutputModule.cc b/DQMServices/StreamerIO/test/DQMStreamerOutputModule.cc index 1e842cc5e6d2a..5e67008f62b8f 100644 --- a/DQMServices/StreamerIO/test/DQMStreamerOutputModule.cc +++ b/DQMServices/StreamerIO/test/DQMStreamerOutputModule.cc @@ -36,10 +36,10 @@ class DQMStreamerOutputModule : public edm::StreamerOutputModuleBase { virtual void doOutputEvent(EventMsgBuilder const& msg) const; virtual void beginLuminosityBlock(edm::LuminosityBlockPrincipal const&, - edm::ModuleCallingContext const*); + edm::ModuleCallingContext const*) override; virtual void endLuminosityBlock(edm::LuminosityBlockPrincipal const&, - edm::ModuleCallingContext const*); + edm::ModuleCallingContext const*) override; private: std::string streamLabel_; @@ -56,7 +56,8 @@ class DQMStreamerOutputModule : public edm::StreamerOutputModuleBase { }; //end-of-class-def DQMStreamerOutputModule::DQMStreamerOutputModule(edm::ParameterSet const& ps) - : edm::StreamerOutputModuleBase(ps), + : edm::one::OutputModuleBase::OutputModuleBase(ps), + edm::StreamerOutputModuleBase(ps), streamLabel_(ps.getUntrackedParameter("streamLabel")), runInputDir_(ps.getUntrackedParameter("runInputDir", "")), processed_(0),