File indexing completed on 2024-04-06 12:18:41
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #include "HLTrigger/HLTcore/interface/HLTFilter.h"
0012
0013 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0014 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0015 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0016
0017
0018
0019
0020 class HLTHcalTowerFilter : public HLTFilter {
0021 public:
0022 explicit HLTHcalTowerFilter(const edm::ParameterSet&);
0023 ~HLTHcalTowerFilter() override;
0024 static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0025
0026 private:
0027 bool hltFilter(edm::Event&,
0028 const edm::EventSetup&,
0029 trigger::TriggerFilterObjectWithRefs& filterproduct) const override;
0030
0031 edm::EDGetTokenT<CaloTowerCollection> inputToken_;
0032 edm::InputTag inputTag_;
0033 double min_E_HB_;
0034 double min_E_HE_;
0035 double min_E_HF_;
0036 int max_N_HB_;
0037 int max_N_HE_;
0038 int max_N_HF_;
0039 int min_N_HF_;
0040 int min_N_HFM_;
0041 int min_N_HFP_;
0042 };
0043
0044 #include <memory>
0045
0046 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0047 #include "DataFormats/Common/interface/Handle.h"
0048 #include "DataFormats/Common/interface/Ref.h"
0049 #include "DataFormats/HLTReco/interface/TriggerFilterObjectWithRefs.h"
0050 #include "DataFormats/HLTReco/interface/TriggerTypeDefs.h"
0051
0052
0053
0054
0055 HLTHcalTowerFilter::HLTHcalTowerFilter(const edm::ParameterSet& config)
0056 : HLTFilter(config),
0057 inputTag_(config.getParameter<edm::InputTag>("inputTag")),
0058 min_E_HB_(config.getParameter<double>("MinE_HB")),
0059 min_E_HE_(config.getParameter<double>("MinE_HE")),
0060 min_E_HF_(config.getParameter<double>("MinE_HF")),
0061 max_N_HB_(config.getParameter<int>("MaxN_HB")),
0062 max_N_HE_(config.getParameter<int>("MaxN_HE")),
0063 max_N_HF_(config.getParameter<int>("MaxN_HF")),
0064 min_N_HF_(-1),
0065 min_N_HFM_(-1),
0066 min_N_HFP_(-1) {
0067 if (config.existsAs<int>("MinN_HF")) {
0068 min_N_HF_ = config.getParameter<int>("MinN_HF");
0069 }
0070 if (config.existsAs<int>("MinN_HFM")) {
0071 min_N_HFM_ = config.getParameter<int>("MinN_HFM");
0072 }
0073 if (config.existsAs<int>("MinN_HFP")) {
0074 min_N_HFP_ = config.getParameter<int>("MinN_HFP");
0075 }
0076
0077 inputToken_ = consumes<CaloTowerCollection>(inputTag_);
0078 }
0079
0080 HLTHcalTowerFilter::~HLTHcalTowerFilter() = default;
0081
0082 void HLTHcalTowerFilter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0083 edm::ParameterSetDescription desc;
0084 makeHLTFilterDescription(desc);
0085 desc.add<edm::InputTag>("inputTag", edm::InputTag("hltTowerMakerForHcal"));
0086 desc.add<double>("MinE_HB", 1.5);
0087 desc.add<double>("MinE_HE", 2.5);
0088 desc.add<double>("MinE_HF", 9.0);
0089 desc.add<int>("MaxN_HB", 2);
0090 desc.add<int>("MaxN_HE", 2);
0091 desc.add<int>("MaxN_HF", 8);
0092 desc.add<int>("MinN_HF", -1);
0093 desc.add<int>("MinN_HFM", -1);
0094 desc.add<int>("MinN_HFP", -1);
0095 descriptions.add("hltHcalTowerFilter", desc);
0096 }
0097
0098
0099
0100
0101
0102
0103 bool HLTHcalTowerFilter::hltFilter(edm::Event& event,
0104 const edm::EventSetup& setup,
0105 trigger::TriggerFilterObjectWithRefs& filterproduct) const {
0106 using namespace std;
0107 using namespace edm;
0108 using namespace reco;
0109 using namespace trigger;
0110
0111
0112 if (saveTags())
0113 filterproduct.addCollectionTag(inputTag_);
0114
0115
0116 Handle<CaloTowerCollection> towers;
0117 event.getByToken(inputToken_, towers);
0118
0119
0120 int n_HB = 0;
0121 int n_HE = 0;
0122 int n_HF = 0;
0123 int n_HFM = 0;
0124 int n_HFP = 0;
0125 double abseta = 0.0;
0126 double eta = 0.0;
0127 for (auto const& i : *towers) {
0128 eta = i.eta();
0129 abseta = std::abs(eta);
0130 if (abseta < 1.305) {
0131 if (i.hadEnergy() >= min_E_HB_) {
0132 n_HB++;
0133
0134
0135 }
0136 } else if (abseta >= 1.305 && abseta < 3) {
0137 if (i.hadEnergy() >= min_E_HE_) {
0138 n_HE++;
0139
0140
0141 }
0142 } else {
0143 if (i.hadEnergy() >= min_E_HF_) {
0144 n_HF++;
0145
0146
0147 if (eta >= 3) {
0148 n_HFP++;
0149 } else {
0150 n_HFM++;
0151 }
0152 }
0153 }
0154 }
0155
0156
0157 bool accept(n_HB < max_N_HB_ && n_HE < max_N_HE_ && n_HF < max_N_HF_ && n_HFP >= min_N_HFP_ && n_HFM >= min_N_HFM_ &&
0158 n_HF >= min_N_HF_);
0159
0160 return accept;
0161 }
0162
0163
0164 #include "FWCore/Framework/interface/MakerMacros.h"
0165 DEFINE_FWK_MODULE(HLTHcalTowerFilter);