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