7 #include <Math/GenVector/Cartesian3D.h>
8 #include <Math/GenVector/VectorUtil.h>
18 static inline T sqr(
const T & val) {
return val * val; }
20 template<
typename T1,
typename T2,
typename R>
21 struct JetDistance :
public std::binary_function<T1, T2, R> {
22 JetDistance(
double sigmaDeltaR,
double sigmaDeltaE) :
23 sigmaDeltaR2(
sqr(sigmaDeltaR)),
24 sigmaDeltaE2(
sqr(sigmaDeltaE)) {}
26 double operator () (
const T1 &v1,
const T2 &v2)
const
28 using namespace ROOT::Math;
32 double x = VectorUtil::DeltaR2(v1, v2) / sigmaDeltaR2 +
33 sqr(2. * (v1.R() - v2.R()) /
34 (v1.R() + v2.R())) / sigmaDeltaE2;
39 double sigmaDeltaR2, sigmaDeltaE2;
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")),
61 typedef ROOT::Math::Cartesian3D<double>
Vector;
63 std::vector<Vector> corrRefJets;
66 iter != refJets_.
end(); ++iter) {
72 corrRefJets.push_back(
Vector(jet.
px(), jet.
py(), jet.
pz()));
76 std::vector<Vector> corrRecJets;
79 iter != recJets_.
end(); ++iter) {
85 corrRecJets.push_back(
Vector(jet.
px(), jet.
py(), jet.
pz()));
98 JetDistance<Vector, Vector, double>(
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;
virtual double energy() const GCC11_FINAL
energy
void matchCollections(const edm::RefToBaseVector< reco::Jet > &refJets, const edm::RefToBaseVector< reco::Jet > &recJets, const edm::EventSetup &es)
match the collections
ROOT::Math::Plane3D::Vector Vector
Base class for all types of Jets.
edm::RefToBaseVector< reco::Jet > refJets
const_iterator end() const
std::vector< int > recToRef
void setEventSetup(const edm::EventSetup &es)
edm::RefToBaseVector< reco::Jet > recJets
virtual double pz() const GCC11_FINAL
z coordinate of momentum vector
virtual double py() const GCC11_FINAL
y coordinate of momentum vector
std::vector< int > refToRec
virtual double px() const GCC11_FINAL
x coordinate of momentum vector
edm::RefToBase< reco::Jet > operator()(const edm::RefToBase< reco::Jet > &recJet) const
Returns the matched "reference" jet.
CorrectJet refJetCorrector
CorrectJet recJetCorrector
const_iterator begin() const
std::vector< Match > match(SortComparator sortComparator=SortComparator(), CutCriterion cutCriterion=CutCriterion())
Square< F >::type sqr(const F &f)
void push_back(const RefToBase< T > &)
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.