CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
OverlapTest.cc
Go to the documentation of this file.
2 
3 #include <algorithm>
6 
7 using namespace pat::helper;
8 
9 void
11 {
13  isPreselected_.resize(candidates_->size());
14  size_t idx = 0;
15  for (reco::CandidateView::const_iterator it = candidates_->begin(); it != candidates_->end(); ++it, ++idx) {
16  isPreselected_[idx] = presel_(*it);
17  }
18  // Yes, I could use std::transform. But would people like it?
19  // http://www.sgi.com/tech/stl/transform.html
20 }
21 
22 bool
24 {
25  size_t idx = 0;
26  std::vector<std::pair<float,size_t> > matches;
27  for (reco::CandidateView::const_iterator it = candidates_->begin(); it != candidates_->end(); ++it, ++idx) {
28  if (!isPreselected_[idx]) continue;
29  double dr = reco::deltaR(item, *it);
30  if (dr < deltaR_) {
33  if (!overlaps(item, *it)) continue;
34  }
35  if (!pairCut_(pat::DiObjectProxy(item,*it))) continue;
36  matches.push_back(std::make_pair(dr, idx));
37  }
38  }
39  // see if we matched anything
40  if (matches.empty()) return false;
41 
42  // sort matches
43  std::sort(matches.begin(), matches.end());
44  // fill ptr vector
45  for (std::vector<std::pair<float,size_t> >::const_iterator it = matches.begin(); it != matches.end(); ++it) {
46  overlapsToFill.push_back(candidates_->ptrAt(it->second));
47  }
48  return true;
49 }
50 
51 bool
53 {
54  const reco::RecoCandidate * input = dynamic_cast<const reco::RecoCandidate *>(&item);
55  if (input == 0) throw cms::Exception("Type Error") << "Input to OverlapBySuperClusterSeed is not a RecoCandidate. "
56  << "It's a " << typeid(item).name() << "\n";
57  reco::SuperClusterRef mySC = input->superCluster();
58  if (mySC.isNull() || !mySC.isAvailable()) {
59  throw cms::Exception("Bad Reference") << "Input to OverlapBySuperClusterSeed has a null or dangling superCluster reference\n";
60  }
61  const reco::CaloClusterPtr & mySeed = mySC->seed();
62  if (mySeed.isNull()) {
63  throw cms::Exception("Bad Reference") << "Input to OverlapBySuperClusterSeed has a null superCluster seed reference\n";
64  }
65  bool hasOverlaps = false;
66  size_t idx = 0;
67 // for (edm::View<reco::RecoCandidate>::const_iterator it = others_->begin(); it != others_->end(); ++it, ++idx) {
68  for (reco::CandidateView::const_iterator it = others_->begin(); it != others_->end(); ++it, ++idx) {
69  const reco::RecoCandidate * other = dynamic_cast<const reco::RecoCandidate *>(&*it);
70  reco::SuperClusterRef otherSc = other->superCluster();
71  if (otherSc.isNull() || !otherSc.isAvailable()) {
72  throw cms::Exception("Bad Reference") << "One item in the OverlapBySuperClusterSeed input list has a null or dangling superCluster reference\n";
73  }
74  if (mySeed == otherSc->seed()) {
75  overlapsToFill.push_back(others_->ptrAt(idx));
76  hasOverlaps = true;
77  }
78  }
79  return hasOverlaps;
80 }
bool isAvailable() const
Definition: Ref.h:576
edm::EDGetTokenT< reco::CandidateView > srcToken_
Definition: OverlapTest.h:39
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
void push_back(Ptr< T > const &iPtr)
Definition: PtrVector.h:141
virtual bool fillOverlapsForItem(const reco::Candidate &item, reco::CandidatePtrVector &overlapsToFill) const
Check for overlaps.
Definition: OverlapTest.cc:23
virtual bool fillOverlapsForItem(const reco::Candidate &item, reco::CandidatePtrVector &overlapsToFill) const
Check for overlaps.
Definition: OverlapTest.cc:52
static std::string const input
Definition: EdmProvDump.cc:44
virtual void readInput(const edm::Event &iEvent, const edm::EventSetup &iSetup)
Read input, apply preselection cut.
Definition: OverlapTest.cc:10
int iEvent
Definition: GenABIO.cc:230
PATStringCutObjectSelector presel_
A generic preselection cut that can work on any Candidate, but has access also to methods of PAT spec...
Definition: OverlapTest.h:60
edm::Handle< reco::CandidateView > candidates_
The collection to check overlaps against.
Definition: OverlapTest.h:69
bool isNull() const
Checks for null.
Definition: Ptr.h:165
std::vector< bool > isPreselected_
Flag saying if each element has passed the preselection or not.
Definition: OverlapTest.h:71
auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:28
bool isNull() const
Checks for null.
Definition: Ref.h:249
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
double deltaR_
Delta R for the match.
Definition: OverlapTest.h:62
const std::string & name() const
Definition: OverlapTest.h:36
bool checkRecoComponents_
Check the overlapping by RECO components.
Definition: OverlapTest.h:64
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
edm::Handle< reco::CandidateView > others_
Definition: OverlapTest.h:86
StringCutObjectSelector< pat::DiObjectProxy > pairCut_
Cut on the pair of objects together.
Definition: OverlapTest.h:66
virtual reco::SuperClusterRef superCluster() const
reference to a SuperCluster