File indexing completed on 2024-04-06 12:18:29
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #include "L1THPSPFTauFilter.h"
0013 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0014
0015 #include "DataFormats/Common/interface/Handle.h"
0016
0017 #include "DataFormats/Common/interface/Ref.h"
0018 #include "DataFormats/HLTReco/interface/TriggerFilterObjectWithRefs.h"
0019 #include "DataFormats/HLTReco/interface/TriggerTypeDefs.h"
0020
0021 #include "FWCore/Framework/interface/EventSetup.h"
0022 #include "FWCore/Framework/interface/EventSetupRecord.h"
0023 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0024
0025
0026
0027
0028
0029 L1THPSPFTauFilter::L1THPSPFTauFilter(const edm::ParameterSet& iConfig)
0030 : HLTFilter(iConfig),
0031 l1HPSPFTauTag_(iConfig.getParameter<edm::InputTag>("inputTag")),
0032 hpspfTauToken_(consumes<l1t::HPSPFTauCollection>(l1HPSPFTauTag_)) {
0033 min_Pt_ = iConfig.getParameter<double>("MinPt");
0034 min_N_ = iConfig.getParameter<int>("MinN");
0035 min_Eta_ = iConfig.getParameter<double>("MinEta");
0036 max_Eta_ = iConfig.getParameter<double>("MaxEta");
0037 max_RelChargedIso_ = iConfig.getParameter<double>("MaxRelChargedIso");
0038 min_LeadTrackPt_ = iConfig.getParameter<double>("MinLeadTrackPt");
0039 scalings_ = iConfig.getParameter<edm::ParameterSet>("Scalings");
0040 barrelScalings_ = scalings_.getParameter<std::vector<double> >("barrel");
0041 overlapScalings_ = scalings_.getParameter<std::vector<double> >("overlap");
0042 endcapScalings_ = scalings_.getParameter<std::vector<double> >("endcap");
0043 }
0044
0045 L1THPSPFTauFilter::~L1THPSPFTauFilter() = default;
0046
0047
0048
0049
0050
0051 void L1THPSPFTauFilter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0052 edm::ParameterSetDescription desc;
0053 makeHLTFilterDescription(desc);
0054 desc.add<double>("MinPt", -1.0);
0055 desc.add<double>("MinEta", -5.0);
0056 desc.add<double>("MaxEta", 5.0);
0057 desc.add<double>("MaxRelChargedIso", 1.0E9);
0058 desc.add<double>("MinLeadTrackPt", -1.0);
0059 desc.add<int>("MinN", 1);
0060 desc.add<edm::InputTag>("inputTag", edm::InputTag("L1HPSPFTaus"));
0061
0062 edm::ParameterSetDescription descScalings;
0063 descScalings.add<std::vector<double> >("barrel", {0.0, 1.0, 0.0});
0064 descScalings.add<std::vector<double> >("overlap", {0.0, 1.0, 0.0});
0065 descScalings.add<std::vector<double> >("endcap", {0.0, 1.0, 0.0});
0066 desc.add<edm::ParameterSetDescription>("Scalings", descScalings);
0067
0068 descriptions.add("L1THPSPFTauFilter", desc);
0069 }
0070
0071
0072 bool L1THPSPFTauFilter::hltFilter(edm::Event& iEvent,
0073 const edm::EventSetup& iSetup,
0074 trigger::TriggerFilterObjectWithRefs& filterproduct) const {
0075 using namespace std;
0076 using namespace edm;
0077 using namespace reco;
0078 using namespace trigger;
0079
0080
0081
0082
0083
0084
0085 if (saveTags()) {
0086 filterproduct.addCollectionTag(l1HPSPFTauTag_);
0087 }
0088
0089
0090
0091
0092 Handle<l1t::HPSPFTauCollection> HPSPFTaus;
0093 iEvent.getByToken(hpspfTauToken_, HPSPFTaus);
0094
0095
0096 int npftau(0);
0097 auto apftaus(HPSPFTaus->begin());
0098 auto opftaus(HPSPFTaus->end());
0099 l1t::HPSPFTauCollection::const_iterator iHPSPFTau;
0100 for (iHPSPFTau = apftaus; iHPSPFTau != opftaus; iHPSPFTau++) {
0101 double offlinePt = this->HPSPFTauOfflineEt(iHPSPFTau->pt(), iHPSPFTau->eta());
0102 if (offlinePt >= min_Pt_ && iHPSPFTau->eta() <= max_Eta_ && iHPSPFTau->eta() >= min_Eta_ &&
0103 (iHPSPFTau->sumChargedIso() / iHPSPFTau->pt()) < max_RelChargedIso_ &&
0104 (iHPSPFTau->leadChargedPFCand()->pfTrack()->pt()) > min_LeadTrackPt_) {
0105 npftau++;
0106 l1t::HPSPFTauRef ref(l1t::HPSPFTauRef(HPSPFTaus, distance(apftaus, iHPSPFTau)));
0107 filterproduct.addObject(trigger::TriggerObjectType::TriggerL1PFTau, ref);
0108 }
0109 }
0110
0111
0112 const bool accept(npftau >= min_N_);
0113 return accept;
0114 }
0115
0116 double L1THPSPFTauFilter::HPSPFTauOfflineEt(double Et, double Eta) const {
0117 if (std::abs(Eta) < 1.5)
0118 return (barrelScalings_.at(0) + Et * barrelScalings_.at(1) + Et * Et * barrelScalings_.at(2));
0119 else
0120 return (endcapScalings_.at(0) + Et * endcapScalings_.at(1) + Et * Et * endcapScalings_.at(2));
0121 }