@@ -73,48 +73,48 @@ void HLTEgammaDoubleXGBoostCombFilter::fillDescriptions(edm::ConfigurationDescri
7373bool 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_)
97+ return false ;
8698
87- for (size_t i = 0 ; i < recCollection->size (); i++) {
99+ if (mvaScorei >= mvaScorej) {
100+ return passesHighMassCuts (mvaScorei, mvaScorej, etai, etaj);
101+ } else {
102+ return passesHighMassCuts (mvaScorej, mvaScorei, etaj, etai);
103+ }
104+ };
105+
106+ // Loop through candidates
107+ for (size_t i = 0 ; i < recCollection->size (); ++i) {
88108 edm::Ref<reco::RecoEcalCandidateCollection> refi (recCollection, i);
89- float EtaSCi = refi->eta ();
90- int eta1 = (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++) {
109+ for (size_t j = i + 1 ; j < recCollection->size (); ++j) {
94110 edm::Ref<reco::RecoEcalCandidateCollection> refj (recCollection, j);
95- float EtaSCj = refj->eta ();
96- int eta2 = (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_[eta1] && mvaScorej > subCutHighMass1_[eta2]) ||
103- (mvaScorei > leadCutHighMass2_[eta1] && mvaScorej > subCutHighMass2_[eta2]) ||
104- (mvaScorei > leadCutHighMass3_[eta1] && mvaScorej > subCutHighMass3_[eta2]))) {
105- accept = true ;
106- } // if scoreI > scoreJ
107- else if (mvaScorej > mvaScorei &&
108- ((mvaScorej > leadCutHighMass1_[eta1] && mvaScorei > subCutHighMass1_[eta2]) ||
109- (mvaScorej > leadCutHighMass2_[eta1] && mvaScorei > subCutHighMass2_[eta2]) ||
110- (mvaScorej > leadCutHighMass3_[eta1] && mvaScorei > subCutHighMass3_[eta2]))) {
111- accept = true ;
112- } // if scoreJ > scoreI
113- } // If high mass
114- } // j loop
115- } // i loop
116- return accept;
117- } // Definition
111+ if (evaluatePair (refi, refj)) {
112+ return true ;
113+ }
114+ }
115+ }
116+ return false ;
117+ }
118118
119119#include " FWCore/Framework/interface/MakerMacros.h"
120120DEFINE_FWK_MODULE (HLTEgammaDoubleXGBoostCombFilter);
0 commit comments