CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 edm::EventSetup &es)
 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  refJetCorrector(pSet.getParameter<std::string>("refJetCorrection")),
45  recJetCorrector(pSet.getParameter<std::string>("recJetCorrection")),
46  maxChi2(pSet.getParameter<double>("maxChi2")),
47  sigmaDeltaR(pSet.getParameter<double>("sigmaDeltaR")),
48  sigmaDeltaE(pSet.getParameter<double>("sigmaDeltaE")),
49  threshold(1.0)
50 {
51 }
T getParameter(std::string const &) const
double sigmaDeltaE
Definition: MatchJet.h:46
double sigmaDeltaR
Definition: MatchJet.h:45
double maxChi2
Definition: MatchJet.h:44
CorrectJet refJetCorrector
Definition: MatchJet.h:41
CorrectJet recJetCorrector
Definition: MatchJet.h:42
double threshold
Definition: MatchJet.h:47

Member Function Documentation

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

match the collections

Definition at line 53 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(), maxChi2, edm::RefToBaseVector< T >::push_back(), reco::LeafCandidate::px(), reco::LeafCandidate::py(), reco::LeafCandidate::pz(), recJetCorrector, recJets, recToRef, refJetCorrector, refJets, refToRec, CorrectJet::setEventSetup(), sigmaDeltaE, sigmaDeltaR, edm::RefToBaseVector< T >::size(), and threshold.

Referenced by BTagPerformanceAnalyzerMC::getJetWithFlavour().

57 {
60 
61  typedef ROOT::Math::Cartesian3D<double> Vector;
62 
63  std::vector<Vector> corrRefJets;
64  refJets.clear();
66  iter != refJets_.end(); ++iter) {
67  edm::RefToBase<reco::Jet> jetRef = *iter;
68  reco::Jet jet = refJetCorrector(*jetRef);
69  if (jet.energy() < threshold)
70  continue;
71 
72  corrRefJets.push_back(Vector(jet.px(), jet.py(), jet.pz()));
73  refJets.push_back(jetRef);
74  }
75 
76  std::vector<Vector> corrRecJets;
77  recJets.clear();
79  iter != recJets_.end(); ++iter) {
80  edm::RefToBase<reco::Jet> jetRec = *iter;
81  reco::Jet jet = recJetCorrector(*jetRec);
82  if (jet.energy() < threshold)
83  continue;
84 
85  corrRecJets.push_back(Vector(jet.px(), jet.py(), jet.pz()));
86  recJets.push_back(jetRec);
87  }
88 
89  this->refJets = refJets;
90  refToRec.clear();
91  refToRec.resize(refJets.size(), -1);
92 
93  this->recJets = recJets;
94  recToRef.clear();
95  recToRef.resize(recJets.size(), -1);
96 
97  Matching<double> matching(corrRefJets, corrRecJets,
98  JetDistance<Vector, Vector, double>(
101 
102  const std::vector<Match>& matches =
103  matching.match(std::less<double>(),
104  std::bind2nd(std::less<double>(), maxChi2));
105  for(std::vector<Match>::const_iterator iter = matches.begin();
106  iter != matches.end(); ++iter) {
107  refToRec[iter->index1] = iter->index2;
108  recToRef[iter->index2] = iter->index1;
109  }
110 }
ROOT::Math::Plane3D::Vector Vector
Definition: EcalHitMaker.cc:28
Base class for all types of Jets.
Definition: Jet.h:21
edm::RefToBaseVector< reco::Jet > refJets
Definition: MatchJet.h:38
std::vector< int > recToRef
Definition: MatchJet.h:37
void setEventSetup(const edm::EventSetup &es)
Definition: CorrectJet.h:23
edm::RefToBaseVector< reco::Jet > recJets
Definition: MatchJet.h:39
double sigmaDeltaE
Definition: MatchJet.h:46
double sigmaDeltaR
Definition: MatchJet.h:45
virtual double energy() const
energy
std::vector< int > refToRec
Definition: MatchJet.h:37
double maxChi2
Definition: MatchJet.h:44
size_type size() const
CorrectJet refJetCorrector
Definition: MatchJet.h:41
CorrectJet recJetCorrector
Definition: MatchJet.h:42
virtual double px() const
x coordinate of momentum vector
virtual double pz() const
z coordinate of momentum vector
const_iterator begin() const
void push_back(const RefToBase< T > &)
double threshold
Definition: MatchJet.h:47
virtual double py() const
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 113 of file MatchJet.cc.

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

114 {
116  if (recJet.id() != recJets.id())
117  return result;
118 
119  for(unsigned int i = 0; i != recJets.size(); ++i) {
120  if (recJets[i] == recJet) {
121  int match = recToRef[i];
122  if (match >= 0)
123  result = refJets[match];
124  break;
125  }
126  }
127 
128  return result;
129 }
int i
Definition: DBlmapReader.cc:9
edm::RefToBaseVector< reco::Jet > refJets
Definition: MatchJet.h:38
std::vector< int > recToRef
Definition: MatchJet.h:37
edm::RefToBaseVector< reco::Jet > recJets
Definition: MatchJet.h:39
ProductID id() const
Definition: RefToBase.h:220
tuple result
Definition: query.py:137
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:6
ProductID id() const
void MatchJet::setThreshold ( const double &  energy)
inline

Member Data Documentation

double MatchJet::maxChi2
private

Definition at line 44 of file MatchJet.h.

Referenced by matchCollections().

CorrectJet MatchJet::recJetCorrector
private

Definition at line 42 of file MatchJet.h.

Referenced by matchCollections().

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

Definition at line 39 of file MatchJet.h.

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

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

Definition at line 37 of file MatchJet.h.

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

CorrectJet MatchJet::refJetCorrector
private

Definition at line 41 of file MatchJet.h.

Referenced by matchCollections().

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

Definition at line 38 of file MatchJet.h.

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

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

Definition at line 37 of file MatchJet.h.

Referenced by matchCollections().

double MatchJet::sigmaDeltaE
private

Definition at line 46 of file MatchJet.h.

Referenced by matchCollections().

double MatchJet::sigmaDeltaR
private

Definition at line 45 of file MatchJet.h.

Referenced by matchCollections().

double MatchJet::threshold
private

Definition at line 47 of file MatchJet.h.

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