CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SignPFSpecificAlgo.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: METAlgorithms
4 // Class: SignPFSpecificAlgo
5 //
6 // Authors: A. Khukhunaishvili (Cornell), L. Gibbons (Cornell)
7 // First Implementation: November 11, 2011
8 //
9 //
10 
11 //____________________________________________________________________________||
13 
15 
16 //____________________________________________________________________________||
18 
19 //____________________________________________________________________________||
21  resolutions_ = resolutions;
22 }
23 
24 //____________________________________________________________________________||
26  std::vector<metsig::SigInputObj> vobj;
27  for (edm::View<reco::PFJet>::const_iterator jet = PFJets->begin(); jet != PFJets->end(); ++jet) {
28  vobj.push_back(resolutions_->evalPFJet(&(*jet)));
29  std::vector<reco::PFCandidatePtr> pfs = jet->getPFConstituents();
30  for (std::vector<reco::PFCandidatePtr>::const_iterator it = pfs.begin(); it != pfs.end(); ++it) {
31  reco::CandidatePtr ptr(*it);
32  clusteredParticlePtrs_.insert(ptr);
33  }
34  }
35  algo_.addObjects(vobj);
36 }
37 
38 //____________________________________________________________________________||
40  std::set<reco::CandidatePtr>::const_iterator it = clusteredParticlePtrs_.begin();
41  reco::CandidatePtr ptr(*it);
42  if (ptr.id() == productID)
43  return; //If the first element is from the right product, return
44 
45  std::set<reco::CandidatePtr> temp;
46  for (; it != clusteredParticlePtrs_.end(); ++it) {
47  reco::CandidatePtr ptr(*it);
48  while (ptr.id() != productID) {
49  ptr = ptr->sourceCandidatePtr(0);
50  if (ptr.isNull())
51  return; //if it does not get to the correct product, return
52  }
53  temp.insert(ptr);
54  }
55  clusteredParticlePtrs_.clear();
56  clusteredParticlePtrs_ = temp;
57 }
58 
59 //____________________________________________________________________________||
61  if (clusteredParticlePtrs_.find(pf) != clusteredParticlePtrs_.end()) {
62  return; //pf candidate already added in jet collection
63  }
64  std::vector<metsig::SigInputObj> vobj;
65  vobj.push_back(resolutions_->evalPF(&(*pf)));
66  algo_.addObjects(vobj);
67 }
68 
69 //____________________________________________________________________________||
71  useOriginalPtrs(PFCandidates.id());
72  for (edm::View<reco::Candidate>::const_iterator iParticle = (PFCandidates.product())->begin();
73  iParticle != (PFCandidates.product())->end();
74  ++iParticle) {
75  const reco::PFCandidate* pfCandidate = dynamic_cast<const reco::PFCandidate*>(&(*iParticle));
76  if (!pfCandidate)
77  continue;
78  reco::CandidatePtr dau(PFCandidates, iParticle - PFCandidates->begin());
79  if (dau.isNull())
80  continue;
81  if (!dau.isAvailable())
82  continue;
83  reco::PFCandidatePtr pf(dau.id(), pfCandidate, dau.key());
84  addPFCandidate(pf);
85  }
86  return getSignifMatrix();
87 }
88 
89 //____________________________________________________________________________||
ROOT::Math::SMatrix< double, 2 > METCovMatrix
Definition: MET.h:39
const_iterator begin() const
void addPFJets(const edm::View< reco::PFJet > *PFJets)
void setResolutions(metsig::SignAlgoResolutions *resolutions)
bool isNull() const
Checks for null.
Definition: Ptr.h:142
reco::METCovMatrix mkSignifMatrix(edm::Handle< edm::View< reco::Candidate > > &PFCandidates)
ProductID id() const
Accessor for product ID.
Definition: Ptr.h:158
void addPFCandidate(reco::PFCandidatePtr pf)
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:41
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
string end
Definition: dataset.py:937
const_iterator end() const
void useOriginalPtrs(const edm::ProductID &productID)
std::set< reco::CandidatePtr > clusteredParticlePtrs_