Main Page
Namespaces
Classes
Package Documentation
DQMOffline
RecoB
src
MatchJet.cc
Go to the documentation of this file.
1
#include <functional>
2
#include <algorithm>
3
#include <vector>
4
#include <memory>
5
#include <string>
6
7
#include <Math/GenVector/Cartesian3D.h>
8
#include <Math/GenVector/VectorUtil.h>
9
10
#include "
DQMOffline/RecoB/interface/MatchJet.h
"
11
12
#include "
Matching.h
"
13
14
using namespace
btag
;
15
16
namespace
{
17
inline
double
sqr
(
double
val
) {
return
val *
val
; }
18
}
19
20
MatchJet::MatchJet
(
const
edm::ParameterSet
& pSet) :
21
maxChi2
(pSet.getParameter<double>(
"maxChi2"
)),
22
sigmaDeltaR2(
sqr
(pSet.getParameter<double>(
"sigmaDeltaR"
))),
23
sigmaDeltaE2(
sqr
(pSet.getParameter<double>(
"sigmaDeltaE"
))),
24
threshold
(1.0)
25
{
26
}
27
28
void
MatchJet::matchCollections
(
29
const
edm::RefToBaseVector<reco::Jet>
& refJets_,
30
const
edm::RefToBaseVector<reco::Jet>
& recJets_,
31
const
reco::JetCorrector
*
corrector
32
)
33
{
34
refJetCorrector
.
setCorrector
(corrector);
35
recJetCorrector
.
setCorrector
(corrector);
36
37
typedef
ROOT::Math::Cartesian3D<double>
Vector
;
38
39
std::vector<Vector> corrRefJets;
40
refJets
.
clear
();
41
for
(
edm::RefToBaseVector<reco::Jet>::const_iterator
iter =
refJets
.
begin
();
42
iter != refJets_.
end
(); ++iter) {
43
edm::RefToBase<reco::Jet>
jetRef = *iter;
44
reco::Jet
jet
=
refJetCorrector
(*jetRef);
45
if
(jet.
energy
() <
threshold
)
46
continue
;
47
48
corrRefJets.push_back(
Vector
(jet.
px
(), jet.
py
(), jet.
pz
()));
49
refJets
.
push_back
(jetRef);
50
}
51
52
std::vector<Vector> corrRecJets;
53
recJets
.
clear
();
54
for
(
edm::RefToBaseVector<reco::Jet>::const_iterator
iter =
recJets
.
begin
();
55
iter != recJets_.
end
(); ++iter) {
56
edm::RefToBase<reco::Jet>
jetRec = *iter;
57
reco::Jet
jet
=
recJetCorrector
(*jetRec);
58
if
(jet.
energy
() <
threshold
)
59
continue
;
60
61
corrRecJets.push_back(
Vector
(jet.
px
(), jet.
py
(), jet.
pz
()));
62
recJets
.
push_back
(jetRec);
63
}
64
65
refToRec
.clear();
66
refToRec
.resize(
refJets
.
size
(), -1);
67
68
recToRef
.clear();
69
recToRef
.resize(
recJets
.
size
(), -1);
70
71
Matching<double>
matching
(corrRefJets, corrRecJets,
72
[
this
](
auto
& v1,
auto
& v2)
73
{
74
double
x
= ROOT::Math::VectorUtil::DeltaR2(v1, v2) / this->
sigmaDeltaR2
+
75
sqr
(2. * (v1.R() - v2.R()) / (v1.R() + v2.R())) / this->
sigmaDeltaE2
;
76
// Possible debug output
77
// std::cout << "xxx " << ROOT::Math::VectorUtil::DeltaPhi(v1, v2) << " " << (v1.Eta() - v2.Eta())
78
// << " " << (v1.R() - v2.R()) / (v1.R() + v2.R()) << " " << x << std::endl;
79
return
x
;
80
});
81
82
typedef
Matching<double>::Match
Match
;
83
84
const
std::vector<Match>&
matches
=
85
matching
.match(std::less<double>(),
86
[&](
auto
&
c
){
return
c
< this->
maxChi2
;});
87
for
(std::vector<Match>::const_iterator iter = matches.begin();
88
iter != matches.end(); ++iter) {
89
refToRec
[iter->index1] = iter->index2;
90
recToRef
[iter->index2] = iter->index1;
91
}
92
}
93
94
edm::RefToBase<reco::Jet>
95
MatchJet::operator()
(
const
edm::RefToBase<reco::Jet>
& recJet)
const
96
{
97
edm::RefToBase<reco::Jet>
result
;
98
if
(recJet.
id
() !=
recJets
.
id
())
99
return
result;
100
101
for
(
unsigned
int
i
= 0;
i
!=
recJets
.
size
(); ++
i
) {
102
if
(
recJets
[
i
] == recJet) {
103
int
match
=
recToRef
[
i
];
104
if
(match >= 0)
105
result =
refJets
[
match
];
106
break
;
107
}
108
}
109
110
return
result
;
111
}
metsig::jet
Definition:
SignAlgoResolutions.h:40
MatchJet::sigmaDeltaE2
double sigmaDeltaE2
Definition:
MatchJet.h:47
mps_fire.i
i
Definition:
mps_fire.py:330
mps_fire.result
result
Definition:
mps_fire.py:283
Vector
ROOT::Math::Plane3D::Vector Vector
Definition:
EcalHitMaker.cc:29
reco::Jet
Base class for all types of Jets.
Definition:
Jet.h:20
PFTauMatching_cfi.matching
matching
Definition:
PFTauMatching_cfi.py:19
reco::LeafCandidate::px
double px() const final
x coordinate of momentum vector
Definition:
LeafCandidate.h:125
EnergyCorrector.c
c
Definition:
EnergyCorrector.py:44
MatchJet::refJets
edm::RefToBaseVector< reco::Jet > refJets
Definition:
MatchJet.h:39
edm::RefToBaseVector::end
const_iterator end() const
Definition:
RefToBaseVector.h:230
edm::reftobase::BaseVectorHolder::const_iterator
Definition:
BaseVectorHolder.h:53
MatchJet::recToRef
std::vector< int > recToRef
Definition:
MatchJet.h:38
patRefSel_triggerMatching_cfi.matches
matches
Definition:
patRefSel_triggerMatching_cfi.py:17
MatchJet::recJets
edm::RefToBaseVector< reco::Jet > recJets
Definition:
MatchJet.h:40
edm::RefToBase::id
ProductID id() const
Definition:
RefToBase.h:242
btag
Definition:
Matching.h:10
edm::RefToBase< reco::Jet >
MatchJet::matchCollections
void matchCollections(const edm::RefToBaseVector< reco::Jet > &refJets, const edm::RefToBaseVector< reco::Jet > &recJets, const reco::JetCorrector *corrector)
match the collections
Definition:
MatchJet.cc:28
edm::RefToBaseVector::clear
void clear()
Definition:
RefToBaseVector.h:197
Matching.h
electronIdCutBased_cfi.threshold
threshold
Definition:
electronIdCutBased_cfi.py:6
MatchJet::refToRec
std::vector< int > refToRec
Definition:
MatchJet.h:38
MatchJet::maxChi2
double maxChi2
Definition:
MatchJet.h:45
reco::LeafCandidate::pz
double pz() const final
z coordinate of momentum vector
Definition:
LeafCandidate.h:129
reco::LeafCandidate::energy
double energy() const final
energy
Definition:
LeafCandidate.h:110
edm::RefToBaseVector< reco::Jet >
MatchJet::sigmaDeltaR2
double sigmaDeltaR2
Definition:
MatchJet.h:46
mitigatedMETSequence_cff.corrector
corrector
Definition:
mitigatedMETSequence_cff.py:43
edm::RefToBaseVector::size
size_type size() const
Definition:
RefToBaseVector.h:189
MatchJet::operator()
edm::RefToBase< reco::Jet > operator()(const edm::RefToBase< reco::Jet > &recJet) const
Returns the matched "reference" jet.
Definition:
MatchJet.cc:95
reco::JetCorrector
Definition:
JetCorrector.h:35
MatchJet::refJetCorrector
CorrectJet refJetCorrector
Definition:
MatchJet.h:42
MatchJet::recJetCorrector
CorrectJet recJetCorrector
Definition:
MatchJet.h:43
matching
Definition:
GenericDigi.h:25
btag::Matching
Definition:
Matching.h:13
CorrectJet::setCorrector
void setCorrector(const reco::JetCorrector *corrector)
Returns the corrected jet.
Definition:
CorrectJet.h:22
reco::LeafCandidate::py
double py() const final
y coordinate of momentum vector
Definition:
LeafCandidate.h:127
edm::RefToBaseVector::begin
const_iterator begin() const
Definition:
RefToBaseVector.h:222
MultipleCompare.Match
def Match(required, got)
Definition:
MultipleCompare.py:75
funct::sqr
Square< F >::type sqr(const F &f)
Definition:
Square.h:13
edm::RefToBaseVector::push_back
void push_back(const RefToBase< T > &)
Definition:
RefToBaseVector.h:264
edm::ParameterSet
Definition:
ParameterSet.h:36
match
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition:
Utils.h:10
MatchJet.h
btag::Matching::Match
Definition:
Matching.h:34
MatchJet::threshold
double threshold
Definition:
MatchJet.h:48
MatchJet::MatchJet
MatchJet()
Definition:
MatchJet.h:22
DDAxes::x
heppy_batch.val
val
Definition:
heppy_batch.py:351
edm::RefToBaseVector::id
ProductID id() const
Definition:
RefToBaseVector.h:206
btvTracks_cfi.maxChi2
maxChi2
Definition:
btvTracks_cfi.py:6
Generated for CMSSW Reference Manual by
1.8.11