JetMETCorrections
InterpolationTables
src
ArrayNDScanner.cc
Go to the documentation of this file.
1
#include "
JetMETCorrections/InterpolationTables/interface/NpstatException.h
"
2
#include <cassert>
3
4
#include "
JetMETCorrections/InterpolationTables/interface/ArrayNDScanner.h
"
5
6
namespace
npstat
{
7
void
ArrayNDScanner::initialize
(
const
unsigned
* shape,
const
unsigned
lenShape) {
8
// Check argument validity
9
if
(lenShape == 0
U
|| lenShape >= CHAR_BIT *
sizeof
(
unsigned
long
))
10
throw
npstat::NpstatInvalidArgument
(
"In npstat::ArrayNDScanner::initialize: invalid scan shape"
);
11
assert
(shape);
12
for
(
unsigned
j
= 0;
j
< lenShape; ++
j
)
13
if
(!shape[
j
])
14
throw
npstat::NpstatInvalidArgument
(
15
"In npstat::ArrayNDScanner::initialize: "
16
"number of scans must be positive in each dimension"
);
17
18
// Initialize the scanner data
19
state_
= 0UL;
20
dim_
= lenShape;
21
strides_
[
dim_
- 1] = 1UL;
22
for
(
unsigned
j
=
dim_
- 1;
j
> 0; --
j
)
23
strides_
[
j
- 1] =
strides_
[
j
] * shape[
j
];
24
maxState_
=
strides_
[0] * shape[0];
25
}
26
27
void
ArrayNDScanner::getIndex
(
unsigned
* ix,
const
unsigned
indexBufferLen)
const
{
28
if
(indexBufferLen <
dim_
)
29
throw
npstat::NpstatInvalidArgument
(
30
"In npstat::ArrayNDScanner::getIndex: "
31
"insufficient length of the output buffer"
);
32
if
(
state_
>=
maxState_
)
33
throw
npstat::NpstatRuntimeError
(
"In npstat::ArrayNDScanner::getIndex: invalid scanner state"
);
34
assert
(ix);
35
36
unsigned
long
l
=
state_
;
37
for
(
unsigned
i
= 0;
i
<
dim_
; ++
i
) {
38
unsigned
long
idx
=
l
/
strides_
[
i
];
39
ix[
i
] = static_cast<unsigned>(
idx
);
40
l
-= (
idx
*
strides_
[
i
]);
41
}
42
}
43
}
// namespace npstat
npstat::ArrayNDScanner::strides_
unsigned long strides_[CHAR_BIT *sizeof(unsigned long)]
Definition:
ArrayNDScanner.h:86
mps_fire.i
i
Definition:
mps_fire.py:428
npstat::ArrayNDScanner::initialize
void initialize(const unsigned *shape, unsigned lenShape)
Definition:
ArrayNDScanner.cc:7
cms::cuda::assert
assert(be >=bs)
npstat::ArrayNDScanner::maxState_
unsigned long maxState_
Definition:
ArrayNDScanner.h:88
npstat::ArrayNDScanner::getIndex
void getIndex(unsigned *index, unsigned indexBufferLen) const
Definition:
ArrayNDScanner.cc:27
heavyIonCSV_trainingSettings.idx
idx
Definition:
heavyIonCSV_trainingSettings.py:5
npstat
Definition:
AbsArrayProjector.h:14
npstat::NpstatRuntimeError
Definition:
NpstatException.h:46
npstat::NpstatInvalidArgument
Definition:
NpstatException.h:38
mitigatedMETSequence_cff.U
U
Definition:
mitigatedMETSequence_cff.py:36
npstat::ArrayNDScanner::dim_
unsigned dim_
Definition:
ArrayNDScanner.h:89
npstat::ArrayNDScanner::state_
unsigned long state_
Definition:
ArrayNDScanner.h:87
cmsLHEtoEOSManager.l
l
Definition:
cmsLHEtoEOSManager.py:204
ArrayNDScanner.h
Iteration over indices of a multidimensional array.
dqmiolumiharvest.j
j
Definition:
dqmiolumiharvest.py:66
NpstatException.h
Exceptions for the npstat namespace.
Generated for CMSSW Reference Manual by
1.8.16