11#include " FWCore/Framework/interface/Frameworkfwd.h"
2- #include " FWCore/Framework /interface/stream/EDFilter .h"
2+ #include " HLTrigger/HLTcore /interface/HLTFilter .h"
33
44#include " FWCore/Framework/interface/Event.h"
55#include " FWCore/Framework/interface/EventSetup.h"
1111#include " FWCore/ParameterSet/interface/ParameterSet.h"
1212#include " FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
1313#include " FWCore/ParameterSet/interface/ParameterSetDescription.h"
14- #include " DataFormats/TrackReco /interface/Track .h"
14+ #include " DataFormats/RecoCandidate /interface/RecoChargedCandidate .h"
1515//
1616// class declaration
1717//
1818
19- class HLTPixelTrackFilter : public edm ::stream::EDFilter<> {
19+ class HLTPixelTrackFilter : public HLTFilter {
2020public:
2121 explicit HLTPixelTrackFilter (const edm::ParameterSet&);
2222 ~HLTPixelTrackFilter () override ;
23+ bool hltFilter (edm::Event&,
24+ const edm::EventSetup&,
25+ trigger::TriggerFilterObjectWithRefs& filterproduct) const override ;
2326 static void fillDescriptions (edm::ConfigurationDescriptions& descriptions);
2427
2528private:
26- bool filter (edm::Event&, const edm::EventSetup&) override ;
27-
2829 edm::InputTag inputTag_; // input tag identifying product containing pixel clusters
2930 unsigned int min_pixelTracks_; // minimum number of clusters
3031 unsigned int max_pixelTracks_; // maximum number of clusters
31- edm::EDGetTokenT<reco::TrackCollection > inputToken_;
32+ edm::EDGetTokenT<reco::RecoChargedCandidateCollection > inputToken_;
3233};
3334
3435//
3536// constructors and destructor
3637//
3738
3839HLTPixelTrackFilter::HLTPixelTrackFilter (const edm::ParameterSet& config)
39- : inputTag_(config.getParameter<edm::InputTag>(" pixelTracks" )),
40+ : HLTFilter(config),
41+ inputTag_(config.getParameter<edm::InputTag>(" pixelTracks" )),
4042 min_pixelTracks_(config.getParameter<unsigned int >(" minPixelTracks" )),
4143 max_pixelTracks_(config.getParameter<unsigned int >(" maxPixelTracks" )) {
42- inputToken_ = consumes<reco::TrackCollection >(inputTag_);
44+ inputToken_ = consumes<reco::RecoChargedCandidateCollection >(inputTag_);
4345 LogDebug (" " ) << " Using the " << inputTag_ << " input collection" ;
4446 LogDebug (" " ) << " Requesting at least " << min_pixelTracks_ << " PixelTracks" ;
4547 if (max_pixelTracks_ > 0 )
@@ -50,6 +52,7 @@ HLTPixelTrackFilter::~HLTPixelTrackFilter() = default;
5052
5153void HLTPixelTrackFilter::fillDescriptions (edm::ConfigurationDescriptions& descriptions) {
5254 edm::ParameterSetDescription desc;
55+ makeHLTFilterDescription (desc);
5356 desc.add <edm::InputTag>(" pixelTracks" , edm::InputTag (" hltPixelTracks" ));
5457 desc.add <unsigned int >(" minPixelTracks" , 0 );
5558 desc.add <unsigned int >(" maxPixelTracks" , 0 );
@@ -60,12 +63,22 @@ void HLTPixelTrackFilter::fillDescriptions(edm::ConfigurationDescriptions& descr
6063// member functions
6164//
6265// ------------ method called to produce the data ------------
63- bool HLTPixelTrackFilter::filter (edm::Event& event, const edm::EventSetup& iSetup) {
66+ bool HLTPixelTrackFilter::hltFilter (edm::Event& event,
67+ const edm::EventSetup& iSetup,
68+ trigger::TriggerFilterObjectWithRefs& filterproduct) const {
69+ // All HLT filters must create and fill an HLT filter object,
70+ // recording any reconstructed physics objects satisfying (or not)
71+ // this HLT filter, and place it in the Event.
72+ if (saveTags ())
73+ filterproduct.addCollectionTag (inputTag_);
74+
6475 // get hold of products from Event
65- edm::Handle<reco::TrackCollection> trackColl;
66- event.getByToken (inputToken_, trackColl);
76+ const auto & trackColl = event.getHandle (inputToken_);
6777
6878 unsigned int numTracks = trackColl->size ();
79+ for (size_t i = 0 ; i < numTracks; i++)
80+ filterproduct.addObject (trigger::TriggerTrack, reco::RecoChargedCandidateRef (trackColl, i));
81+
6982 LogDebug (" " ) << " Number of tracks accepted: " << numTracks;
7083 bool accept = (numTracks >= min_pixelTracks_);
7184 if (max_pixelTracks_ > 0 )
0 commit comments