test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HGCal64BitRandomCodecImpl.cc
Go to the documentation of this file.
3 
4 #include <limits>
5 #include "TRandom3.h"
6 
7 
10  data.payload = 0;
11  for( unsigned i = 0; i < 8*sizeof(data_type); ++i ) {
12  data.payload |= static_cast<uint64_t>(rand_.Rndm() > 0.5) << i;
13  }
14 }
15 
16 std::vector<bool>
19  std::vector<bool> result;
20  result.resize(8*sizeof(data_type));
21  for( unsigned i = 0; i < 8*sizeof(data_type); ++i ) {
22  result[i] = static_cast<bool>((data.payload >> i) & 0x1);
23  }
24  return result;
25 }
26 
29 decode(const std::vector<bool>& data) const {
31  result.payload = 0;
32  if( data.size() > 8*sizeof(data_type) ) {
33  edm::LogWarning("HGCal64BitRandomCodecImpl|TruncateInput")
34  << "Input to be encoded was larger than data size: "
35  << sizeof(data_type) << ". Truncating to fit!";
36  }
37  for( unsigned i = 0; i < 8*sizeof(data_type); ++i ) {
38  result.payload |= static_cast<uint64_t>(data[i]) << i;
39  }
40  return result;
41 }
42 
43 
int i
Definition: DBlmapReader.cc:9
std::vector< bool > encode(const data_type &) const
tuple result
Definition: mps_fire.py:84
HGCal64BitRandomDataPayload data_type
data_type decode(const std::vector< bool > &) const
unsigned long long uint64_t
Definition: Time.h:15
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82