PhysicsTools
PatUtils
interface
GenericDuplicateRemover.h
Go to the documentation of this file.
1
#ifndef PhysicsTools_PatUtils_GenericDuplicateRemover_h
2
#define PhysicsTools_PatUtils_GenericDuplicateRemover_h
3
4
#include <memory>
5
#include <vector>
6
#include <sys/types.h>
7
8
namespace
pat
{
9
10
template
<
typename
Comparator,
typename
Arbitrator>
11
class
GenericDuplicateRemover
{
12
public
:
13
GenericDuplicateRemover
() {}
14
GenericDuplicateRemover
(
const
Comparator
&
comp
) :
comparator_
(
comp
) {}
15
GenericDuplicateRemover
(
const
Comparator
&
comp
,
const
Arbitrator &arbiter) :
comparator_
(
comp
),
arbiter_
(arbiter) {}
16
17
~GenericDuplicateRemover
() {}
18
24
template
<
typename
Collection>
25
std::unique_ptr<std::vector<size_t>>
duplicates
(
const
Collection &
items
)
const
;
26
27
private
:
28
Comparator
comparator_
;
29
Arbitrator
arbiter_
;
30
31
};
// class
32
}
// namespace pat
33
34
template
<
typename
Comparator,
typename
Arbitrator>
35
template
<
typename
Collection>
36
std::unique_ptr<std::vector<size_t>>
pat::GenericDuplicateRemover<Comparator, Arbitrator>::duplicates
(
37
const
Collection &
items
)
const
{
38
size_t
size
=
items
.size();
39
40
std::vector<bool> bad(
size
,
false
);
41
42
for
(
size_t
ie = 0; ie <
size
; ++ie) {
43
if
(bad[ie])
44
continue
;
// if already marked bad
45
46
for
(
size_t
je = ie + 1; je <
size
; ++je) {
47
if
(bad[je])
48
continue
;
// if already marked bad
49
50
if
(comparator_(
items
[ie],
items
[je])) {
51
int
toRemove = arbiter_(
items
[ie],
items
[je]) ? je : ie;
52
bad[toRemove] =
true
;
53
}
54
}
55
}
56
57
auto
ret
= std::make_unique<std::vector<size_t>>();
58
59
for
(
size_t
i
= 0;
i
<
size
; ++
i
) {
60
if
(bad[
i
])
61
ret
->push_back(
i
);
62
}
63
64
return
ret
;
65
}
66
67
#endif
runTheMatrix.ret
ret
prodAgent to be discontinued
Definition:
runTheMatrix.py:542
pat::GenericDuplicateRemover::GenericDuplicateRemover
GenericDuplicateRemover()
Definition:
GenericDuplicateRemover.h:13
mps_fire.i
i
Definition:
mps_fire.py:428
pat::GenericDuplicateRemover::~GenericDuplicateRemover
~GenericDuplicateRemover()
Definition:
GenericDuplicateRemover.h:17
pat::GenericDuplicateRemover
Definition:
GenericDuplicateRemover.h:11
pat::GenericDuplicateRemover::GenericDuplicateRemover
GenericDuplicateRemover(const Comparator &comp)
Definition:
GenericDuplicateRemover.h:14
AlCaHLTBitMon_QueryRunRegistry.comp
comp
Definition:
AlCaHLTBitMon_QueryRunRegistry.py:249
mps_monitormerge.items
list items
Definition:
mps_monitormerge.py:29
pat::GenericDuplicateRemover::duplicates
std::unique_ptr< std::vector< size_t > > duplicates(const Collection &items) const
Definition:
GenericDuplicateRemover.h:36
pat::GenericDuplicateRemover::GenericDuplicateRemover
GenericDuplicateRemover(const Comparator &comp, const Arbitrator &arbiter)
Definition:
GenericDuplicateRemover.h:15
pat
Definition:
HeavyIon.h:7
pat::GenericDuplicateRemover::arbiter_
Arbitrator arbiter_
Definition:
GenericDuplicateRemover.h:29
Comparator
Definition:
Comparator.h:15
pat::GenericDuplicateRemover::comparator_
Comparator comparator_
Definition:
GenericDuplicateRemover.h:28
findQualityFiles.size
size
Write out results.
Definition:
findQualityFiles.py:443
Generated for CMSSW Reference Manual by
1.8.16