CMS 3D CMS Logo

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 //____________________________________________________________________________||
17 metsig::SignPFSpecificAlgo::SignPFSpecificAlgo() : resolutions_(nullptr), algo_() { clusteredParticlePtrs_.clear(); }
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 //____________________________________________________________________________||
metsig::SignPFSpecificAlgo::useOriginalPtrs
void useOriginalPtrs(const edm::ProductID &productID)
Definition: SignPFSpecificAlgo.cc:39
PFCandidate.h
edm::Handle
Definition: AssociativeIterator.h:50
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
jetMETAnalyzer_cfi.PFCandidates
PFCandidates
Definition: jetMETAnalyzer_cfi.py:129
mps_fire.end
end
Definition: mps_fire.py:242
JetHTJetPlusHOFilter_cff.PFJets
PFJets
Definition: JetHTJetPlusHOFilter_cff.py:5
metsig::SignPFSpecificAlgo::clusteredParticlePtrs_
std::set< reco::CandidatePtr > clusteredParticlePtrs_
Definition: SignPFSpecificAlgo.h:44
edm::View
Definition: CaloClusterFwd.h:14
edm::Ptr::id
ProductID id() const
Accessor for product ID.
Definition: Ptr.h:158
metsig::SignPFSpecificAlgo::addPFJets
void addPFJets(const edm::View< reco::PFJet > *PFJets)
Definition: SignPFSpecificAlgo.cc:25
metsig::SignPFSpecificAlgo::mkSignifMatrix
reco::METCovMatrix mkSignifMatrix(edm::Handle< edm::View< reco::Candidate > > &PFCandidates)
Definition: SignPFSpecificAlgo.cc:70
metsig::SignPFSpecificAlgo::setResolutions
void setResolutions(metsig::SignAlgoResolutions *resolutions)
Definition: SignPFSpecificAlgo.cc:20
metsig::SignPFSpecificAlgo::SignPFSpecificAlgo
SignPFSpecificAlgo()
Definition: SignPFSpecificAlgo.cc:17
edm::Ptr< Candidate >
electronProducer_cfi.resolutions
resolutions
Definition: electronProducer_cfi.py:80
metsig::SignAlgoResolutions
Definition: SignAlgoResolutions.h:61
packedPFCandidateRefMixer_cfi.pf
pf
Definition: packedPFCandidateRefMixer_cfi.py:4
metsig::jet
Definition: SignAlgoResolutions.h:47
edm::View::const_iterator
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
reco::PFCandidate
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:41
metsig::SignPFSpecificAlgo::addPFCandidate
void addPFCandidate(reco::PFCandidatePtr pf)
Definition: SignPFSpecificAlgo.cc:60
edm::Ptr::isNull
bool isNull() const
Checks for null.
Definition: Ptr.h:142
edm::ProductID
Definition: ProductID.h:27
reco::METCovMatrix
ROOT::Math::SMatrix< double, 2 > METCovMatrix
Definition: MET.h:39
SignPFSpecificAlgo.h