Skip to content

Commit 3258e6b

Browse files
committed
refactored version of Dipohoton MVA filter by M. Musich
1 parent ca30afe commit 3258e6b

File tree

1 file changed

+34
-35
lines changed

1 file changed

+34
-35
lines changed

HLTrigger/Egamma/plugins/HLTEgammaDoubleXGBoostCombFilter.cc

+34-35
Original file line numberDiff line numberDiff line change
@@ -73,48 +73,47 @@ void HLTEgammaDoubleXGBoostCombFilter::fillDescriptions(edm::ConfigurationDescri
7373
bool HLTEgammaDoubleXGBoostCombFilter::hltFilter(edm::Event& event,
7474
const edm::EventSetup& setup,
7575
trigger::TriggerFilterObjectWithRefs& filterproduct) const {
76-
//producer collection (hltEgammaCandidates(Unseeded))
7776
const auto& recCollection = event.getHandle(candToken_);
78-
79-
//get hold of photon MVA association map
8077
const auto& mvaMap = event.getHandle(mvaToken_);
8178

82-
std::vector<math::XYZTLorentzVector> p4s(recCollection->size());
83-
std::vector<bool> isTight(recCollection->size());
79+
// Lambda to evaluate pair cuts
80+
auto passesHighMassCuts = [&](float leadScore, float subScore, int leadEta, int subEta) {
81+
return (leadScore > leadCutHighMass1_[leadEta] && subScore > subCutHighMass1_[subEta]) ||
82+
(leadScore > leadCutHighMass2_[leadEta] && subScore > subCutHighMass2_[subEta]) ||
83+
(leadScore > leadCutHighMass3_[leadEta] && subScore > subCutHighMass3_[subEta]);
84+
};
85+
86+
// Lambda to evaluate a candidate pair
87+
auto evaluatePair = [&](const edm::Ref<reco::RecoEcalCandidateCollection>& refi,
88+
const edm::Ref<reco::RecoEcalCandidateCollection>& refj) {
89+
float mvaScorei = (*mvaMap).find(refi)->val;
90+
float mvaScorej = (*mvaMap).find(refj)->val;
91+
92+
int etai = (std::abs(refi->eta()) < 1.5) ? 0 : 1;
93+
int etaj = (std::abs(refj->eta()) < 1.5) ? 0 : 1;
8494

85-
bool accept = false;
95+
double mass = (refi->p4() + refj->p4()).M();
96+
if (mass < highMassCut_) return false;
8697

87-
for (size_t i = 0; i < recCollection->size(); i++) {
98+
if (mvaScorei >= mvaScorej) {
99+
return passesHighMassCuts(mvaScorei, mvaScorej, etai, etaj);
100+
} else {
101+
return passesHighMassCuts(mvaScorej, mvaScorei, etaj, etai);
102+
}
103+
};
104+
105+
// Loop through candidates
106+
for (size_t i = 0; i < recCollection->size(); ++i) {
88107
edm::Ref<reco::RecoEcalCandidateCollection> refi(recCollection, i);
89-
float EtaSCi = refi->eta();
90-
int etai = (std::abs(EtaSCi) < 1.5) ? 0 : 1;
91-
float mvaScorei = (*mvaMap).find(refi)->val;
92-
math::XYZTLorentzVector p4i = refi->p4();
93-
for (size_t j = i + 1; j < recCollection->size(); j++) {
108+
for (size_t j = i + 1; j < recCollection->size(); ++j) {
94109
edm::Ref<reco::RecoEcalCandidateCollection> refj(recCollection, j);
95-
float EtaSCj = refj->eta();
96-
int etaj = (std::abs(EtaSCj) < 1.5) ? 0 : 1;
97-
float mvaScorej = (*mvaMap).find(refj)->val;
98-
math::XYZTLorentzVector p4j = refj->p4();
99-
math::XYZTLorentzVector pairP4 = p4i + p4j;
100-
double mass = pairP4.M();
101-
if (mass >= highMassCut_) {
102-
if (mvaScorei >= mvaScorej && ((mvaScorei > leadCutHighMass1_[etai] && mvaScorej > subCutHighMass1_[etaj]) ||
103-
(mvaScorei > leadCutHighMass2_[etai] && mvaScorej > subCutHighMass2_[etaj]) ||
104-
(mvaScorei > leadCutHighMass3_[etai] && mvaScorej > subCutHighMass3_[etaj]))) {
105-
accept = true;
106-
} //if scoreI > scoreJ
107-
else if (mvaScorej > mvaScorei &&
108-
((mvaScorej > leadCutHighMass1_[etaj] && mvaScorei > subCutHighMass1_[etai]) ||
109-
(mvaScorej > leadCutHighMass2_[etaj] && mvaScorei > subCutHighMass2_[etai]) ||
110-
(mvaScorej > leadCutHighMass3_[etaj] && mvaScorei > subCutHighMass3_[etai]))) {
111-
accept = true;
112-
} // if scoreJ > scoreI
113-
} //If high mass
114-
} //j loop
115-
} //i loop
116-
return accept;
117-
} //Definition
110+
if (evaluatePair(refi, refj)) {
111+
return true;
112+
}
113+
}
114+
}
115+
return false;
116+
}
118117

119118
#include "FWCore/Framework/interface/MakerMacros.h"
120119
DEFINE_FWK_MODULE(HLTEgammaDoubleXGBoostCombFilter);

0 commit comments

Comments
 (0)