DataFormats
PatCandidates
src
VIDCutFlowResult.cc
Go to the documentation of this file.
1
#include "
DataFormats/PatCandidates/interface/VIDCutFlowResult.h
"
2
#include "
FWCore/Utilities/interface/Exception.h
"
3
4
namespace
{
5
const
std::string
empty_str(
""
);
6
}
7
8
namespace
vid
{
9
10
CutFlowResult::CutFlowResult
(
const
std::string
&
name
,
11
const
std::string
&
hash
,
12
const
std::map<std::string, unsigned>& n2idx,
13
const
std::vector<double>&
values
,
14
unsigned
bitmap,
15
unsigned
mask)
16
: name_(
name
), hash_(
hash
), bitmap_(bitmap), mask_(mask), values_(
values
) {
17
for
(
const
auto
&
val
: n2idx) {
18
names_
.push_back(
val
.first);
19
indices_
.push_back(
val
.second);
20
}
21
}
22
23
const
std::string
&
CutFlowResult::getNameAtIndex
(
const
unsigned
idx
)
const
{
24
unsigned
internal_idx = 0;
25
for
(
const
auto
&
value
:
indices_
) {
26
if
(
value
==
idx
)
27
return
names_
[internal_idx];
28
++internal_idx;
29
}
30
throw
cms::Exception
(
"IndexNotFound"
) <<
"index = "
<<
idx
<<
" has no corresponding cut name!"
;
31
return
empty_str;
32
}
33
34
bool
CutFlowResult::getCutResultByIndex
(
const
unsigned
idx
)
const
{
35
if
(
idx
>=
indices_
.size()) {
36
throw
cms::Exception
(
"OutOfBounds"
) <<
idx
<<
" is out of bounds for this cut flow!"
;
37
}
38
return
getCutBit
(
idx
);
39
}
40
41
bool
CutFlowResult::getCutResultByName
(
const
std::string
&
name
)
const
{
42
auto
found_name =
std::lower_bound
(
names_
.begin(),
names_
.end(),
name
);
43
if
(found_name ==
names_
.end() || *found_name !=
name
) {
44
throw
cms::Exception
(
"UnknownName"
) <<
"Cut name: "
<<
name
<<
" is not known for this cutflow!"
;
45
}
46
return
getCutBit
(
indices_
[
std::distance
(
names_
.begin(), found_name)]);
47
}
48
49
bool
CutFlowResult::isCutMasked
(
const
unsigned
idx
)
const
{
50
if
(
idx
>=
indices_
.size()) {
51
throw
cms::Exception
(
"OutOfBounds"
) <<
idx
<<
" is out of bounds for this cut flow!"
;
52
}
53
return
getMaskBit
(
idx
);
54
}
55
56
bool
CutFlowResult::isCutMasked
(
const
std::string
&
name
)
const
{
57
auto
found_name =
std::lower_bound
(
names_
.begin(),
names_
.end(),
name
);
58
if
(found_name ==
names_
.end() || *found_name !=
name
) {
59
throw
cms::Exception
(
"UnknownName"
) <<
"Cut name: "
<<
name
<<
" is not known for this cutflow!"
;
60
}
61
return
getMaskBit
(
indices_
[
std::distance
(
names_
.begin(), found_name)]);
62
}
63
64
double
CutFlowResult::getValueCutUpon
(
const
unsigned
idx
)
const
{
65
if
(
idx
>=
indices_
.size()) {
66
throw
cms::Exception
(
"OutOfBounds"
) <<
idx
<<
" is out of bounds for this cut flow!"
;
67
}
68
return
getCutValue
(
idx
);
69
}
70
71
double
CutFlowResult::getValueCutUpon
(
const
std::string
&
name
)
const
{
72
auto
found_name =
std::lower_bound
(
names_
.begin(),
names_
.end(),
name
);
73
if
(found_name ==
names_
.end() || *found_name !=
name
) {
74
throw
cms::Exception
(
"UnknownName"
) <<
"Cut name: "
<<
name
<<
" is not known for this cutflow!"
;
75
}
76
return
getCutValue
(
indices_
[
std::distance
(
names_
.begin(), found_name)]);
77
}
78
79
CutFlowResult
CutFlowResult::getCutFlowResultMasking
(
const
std::vector<unsigned>& idxs)
const
{
80
unsigned
bitmap =
bitmap_
;
81
unsigned
mask =
mask_
;
82
for
(
const
unsigned
idx
: idxs) {
83
if
(
idx
>=
indices_
.size()) {
84
throw
cms::Exception
(
"OutOfBounds"
) <<
idx
<<
" is out of bounds for this cut flow!"
;
85
}
86
mask = mask | 1 <<
idx
;
87
}
88
bitmap = bitmap | mask;
89
return
CutFlowResult
(
name_
, empty_str,
names_
,
indices_
,
values_
, bitmap, mask);
90
}
91
92
CutFlowResult
CutFlowResult::getCutFlowResultMasking
(
const
std::vector<std::string>&
names
)
const
{
93
unsigned
bitmap =
bitmap_
;
94
unsigned
mask =
mask_
;
95
for
(
const
std::string
&
name
:
names
) {
96
auto
found_name =
std::lower_bound
(
names_
.begin(),
names_
.end(),
name
);
97
if
(found_name ==
names_
.end() || *found_name !=
name
) {
98
throw
cms::Exception
(
"UnknownName"
) <<
"Cut name: "
<<
name
<<
" is not known for this cutflow!"
;
99
}
100
mask = mask | 1 <<
indices_
[
std::distance
(
names_
.begin(), found_name)];
101
}
102
bitmap = bitmap | mask;
103
return
CutFlowResult
(
name_
, empty_str,
names_
,
indices_
,
values_
, bitmap, mask);
104
}
105
106
CutFlowResult
CutFlowResult::getCutFlowResultMasking
(
const
unsigned
idx
)
const
{
107
unsigned
bitmap =
bitmap_
;
108
unsigned
mask =
mask_
;
109
if
(
idx
>=
indices_
.size()) {
110
throw
cms::Exception
(
"OutOfBounds"
) <<
idx
<<
" is out of bounds for this cut flow!"
;
111
}
112
mask = mask | 1 <<
idx
;
113
bitmap = bitmap | mask;
114
return
CutFlowResult
(
name_
, empty_str,
names_
,
indices_
,
values_
, bitmap, mask);
115
}
116
117
CutFlowResult
CutFlowResult::getCutFlowResultMasking
(
const
std::string
&
name
)
const
{
118
unsigned
bitmap =
bitmap_
;
119
unsigned
mask =
mask_
;
120
auto
found_name =
std::lower_bound
(
names_
.begin(),
names_
.end(),
name
);
121
if
(found_name ==
names_
.end() || *found_name !=
name
) {
122
throw
cms::Exception
(
"UnknownName"
) <<
"Cut name: "
<<
name
<<
" is not known for this cutflow!"
;
123
}
124
mask = mask | 1 <<
indices_
[
std::distance
(
names_
.begin(), found_name)];
125
bitmap = bitmap | mask;
126
return
CutFlowResult
(
name_
, empty_str,
names_
,
indices_
,
values_
, bitmap, mask);
127
}
128
}
// namespace vid
vid::CutFlowResult::mask_
unsigned mask_
Definition:
VIDCutFlowResult.h:107
vid::CutFlowResult::values_
std::vector< double > values_
Definition:
VIDCutFlowResult.h:108
vid
Definition:
VIDCutFlowResult.h:25
vid::CutFlowResult::CutFlowResult
CutFlowResult()
Definition:
VIDCutFlowResult.h:61
cond::hash
Definition:
Time.h:19
vid::CutFlowResult
Definition:
VIDCutFlowResult.h:41
vid::CutFlowResult::bitmap_
unsigned bitmap_
Definition:
VIDCutFlowResult.h:107
vid::CutFlowResult::getCutValue
double getCutValue(const unsigned idx) const
Definition:
VIDCutFlowResult.h:125
heavyIonCSV_trainingSettings.idx
idx
Definition:
heavyIonCSV_trainingSettings.py:5
vid::CutFlowResult::names_
std::vector< std::string > names_
Definition:
VIDCutFlowResult.h:109
vid::CutFlowResult::getCutFlowResultMasking
CutFlowResult getCutFlowResultMasking(const unsigned idx) const
Definition:
VIDCutFlowResult.cc:106
names
const std::string names[nVars_]
Definition:
PhotonIDValueMapProducer.cc:124
contentValuesCheck.values
values
Definition:
contentValuesCheck.py:38
vid::CutFlowResult::getCutResultByIndex
bool getCutResultByIndex(const unsigned idx) const
Definition:
VIDCutFlowResult.cc:34
vid::CutFlowResult::indices_
std::vector< unsigned > indices_
Definition:
VIDCutFlowResult.h:110
vid::CutFlowResult::getNameAtIndex
const std::string & getNameAtIndex(const unsigned idx) const
Definition:
VIDCutFlowResult.cc:23
pfDeepBoostedJetPreprocessParams_cfi.lower_bound
lower_bound
Definition:
pfDeepBoostedJetPreprocessParams_cfi.py:15
vid::CutFlowResult::name_
std::string name_
Definition:
VIDCutFlowResult.h:106
value
Definition:
value.py:1
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition:
AlCaHLTBitMon_QueryRunRegistry.py:256
vid::CutFlowResult::getCutResultByName
bool getCutResultByName(const std::string &name) const
Definition:
VIDCutFlowResult.cc:41
vid::CutFlowResult::getCutBit
bool getCutBit(const unsigned idx) const
Definition:
VIDCutFlowResult.h:123
vid::CutFlowResult::isCutMasked
bool isCutMasked(const unsigned idx) const
Definition:
VIDCutFlowResult.cc:49
heppy_batch.val
val
Definition:
heppy_batch.py:351
VIDCutFlowResult.h
vid::CutFlowResult::getMaskBit
bool getMaskBit(const unsigned idx) const
Definition:
VIDCutFlowResult.h:121
vid::CutFlowResult::getValueCutUpon
double getValueCutUpon(const unsigned idx) const
Definition:
VIDCutFlowResult.cc:64
Exception
Definition:
hltDiff.cc:245
Skims_PA_cff.name
name
Definition:
Skims_PA_cff.py:17
Exception.h
HLT_FULL_cff.distance
distance
Definition:
HLT_FULL_cff.py:7746
Generated for CMSSW Reference Manual by
1.8.16