CMS 3D CMS Logo

BitSet.cc
Go to the documentation of this file.
3 
4 namespace PhysicsTools {
5 
7  static constexpr unsigned char byteBits[256] = {
8  0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 1, 2, 2, 3, 2,
9  3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3,
10  3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5,
11  6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4,
12  3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4,
13  5, 5, 6, 5, 6, 6, 7, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6,
14  6, 7, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8};
15  const unsigned char *begin = reinterpret_cast<const unsigned char *>(store);
16  const unsigned char *end = reinterpret_cast<const unsigned char *>(store + bitsToWords(bits_));
17 
18  size_t bits = 0;
19  for (const unsigned char *p = begin; p < end; p++)
20  bits += byteBits[*p];
21 
22  return bits;
23  }
24 
26  PhysicsTools::BitSet::size_t size = bitSet.store.size();
27  size = (size - 1) * 8 + (bitSet.bitsInLast + 7) % 8 + 1;
28 
30  for (PhysicsTools::BitSet::size_t i = 0; i < size; i++)
31  result[i] = bitSet.store[i / 8] & (1 << (i % 8));
32 
33  return result;
34  }
35 
38  PhysicsTools::BitSet::size_t bytes = (size + 7) / 8;
39 
41  result.store.resize(bytes);
42  result.bitsInLast = (size + 7) % 8 + 1;
43 
44  for (PhysicsTools::BitSet::size_t i = 0; i < size; i++)
45  result.store[i / 8] |= bitSet[i] ? (1 << (i % 8)) : 0;
46 
47  return result;
48  }
49 
50 } // namespace PhysicsTools
PhysicsTools::Calibration::convert
PhysicsTools::BitSet convert(const BitSet &bitSet)
constructs BitSet container from persistent representation
Definition: BitSet.cc:25
PhysicsTools::BitSet::bits_
size_t bits_
Definition: BitSet.h:187
mps_fire.i
i
Definition: mps_fire.py:355
PhysicsTools::Calibration::BitSet::store
std::vector< unsigned char > store
Definition: MVAComputer.h:38
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
PhysicsTools::BitSet::size
size_t size() const
returns the number of all bits in the container
Definition: BitSet.h:173
PhysicsTools::BitSet::size_t
std::size_t size_t
Definition: BitSet.h:31
end
#define end
Definition: vmac.h:39
PhysicsTools::Calibration::BitSet::bitsInLast
unsigned int bitsInLast
Definition: MVAComputer.h:39
BitSet.h
PhysicsTools::BitSet::store
Word_t * store
Definition: BitSet.h:186
PhysicsTools
Definition: Histogram.h:13
PhysicsTools::Calibration::BitSet
Definition: MVAComputer.h:29
PhysicsTools::BitSet::bits
size_t bits() const
returns the number of set bits in the container
Definition: BitSet.cc:6
PhysicsTools::BitSet::bitsToWords
static size_t bitsToWords(std::size_t bits)
Definition: BitSet.h:182
PhysicsTools::BitSet
A compact container for storing single bits.
Definition: BitSet.h:29
Calibration.h
mps_fire.result
result
Definition: mps_fire.py:303
begin
#define begin
Definition: vmac.h:32
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443