JetMETCorrections
InterpolationTables
src
ArrayShape.cc
Go to the documentation of this file.
1
#include <cassert>
2
#include "
JetMETCorrections/InterpolationTables/interface/NpstatException.h
"
3
4
#include "
JetMETCorrections/InterpolationTables/interface/ArrayShape.h
"
5
6
namespace
npstat
{
7
ArrayShape
makeShape
() {
return
ArrayShape
(); }
8
9
ArrayShape
makeShape
(
unsigned
i0) {
return
ArrayShape
(1, i0); }
10
11
ArrayShape
makeShape
(
unsigned
i0,
unsigned
i1
) {
12
ArrayShape
s
;
13
s
.reserve(2);
14
s
.push_back(i0);
15
s
.push_back(
i1
);
16
return
s
;
17
}
18
19
ArrayShape
makeShape
(
unsigned
i0,
unsigned
i1
,
unsigned
i2
) {
20
ArrayShape
s
;
21
s
.reserve(3);
22
s
.push_back(i0);
23
s
.push_back(
i1
);
24
s
.push_back(
i2
);
25
return
s
;
26
}
27
28
ArrayShape
makeShape
(
unsigned
i0,
unsigned
i1
,
unsigned
i2
,
unsigned
i3
) {
29
ArrayShape
s
;
30
s
.reserve(4);
31
s
.push_back(i0);
32
s
.push_back(
i1
);
33
s
.push_back(
i2
);
34
s
.push_back(
i3
);
35
return
s
;
36
}
37
38
ArrayShape
makeShape
(
unsigned
i0,
unsigned
i1
,
unsigned
i2
,
unsigned
i3
,
unsigned
i4) {
39
ArrayShape
s
;
40
s
.reserve(5);
41
s
.push_back(i0);
42
s
.push_back(
i1
);
43
s
.push_back(
i2
);
44
s
.push_back(
i3
);
45
s
.push_back(i4);
46
return
s
;
47
}
48
49
ArrayShape
makeShape
(
unsigned
i0,
unsigned
i1
,
unsigned
i2
,
unsigned
i3
,
unsigned
i4,
unsigned
i5) {
50
ArrayShape
s
;
51
s
.reserve(6);
52
s
.push_back(i0);
53
s
.push_back(
i1
);
54
s
.push_back(
i2
);
55
s
.push_back(
i3
);
56
s
.push_back(i4);
57
s
.push_back(i5);
58
return
s
;
59
}
60
61
ArrayShape
makeShape
(
unsigned
i0,
unsigned
i1
,
unsigned
i2
,
unsigned
i3
,
unsigned
i4,
unsigned
i5,
unsigned
i6) {
62
ArrayShape
s
;
63
s
.reserve(7);
64
s
.push_back(i0);
65
s
.push_back(
i1
);
66
s
.push_back(
i2
);
67
s
.push_back(
i3
);
68
s
.push_back(i4);
69
s
.push_back(i5);
70
s
.push_back(i6);
71
return
s
;
72
}
73
74
ArrayShape
makeShape
(
75
unsigned
i0,
unsigned
i1
,
unsigned
i2
,
unsigned
i3
,
unsigned
i4,
unsigned
i5,
unsigned
i6,
unsigned
i7) {
76
ArrayShape
s
;
77
s
.reserve(8);
78
s
.push_back(i0);
79
s
.push_back(
i1
);
80
s
.push_back(
i2
);
81
s
.push_back(
i3
);
82
s
.push_back(i4);
83
s
.push_back(i5);
84
s
.push_back(i6);
85
s
.push_back(i7);
86
return
s
;
87
}
88
89
ArrayShape
makeShape
(
unsigned
i0,
90
unsigned
i1
,
91
unsigned
i2
,
92
unsigned
i3
,
93
unsigned
i4,
94
unsigned
i5,
95
unsigned
i6,
96
unsigned
i7,
97
unsigned
i8) {
98
ArrayShape
s
;
99
s
.reserve(9);
100
s
.push_back(i0);
101
s
.push_back(
i1
);
102
s
.push_back(
i2
);
103
s
.push_back(
i3
);
104
s
.push_back(i4);
105
s
.push_back(i5);
106
s
.push_back(i6);
107
s
.push_back(i7);
108
s
.push_back(i8);
109
return
s
;
110
}
111
112
ArrayShape
makeShape
(
unsigned
i0,
113
unsigned
i1
,
114
unsigned
i2
,
115
unsigned
i3
,
116
unsigned
i4,
117
unsigned
i5,
118
unsigned
i6,
119
unsigned
i7,
120
unsigned
i8,
121
unsigned
i9) {
122
ArrayShape
s
;
123
s
.reserve(10);
124
s
.push_back(i0);
125
s
.push_back(
i1
);
126
s
.push_back(
i2
);
127
s
.push_back(
i3
);
128
s
.push_back(i4);
129
s
.push_back(i5);
130
s
.push_back(i6);
131
s
.push_back(i7);
132
s
.push_back(i8);
133
s
.push_back(i9);
134
return
s
;
135
}
136
137
ArrayShape
makeShape
(
const
unsigned
*
indices
,
const
unsigned
nIndices) {
138
ArrayShape
s
;
139
if
(nIndices) {
140
assert
(
indices
);
141
s
.reserve(nIndices);
142
for
(
unsigned
i
= 0;
i
< nIndices; ++
i
)
143
s
.push_back(
indices
[
i
]);
144
}
145
return
s
;
146
}
147
148
ArrayShape
doubleShape
(
const
ArrayShape
& inputShape) {
149
ArrayShape
s
(inputShape);
150
const
unsigned
len =
s
.size();
151
for
(
unsigned
i
= 0;
i
< len; ++
i
)
152
s
[
i
] *= 2
U
;
153
return
s
;
154
}
155
156
ArrayShape
halfShape
(
const
ArrayShape
& inputShape) {
157
ArrayShape
s
(inputShape);
158
const
unsigned
len =
s
.size();
159
for
(
unsigned
i
= 0;
i
< len; ++
i
) {
160
if
(!(
s
[
i
] % 2
U
== 0))
161
throw
npstat::NpstatInvalidArgument
(
162
"In npstat::halfShape: array span must be "
163
"even in each dimension"
);
164
s
[
i
] /= 2
U
;
165
}
166
return
s
;
167
}
168
169
bool
isSubShape
(
const
ArrayShape
& sh1,
const
ArrayShape
& sh2) {
170
const
unsigned
len = sh1.size();
171
if
(len != sh2.size())
172
return
false
;
173
for
(
unsigned
i
= 0;
i
< len; ++
i
)
174
if
(sh1[
i
] > sh2[
i
])
175
return
false
;
176
return
true
;
177
}
178
}
// namespace npstat
bTagCombinedSVVariables_cff.indices
indices
Definition:
bTagCombinedSVVariables_cff.py:67
testProducerWithPsetDescEmpty_cfi.i2
i2
Definition:
testProducerWithPsetDescEmpty_cfi.py:46
testProducerWithPsetDescEmpty_cfi.i3
i3
Definition:
testProducerWithPsetDescEmpty_cfi.py:47
mps_fire.i
i
Definition:
mps_fire.py:428
testProducerWithPsetDescEmpty_cfi.i1
i1
Definition:
testProducerWithPsetDescEmpty_cfi.py:45
cms::cuda::assert
assert(be >=bs)
npstat::isSubShape
bool isSubShape(const ArrayShape &sh1, const ArrayShape &sh2)
Definition:
ArrayShape.cc:169
npstat::ArrayShape
std::vector< unsigned > ArrayShape
Definition:
ArrayShape.h:21
npstat
Definition:
AbsArrayProjector.h:14
alignCSCRings.s
s
Definition:
alignCSCRings.py:92
ArrayShape.h
Utilities for defining shapes of multidimensional arrays.
npstat::NpstatInvalidArgument
Definition:
NpstatException.h:38
mitigatedMETSequence_cff.U
U
Definition:
mitigatedMETSequence_cff.py:36
npstat::doubleShape
ArrayShape doubleShape(const ArrayShape &inputShape)
Definition:
ArrayShape.cc:148
npstat::makeShape
ArrayShape makeShape()
Definition:
ArrayShape.cc:7
npstat::halfShape
ArrayShape halfShape(const ArrayShape &inputShape)
Definition:
ArrayShape.cc:156
NpstatException.h
Exceptions for the npstat namespace.
Generated for CMSSW Reference Manual by
1.8.16