File indexing completed on 2024-04-06 12:18:20
0001
0002
0003
0004
0005
0006
0007 #include "HLTEgammaL1MatchFilterPairs.h"
0008 #include "DataFormats/Common/interface/Handle.h"
0009 #include "DataFormats/HLTReco/interface/TriggerFilterObjectWithRefs.h"
0010 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0011 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0012 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0013 #include "FWCore/Framework/interface/EventSetup.h"
0014
0015 #include <vector>
0016 #include <cmath>
0017
0018 #define TWOPI 2 * M_PI
0019
0020
0021
0022 HLTEgammaL1MatchFilterPairs::HLTEgammaL1MatchFilterPairs(const edm::ParameterSet& iConfig) : HLTFilter(iConfig) {
0023 candIsolatedTag_ = iConfig.getParameter<edm::InputTag>("candIsolatedTag");
0024 l1IsolatedTag_ = iConfig.getParameter<edm::InputTag>("l1IsolatedTag");
0025 candNonIsolatedTag_ = iConfig.getParameter<edm::InputTag>("candNonIsolatedTag");
0026 l1NonIsolatedTag_ = iConfig.getParameter<edm::InputTag>("l1NonIsolatedTag");
0027 L1SeedFilterTag_ = iConfig.getParameter<edm::InputTag>("L1SeedFilterTag");
0028
0029 AlsoNonIsolatedFirst_ = iConfig.getParameter<bool>("AlsoNonIsolatedFirst");
0030 AlsoNonIsolatedSecond_ = iConfig.getParameter<bool>("AlsoNonIsolatedSecond");
0031
0032 region_eta_size_ = iConfig.getParameter<double>("region_eta_size");
0033 region_eta_size_ecap_ = iConfig.getParameter<double>("region_eta_size_ecap");
0034 region_phi_size_ = iConfig.getParameter<double>("region_phi_size");
0035 barrel_end_ = iConfig.getParameter<double>("barrel_end");
0036 endcap_end_ = iConfig.getParameter<double>("endcap_end");
0037
0038 candIsolatedToken_ = consumes<reco::RecoEcalCandidateCollection>(candIsolatedTag_);
0039 candNonIsolatedToken_ = consumes<reco::RecoEcalCandidateCollection>(candNonIsolatedTag_);
0040 L1SeedFilterToken_ = consumes<trigger::TriggerFilterObjectWithRefs>(L1SeedFilterTag_);
0041 }
0042
0043 HLTEgammaL1MatchFilterPairs::~HLTEgammaL1MatchFilterPairs() = default;
0044
0045 void HLTEgammaL1MatchFilterPairs::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0046 edm::ParameterSetDescription desc;
0047 makeHLTFilterDescription(desc);
0048 desc.add<edm::InputTag>("candIsolatedTag", edm::InputTag("hltRecoIsolatedEcalCandidate"));
0049 desc.add<edm::InputTag>("l1IsolatedTag", edm::InputTag("l1extraParticles", "Isolated"));
0050 desc.add<edm::InputTag>("candNonIsolatedTag", edm::InputTag("hltRecoNonIsolatedEcalCandidate"));
0051 desc.add<edm::InputTag>("l1NonIsolatedTag", edm::InputTag("l1extraParticles", "NonIsolated"));
0052 desc.add<edm::InputTag>("L1SeedFilterTag", edm::InputTag("theL1SeedFilter"));
0053 desc.add<bool>("AlsoNonIsolatedFirst", false);
0054 desc.add<bool>("AlsoNonIsolatedSecond", false);
0055 desc.add<double>("region_eta_size", 0.522);
0056 desc.add<double>("region_eta_size_ecap", 1.0);
0057 desc.add<double>("region_phi_size", 1.044);
0058 desc.add<double>("barrel_end", 1.4791);
0059 desc.add<double>("endcap_end", 2.65);
0060 descriptions.add("hltEgammaL1MatchFilterPairs", desc);
0061 }
0062
0063
0064 bool HLTEgammaL1MatchFilterPairs::hltFilter(edm::Event& iEvent,
0065 const edm::EventSetup& iSetup,
0066 trigger::TriggerFilterObjectWithRefs& filterproduct) const {
0067 using namespace trigger;
0068 using namespace l1extra;
0069 std::vector<std::pair<edm::Ref<reco::RecoEcalCandidateCollection>, edm::Ref<reco::RecoEcalCandidateCollection> > >
0070 thePairs;
0071
0072 edm::Handle<reco::RecoEcalCandidateCollection> recoIsolecalcands;
0073 iEvent.getByToken(candIsolatedToken_, recoIsolecalcands);
0074 edm::Handle<reco::RecoEcalCandidateCollection> recoNonIsolecalcands;
0075 iEvent.getByToken(candNonIsolatedToken_, recoNonIsolecalcands);
0076
0077
0078 for (auto recoecalcand1 = recoIsolecalcands->begin(); recoecalcand1 != recoIsolecalcands->end(); recoecalcand1++) {
0079 edm::Ref<reco::RecoEcalCandidateCollection> ref1 = edm::Ref<reco::RecoEcalCandidateCollection>(
0080 recoIsolecalcands, distance(recoIsolecalcands->begin(), recoecalcand1));
0081 for (auto recoecalcand2 = recoIsolecalcands->begin(); recoecalcand2 != recoIsolecalcands->end(); recoecalcand2++) {
0082 edm::Ref<reco::RecoEcalCandidateCollection> ref2 = edm::Ref<reco::RecoEcalCandidateCollection>(
0083 recoIsolecalcands, distance(recoIsolecalcands->begin(), recoecalcand2));
0084 if (&(*ref1) != &(*ref2)) {
0085 thePairs.push_back(
0086 std::pair<edm::Ref<reco::RecoEcalCandidateCollection>, edm::Ref<reco::RecoEcalCandidateCollection> >(ref1,
0087 ref2));
0088 }
0089 }
0090 if (AlsoNonIsolatedSecond_) {
0091 for (auto recoecalcand2 = recoNonIsolecalcands->begin(); recoecalcand2 != recoNonIsolecalcands->end();
0092 recoecalcand2++) {
0093 edm::Ref<reco::RecoEcalCandidateCollection> ref2 = edm::Ref<reco::RecoEcalCandidateCollection>(
0094 recoNonIsolecalcands, distance(recoNonIsolecalcands->begin(), recoecalcand2));
0095 if (&(*ref1) != &(*ref2)) {
0096 thePairs.push_back(
0097 std::pair<edm::Ref<reco::RecoEcalCandidateCollection>, edm::Ref<reco::RecoEcalCandidateCollection> >(
0098 ref1, ref2));
0099 }
0100 }
0101 }
0102 }
0103
0104
0105 if (AlsoNonIsolatedFirst_) {
0106 for (auto recoecalcand1 = recoNonIsolecalcands->begin(); recoecalcand1 != recoNonIsolecalcands->end();
0107 recoecalcand1++) {
0108 edm::Ref<reco::RecoEcalCandidateCollection> ref1 = edm::Ref<reco::RecoEcalCandidateCollection>(
0109 recoNonIsolecalcands, distance(recoNonIsolecalcands->begin(), recoecalcand1));
0110 for (auto recoecalcand2 = recoIsolecalcands->begin(); recoecalcand2 != recoIsolecalcands->end();
0111 recoecalcand2++) {
0112 edm::Ref<reco::RecoEcalCandidateCollection> ref2 = edm::Ref<reco::RecoEcalCandidateCollection>(
0113 recoIsolecalcands, distance(recoIsolecalcands->begin(), recoecalcand2));
0114 if (&(*ref1) != &(*ref2)) {
0115 thePairs.push_back(
0116 std::pair<edm::Ref<reco::RecoEcalCandidateCollection>, edm::Ref<reco::RecoEcalCandidateCollection> >(
0117 ref1, ref2));
0118 }
0119 }
0120 if (AlsoNonIsolatedSecond_) {
0121 for (auto recoecalcand2 = recoNonIsolecalcands->begin(); recoecalcand2 != recoNonIsolecalcands->end();
0122 recoecalcand2++) {
0123 edm::Ref<reco::RecoEcalCandidateCollection> ref2 = edm::Ref<reco::RecoEcalCandidateCollection>(
0124 recoNonIsolecalcands, distance(recoNonIsolecalcands->begin(), recoecalcand2));
0125 if (&(*ref1) != &(*ref2)) {
0126 thePairs.push_back(
0127 std::pair<edm::Ref<reco::RecoEcalCandidateCollection>, edm::Ref<reco::RecoEcalCandidateCollection> >(
0128 ref1, ref2));
0129 }
0130 }
0131 }
0132 }
0133 }
0134
0135
0136 int n(0);
0137
0138 edm::Handle<trigger::TriggerFilterObjectWithRefs> L1SeedOutput;
0139 iEvent.getByToken(L1SeedFilterToken_, L1SeedOutput);
0140
0141 std::vector<l1extra::L1EmParticleRef> l1EGIso;
0142 L1SeedOutput->getObjects(TriggerL1IsoEG, l1EGIso);
0143 std::vector<l1extra::L1EmParticleRef> l1EGNonIso;
0144 L1SeedOutput->getObjects(TriggerL1NoIsoEG, l1EGNonIso);
0145
0146
0147
0148
0149
0150
0151
0152 std::vector<std::pair<edm::Ref<reco::RecoEcalCandidateCollection>,
0153 edm::Ref<reco::RecoEcalCandidateCollection> > >::iterator pairsIt;
0154 for (pairsIt = thePairs.begin(); pairsIt != thePairs.end(); pairsIt++) {
0155
0156
0157
0158
0159 if (CheckL1Matching(pairsIt->first, l1EGIso, l1EGNonIso) && CheckL1Matching(pairsIt->second, l1EGIso, l1EGNonIso)) {
0160 filterproduct.addObject(TriggerCluster, pairsIt->first);
0161 filterproduct.addObject(TriggerCluster, pairsIt->second);
0162 n++;
0163 }
0164 }
0165
0166
0167
0168 bool accept(n >= 1);
0169
0170 return accept;
0171 }
0172
0173 bool HLTEgammaL1MatchFilterPairs::CheckL1Matching(edm::Ref<reco::RecoEcalCandidateCollection> ref,
0174 std::vector<l1extra::L1EmParticleRef>& l1EGIso,
0175 std::vector<l1extra::L1EmParticleRef>& l1EGNonIso) const {
0176 for (auto& i : l1EGIso) {
0177
0178 double etaBinLow = 0.;
0179 double etaBinHigh = 0.;
0180 if (fabs(ref->eta()) < barrel_end_) {
0181 etaBinLow = i->eta() - region_eta_size_ / 2.;
0182 etaBinHigh = etaBinLow + region_eta_size_;
0183 } else {
0184 etaBinLow = i->eta() - region_eta_size_ecap_ / 2.;
0185 etaBinHigh = etaBinLow + region_eta_size_ecap_;
0186 }
0187
0188 float deltaphi = fabs(ref->phi() - i->phi());
0189 if (deltaphi > TWOPI)
0190 deltaphi -= TWOPI;
0191 if (deltaphi > M_PI)
0192 deltaphi = TWOPI - deltaphi;
0193
0194 if (ref->eta() < etaBinHigh && ref->eta() > etaBinLow && deltaphi < region_phi_size_ / 2.) {
0195 return true;
0196 }
0197 }
0198
0199 for (auto& i : l1EGNonIso) {
0200
0201 double etaBinLow = 0.;
0202 double etaBinHigh = 0.;
0203 if (fabs(ref->eta()) < barrel_end_) {
0204 etaBinLow = i->eta() - region_eta_size_ / 2.;
0205 etaBinHigh = etaBinLow + region_eta_size_;
0206 } else {
0207 etaBinLow = i->eta() - region_eta_size_ecap_ / 2.;
0208 etaBinHigh = etaBinLow + region_eta_size_ecap_;
0209 }
0210
0211 float deltaphi = fabs(ref->phi() - i->phi());
0212 if (deltaphi > TWOPI)
0213 deltaphi -= TWOPI;
0214 if (deltaphi > M_PI)
0215 deltaphi = TWOPI - deltaphi;
0216
0217 if (ref->eta() < etaBinHigh && ref->eta() > etaBinLow && deltaphi < region_phi_size_ / 2.) {
0218 return true;
0219 }
0220 }
0221
0222 return false;
0223 }
0224
0225
0226 #include "FWCore/Framework/interface/MakerMacros.h"
0227 DEFINE_FWK_MODULE(HLTEgammaL1MatchFilterPairs);