Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avoid duplicates in HLTPMMassFilter plugin [13_0_X] #40919

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 26 additions & 32 deletions HLTrigger/Egamma/plugins/HLTPMMassFilter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
*/
#include "HLTPMMassFilter.h"

#include <cstdlib>
#include <cmath>

//
// constructors and destructor
//
Expand Down Expand Up @@ -79,7 +82,6 @@ bool HLTPMMassFilter::hltFilter(edm::Event& iEvent,
std::vector<TLorentzVector> pEleCh1;
std::vector<TLorentzVector> pEleCh2;
std::vector<double> charge;
std::vector<double> etaOrig;

if (isElectron1_ && isElectron2_) {
Ref<ElectronCollection> refele;
Expand All @@ -95,25 +97,18 @@ bool HLTPMMassFilter::hltFilter(edm::Event& iEvent,
charge.push_back(refele->charge());
}

std::vector<bool> save_cand(electrons.size(), true);
for (unsigned int jj = 0; jj < electrons.size(); jj++) {
TLorentzVector p1Ele = pEleCh1.at(jj);
for (unsigned int ii = jj + 1; ii < electrons.size(); ii++) {
TLorentzVector p2Ele = pEleCh1.at(ii);

if (fabs(p1Ele.E() - p2Ele.E()) < 0.00001)
continue;
if (reqOppCharge_ && charge[jj] * charge[ii] > 0)
continue;

TLorentzVector pTot = p1Ele + p2Ele;
double mass = pTot.M();

if (mass >= lowerMassCut_ && mass <= upperMassCut_) {
if (isGoodPair(pEleCh1[jj], pEleCh1[ii])) {
n++;
refele = electrons[ii];
filterproduct.addObject(TriggerElectron, refele);
refele = electrons[jj];
filterproduct.addObject(TriggerElectron, refele);
for (auto const idx : {jj, ii}) {
if (save_cand[idx])
filterproduct.addObject(TriggerElectron, electrons[idx]);
save_cand[idx] = false;
}
}
}
}
Expand All @@ -134,38 +129,37 @@ bool HLTPMMassFilter::hltFilter(edm::Event& iEvent,

TLorentzVector pscEle = approxMomAtVtx(theMagField, vertexPos, sc, -1);
pEleCh2.push_back(pscEle);
etaOrig.push_back(sc->eta());
}

std::vector<bool> save_cand(scs.size(), true);
for (unsigned int jj = 0; jj < scs.size(); jj++) {
TLorentzVector p1Ele = pEleCh1.at(jj);
for (unsigned int ii = 0; ii < scs.size(); ii++) {
TLorentzVector p2Ele = pEleCh2.at(ii);

if (fabs(p1Ele.E() - p2Ele.E()) < 0.00001)
continue;

TLorentzVector pTot = p1Ele + p2Ele;
double mass = pTot.M();

if (mass >= lowerMassCut_ && mass <= upperMassCut_) {
for (unsigned int ii = jj + 1; ii < scs.size(); ii++) {
if (isGoodPair(pEleCh1[jj], pEleCh2[ii]) or isGoodPair(pEleCh2[jj], pEleCh1[ii])) {
n++;
refsc = scs[ii];
filterproduct.addObject(TriggerCluster, refsc);
refsc = scs[jj];
filterproduct.addObject(TriggerCluster, refsc);
for (auto const idx : {jj, ii}) {
if (save_cand[idx])
filterproduct.addObject(TriggerCluster, scs[idx]);
save_cand[idx] = false;
}
}
}
}
}

// filter decision
bool accept(n >= nZcandcut_);
// if (accept) std::cout << "n size = " << n << std::endl;

return accept;
}

bool HLTPMMassFilter::isGoodPair(TLorentzVector const& v1, TLorentzVector const& v2) const {
if (std::abs(v1.E() - v2.E()) < 0.00001)
return false;

auto const mass = (v1 + v2).M();
return (mass >= lowerMassCut_ and mass <= upperMassCut_);
}

TLorentzVector HLTPMMassFilter::approxMomAtVtx(const MagneticField& magField,
const GlobalPoint& xvert,
const reco::SuperClusterRef sc,
Expand Down
2 changes: 2 additions & 0 deletions HLTrigger/Egamma/plugins/HLTPMMassFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ class HLTPMMassFilter : public HLTFilter {
static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);

private:
bool isGoodPair(TLorentzVector const& v1, TLorentzVector const& v2) const;

TLorentzVector approxMomAtVtx(const MagneticField& magField,
const GlobalPoint& xvert,
const reco::SuperClusterRef sc,
Expand Down