Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-02-25 23:40:14

0001 
0002 #include "IOPool/Streamer/interface/StreamerOutputModuleBase.h"
0003 
0004 #include "IOPool/Streamer/interface/InitMsgBuilder.h"
0005 #include "IOPool/Streamer/interface/EventMsgBuilder.h"
0006 #include "FWCore/Framework/interface/EventForOutput.h"
0007 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0008 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0009 #include "DataFormats/Common/interface/TriggerResults.h"
0010 #include "DataFormats/Provenance/interface/ModuleDescription.h"
0011 #include "DataFormats/Provenance/interface/ParameterSetID.h"
0012 
0013 #include "zlib.h"
0014 
0015 namespace edm {
0016   StreamerOutputModuleBase::StreamerOutputModuleBase(ParameterSet const& ps)
0017       : one::OutputModuleBase::OutputModuleBase(ps),
0018         one::OutputModule<one::WatchRuns, one::WatchLuminosityBlocks>(ps),
0019         StreamerOutputModuleCommon(ps, &keptProducts()[InEvent], description().moduleLabel()),
0020         trToken_(consumes<edm::TriggerResults>(edm::InputTag("TriggerResults"))),
0021         psetToken_(
0022             consumes<SendJobHeader::ParameterSetMap, edm::InRun>(ps.getUntrackedParameter<edm::InputTag>("psetMap"))) {}
0023 
0024   StreamerOutputModuleBase::~StreamerOutputModuleBase() {}
0025 
0026   void StreamerOutputModuleBase::beginRun(RunForOutput const& iRun) {
0027     start();
0028 
0029     auto psetMapHandle = iRun.getHandle(psetToken_);
0030 
0031     std::unique_ptr<InitMsgBuilder> init_message =
0032         serializeRegistry(*getSerializerBuffer(),
0033                           *branchIDLists(),
0034                           *thinnedAssociationsHelper(),
0035                           OutputModule::processName(),
0036                           description().moduleLabel(),
0037                           moduleDescription().mainParameterSetID(),
0038                           psetMapHandle.isValid() ? psetMapHandle.product() : nullptr);
0039 
0040     doOutputHeader(*init_message);
0041     serializerBuffer_->clearHeaderBuffer();
0042   }
0043 
0044   void StreamerOutputModuleBase::endRun(RunForOutput const&) { stop(); }
0045 
0046   void StreamerOutputModuleBase::beginJob() {}
0047 
0048   void StreamerOutputModuleBase::endJob() { stop(); }
0049 
0050   void StreamerOutputModuleBase::writeRun(RunForOutput const&) {}
0051 
0052   void StreamerOutputModuleBase::writeLuminosityBlock(LuminosityBlockForOutput const&) {}
0053 
0054   void StreamerOutputModuleBase::write(EventForOutput const& e) {
0055     Handle<TriggerResults> const& triggerResults = getTriggerResults(trToken_, e);
0056 
0057     std::unique_ptr<EventMsgBuilder> msg = serializeEvent(*getSerializerBuffer(), e, triggerResults, selectorConfig());
0058     doOutputEvent(*msg);  // You can't use msg in StreamerOutputModuleBase after this point
0059   }
0060 
0061   Trig StreamerOutputModuleBase::getTriggerResults(EDGetTokenT<TriggerResults> const& token,
0062                                                    EventForOutput const& e) const {
0063     Trig result;
0064     e.getByToken<TriggerResults>(token, result);
0065     return result;
0066   }
0067 
0068   void StreamerOutputModuleBase::fillDescription(ParameterSetDescription& desc) {
0069     StreamerOutputModuleCommon::fillDescription(desc);
0070     OutputModule::fillDescription(desc);
0071     desc.addUntracked<edm::InputTag>("psetMap", {"hltPSetMap"})
0072         ->setComment("Optionally allow the map of ParameterSets to be calculated externally.");
0073   }
0074 }  // namespace edm