CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Attributes
HGCal64BitRandomCodecImpl Class Reference

#include <HGCal64BitRandomCodecImpl.h>

Public Types

typedef HGCal64BitRandomDataPayload data_type
 

Public Member Functions

data_type decode (const std::vector< bool > &) const
 
std::vector< bool > encode (const data_type &) const
 
 HGCal64BitRandomCodecImpl (const edm::ParameterSet &conf)
 
void setDataPayload (data_type &)
 

Private Attributes

TRandom3 rand_
 

Detailed Description

Definition at line 13 of file HGCal64BitRandomCodecImpl.h.

Member Typedef Documentation

Definition at line 15 of file HGCal64BitRandomCodecImpl.h.

Constructor & Destructor Documentation

HGCal64BitRandomCodecImpl::HGCal64BitRandomCodecImpl ( const edm::ParameterSet conf)
inline

Definition at line 17 of file HGCal64BitRandomCodecImpl.h.

References edm::decode(), and alcaDQMUpload::encode().

17  {
18  rand_.SetSeed(0);
19  }

Member Function Documentation

HGCal64BitRandomCodecImpl::data_type HGCal64BitRandomCodecImpl::decode ( const std::vector< bool > &  data) const

Definition at line 29 of file HGCal64BitRandomCodecImpl.cc.

References mps_fire::i, HGCal64BitRandomDataPayload::payload, and mps_fire::result.

Referenced by encode().

29  {
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 }
HGCal64BitRandomDataPayload data_type
unsigned long long uint64_t
Definition: Time.h:15
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
std::vector< bool > HGCal64BitRandomCodecImpl::encode ( const data_type data) const

Definition at line 18 of file HGCal64BitRandomCodecImpl.cc.

References decode(), mps_fire::i, HGCal64BitRandomDataPayload::payload, mps_fire::result, and globals_cff::x1.

Referenced by setDataPayload().

18  {
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 }
HGCal64BitRandomDataPayload data_type
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
void HGCal64BitRandomCodecImpl::setDataPayload ( data_type data)

Definition at line 9 of file HGCal64BitRandomCodecImpl.cc.

References encode(), mps_fire::i, HGCal64BitRandomDataPayload::payload, and rand_.

9  {
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 }
HGCal64BitRandomDataPayload data_type
unsigned long long uint64_t
Definition: Time.h:15
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82

Member Data Documentation

TRandom3 HGCal64BitRandomCodecImpl::rand_
private

Definition at line 26 of file HGCal64BitRandomCodecImpl.h.

Referenced by setDataPayload().