EventFilter
CSCRawToDigi
src
bitset_append.cc
Go to the documentation of this file.
1
3
#include "
EventFilter/CSCRawToDigi/interface/bitset_append.h
"
4
#include <iostream>
5
#include <cstdio>
6
7
namespace
bitset_utilities
{
8
10
boost::dynamic_bitset<>
append
(
const
boost::dynamic_bitset<> &bs1,
const
boost::dynamic_bitset<> &bs2) {
11
boost::dynamic_bitset<>
result
(bs1.size() + bs2.size());
12
unsigned
size1 = bs1.size();
13
for
(
unsigned
i
= 0;
i
< size1; ++
i
) {
14
result
[
i
] = bs1[
i
];
15
}
16
for
(
unsigned
i
= 0;
i
< bs2.size(); ++
i
) {
17
result
[size1 +
i
] = bs2[
i
];
18
}
19
return
result
;
20
}
21
23
boost::dynamic_bitset<>
ushortToBitset
(
const
unsigned
int
numberOfBits,
unsigned
short
*
buf
) {
24
boost::dynamic_bitset<>
result
(numberOfBits);
25
for
(
unsigned
i
= 0;
i
<
result
.size(); ++
i
) {
26
result
[
i
] = (
buf
[
i
/ 16] >> (
i
% 16)) & 0x1;
27
}
28
return
result
;
29
}
30
32
void
bitsetToChar
(
const
boost::dynamic_bitset<> &
bs
,
unsigned
char
*
result
) {
33
for
(
unsigned
i
= 0;
i
<
bs
.size(); ++
i
) {
34
result
[
i
/ 8] = (
bs
[
i
+ 7] << 7) + (
bs
[
i
+ 6] << 6) + (
bs
[
i
+ 5] << 5) + (
bs
[
i
+ 4] << 4) + (
bs
[
i
+ 3] << 3) +
35
(
bs
[
i
+ 2] << 2) + (
bs
[
i
+ 1] << 1) +
bs
[
i
];
36
i
+= 7;
37
}
38
}
39
40
void
printWords
(
const
boost::dynamic_bitset<> &
bs
) {
41
constexpr
unsigned
int
nShorts = 30000;
42
unsigned
char
words[nShorts * 2];
43
bitsetToChar
(
bs
, words);
44
unsigned
short
*
buf
= (
unsigned
short
*)words;
45
for
(
int
unsigned
i
= 0;
i
<
bs
.size() / 16 &&
i
+ 3 < nShorts; ++
i
) {
46
printf(
"%04x %04x %04x %04x\n"
,
buf
[
i
+ 3],
buf
[
i
+ 2],
buf
[
i
+ 1],
buf
[
i
]);
47
i
+= 3;
48
}
49
}
50
}
// namespace bitset_utilities
mps_fire.i
i
Definition:
mps_fire.py:428
bitset_utilities::append
boost::dynamic_bitset append(const boost::dynamic_bitset<> &bs1, const boost::dynamic_bitset<> &bs2)
this method takes two bitsets bs1 and bs2 and returns result of bs2 appended to the end of bs1
Definition:
bitset_append.cc:10
bitset_utilities::bitsetToChar
void bitsetToChar(const boost::dynamic_bitset<> &bs, unsigned char *result)
this method takes bitset obj and returns char * array
Definition:
bitset_append.cc:32
cms::cuda::bs
bs
Definition:
HistoContainer.h:76
visDQMUpload.buf
buf
Definition:
visDQMUpload.py:160
bitset_utilities::ushortToBitset
boost::dynamic_bitset ushortToBitset(const unsigned int numberOfBits, unsigned short *buf)
this method takes numberOfBits bits from unsigned short * array and returns them in the bitset obj.
Definition:
bitset_append.cc:23
bitset_utilities
this file contains additional dynamic_bitset methods
Definition:
bitset_append.h:5
bitset_append.h
mps_fire.result
result
Definition:
mps_fire.py:311
bitset_utilities::printWords
void printWords(const boost::dynamic_bitset<> &bs)
Definition:
bitset_append.cc:40
Generated for CMSSW Reference Manual by
1.8.16