Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:18:26

0001 /** \class HLTStreamFilter
0002  *
0003  *
0004  *  This class derives from EDFilter and adds a few HLT specific
0005  *  items. Any and all HLT filters must derive from the HLTStreamFilter
0006  *  class!
0007  *
0008  *
0009  *  \author Martin Grunewald
0010  *
0011  */
0012 
0013 #include "DataFormats/HLTReco/interface/TriggerFilterObjectWithRefs.h"
0014 #include "HLTrigger/HLTcore/interface/HLTStreamFilter.h"
0015 
0016 #include "FWCore/ServiceRegistry/interface/PathContext.h"
0017 #include "FWCore/ServiceRegistry/interface/PlaceInPathContext.h"
0018 #include "FWCore/ServiceRegistry/interface/ModuleCallingContext.h"
0019 
0020 HLTStreamFilter::HLTStreamFilter(const edm::ParameterSet& config)
0021     : EDFilter(), saveTags_(config.getParameter<bool>("saveTags")) {
0022   // register common HLTStreamFilter products
0023   produces<trigger::TriggerFilterObjectWithRefs>();
0024 }
0025 
0026 void HLTStreamFilter::makeHLTFilterDescription(edm::ParameterSetDescription& desc) { desc.add<bool>("saveTags", true); }
0027 
0028 HLTStreamFilter::~HLTStreamFilter() = default;
0029 
0030 bool HLTStreamFilter::filter(edm::Event& event, const edm::EventSetup& setup) {
0031   std::unique_ptr<trigger::TriggerFilterObjectWithRefs> filterproduct(
0032       new trigger::TriggerFilterObjectWithRefs(path(event), module(event)));
0033 
0034   // compute the result of the HLTStreamFilter implementation
0035   bool result = hltFilter(event, setup, *filterproduct);
0036 
0037   // put filter object into the Event
0038   event.put(std::move(filterproduct));
0039 
0040   // retunr the result of the HLTStreamFilter
0041   return result;
0042 }
0043 
0044 int HLTStreamFilter::path(edm::Event const& event) const {
0045   return static_cast<int>(event.moduleCallingContext()->placeInPathContext()->pathContext()->pathID());
0046 }
0047 
0048 int HLTStreamFilter::module(edm::Event const& event) const {
0049   return static_cast<int>(event.moduleCallingContext()->placeInPathContext()->placeInPath());
0050 }
0051 
0052 std::pair<int, int> HLTStreamFilter::pmid(edm::Event const& event) const {
0053   edm::PlaceInPathContext const* placeInPathContext = event.moduleCallingContext()->placeInPathContext();
0054   return std::make_pair(static_cast<int>(placeInPathContext->pathContext()->pathID()),
0055                         static_cast<int>(placeInPathContext->placeInPath()));
0056 }
0057 
0058 const std::string* HLTStreamFilter::pathName(edm::Event const& event) const {
0059   return &event.moduleCallingContext()->placeInPathContext()->pathContext()->pathName();
0060 }
0061 
0062 const std::string* HLTStreamFilter::moduleLabel() const { return &moduleDescription().moduleLabel(); }