CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Attributes
pat::helper::BasicOverlapTest Class Reference

#include <OverlapTest.h>

Inheritance diagram for pat::helper::BasicOverlapTest:
pat::helper::OverlapTest

Public Member Functions

 BasicOverlapTest (const std::string &name, const edm::ParameterSet &iConfig, edm::ConsumesCollector &&iC)
 
bool fillOverlapsForItem (const reco::Candidate &item, reco::CandidatePtrVector &overlapsToFill) const override
 Check for overlaps. More...
 
void readInput (const edm::Event &iEvent, const edm::EventSetup &iSetup) override
 Read input, apply preselection cut. More...
 
- Public Member Functions inherited from pat::helper::OverlapTest
virtual void done ()
 end of event method. does nothing More...
 
const std::string & name () const
 
 OverlapTest (const std::string &name, const edm::ParameterSet &iConfig, edm::ConsumesCollector &iC)
 constructor: reads 'src' and 'requireNoOverlaps' parameters More...
 
bool requireNoOverlaps () const
 
virtual ~OverlapTest ()
 destructor, does nothing More...
 

Protected Attributes

edm::Handle< reco::CandidateViewcandidates_
 The collection to check overlaps against. More...
 
bool checkRecoComponents_
 Check the overlapping by RECO components. More...
 
double deltaR_
 Delta R for the match. More...
 
std::vector< bool > isPreselected_
 Flag saying if each element has passed the preselection or not. More...
 
StringCutObjectSelector< pat::DiObjectProxypairCut_
 Cut on the pair of objects together. More...
 
PATStringCutObjectSelector presel_
 A generic preselection cut that can work on any Candidate, but has access also to methods of PAT specific objects. More...
 
- Protected Attributes inherited from pat::helper::OverlapTest
std::string name_
 
bool requireNoOverlaps_
 
edm::EDGetTokenT< reco::CandidateViewsrcToken_
 

Detailed Description

Definition at line 46 of file OverlapTest.h.

Constructor & Destructor Documentation

◆ BasicOverlapTest()

pat::helper::BasicOverlapTest::BasicOverlapTest ( const std::string &  name,
const edm::ParameterSet iConfig,
edm::ConsumesCollector &&  iC 
)
inline

Definition at line 48 of file OverlapTest.h.

49  : OverlapTest(name, iConfig, iC),
50  presel_(iConfig.getParameter<std::string>("preselection")),
51  deltaR_(iConfig.getParameter<double>("deltaR")),
52  checkRecoComponents_(iConfig.getParameter<bool>("checkRecoComponents")),
53  pairCut_(iConfig.getParameter<std::string>("pairCut")) {}

Member Function Documentation

◆ fillOverlapsForItem()

bool BasicOverlapTest::fillOverlapsForItem ( const reco::Candidate item,
reco::CandidatePtrVector overlapsToFill 
) const
overridevirtual

Check for overlaps.

Implements pat::helper::OverlapTest.

Definition at line 20 of file OverlapTest.cc.

21  {
22  size_t idx = 0;
23  std::vector<std::pair<float, size_t> > matches;
24  for (reco::CandidateView::const_iterator it = candidates_->begin(); it != candidates_->end(); ++it, ++idx) {
25  if (!isPreselected_[idx])
26  continue;
27  double dr = reco::deltaR(item, *it);
28  if (dr < deltaR_) {
31  if (!overlaps(item, *it))
32  continue;
33  }
34  if (!pairCut_(pat::DiObjectProxy(item, *it)))
35  continue;
36  matches.push_back(std::make_pair(dr, idx));
37  }
38  }
39  // see if we matched anything
40  if (matches.empty())
41  return false;
42 
43  // sort matches
44  std::sort(matches.begin(), matches.end());
45  // fill ptr vector
46  for (std::vector<std::pair<float, size_t> >::const_iterator it = matches.begin(); it != matches.end(); ++it) {
47  overlapsToFill.push_back(candidates_->ptrAt(it->second));
48  }
49  return true;
50 }

References candidates_, checkRecoComponents_, reco::deltaR(), deltaR_, flavorHistoryFilter_cfi::dr, training_settings::idx, isPreselected_, B2GTnPMonitor_cfi::item, patCandidatesForDimuonsSequences_cff::matches, analyzePatCleaning_cfg::overlaps, pairCut_, and edm::PtrVector< T >::push_back().

◆ readInput()

void BasicOverlapTest::readInput ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
overridevirtual

Read input, apply preselection cut.

Implements pat::helper::OverlapTest.

Definition at line 9 of file OverlapTest.cc.

9  {
10  iEvent.getByToken(srcToken_, candidates_);
11  isPreselected_.resize(candidates_->size());
12  size_t idx = 0;
13  for (reco::CandidateView::const_iterator it = candidates_->begin(); it != candidates_->end(); ++it, ++idx) {
14  isPreselected_[idx] = presel_(*it);
15  }
16  // Yes, I could use std::transform. But would people like it?
17  // http://www.sgi.com/tech/stl/transform.html
18 }

References candidates_, training_settings::idx, iEvent, isPreselected_, presel_, and pat::helper::OverlapTest::srcToken_.

Member Data Documentation

◆ candidates_

edm::Handle<reco::CandidateView> pat::helper::BasicOverlapTest::candidates_
protected

The collection to check overlaps against.

Definition at line 72 of file OverlapTest.h.

Referenced by fillOverlapsForItem(), and readInput().

◆ checkRecoComponents_

bool pat::helper::BasicOverlapTest::checkRecoComponents_
protected

Check the overlapping by RECO components.

Definition at line 67 of file OverlapTest.h.

Referenced by fillOverlapsForItem().

◆ deltaR_

double pat::helper::BasicOverlapTest::deltaR_
protected

Delta R for the match.

Definition at line 65 of file OverlapTest.h.

Referenced by fillOverlapsForItem().

◆ isPreselected_

std::vector<bool> pat::helper::BasicOverlapTest::isPreselected_
protected

Flag saying if each element has passed the preselection or not.

Definition at line 74 of file OverlapTest.h.

Referenced by fillOverlapsForItem(), and readInput().

◆ pairCut_

StringCutObjectSelector<pat::DiObjectProxy> pat::helper::BasicOverlapTest::pairCut_
protected

Cut on the pair of objects together.

Definition at line 69 of file OverlapTest.h.

Referenced by fillOverlapsForItem().

◆ presel_

PATStringCutObjectSelector pat::helper::BasicOverlapTest::presel_
protected

A generic preselection cut that can work on any Candidate, but has access also to methods of PAT specific objects.

Definition at line 63 of file OverlapTest.h.

Referenced by readInput().

OverlapChecker
Definition: OverlapChecker.h:17
pat::helper::BasicOverlapTest::checkRecoComponents_
bool checkRecoComponents_
Check the overlapping by RECO components.
Definition: OverlapTest.h:67
training_settings.idx
idx
Definition: training_settings.py:16
pat::helper::BasicOverlapTest::deltaR_
double deltaR_
Delta R for the match.
Definition: OverlapTest.h:65
pat::helper::OverlapTest::OverlapTest
OverlapTest(const std::string &name, const edm::ParameterSet &iConfig, edm::ConsumesCollector &iC)
constructor: reads 'src' and 'requireNoOverlaps' parameters
Definition: OverlapTest.h:22
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::PtrVector::push_back
void push_back(Ptr< T > const &iPtr)
Definition: PtrVector.h:149
analyzePatCleaning_cfg.overlaps
overlaps
Definition: analyzePatCleaning_cfg.py:9
pat::helper::OverlapTest::name
const std::string & name() const
Definition: OverlapTest.h:37
pat::helper::BasicOverlapTest::candidates_
edm::Handle< reco::CandidateView > candidates_
The collection to check overlaps against.
Definition: OverlapTest.h:72
iEvent
int iEvent
Definition: GenABIO.cc:224
pat::helper::BasicOverlapTest::isPreselected_
std::vector< bool > isPreselected_
Flag saying if each element has passed the preselection or not.
Definition: OverlapTest.h:74
B2GTnPMonitor_cfi.item
item
Definition: B2GTnPMonitor_cfi.py:147
pat::helper::OverlapTest::srcToken_
edm::EDGetTokenT< reco::CandidateView > srcToken_
Definition: OverlapTest.h:41
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
pat::helper::BasicOverlapTest::presel_
PATStringCutObjectSelector presel_
A generic preselection cut that can work on any Candidate, but has access also to methods of PAT spec...
Definition: OverlapTest.h:63
flavorHistoryFilter_cfi.dr
dr
Definition: flavorHistoryFilter_cfi.py:37
reco::deltaR
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:30
patCandidatesForDimuonsSequences_cff.matches
matches
Definition: patCandidatesForDimuonsSequences_cff.py:131
edm::View::const_iterator
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
pat::DiObjectProxy
Definition: PATDiObjectProxy.h:19
pat::helper::BasicOverlapTest::pairCut_
StringCutObjectSelector< pat::DiObjectProxy > pairCut_
Cut on the pair of objects together.
Definition: OverlapTest.h:69