Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-05-31 04:19:42

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::streamer {
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(OutputModule::processName(),
0033                           description().moduleLabel(),
0034                           moduleDescription().mainParameterSetID(),
0035                           psetMapHandle.isValid() ? psetMapHandle.product() : nullptr);
0036 
0037     doOutputHeader(*init_message);
0038     lastCallWasBeginRun_ = true;
0039 
0040     clearHeaderBuffer();
0041   }
0042 
0043   void StreamerOutputModuleBase::endRun(RunForOutput const&) { stop(); }
0044 
0045   void StreamerOutputModuleBase::beginJob() {}
0046 
0047   void StreamerOutputModuleBase::endJob() { stop(); }
0048 
0049   void StreamerOutputModuleBase::writeRun(RunForOutput const&) {}
0050 
0051   void StreamerOutputModuleBase::writeLuminosityBlock(LuminosityBlockForOutput const&) {}
0052 
0053   void StreamerOutputModuleBase::write(EventForOutput const& e) {
0054     Handle<TriggerResults> const& triggerResults = getTriggerResults(trToken_, e);
0055 
0056     if (lastCallWasBeginRun_) {
0057       auto msg = serializeEventMetaData(*branchIDLists(), *thinnedAssociationsHelper());
0058       doOutputEvent(*msg);
0059       lastCallWasBeginRun_ = false;
0060     }
0061     auto msg = serializeEvent(e, triggerResults, selectorConfig());
0062 
0063     doOutputEvent(*msg);  // You can't use msg in StreamerOutputModuleBase after this point
0064   }
0065 
0066   Trig StreamerOutputModuleBase::getTriggerResults(EDGetTokenT<TriggerResults> const& token,
0067                                                    EventForOutput const& e) const {
0068     Trig result;
0069     e.getByToken<TriggerResults>(token, result);
0070     return result;
0071   }
0072 
0073   void StreamerOutputModuleBase::fillDescription(ParameterSetDescription& desc) {
0074     StreamerOutputModuleCommon::fillDescription(desc);
0075     OutputModule::fillDescription(desc);
0076     desc.addUntracked<edm::InputTag>("psetMap", {"hltPSetMap"})
0077         ->setComment("Optionally allow the map of ParameterSets to be calculated externally.");
0078   }
0079 }  // namespace edm::streamer