From 62adcce7b29d59cb2415e33652a9644a14c1ef24 Mon Sep 17 00:00:00 2001 From: Jan-Frederik Date: Mon, 4 Jun 2018 10:47:52 +0200 Subject: [PATCH 1/4] add filter to count pixel tracks for beta star 90m run --- .../special/plugins/HLTPixelTrackFilter.cc | 92 +++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 HLTrigger/special/plugins/HLTPixelTrackFilter.cc diff --git a/HLTrigger/special/plugins/HLTPixelTrackFilter.cc b/HLTrigger/special/plugins/HLTPixelTrackFilter.cc new file mode 100644 index 0000000000000..826a653ab78e4 --- /dev/null +++ b/HLTrigger/special/plugins/HLTPixelTrackFilter.cc @@ -0,0 +1,92 @@ +#include "HLTrigger/HLTcore/interface/HLTFilter.h" + +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" +#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" +#include "DataFormats/TrackReco/interface/Track.h" +// +// class declaration +// + +class HLTPixelTrackFilter : public HLTFilter { +public: + explicit HLTPixelTrackFilter(const edm::ParameterSet&); + ~HLTPixelTrackFilter() override; + static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); + +private: + bool hltFilter(edm::Event&, const edm::EventSetup&, trigger::TriggerFilterObjectWithRefs & filterproduct) const override; +// int countLayersWithClusters(edm::Handle > & clusterCol,const TrackerTopology& tTopo); + + edm::InputTag inputTag_; // input tag identifying product containing pixel clusters + unsigned int min_pixelTracks_; // minimum number of clusters + unsigned int max_pixelTracks_; // maximum number of clusters + edm::EDGetTokenT inputToken_; + +}; + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "DataFormats/Common/interface/Handle.h" +#include "DataFormats/HLTReco/interface/TriggerFilterObjectWithRefs.h" +#include "DataFormats/HLTReco/interface/TriggerTypeDefs.h" +// +// constructors and destructor +// + +HLTPixelTrackFilter::HLTPixelTrackFilter(const edm::ParameterSet& config) : HLTFilter(config), + inputTag_ (config.getParameter("pixelTracks")), + min_pixelTracks_ (config.getParameter("maxPixelTracks")), + max_pixelTracks_ (config.getParameter("minPixelTracks")) +{ + inputToken_ = consumes< reco::TrackCollection >(inputTag_); + LogDebug("") << "Using the " << inputTag_ << " input collection"; + LogDebug("") << "Requesting at least " << min_pixelTracks_ << " PixelTracks"; + if(max_pixelTracks_ > 0) + LogDebug("") << "...but no more than " << max_pixelTracks_ << " PixelTracks"; +} + +HLTPixelTrackFilter::~HLTPixelTrackFilter() = default; + +void +HLTPixelTrackFilter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + edm::ParameterSetDescription desc; + makeHLTFilterDescription(desc); + desc.add("pixelTracks",edm::InputTag("hltPixelTracks")); + desc.add("minPixelTracks",0); + desc.add("maxPixelTracks",0); + descriptions.add("hltPixelTrackFilter",desc); + +} + +// +// member functions +// +// ------------ method called to produce the data ------------ +bool HLTPixelTrackFilter::hltFilter(edm::Event& event, const edm::EventSetup& iSetup, trigger::TriggerFilterObjectWithRefs & filterproduct) const +{ + // All HLT filters must create and fill an HLT filter object, + // recording any reconstructed physics objects satisfying (or not) + // this HLT filter, and place it in the Event. + + // The filter object + if (saveTags()) filterproduct.addCollectionTag(inputTag_); + + // get hold of products from Event + edm::Handle< reco::TrackCollection> trackColl; + event.getByToken(inputToken_, trackColl); + + unsigned int numTracks = trackColl->size(); + LogDebug("") << "Number of tracks accepted: " << numTracks; + bool accept = (numTracks >= min_pixelTracks_); + if(max_pixelTracks_ > 0) + accept &= (numTracks <= max_pixelTracks_); + std::cout << numTracks << std::endl; + // return with final filter decision + return accept; +} + +// define as a framework module +#include "FWCore/Framework/interface/MakerMacros.h" +DEFINE_FWK_MODULE(HLTPixelTrackFilter); From 69f3a7b28007e3f8e46885d5ad9dcabb9a1b8e76 Mon Sep 17 00:00:00 2001 From: Jan-Frederik Date: Mon, 4 Jun 2018 23:37:06 +0200 Subject: [PATCH 2/4] move to EDFilter and remove leftover cout --- .../special/plugins/HLTPixelTrackFilter.cc | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/HLTrigger/special/plugins/HLTPixelTrackFilter.cc b/HLTrigger/special/plugins/HLTPixelTrackFilter.cc index 826a653ab78e4..c595edba5fbf3 100644 --- a/HLTrigger/special/plugins/HLTPixelTrackFilter.cc +++ b/HLTrigger/special/plugins/HLTPixelTrackFilter.cc @@ -1,4 +1,13 @@ -#include "HLTrigger/HLTcore/interface/HLTFilter.h" +//#include "HLTrigger/HLTcore/interface/HLTFilter.h" +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/stream/EDFilter.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "DataFormats/Common/interface/Handle.h" +#include "DataFormats/HLTReco/interface/TriggerFilterObjectWithRefs.h" +#include "DataFormats/HLTReco/interface/TriggerTypeDefs.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" @@ -8,14 +17,14 @@ // class declaration // -class HLTPixelTrackFilter : public HLTFilter { +class HLTPixelTrackFilter : public edm::stream::EDFilter<> { public: explicit HLTPixelTrackFilter(const edm::ParameterSet&); - ~HLTPixelTrackFilter() override; + ~HLTPixelTrackFilter(); static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); private: - bool hltFilter(edm::Event&, const edm::EventSetup&, trigger::TriggerFilterObjectWithRefs & filterproduct) const override; + bool filter(edm::Event&, const edm::EventSetup&); // int countLayersWithClusters(edm::Handle > & clusterCol,const TrackerTopology& tTopo); edm::InputTag inputTag_; // input tag identifying product containing pixel clusters @@ -25,17 +34,11 @@ class HLTPixelTrackFilter : public HLTFilter { }; -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "DataFormats/Common/interface/Handle.h" -#include "DataFormats/HLTReco/interface/TriggerFilterObjectWithRefs.h" -#include "DataFormats/HLTReco/interface/TriggerTypeDefs.h" // // constructors and destructor // -HLTPixelTrackFilter::HLTPixelTrackFilter(const edm::ParameterSet& config) : HLTFilter(config), +HLTPixelTrackFilter::HLTPixelTrackFilter(const edm::ParameterSet& config): inputTag_ (config.getParameter("pixelTracks")), min_pixelTracks_ (config.getParameter("maxPixelTracks")), max_pixelTracks_ (config.getParameter("minPixelTracks")) @@ -52,7 +55,6 @@ HLTPixelTrackFilter::~HLTPixelTrackFilter() = default; void HLTPixelTrackFilter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; - makeHLTFilterDescription(desc); desc.add("pixelTracks",edm::InputTag("hltPixelTracks")); desc.add("minPixelTracks",0); desc.add("maxPixelTracks",0); @@ -64,14 +66,13 @@ HLTPixelTrackFilter::fillDescriptions(edm::ConfigurationDescriptions& descriptio // member functions // // ------------ method called to produce the data ------------ -bool HLTPixelTrackFilter::hltFilter(edm::Event& event, const edm::EventSetup& iSetup, trigger::TriggerFilterObjectWithRefs & filterproduct) const +bool HLTPixelTrackFilter::filter(edm::Event& event, const edm::EventSetup& iSetup) { // All HLT filters must create and fill an HLT filter object, // recording any reconstructed physics objects satisfying (or not) // this HLT filter, and place it in the Event. // The filter object - if (saveTags()) filterproduct.addCollectionTag(inputTag_); // get hold of products from Event edm::Handle< reco::TrackCollection> trackColl; @@ -82,7 +83,6 @@ bool HLTPixelTrackFilter::hltFilter(edm::Event& event, const edm::EventSetup& iS bool accept = (numTracks >= min_pixelTracks_); if(max_pixelTracks_ > 0) accept &= (numTracks <= max_pixelTracks_); - std::cout << numTracks << std::endl; // return with final filter decision return accept; } From e48594ee5714947a49c1354133c92a2f49bfc3e4 Mon Sep 17 00:00:00 2001 From: Jan-Frederik Date: Mon, 4 Jun 2018 23:45:35 +0200 Subject: [PATCH 3/4] appl code check patch --- HLTrigger/special/plugins/HLTPixelTrackFilter.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/HLTrigger/special/plugins/HLTPixelTrackFilter.cc b/HLTrigger/special/plugins/HLTPixelTrackFilter.cc index c595edba5fbf3..adf887a190902 100644 --- a/HLTrigger/special/plugins/HLTPixelTrackFilter.cc +++ b/HLTrigger/special/plugins/HLTPixelTrackFilter.cc @@ -20,11 +20,11 @@ class HLTPixelTrackFilter : public edm::stream::EDFilter<> { public: explicit HLTPixelTrackFilter(const edm::ParameterSet&); - ~HLTPixelTrackFilter(); + ~HLTPixelTrackFilter() override; static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); private: - bool filter(edm::Event&, const edm::EventSetup&); + bool filter(edm::Event&, const edm::EventSetup&) override; // int countLayersWithClusters(edm::Handle > & clusterCol,const TrackerTopology& tTopo); edm::InputTag inputTag_; // input tag identifying product containing pixel clusters From e2e6ac12dca905348194ed8fda13df9843889387 Mon Sep 17 00:00:00 2001 From: Jan-Frederik Date: Mon, 4 Jun 2018 23:55:13 +0200 Subject: [PATCH 4/4] clean up some comments --- HLTrigger/special/plugins/HLTPixelTrackFilter.cc | 8 -------- 1 file changed, 8 deletions(-) diff --git a/HLTrigger/special/plugins/HLTPixelTrackFilter.cc b/HLTrigger/special/plugins/HLTPixelTrackFilter.cc index adf887a190902..07cb17e1471ca 100644 --- a/HLTrigger/special/plugins/HLTPixelTrackFilter.cc +++ b/HLTrigger/special/plugins/HLTPixelTrackFilter.cc @@ -1,4 +1,3 @@ -//#include "HLTrigger/HLTcore/interface/HLTFilter.h" #include "FWCore/Framework/interface/Frameworkfwd.h" #include "FWCore/Framework/interface/stream/EDFilter.h" @@ -25,7 +24,6 @@ class HLTPixelTrackFilter : public edm::stream::EDFilter<> { private: bool filter(edm::Event&, const edm::EventSetup&) override; -// int countLayersWithClusters(edm::Handle > & clusterCol,const TrackerTopology& tTopo); edm::InputTag inputTag_; // input tag identifying product containing pixel clusters unsigned int min_pixelTracks_; // minimum number of clusters @@ -68,12 +66,6 @@ HLTPixelTrackFilter::fillDescriptions(edm::ConfigurationDescriptions& descriptio // ------------ method called to produce the data ------------ bool HLTPixelTrackFilter::filter(edm::Event& event, const edm::EventSetup& iSetup) { - // All HLT filters must create and fill an HLT filter object, - // recording any reconstructed physics objects satisfying (or not) - // this HLT filter, and place it in the Event. - - // The filter object - // get hold of products from Event edm::Handle< reco::TrackCollection> trackColl; event.getByToken(inputToken_, trackColl);