CMS 3D CMS Logo

OverlapTest.cc
Go to the documentation of this file.
2 
3 #include <algorithm>
6 
7 using namespace pat::helper;
8 
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 }
19 
21  reco::CandidatePtrVector &overlapsToFill) const {
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 }
51 
53  reco::CandidatePtrVector &overlapsToFill) const {
54  const reco::RecoCandidate *input = dynamic_cast<const reco::RecoCandidate *>(&item);
55  if (input == nullptr)
56  throw cms::Exception("Type Error") << "Input to OverlapBySuperClusterSeed is not a RecoCandidate. "
57  << "It's a " << typeid(item).name() << "\n";
58  reco::SuperClusterRef mySC = input->superCluster();
59  if (mySC.isNull() || !mySC.isAvailable()) {
60  throw cms::Exception("Bad Reference")
61  << "Input to OverlapBySuperClusterSeed has a null or dangling superCluster reference\n";
62  }
63  const reco::CaloClusterPtr &mySeed = mySC->seed();
64  if (mySeed.isNull()) {
65  throw cms::Exception("Bad Reference")
66  << "Input to OverlapBySuperClusterSeed has a null superCluster seed reference\n";
67  }
68  bool hasOverlaps = false;
69  size_t idx = 0;
70  // for (edm::View<reco::RecoCandidate>::const_iterator it = others_->begin(); it != others_->end(); ++it, ++idx) {
71  for (reco::CandidateView::const_iterator it = others_->begin(); it != others_->end(); ++it, ++idx) {
72  const reco::RecoCandidate *other = dynamic_cast<const reco::RecoCandidate *>(&*it);
73  reco::SuperClusterRef otherSc = other->superCluster();
74  if (otherSc.isNull() || !otherSc.isAvailable()) {
75  throw cms::Exception("Bad Reference")
76  << "One item in the OverlapBySuperClusterSeed input list has a null or dangling superCluster reference\n";
77  }
78  if (mySeed == otherSc->seed()) {
79  overlapsToFill.push_back(others_->ptrAt(idx));
80  hasOverlaps = true;
81  }
82  }
83  return hasOverlaps;
84 }
OverlapChecker
Definition: OverlapChecker.h:17
input
static const std::string input
Definition: EdmProvDump.cc:48
edm::Ref::isAvailable
bool isAvailable() const
Definition: Ref.h:537
edm::Ref::isNull
bool isNull() const
Checks for null.
Definition: Ref.h:235
pat::helper::BasicOverlapTest::checkRecoComponents_
bool checkRecoComponents_
Check the overlapping by RECO components.
Definition: OverlapTest.h:67
pat::helper
Definition: ParametrizationHelper.h:8
oniaPATMuonsWithTrigger_cff.matches
matches
Definition: oniaPATMuonsWithTrigger_cff.py:77
ecalTB2006H4_GenSimDigiReco_cfg.mySeed
mySeed
Definition: ecalTB2006H4_GenSimDigiReco_cfg.py:8
pat::helper::BasicOverlapTest::readInput
void readInput(const edm::Event &iEvent, const edm::EventSetup &iSetup) override
Read input, apply preselection cut.
Definition: OverlapTest.cc:9
edm::Ref< SuperClusterCollection >
heavyIonCSV_trainingSettings.idx
idx
Definition: heavyIonCSV_trainingSettings.py:5
pat::helper::BasicOverlapTest::deltaR_
double deltaR_
Delta R for the match.
Definition: OverlapTest.h:65
OverlapTest.h
pat::helper::OverlapBySuperClusterSeed::fillOverlapsForItem
bool fillOverlapsForItem(const reco::Candidate &item, reco::CandidatePtrVector &overlapsToFill) const override
Check for overlaps.
Definition: OverlapTest.cc:52
edm::PtrVector< Candidate >
pat::helper::OverlapBySuperClusterSeed::others_
edm::Handle< reco::CandidateView > others_
Definition: OverlapTest.h:91
trackingPlots.other
other
Definition: trackingPlots.py:1460
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
deltaR.h
pat::helper::BasicOverlapTest::fillOverlapsForItem
bool fillOverlapsForItem(const reco::Candidate &item, reco::CandidatePtrVector &overlapsToFill) const override
Check for overlaps.
Definition: OverlapTest.cc:20
jetUpdater_cfi.sort
sort
Definition: jetUpdater_cfi.py:29
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
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
B2GTnPMonitor_cfi.item
item
Definition: B2GTnPMonitor_cfi.py:147
edm::EventSetup
Definition: EventSetup.h:58
pat::helper::OverlapTest::srcToken_
edm::EDGetTokenT< reco::CandidateView > srcToken_
Definition: OverlapTest.h:41
reco::RecoCandidate
Definition: RecoCandidate.h:20
edm::Ptr< CaloCluster >
reco::Candidate
Definition: Candidate.h:27
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
Exception
Definition: hltDiff.cc:245
reco::deltaR
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:30
edm::View::const_iterator
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
OverlapChecker.h
pat::DiObjectProxy
Definition: PATDiObjectProxy.h:19
edm::Event
Definition: Event.h:73
pat::helper::BasicOverlapTest::pairCut_
StringCutObjectSelector< pat::DiObjectProxy > pairCut_
Cut on the pair of objects together.
Definition: OverlapTest.h:69