Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 /** \class HLTFilter
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 HLTFilter
0006  *  class!
0007  *
0008  *
0009  *  \author Martin Grunewald
0010  *
0011  */
0012 
0013 #include "DataFormats/HLTReco/interface/TriggerFilterObjectWithRefs.h"
0014 #include "HLTrigger/HLTcore/interface/HLTFilter.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 HLTFilter::HLTFilter(const edm::ParameterSet& config) : EDFilter(), saveTags_(config.getParameter<bool>("saveTags")) {
0021   // register common HLTFilter products
0022   produces<trigger::TriggerFilterObjectWithRefs>();
0023 }
0024 
0025 void HLTFilter::makeHLTFilterDescription(edm::ParameterSetDescription& desc) { desc.add<bool>("saveTags", true); }
0026 
0027 HLTFilter::~HLTFilter() = default;
0028 
0029 bool HLTFilter::filter(edm::StreamID, edm::Event& event, const edm::EventSetup& setup) const {
0030   std::unique_ptr<trigger::TriggerFilterObjectWithRefs> filterproduct(
0031       new trigger::TriggerFilterObjectWithRefs(path(event), module(event)));
0032 
0033   // compute the result of the HLTFilter implementation
0034   bool result = hltFilter(event, setup, *filterproduct);
0035 
0036   // put filter object into the Event
0037   event.put(std::move(filterproduct));
0038 
0039   // retunr the result of the HLTFilter
0040   return result;
0041 }
0042 
0043 int HLTFilter::path(edm::Event const& event) const {
0044   return static_cast<int>(event.moduleCallingContext()->placeInPathContext()->pathContext()->pathID());
0045 }
0046 
0047 int HLTFilter::module(edm::Event const& event) const {
0048   return static_cast<int>(event.moduleCallingContext()->placeInPathContext()->placeInPath());
0049 }
0050 
0051 std::pair<int, int> HLTFilter::pmid(edm::Event const& event) const {
0052   edm::PlaceInPathContext const* placeInPathContext = event.moduleCallingContext()->placeInPathContext();
0053   return std::make_pair(static_cast<int>(placeInPathContext->pathContext()->pathID()),
0054                         static_cast<int>(placeInPathContext->placeInPath()));
0055 }
0056 
0057 const std::string* HLTFilter::pathName(edm::Event const& event) const {
0058   return &event.moduleCallingContext()->placeInPathContext()->pathContext()->pathName();
0059 }
0060 
0061 const std::string* HLTFilter::moduleLabel() const { return &moduleDescription().moduleLabel(); }