SimTracker
TrackerHitAssociation
interface
ClusterTPAssociation.h
Go to the documentation of this file.
1
#ifndef SimTracker_TrackerHitAssociation_ClusterTPAssociation_h
2
#define SimTracker_TrackerHitAssociation_ClusterTPAssociation_h
3
4
#include "
DataFormats/Provenance/interface/ProductID.h
"
5
#include "
DataFormats/Common/interface/HandleBase.h
"
6
#include "
DataFormats/TrackerRecHit2D/interface/OmniClusterRef.h
"
7
#include "
FWCore/Utilities/interface/VecArray.h
"
8
#include "
SimDataFormats/TrackingAnalysis/interface/TrackingParticle.h
"
9
#include "
SimDataFormats/TrackingAnalysis/interface/TrackingParticleFwd.h
"
10
11
#include <vector>
12
#include <utility>
13
#include <algorithm>
14
21
class
ClusterTPAssociation
{
22
public
:
23
using
key_type
=
OmniClusterRef
;
24
using
mapped_type
=
TrackingParticleRef
;
25
using
value_type
= std::pair<key_type, mapped_type>;
26
using
map_type
= std::vector<value_type>;
27
using
const_iterator
=
typename
map_type::const_iterator;
28
using
range
= std::pair<const_iterator, const_iterator>;
29
30
ClusterTPAssociation
() {}
31
explicit
ClusterTPAssociation
(
const
edm::HandleBase
& mappedHandle) :
ClusterTPAssociation
(mappedHandle.
id
()) {}
32
explicit
ClusterTPAssociation
(
const
edm::ProductID
& mappedProductId) :
mappedProductId_
(mappedProductId) {}
33
34
void
addKeyID
(
edm::ProductID
id
) {
35
auto
foundKeyID =
std::find
(
std::begin
(
keyProductIDs_
),
std::end
(
keyProductIDs_
),
id
);
36
if
(foundKeyID ==
std::end
(
keyProductIDs_
)) {
37
keyProductIDs_
.
emplace_back
(
id
);
38
}
39
}
40
41
void
emplace_back
(
const
OmniClusterRef
& cluster,
const
TrackingParticleRef
&
tp
) {
42
checkMappedProductID
(
tp
);
43
checkKeyProductID
(cluster.
id
());
44
map_
.emplace_back(cluster,
tp
);
45
}
46
void
sortAndUnique
() {
47
std::sort(
map_
.begin(),
map_
.end(),
compareSort
);
48
auto
last
=
std::unique
(
map_
.begin(),
map_
.end());
49
map_
.erase(
last
,
map_
.end());
50
map_
.shrink_to_fit();
51
}
52
void
swap
(
ClusterTPAssociation
&
other
) {
53
map_
.swap(
other
.map_);
54
mappedProductId_
.
swap
(
other
.mappedProductId_);
55
}
56
57
bool
empty
()
const
{
return
map_
.empty(); }
58
size_t
size
()
const
{
return
map_
.size(); }
59
60
const_iterator
begin
()
const
{
return
map_
.begin(); }
61
const_iterator
cbegin
()
const
{
return
map_
.cbegin(); }
62
const_iterator
end
()
const
{
return
map_
.end(); }
63
const_iterator
cend
()
const
{
return
map_
.end(); }
64
65
range
equal_range
(
const
OmniClusterRef
&
key
)
const
{
66
checkKeyProductID
(
key
);
67
return
std::equal_range(
map_
.begin(),
map_
.end(),
value_type
(
key
,
TrackingParticleRef
()),
compare
);
68
}
69
70
const
map_type
&
map
()
const
{
return
map_
; }
71
72
void
checkKeyProductID
(
const
OmniClusterRef
&
key
)
const
{
checkKeyProductID
(
key
.id()); }
73
void
checkKeyProductID
(
const
edm::ProductID
&
id
)
const
;
74
75
void
checkMappedProductID
(
const
edm::HandleBase
& mappedHandle)
const
{
checkMappedProductID
(mappedHandle.
id
()); }
76
void
checkMappedProductID
(
const
TrackingParticleRef
&
tp
)
const
{
checkMappedProductID
(
tp
.id()); }
77
void
checkMappedProductID
(
const
edm::ProductID
&
id
)
const
;
78
79
private
:
80
static
bool
compare
(
const
value_type
&
i
,
const
value_type
&
j
) {
return
i
.first.rawIndex() >
j
.first.rawIndex(); }
81
82
static
bool
compareSort
(
const
value_type
&
i
,
const
value_type
&
j
) {
83
// For sorting compare also TrackingParticle keys in order to
84
// remove duplicate matches
85
return
compare
(
i
,
j
) || (
i
.first.rawIndex() ==
j
.first.rawIndex() &&
i
.second.key() >
j
.second.key());
86
}
87
88
map_type
map_
;
89
edm::VecArray<edm::ProductID, 2>
keyProductIDs_
;
90
edm::ProductID
mappedProductId_
;
91
};
92
93
#endif
mps_fire.i
i
Definition:
mps_fire.py:355
ClusterTPAssociation::compare
static bool compare(const value_type &i, const value_type &j)
Definition:
ClusterTPAssociation.h:80
ClusterTPAssociation::keyProductIDs_
edm::VecArray< edm::ProductID, 2 > keyProductIDs_
Definition:
ClusterTPAssociation.h:89
ClusterTPAssociation::emplace_back
void emplace_back(const OmniClusterRef &cluster, const TrackingParticleRef &tp)
Definition:
ClusterTPAssociation.h:41
ClusterTPAssociation
Definition:
ClusterTPAssociation.h:21
ClusterTPAssociation::addKeyID
void addKeyID(edm::ProductID id)
Definition:
ClusterTPAssociation.h:34
edm::HandleBase
Definition:
HandleBase.h:40
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition:
FindCaloHit.cc:19
ClusterTPAssociation::value_type
std::pair< key_type, mapped_type > value_type
Definition:
ClusterTPAssociation.h:25
ClusterTPAssociation::begin
const_iterator begin() const
Definition:
ClusterTPAssociation.h:60
OmniClusterRef
Definition:
OmniClusterRef.h:12
ClusterTPAssociation::const_iterator
typename map_type::const_iterator const_iterator
Definition:
ClusterTPAssociation.h:27
end
#define end
Definition:
vmac.h:39
edm::Ref< TrackingParticleCollection >
ClusterTPAssociation::map_type
std::vector< value_type > map_type
Definition:
ClusterTPAssociation.h:26
HandleBase.h
ClusterTPAssociation::sortAndUnique
void sortAndUnique()
Definition:
ClusterTPAssociation.h:46
ClusterTPAssociation::mappedProductId_
edm::ProductID mappedProductId_
Definition:
ClusterTPAssociation.h:90
ClusterTPAssociation::ClusterTPAssociation
ClusterTPAssociation()
Definition:
ClusterTPAssociation.h:30
dqmdumpme.last
last
Definition:
dqmdumpme.py:56
ClusterTPAssociation::ClusterTPAssociation
ClusterTPAssociation(const edm::HandleBase &mappedHandle)
Definition:
ClusterTPAssociation.h:31
ClusterTPAssociation::map
const map_type & map() const
Definition:
ClusterTPAssociation.h:70
ProductID.h
ClusterTPAssociation::checkKeyProductID
void checkKeyProductID(const OmniClusterRef &key) const
Definition:
ClusterTPAssociation.h:72
ClusterTPAssociation::range
std::pair< const_iterator, const_iterator > range
Definition:
ClusterTPAssociation.h:28
trackingPlots.other
other
Definition:
trackingPlots.py:1465
ClusterTPAssociation::ClusterTPAssociation
ClusterTPAssociation(const edm::ProductID &mappedProductId)
Definition:
ClusterTPAssociation.h:32
ClusterTPAssociation::compareSort
static bool compareSort(const value_type &i, const value_type &j)
Definition:
ClusterTPAssociation.h:82
cmsswSequenceInfo.tp
tp
Definition:
cmsswSequenceInfo.py:17
edm::VecArray< edm::ProductID, 2 >
ClusterTPAssociation::map_
map_type map_
Definition:
ClusterTPAssociation.h:88
ClusterTPAssociation::size
size_t size() const
Definition:
ClusterTPAssociation.h:58
ClusterTPAssociation::swap
void swap(ClusterTPAssociation &other)
Definition:
ClusterTPAssociation.h:52
ClusterTPAssociation::end
const_iterator end() const
Definition:
ClusterTPAssociation.h:62
ClusterTPAssociation::equal_range
range equal_range(const OmniClusterRef &key) const
Definition:
ClusterTPAssociation.h:65
edm::ProductID::swap
void swap(ProductID &other)
Definition:
ProductID.cc:16
edm::VecArray::emplace_back
void emplace_back(Args &&... args)
Definition:
VecArray.h:90
ClusterTPAssociation::checkMappedProductID
void checkMappedProductID(const edm::HandleBase &mappedHandle) const
Definition:
ClusterTPAssociation.h:75
OmniClusterRef.h
ClusterTPAssociation::checkMappedProductID
void checkMappedProductID(const TrackingParticleRef &tp) const
Definition:
ClusterTPAssociation.h:76
TrackingParticle.h
OmniClusterRef::id
edm::ProductID id() const
Definition:
OmniClusterRef.h:69
tier0.unique
def unique(seq, keepstr=True)
Definition:
tier0.py:24
TrackingParticleFwd.h
triggerObjects_cff.id
id
Definition:
triggerObjects_cff.py:31
VecArray.h
ClusterTPAssociation::cbegin
const_iterator cbegin() const
Definition:
ClusterTPAssociation.h:61
ClusterTPAssociation::cend
const_iterator cend() const
Definition:
ClusterTPAssociation.h:63
TrackingParticleRef
edm::Ref< TrackingParticleCollection > TrackingParticleRef
Definition:
TrackingParticleFwd.h:10
dqmiolumiharvest.j
j
Definition:
dqmiolumiharvest.py:66
ClusterTPAssociation::empty
bool empty() const
Definition:
ClusterTPAssociation.h:57
crabWrapper.key
key
Definition:
crabWrapper.py:19
edm::HandleBase::id
ProductID id() const
Definition:
HandleBase.cc:13
begin
#define begin
Definition:
vmac.h:32
edm::ProductID
Definition:
ProductID.h:27
Generated for CMSSW Reference Manual by
1.8.16