CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
MatchJet Class Reference

#include <MatchJet.h>

Public Member Functions

void matchCollections (const edm::RefToBaseVector< reco::Jet > &refJets, const edm::RefToBaseVector< reco::Jet > &recJets, const reco::JetCorrector *corrector)
 match the collections More...
 
 MatchJet ()
 
 MatchJet (const edm::ParameterSet &pSet)
 
edm::RefToBase< reco::Jetoperator() (const edm::RefToBase< reco::Jet > &recJet) const
 Returns the matched "reference" jet. More...
 
void setThreshold (const double &energy)
 

Private Attributes

double maxChi2
 
CorrectJet recJetCorrector
 
edm::RefToBaseVector< reco::JetrecJets
 
std::vector< int > recToRef
 
CorrectJet refJetCorrector
 
edm::RefToBaseVector< reco::JetrefJets
 
std::vector< int > refToRec
 
double sigmaDeltaE
 
double sigmaDeltaR
 
double threshold
 

Detailed Description

Match jets

Definition at line 19 of file MatchJet.h.

Constructor & Destructor Documentation

MatchJet::MatchJet ( )
inline

Definition at line 22 of file MatchJet.h.

22 {}
MatchJet::MatchJet ( const edm::ParameterSet pSet)

Definition at line 43 of file MatchJet.cc.

43  :
44  maxChi2(pSet.getParameter<double>("maxChi2")),
45  sigmaDeltaR(pSet.getParameter<double>("sigmaDeltaR")),
46  sigmaDeltaE(pSet.getParameter<double>("sigmaDeltaE")),
47  threshold(1.0)
48 {
49 }
T getParameter(std::string const &) const
double sigmaDeltaE
Definition: MatchJet.h:47
double sigmaDeltaR
Definition: MatchJet.h:46
double maxChi2
Definition: MatchJet.h:45
double threshold
Definition: MatchJet.h:48

Member Function Documentation

void MatchJet::matchCollections ( const edm::RefToBaseVector< reco::Jet > &  refJets,
const edm::RefToBaseVector< reco::Jet > &  recJets,
const reco::JetCorrector corrector 
)

match the collections

Definition at line 51 of file MatchJet.cc.

References edm::RefToBaseVector< T >::begin(), edm::RefToBaseVector< T >::clear(), edm::RefToBaseVector< T >::end(), reco::LeafCandidate::energy(), metsig::jet, btag::Matching< Delta >::match(), MultipleCompare::Match(), patRefSel_triggerMatching_cfi::matches, PFTauMatching_cfi::matching, maxChi2, edm::RefToBaseVector< T >::push_back(), reco::LeafCandidate::px(), reco::LeafCandidate::py(), reco::LeafCandidate::pz(), recJetCorrector, recJets, recToRef, refJetCorrector, refJets, refToRec, CorrectJet::setCorrector(), sigmaDeltaE, sigmaDeltaR, edm::RefToBaseVector< T >::size(), and threshold.

Referenced by BTagPerformanceAnalyzerMC::getJetWithFlavour(), and setThreshold().

56 {
57  refJetCorrector.setCorrector(corrector);
58  recJetCorrector.setCorrector(corrector);
59 
60  typedef ROOT::Math::Cartesian3D<double> Vector;
61 
62  std::vector<Vector> corrRefJets;
63  refJets.clear();
65  iter != refJets_.end(); ++iter) {
66  edm::RefToBase<reco::Jet> jetRef = *iter;
67  reco::Jet jet = refJetCorrector(*jetRef);
68  if (jet.energy() < threshold)
69  continue;
70 
71  corrRefJets.push_back(Vector(jet.px(), jet.py(), jet.pz()));
72  refJets.push_back(jetRef);
73  }
74 
75  std::vector<Vector> corrRecJets;
76  recJets.clear();
78  iter != recJets_.end(); ++iter) {
79  edm::RefToBase<reco::Jet> jetRec = *iter;
80  reco::Jet jet = recJetCorrector(*jetRec);
81  if (jet.energy() < threshold)
82  continue;
83 
84  corrRecJets.push_back(Vector(jet.px(), jet.py(), jet.pz()));
85  recJets.push_back(jetRec);
86  }
87 
88  this->refJets = refJets;
89  refToRec.clear();
90  refToRec.resize(refJets.size(), -1);
91 
92  this->recJets = recJets;
93  recToRef.clear();
94  recToRef.resize(recJets.size(), -1);
95 
96  Matching<double> matching(corrRefJets, corrRecJets,
100 
101  const std::vector<Match>& matches =
102  matching.match(std::less<double>(),
103  std::bind2nd(std::less<double>(), maxChi2));
104  for(std::vector<Match>::const_iterator iter = matches.begin();
105  iter != matches.end(); ++iter) {
106  refToRec[iter->index1] = iter->index2;
107  recToRef[iter->index2] = iter->index1;
108  }
109 }
ROOT::Math::Plane3D::Vector Vector
Definition: EcalHitMaker.cc:29
Base class for all types of Jets.
Definition: Jet.h:20
edm::RefToBaseVector< reco::Jet > refJets
Definition: MatchJet.h:39
std::vector< int > recToRef
Definition: MatchJet.h:38
edm::RefToBaseVector< reco::Jet > recJets
Definition: MatchJet.h:40
double sigmaDeltaE
Definition: MatchJet.h:47
double sigmaDeltaR
Definition: MatchJet.h:46
std::vector< int > refToRec
Definition: MatchJet.h:38
double maxChi2
Definition: MatchJet.h:45
virtual double px() const final
x coordinate of momentum vector
virtual double energy() const final
energy
size_type size() const
virtual double pz() const final
z coordinate of momentum vector
CorrectJet refJetCorrector
Definition: MatchJet.h:42
CorrectJet recJetCorrector
Definition: MatchJet.h:43
void setCorrector(const reco::JetCorrector *corrector)
Returns the corrected jet.
Definition: CorrectJet.h:22
const_iterator begin() const
def Match(required, got)
void push_back(const RefToBase< T > &)
double threshold
Definition: MatchJet.h:48
virtual double py() const final
y coordinate of momentum vector
edm::RefToBase< reco::Jet > MatchJet::operator() ( const edm::RefToBase< reco::Jet > &  recJet) const

Returns the matched "reference" jet.

Definition at line 112 of file MatchJet.cc.

References mps_fire::i, edm::RefToBaseVector< T >::id(), edm::RefToBase< T >::id(), match(), recJets, recToRef, refJets, mps_fire::result, and edm::RefToBaseVector< T >::size().

Referenced by setThreshold().

113 {
115  if (recJet.id() != recJets.id())
116  return result;
117 
118  for(unsigned int i = 0; i != recJets.size(); ++i) {
119  if (recJets[i] == recJet) {
120  int match = recToRef[i];
121  if (match >= 0)
122  result = refJets[match];
123  break;
124  }
125  }
126 
127  return result;
128 }
edm::RefToBaseVector< reco::Jet > refJets
Definition: MatchJet.h:39
std::vector< int > recToRef
Definition: MatchJet.h:38
edm::RefToBaseVector< reco::Jet > recJets
Definition: MatchJet.h:40
ProductID id() const
Definition: RefToBase.h:242
size_type size() const
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
ProductID id() const
void MatchJet::setThreshold ( const double &  energy)
inline

Member Data Documentation

double MatchJet::maxChi2
private

Definition at line 45 of file MatchJet.h.

Referenced by matchCollections().

CorrectJet MatchJet::recJetCorrector
private

Definition at line 43 of file MatchJet.h.

Referenced by matchCollections().

edm::RefToBaseVector<reco::Jet> MatchJet::recJets
private

Definition at line 40 of file MatchJet.h.

Referenced by matchCollections(), operator()(), and setThreshold().

std::vector<int> MatchJet::recToRef
private

Definition at line 38 of file MatchJet.h.

Referenced by matchCollections(), and operator()().

CorrectJet MatchJet::refJetCorrector
private

Definition at line 42 of file MatchJet.h.

Referenced by matchCollections().

edm::RefToBaseVector<reco::Jet> MatchJet::refJets
private

Definition at line 39 of file MatchJet.h.

Referenced by matchCollections(), operator()(), and setThreshold().

std::vector<int> MatchJet::refToRec
private

Definition at line 38 of file MatchJet.h.

Referenced by matchCollections().

double MatchJet::sigmaDeltaE
private

Definition at line 47 of file MatchJet.h.

Referenced by matchCollections().

double MatchJet::sigmaDeltaR
private

Definition at line 46 of file MatchJet.h.

Referenced by matchCollections().

double MatchJet::threshold
private

Definition at line 48 of file MatchJet.h.

Referenced by utils.StatisticalTest::get_status(), matchCollections(), and setThreshold().