|
| 1 | +#include "FWCore/Framework/interface/stream/EDProducer.h" |
| 2 | +#include "FWCore/Framework/interface/Event.h" |
| 3 | +#include "FWCore/ParameterSet/interface/ParameterSet.h" |
| 4 | +#include "DataFormats/L1Trigger/interface/Tau.h" |
| 5 | +#include "HLTrigger/HLTcore/interface/HLTFilter.h" |
| 6 | +#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" |
| 7 | + |
| 8 | +class L1TauTriggerFilterObjectProducer : public HLTFilter { |
| 9 | +public: |
| 10 | + explicit L1TauTriggerFilterObjectProducer(const edm::ParameterSet& cfg) |
| 11 | + : HLTFilter(cfg), |
| 12 | + tausSrc_(cfg.getParameter<edm::InputTag>("taus")), |
| 13 | + tausToken_(consumes<l1t::TauBxCollection>(tausSrc_)), |
| 14 | + selectedBx_(cfg.getParameter<std::vector<int>>("selectedBx")), |
| 15 | + minPt_(cfg.getParameter<double>("minPt")), |
| 16 | + minHwIso_(cfg.getParameter<int>("minHwIso")), |
| 17 | + nExpected_(cfg.getParameter<int>("nExpected")) {} |
| 18 | + |
| 19 | + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) { |
| 20 | + edm::ParameterSetDescription desc; |
| 21 | + makeHLTFilterDescription(desc); |
| 22 | + desc.add<edm::InputTag>("taus", edm::InputTag("hltGtStage2Digis", "Tau"))->setComment("Input GT stage 2 L1 taus"); |
| 23 | + desc.add<std::vector<int>>("selectedBx", std::vector<int>()) |
| 24 | + ->setComment("bunch crossings to select, empty means all"); |
| 25 | + desc.add<double>("minPt", 0)->setComment("select taus with pt > minPt. minPt=0 means no pt cut"); |
| 26 | + desc.add<int>("minHwIso", 0)->setComment("select taus with hwIso >= minHwIso. minHwIso=0 means no hwIso cut"); |
| 27 | + desc.add<int>("nExpected", 0)->setComment("minimal number of taus per event to pass the filter"); |
| 28 | + descriptions.addWithDefaultLabel(desc); |
| 29 | + } |
| 30 | + |
| 31 | + bool hltFilter(edm::Event& event, |
| 32 | + const edm::EventSetup& eventsetup, |
| 33 | + trigger::TriggerFilterObjectWithRefs& filterproduct) const override { |
| 34 | + if (saveTags()) |
| 35 | + filterproduct.addCollectionTag(tausSrc_); |
| 36 | + const auto& taus = event.getHandle(tausToken_); |
| 37 | + int nPassed = 0; |
| 38 | + for (int bx_index = taus->getFirstBX(); bx_index <= taus->getLastBX(); ++bx_index) { |
| 39 | + if (!selectedBx_.empty() && std::find(selectedBx_.begin(), selectedBx_.end(), bx_index) == selectedBx_.end()) |
| 40 | + continue; |
| 41 | + const unsigned bx_index_shift = taus->begin(bx_index) - taus->begin(); |
| 42 | + unsigned index_in_bx = 0; |
| 43 | + for (auto it = taus->begin(bx_index); it != taus->end(bx_index); ++it, ++index_in_bx) { |
| 44 | + if (it->pt() <= minPt_ || it->hwIso() < minHwIso_) |
| 45 | + continue; |
| 46 | + const l1t::TauRef tauRef(taus, bx_index_shift + index_in_bx); |
| 47 | + filterproduct.addObject(trigger::TriggerL1Tau, tauRef); |
| 48 | + ++nPassed; |
| 49 | + } |
| 50 | + } |
| 51 | + return nPassed >= nExpected_; |
| 52 | + } |
| 53 | + |
| 54 | +private: |
| 55 | + const edm::InputTag tausSrc_; |
| 56 | + const edm::EDGetTokenT<l1t::TauBxCollection> tausToken_; |
| 57 | + const std::vector<int> selectedBx_; |
| 58 | + const double minPt_; |
| 59 | + const int minHwIso_; |
| 60 | + const int nExpected_; |
| 61 | +}; |
| 62 | + |
| 63 | +#include "FWCore/Framework/interface/MakerMacros.h" |
| 64 | +DEFINE_FWK_MODULE(L1TauTriggerFilterObjectProducer); |
0 commit comments