Main Page
Namespaces
Classes
Package Documentation
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Pages
PhysicsTools
PatUtils
interface
GenericOverlapFinder.h
Go to the documentation of this file.
1
#ifndef PhysicsTools_PatUtils_GenericOverlapFinder_h
2
#define PhysicsTools_PatUtils_GenericOverlapFinder_h
3
4
#include "
DataFormats/Math/interface/deltaR.h
"
5
6
#include <memory>
7
#include <vector>
8
#include <algorithm>
9
10
namespace
pat {
11
15
typedef
std::vector< std::pair<size_t, size_t> >
OverlapList
;
16
23
template
<
typename
Comparator>
24
struct
OverlapDistance
{
25
public
:
26
OverlapDistance
() {}
27
OverlapDistance
(
const
Comparator
&
comp
) :
comp_
(comp) {}
28
template
<
typename
T1,
typename
T2>
29
double
operator()
(
const
T1 &t1,
const
T2 &
t2
)
const
{
30
return
1.0 -
comp_
(t1,t2);
31
}
32
private
:
33
Comparator
comp_
;
34
};
//struct
35
38
struct
OverlapByDeltaR
{
39
public
:
40
OverlapByDeltaR
(
double
deltaR
) :
scale_
(1.0/(deltaR*deltaR)) {}
41
template
<
typename
T1,
typename
T2>
42
double
operator()
(
const
T1 &t1,
const
T2 &
t2
)
const
{
43
return
deltaR2
(t1,t2) *
scale_
;
44
}
45
private
:
46
double
scale_
;
47
};
//struct
48
49
50
template
<
typename
Distance>
51
class
GenericOverlapFinder
{
52
53
public
:
54
55
GenericOverlapFinder
() {}
56
GenericOverlapFinder
(
const
Distance &dist) :
distance_
(dist) {}
57
61
template
<
typename
Collection,
typename
OtherCollection>
62
std::unique_ptr< OverlapList >
63
find
(
const
Collection &
items
,
const
OtherCollection &other)
const
;
64
65
private
:
66
Distance
distance_
;
67
68
};
// class
69
}
70
71
template
<
typename
Distance>
72
template
<
typename
Collection,
typename
OtherCollection>
73
std::unique_ptr< pat::OverlapList >
74
pat::GenericOverlapFinder<Distance>::find
(
const
Collection &
items
,
const
OtherCollection &other)
const
75
{
76
size_t
size
= items.size(), size2 = other.size();
77
78
auto
ret
= std::make_unique<OverlapList>();
79
80
for
(
size_t
ie = 0; ie <
size
; ++ie) {
81
double
dmin = 1.0;
82
size_t
match
= 0;
83
84
for
(
size_t
je = 0; je < size2; ++je) {
85
double
dist =
distance_
(items[ie], other[je]);
86
if
(dist < dmin) { match = je; dmin = dist; }
87
}
88
89
if
(dmin < 1.0) {
90
ret
->push_back(std::make_pair(ie,match));
91
}
92
}
93
94
return
ret
;
95
}
96
97
98
#endif
pat::OverlapByDeltaR::operator()
double operator()(const T1 &t1, const T2 &t2) const
Definition:
GenericOverlapFinder.h:42
runTheMatrix.ret
tuple ret
prodAgent to be discontinued
Definition:
runTheMatrix.py:279
pat::OverlapDistance
Definition:
GenericOverlapFinder.h:24
pat::OverlapDistance::operator()
double operator()(const T1 &t1, const T2 &t2) const
Definition:
GenericOverlapFinder.h:29
pat::GenericOverlapFinder
Definition:
GenericOverlapFinder.h:51
AlCaHLTBitMon_QueryRunRegistry.comp
string comp
Definition:
AlCaHLTBitMon_QueryRunRegistry.py:248
deltaR.h
reco::t2
auto const T2 &decltype(t1.eta()) t2
Definition:
deltaR.h:16
pat::GenericOverlapFinder::GenericOverlapFinder
GenericOverlapFinder(const Distance &dist)
Definition:
GenericOverlapFinder.h:56
pat::OverlapByDeltaR::scale_
double scale_
Definition:
GenericOverlapFinder.h:46
pat::OverlapDistance::OverlapDistance
OverlapDistance()
Definition:
GenericOverlapFinder.h:26
pat::OverlapDistance::comp_
Comparator comp_
Definition:
GenericOverlapFinder.h:33
pat::GenericOverlapFinder::GenericOverlapFinder
GenericOverlapFinder()
Definition:
GenericOverlapFinder.h:55
deltaR
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition:
TreeUtility.cc:17
pat::OverlapList
std::vector< std::pair< size_t, size_t > > OverlapList
Definition:
GenericOverlapFinder.h:15
mps_monitormerge.items
list items
Definition:
mps_monitormerge.py:27
pat::GenericOverlapFinder::find
std::unique_ptr< OverlapList > find(const Collection &items, const OtherCollection &other) const
pat::OverlapByDeltaR::OverlapByDeltaR
OverlapByDeltaR(double deltaR)
Definition:
GenericOverlapFinder.h:40
reco::deltaR2
T1 deltaR2(T1 eta1, T2 phi1, T3 eta2, T4 phi2)
Definition:
deltaR.h:36
pat::OverlapByDeltaR
Definition:
GenericOverlapFinder.h:38
match
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition:
Utils.h:10
distance_
double distance_
Definition:
PFRecoTauChargedHadronFromTrackPlugin.cc:122
Comparator
Definition:
Comparator.h:15
findQualityFiles.size
tuple size
Write out results.
Definition:
findQualityFiles.py:442
pat::OverlapDistance::OverlapDistance
OverlapDistance(const Comparator &comp)
Definition:
GenericOverlapFinder.h:27
pat::GenericOverlapFinder::distance_
Distance distance_
Definition:
GenericOverlapFinder.h:66
Generated for CMSSW Reference Manual by
1.8.5