diff --git a/HLTrigger/btau/src/HLTmumutkFilter.cc b/HLTrigger/btau/src/HLTmumutkFilter.cc index e91de43e24472..f721b4b92f745 100644 --- a/HLTrigger/btau/src/HLTmumutkFilter.cc +++ b/HLTrigger/btau/src/HLTmumutkFilter.cc @@ -131,35 +131,36 @@ bool HLTmumutkFilter::hltFilter(edm::Event& iEvent, const edm::EventSetup& iSetu reco::RecoChargedCandidateCollection::const_iterator tkcand ; int iFoundRefs = 0; - bool threeMuons = false; + bool track1Matched = false; + bool track2Matched = false; + bool track3Matched = false; for (auto cand=mucands->begin(); cand!=mucands->end(); cand++) { reco::TrackRef tkRef = cand->get(); - if (tkRef == vertextkRef1 && iFoundRefs==0) {mucand1 = cand; iFoundRefs++;} - else if(tkRef == vertextkRef1 && iFoundRefs==1) {mucand2 = cand; iFoundRefs++;} - else if(tkRef == vertextkRef1 && iFoundRefs==2) {threeMuons = true;} - if (tkRef == vertextkRef2 && iFoundRefs==0) {mucand1 = cand; iFoundRefs++;} - else if(tkRef == vertextkRef2 && iFoundRefs==1) {mucand2 = cand; iFoundRefs++;} - else if(tkRef == vertextkRef2 && iFoundRefs==2) {threeMuons = true;} - if (tkRef == vertextkRef3 && iFoundRefs==0) {mucand1 = cand; iFoundRefs++;} - else if(tkRef == vertextkRef3 && iFoundRefs==1) {mucand2 = cand; iFoundRefs++;} - else if(tkRef == vertextkRef3 && iFoundRefs==2) {threeMuons = true;} + if (!track1Matched) { + if (tkRef == vertextkRef1 && iFoundRefs==0) {mucand1 = cand; iFoundRefs++; track1Matched = true;} + else if(tkRef == vertextkRef1 && iFoundRefs==1) {mucand2 = cand; iFoundRefs++; track1Matched = true;} + } + if (!track2Matched) { + if (tkRef == vertextkRef2 && iFoundRefs==0) {mucand1 = cand; iFoundRefs++; track2Matched = true;} + else if(tkRef == vertextkRef2 && iFoundRefs==1) {mucand2 = cand; iFoundRefs++; track2Matched = true;} + } + if (!track3Matched) { + if (tkRef == vertextkRef3 && iFoundRefs==0) {mucand1 = cand; iFoundRefs++; track3Matched = true;} + else if(tkRef == vertextkRef3 && iFoundRefs==1) {mucand2 = cand; iFoundRefs++; track3Matched = true;} + } } - if(threeMuons) throw cms::Exception("BadLogic") << "HLTmumutkFilterr: ERROR: the vertex must have " - << " exactly two muons by definition." << std::endl; + if(iFoundRefs < 2) throw cms::Exception("BadLogic") << "HLTmumutkFilterr: ERROR: the vertex must have " + << " at least two muons by definition." << std::endl; - bool twoTrks = false; int iTrkFoundRefs = 0; for (auto cand=trkcands->begin(); cand!=trkcands->end(); cand++) { reco::TrackRef tkRef = cand->get(); - if (tkRef == vertextkRef1 && iTrkFoundRefs==0) {tkcand = cand; iTrkFoundRefs++;} - else if(tkRef == vertextkRef1 && iTrkFoundRefs==1) {twoTrks = true;} - if (tkRef == vertextkRef2 && iTrkFoundRefs==0) {tkcand = cand; iTrkFoundRefs++;} - else if(tkRef == vertextkRef2 && iTrkFoundRefs==1) {twoTrks = true;} - if (tkRef == vertextkRef3 && iTrkFoundRefs==0) {tkcand = cand; iTrkFoundRefs++;} - else if(tkRef == vertextkRef3 && iTrkFoundRefs==1) {twoTrks = true;} + if (tkRef == vertextkRef1 && iTrkFoundRefs==0 && !track1Matched) {tkcand = cand; iTrkFoundRefs++; track1Matched = true; break;} + if (tkRef == vertextkRef2 && iTrkFoundRefs==0 && !track2Matched) {tkcand = cand; iTrkFoundRefs++; track2Matched = true; break;} + if (tkRef == vertextkRef3 && iTrkFoundRefs==0 && !track3Matched) {tkcand = cand; iTrkFoundRefs++; track3Matched = true; break;} } - if(twoTrks) throw cms::Exception("BadLogic") << "HLTmumutkFilterr: ERROR: the vertex must have " - << " exactly one track by definition." << std::endl; + if(iTrkFoundRefs == 0) throw cms::Exception("BadLogic") << "HLTmumutkFilterr: ERROR: the vertex must have " + << " at least one track by definition." << std::endl; // calculate three-track transverse momentum math::XYZVector pperp(mucand1->px() + mucand2->px() + tkcand->px(), @@ -209,4 +210,4 @@ bool HLTmumutkFilter::triggerdByPreviousLevel(const reco::RecoChargedCandidateRe if (candref == vcands[i]) return true; } return false; -} \ No newline at end of file +} diff --git a/HLTrigger/btau/src/HLTmumutktkFilter.cc b/HLTrigger/btau/src/HLTmumutktkFilter.cc index fffc28d0d9c30..fed550ea4f8c2 100644 --- a/HLTrigger/btau/src/HLTmumutktkFilter.cc +++ b/HLTrigger/btau/src/HLTmumutktkFilter.cc @@ -134,8 +134,8 @@ bool HLTmumutktkFilter::hltFilter(edm::Event& iEvent, const edm::EventSetup& iSe if (tkRef == iVec) {mucandVec.push_back(cand); break;} } } - if(mucandVec.size()!= 2) throw cms::Exception("BadLogic") << "HLTmumutktkFilterr: ERROR: the vertex must have " - << " exactly two muons by definition." << std::endl; + if(mucandVec.size() < 2) throw cms::Exception("BadLogic") << "HLTmumutktkFilterr: ERROR: the vertex must have " + << " at least two muons by definition." << std::endl; for (auto cand=trkcands->begin(); cand!=trkcands->end(); cand++) { reco::TrackRef tkRef = cand->get(); @@ -143,8 +143,8 @@ bool HLTmumutktkFilter::hltFilter(edm::Event& iEvent, const edm::EventSetup& iSe if (tkRef == iVec) {trkcandVec.push_back(cand); break;} } } - if(trkcandVec.size()!= 2 ) throw cms::Exception("BadLogic") << "HLTmumutktkFilterr: ERROR: the vertex must have " - << " exactly two tracks by definition." << std::endl; + if(trkcandVec.size() < 2 ) throw cms::Exception("BadLogic") << "HLTmumutktkFilterr: ERROR: the vertex must have " + << " at least two tracks by definition." << std::endl; // calculate four-track transverse momentum math::XYZVector pperp(mucandVec.at(0)->px() + mucandVec.at(1)->px() + trkcandVec.at(0)->px() + trkcandVec.at(1)->px(), @@ -198,4 +198,4 @@ bool HLTmumutktkFilter::triggerdByPreviousLevel(const reco::RecoChargedCandidate if (candref == vcands[i]) return true; } return false; -} \ No newline at end of file +}