Skip to content

Commit

Permalink
Merge pull request #11245 from smorovic/one-StreamerOutputModule-74X
Browse files Browse the repository at this point in the history
Streamer output modules ported to one::OutputModule (74X)
  • Loading branch information
cmsbuild committed Sep 17, 2015
2 parents 1729684 + caed04f commit c5fe44a
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 12 deletions.
7 changes: 4 additions & 3 deletions DQMServices/StreamerIO/test/DQMStreamerOutputModule.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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_;
Expand All @@ -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<std::string>("streamLabel")),
runInputDir_(ps.getUntrackedParameter<std::string>("runInputDir", "")),
processed_(0),
Expand Down
7 changes: 4 additions & 3 deletions EventFilter/Utilities/plugins/RecoEventOutputModuleForFU.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ 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 beginLuminosityBlock(edm::LuminosityBlockPrincipal const&, edm::ModuleCallingContext const*);
virtual void endLuminosityBlock(edm::LuminosityBlockPrincipal const&, edm::ModuleCallingContext const*);
virtual void beginJob() override;
virtual void beginLuminosityBlock(edm::LuminosityBlockPrincipal const&, edm::ModuleCallingContext const*) override;
virtual void endLuminosityBlock(edm::LuminosityBlockPrincipal const&, edm::ModuleCallingContext const*) override;

private:
std::auto_ptr<Consumer> c_;
Expand All @@ -72,6 +72,7 @@ namespace evf {

template<typename Consumer>
RecoEventOutputModuleForFU<Consumer>::RecoEventOutputModuleForFU(edm::ParameterSet const& ps) :
edm::one::OutputModuleBase::OutputModuleBase(ps),
edm::StreamerOutputModuleBase(ps),
c_(new Consumer(ps)),
stream_label_(ps.getParameter<std::string>("@module_label")),
Expand Down
14 changes: 13 additions & 1 deletion IOPool/Streamer/interface/StreamerOutputModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,19 @@ 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<Consumer> c_;
}; //end-of-class-def

template<typename Consumer>
StreamerOutputModule<Consumer>::StreamerOutputModule(ParameterSet const& ps) :
edm::one::OutputModuleBase::OutputModuleBase(ps),
StreamerOutputModuleBase(ps),
c_(new Consumer(ps)) {
c_(new Consumer(ps))
{
}

template<typename Consumer>
Expand Down Expand Up @@ -65,6 +69,14 @@ namespace edm {
c_->doOutputEvent(msg); // You can't use msg in StreamerOutputModule after this point
}

template<typename Consumer>
void
StreamerOutputModule<Consumer>::beginLuminosityBlock(edm::LuminosityBlockPrincipal const&, edm::ModuleCallingContext const*) {}

template<typename Consumer>
void
StreamerOutputModule<Consumer>::endLuminosityBlock(edm::LuminosityBlockPrincipal const&, edm::ModuleCallingContext const*) {}

template<typename Consumer>
void
StreamerOutputModule<Consumer>::fillDescriptions(ConfigurationDescriptions& descriptions) {
Expand Down
11 changes: 8 additions & 3 deletions IOPool/Streamer/interface/StreamerOutputModuleBase.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#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"
#include <memory>
Expand All @@ -13,9 +14,11 @@ namespace edm {
class ModuleCallingContext;
class ParameterSetDescription;

class StreamerOutputModuleBase : public OutputModule {
typedef detail::TriggerResultsBasedEventSelector::handle_t Trig;

class StreamerOutputModuleBase : public one::OutputModule<one::WatchRuns, one::WatchLuminosityBlocks> {
public:
explicit StreamerOutputModuleBase(ParameterSet const& ps);
explicit StreamerOutputModuleBase(ParameterSet const& ps);
virtual ~StreamerOutputModuleBase();
static void fillDescription(ParameterSetDescription & desc);

Expand All @@ -35,6 +38,7 @@ namespace edm {

std::auto_ptr<InitMsgBuilder> serializeRegistry();
std::auto_ptr<EventMsgBuilder> serializeEvent(EventPrincipal const& e, ModuleCallingContext const* mcc);
Trig getTriggerResults(EDGetTokenT<TriggerResults> const& token, EventPrincipal const& ep, ModuleCallingContext const*) const;
void setHltMask(EventPrincipal const& e, ModuleCallingContext const*);
void setLumiSection();

Expand All @@ -61,6 +65,7 @@ namespace edm {
uint32 origSize_;
char host_name_[255];

edm::EDGetTokenT<edm::TriggerResults> trToken_;
Strings hltTriggerSelections_;
uint32 outputModuleId_;
}; //end-of-class-def
Expand Down
18 changes: 16 additions & 2 deletions IOPool/Streamer/src/StreamerOutputModuleBase.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -55,7 +56,8 @@ namespace {

namespace edm {
StreamerOutputModuleBase::StreamerOutputModuleBase(ParameterSet const& ps) :
OutputModule(ps),
one::OutputModuleBase::OutputModuleBase(ps),
one::OutputModule<one::WatchRuns, one::WatchLuminosityBlocks>(ps),
selections_(&keptProducts()[InEvent]),
maxEventSize_(ps.getUntrackedParameter<int>("max_event_size")),
useCompression_(ps.getUntrackedParameter<bool>("use_compression")),
Expand All @@ -69,6 +71,7 @@ namespace edm {
hltbits_(0),
origSize_(0),
host_name_(),
trToken_(consumes<edm::TriggerResults>(edm::InputTag("TriggerResults"))),
hltTriggerSelections_(),
outputModuleId_(0) {
// no compression as default value - we need this!
Expand Down Expand Up @@ -193,12 +196,23 @@ namespace edm {
return init_message;
}

Trig
StreamerOutputModuleBase::getTriggerResults(EDGetTokenT<TriggerResults> 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<EventPrincipal&>(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<TriggerResults> const& prod = getTriggerResults(e, mcc);
Handle<TriggerResults> const& prod = getTriggerResults(trToken_, e, mcc);
//Trig const& prod = getTrigMask(e);
std::vector<unsigned char> vHltState;

Expand Down

0 comments on commit c5fe44a

Please sign in to comment.