CondFormats
HcalObjects
src
HcalIndexLookup.cc
Go to the documentation of this file.
1
#include <algorithm>
2
3
#include "
CondFormats/HcalObjects/interface/HcalIndexLookup.h
"
4
5
void
HcalIndexLookup::clear
() {
6
data_
.clear();
7
sorted_
=
true
;
8
}
9
10
void
HcalIndexLookup::sort
() {
11
if
(!
sorted_
) {
12
std::sort
(
data_
.begin(),
data_
.end());
13
sorted_
=
true
;
14
}
15
}
16
17
bool
HcalIndexLookup::hasDuplicateIds
() {
18
const
std::size_t sz =
data_
.size();
19
if
(sz) {
20
sort
();
21
const
std::size_t szm1 = sz - 1;
22
for
(std::size_t
i
= 0;
i
< szm1; ++
i
)
23
if
(
data_
[
i
].
first
==
data_
[
i
+ 1].
first
)
24
return
true
;
25
}
26
return
false
;
27
}
28
29
void
HcalIndexLookup::add
(
const
unsigned
detId,
const
unsigned
index
) {
30
if
(
index
==
InvalidIndex
)
31
throw
cms::Exception
(
"In HcalIndexLookup::add: invalid index"
);
32
data_
.push_back(std::pair<uint32_t, uint32_t>(detId,
index
));
33
sorted_
=
false
;
34
}
35
36
unsigned
HcalIndexLookup::find
(
const
unsigned
detId)
const
{
37
if
(
data_
.empty())
38
return
InvalidIndex
;
39
if
(!
sorted_
)
40
throw
cms::Exception
(
41
"In HcalIndexLookup::lookup:"
42
" collection is not sorted"
);
43
std::pair<uint32_t, uint32_t>
search
(detId, 0
U
);
44
auto
end
=
data_
.end();
45
auto
it =
std::lower_bound
(
data_
.begin(),
end
,
search
);
46
if
(it ==
end
)
47
return
InvalidIndex
;
48
if
(it->first == detId)
49
return
it->second;
50
else
51
return
InvalidIndex
;
52
}
53
54
unsigned
HcalIndexLookup::largestIndex
()
const
{
55
const
std::size_t sz =
data_
.size();
56
if
(sz) {
57
uint32_t largest = 0;
58
for
(std::size_t
i
= 0;
i
< sz; ++
i
)
59
if
(
data_
[
i
].
second
> largest)
60
largest =
data_
[
i
].second;
61
return
largest;
62
}
else
63
return
InvalidIndex
;
64
}
mps_fire.i
i
Definition:
mps_fire.py:428
HcalIndexLookup::clear
void clear()
Definition:
HcalIndexLookup.cc:5
HcalIndexLookup.h
edm::second
U second(std::pair< T, U > const &p)
Definition:
ParameterSet.cc:222
HcalIndexLookup::sorted_
bool sorted_
Definition:
HcalIndexLookup.h:59
mps_fire.end
end
Definition:
mps_fire.py:242
cond::persistency::search
std::vector< T >::const_iterator search(const cond::Time_t &val, const std::vector< T > &container)
Definition:
IOVProxy.cc:21
first
auto first
Definition:
CAHitNtupletGeneratorKernelsImpl.h:125
mitigatedMETSequence_cff.U
U
Definition:
mitigatedMETSequence_cff.py:36
pfDeepBoostedJetPreprocessParams_cfi.lower_bound
lower_bound
Definition:
pfDeepBoostedJetPreprocessParams_cfi.py:15
HcalIndexLookup::largestIndex
unsigned largestIndex() const
Definition:
HcalIndexLookup.cc:54
jetUpdater_cfi.sort
sort
Definition:
jetUpdater_cfi.py:29
HcalIndexLookup::InvalidIndex
static const unsigned InvalidIndex
Definition:
HcalIndexLookup.h:21
HcalIndexLookup::sort
void sort()
Definition:
HcalIndexLookup.cc:10
HcalIndexLookup::add
void add(unsigned transformedId, unsigned index)
Definition:
HcalIndexLookup.cc:29
HcalIndexLookup::hasDuplicateIds
bool hasDuplicateIds()
Definition:
HcalIndexLookup.cc:17
Exception
Definition:
hltDiff.cc:245
HcalIndexLookup::find
unsigned find(unsigned detId) const
Definition:
HcalIndexLookup.cc:36
HcalIndexLookup::data_
std::vector< std::pair< uint32_t, uint32_t > > data_
Definition:
HcalIndexLookup.h:58
AlignmentPI::index
index
Definition:
AlignmentPayloadInspectorHelper.h:46
Generated for CMSSW Reference Manual by
1.8.16