File indexing completed on 2024-04-06 12:18:39
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 #include "FWCore/Framework/interface/Frameworkfwd.h"
0018 #include "FWCore/Framework/interface/Event.h"
0019 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0020 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0021 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0022 #include "DataFormats/Common/interface/Handle.h"
0023 #include "DataFormats/CaloTowers/interface/CaloTower.h"
0024 #include "DataFormats/CaloTowers/interface/CaloTowerDefs.h"
0025 #include "DataFormats/HLTReco/interface/TriggerFilterObjectWithRefs.h"
0026 #include "DataFormats/HLTReco/interface/TriggerTypeDefs.h"
0027 #include "HLTrigger/HLTcore/interface/HLTFilter.h"
0028
0029
0030
0031
0032 class HLTCaloTowerFilter : public HLTFilter {
0033 public:
0034 explicit HLTCaloTowerFilter(const edm::ParameterSet&);
0035 ~HLTCaloTowerFilter() override;
0036 static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0037
0038 private:
0039 bool hltFilter(edm::Event&,
0040 const edm::EventSetup&,
0041 trigger::TriggerFilterObjectWithRefs& filterproduct) const override;
0042
0043
0044 edm::EDGetTokenT<CaloTowerCollection> inputToken_;
0045 edm::InputTag inputTag_;
0046 double min_Pt_;
0047 double max_Eta_;
0048 unsigned int min_N_;
0049 };
0050
0051
0052
0053
0054 HLTCaloTowerFilter::HLTCaloTowerFilter(const edm::ParameterSet& config)
0055 : HLTFilter(config),
0056 inputTag_(config.getParameter<edm::InputTag>("inputTag")),
0057 min_Pt_(config.getParameter<double>("MinPt")),
0058 max_Eta_(config.getParameter<double>("MaxEta")),
0059 min_N_(config.getParameter<unsigned int>("MinN")) {
0060 inputToken_ = consumes<CaloTowerCollection>(inputTag_);
0061 }
0062
0063 HLTCaloTowerFilter::~HLTCaloTowerFilter() {
0064
0065
0066 }
0067
0068 void HLTCaloTowerFilter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0069 edm::ParameterSetDescription desc;
0070 makeHLTFilterDescription(desc);
0071 desc.add<edm::InputTag>("inputTag", edm::InputTag("hltTowerMakerForEcal"));
0072 desc.add<double>("MinPt", 3.0);
0073 desc.add<double>("MaxEta", 3.0);
0074 desc.add<unsigned int>("MinN", 1);
0075 descriptions.add("hltCaloTowerFilter", desc);
0076 }
0077
0078
0079
0080
0081
0082
0083 bool HLTCaloTowerFilter::hltFilter(edm::Event& event,
0084 const edm::EventSetup& setup,
0085 trigger::TriggerFilterObjectWithRefs& filterproduct) const {
0086 using namespace std;
0087 using namespace edm;
0088 using namespace reco;
0089
0090
0091
0092
0093
0094
0095 if (saveTags())
0096 filterproduct.addCollectionTag(inputTag_);
0097
0098
0099 Handle<CaloTowerCollection> caloTowers;
0100 event.getByToken(inputToken_, caloTowers);
0101
0102
0103 unsigned int n = 0;
0104 for (auto const& i : *caloTowers) {
0105 if ((i.pt() >= min_Pt_) and ((max_Eta_ < 0.0) or (std::abs(i.eta()) <= max_Eta_)))
0106 ++n;
0107
0108
0109 }
0110
0111
0112 return (n >= min_N_);
0113 }
0114
0115
0116 #include "FWCore/Framework/interface/MakerMacros.h"
0117 DEFINE_FWK_MODULE(HLTCaloTowerFilter);