#include <OverlapTest.h>
Public Member Functions | |
BasicOverlapTest (const std::string &name, const edm::ParameterSet &iConfig) | |
virtual bool | fillOverlapsForItem (const reco::Candidate &item, reco::CandidatePtrVector &overlapsToFill) const |
Check for overlaps. | |
virtual void | readInput (const edm::Event &iEvent, const edm::EventSetup &iSetup) |
Read input, apply preselection cut. | |
Protected Attributes | |
edm::Handle< reco::CandidateView > | candidates_ |
The collection to check overlaps against. | |
bool | checkRecoComponents_ |
Check the overlapping by RECO components. | |
double | deltaR_ |
Delta R for the match. | |
std::vector< bool > | isPreselected_ |
Flag saying if each element has passed the preselection or not. | |
StringCutObjectSelector < pat::DiObjectProxy > | pairCut_ |
Cut on the pair of objects together. | |
PATStringCutObjectSelector | presel_ |
A generic preselection cut that can work on any Candidate, but has access also to methods of PAT specific objects. |
Definition at line 43 of file OverlapTest.h.
pat::helper::BasicOverlapTest::BasicOverlapTest | ( | const std::string & | name, |
const edm::ParameterSet & | iConfig | ||
) | [inline] |
Definition at line 45 of file OverlapTest.h.
: OverlapTest(name, iConfig), presel_(iConfig.getParameter<std::string>("preselection")), deltaR_(iConfig.getParameter<double>("deltaR")), checkRecoComponents_(iConfig.getParameter<bool>("checkRecoComponents")), pairCut_(iConfig.getParameter<std::string>("pairCut")) {}
bool BasicOverlapTest::fillOverlapsForItem | ( | const reco::Candidate & | item, |
reco::CandidatePtrVector & | overlapsToFill | ||
) | const [virtual] |
Check for overlaps.
Implements pat::helper::OverlapTest.
Definition at line 23 of file OverlapTest.cc.
References candidates_, checkRecoComponents_, deltaR(), deltaR_, isPreselected_, analyzePatCleaning_cfg::overlaps, pairCut_, edm::PtrVector< T >::push_back(), and python::multivaluedict::sort().
{ size_t idx = 0; std::vector<std::pair<float,size_t> > matches; for (reco::CandidateView::const_iterator it = candidates_->begin(); it != candidates_->end(); ++it, ++idx) { if (!isPreselected_[idx]) continue; double dr = reco::deltaR(item, *it); if (dr < deltaR_) { if (checkRecoComponents_) { OverlapChecker overlaps; if (!overlaps(item, *it)) continue; } if (!pairCut_(pat::DiObjectProxy(item,*it))) continue; matches.push_back(std::make_pair(dr, idx)); } } // see if we matched anything if (matches.empty()) return false; // sort matches std::sort(matches.begin(), matches.end()); // fill ptr vector for (std::vector<std::pair<float,size_t> >::const_iterator it = matches.begin(); it != matches.end(); ++it) { overlapsToFill.push_back(candidates_->ptrAt(it->second)); } return true; }
void BasicOverlapTest::readInput | ( | const edm::Event & | iEvent, |
const edm::EventSetup & | iSetup | ||
) | [virtual] |
Read input, apply preselection cut.
Implements pat::helper::OverlapTest.
Definition at line 10 of file OverlapTest.cc.
References candidates_, edm::Event::getByLabel(), isPreselected_, presel_, and pat::helper::OverlapTest::src_.
{ iEvent.getByLabel(src_, candidates_); isPreselected_.resize(candidates_->size()); size_t idx = 0; for (reco::CandidateView::const_iterator it = candidates_->begin(); it != candidates_->end(); ++it, ++idx) { isPreselected_[idx] = presel_(*it); } // Yes, I could use std::transform. But would people like it? // https://www.sgi.com/tech/stl/transform.html }
The collection to check overlaps against.
Definition at line 68 of file OverlapTest.h.
Referenced by fillOverlapsForItem(), and readInput().
bool pat::helper::BasicOverlapTest::checkRecoComponents_ [protected] |
Check the overlapping by RECO components.
Definition at line 63 of file OverlapTest.h.
Referenced by fillOverlapsForItem().
double pat::helper::BasicOverlapTest::deltaR_ [protected] |
Delta R for the match.
Definition at line 61 of file OverlapTest.h.
Referenced by fillOverlapsForItem().
std::vector<bool> pat::helper::BasicOverlapTest::isPreselected_ [protected] |
Flag saying if each element has passed the preselection or not.
Definition at line 70 of file OverlapTest.h.
Referenced by fillOverlapsForItem(), and readInput().
Cut on the pair of objects together.
Definition at line 65 of file OverlapTest.h.
Referenced by fillOverlapsForItem().
A generic preselection cut that can work on any Candidate, but has access also to methods of PAT specific objects.
Definition at line 59 of file OverlapTest.h.
Referenced by readInput().