CMS 3D CMS Logo

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

#include <PhiMemoryImage.h>

Public Types

typedef uint64_t value_type
 

Public Member Functions

void clear_bit (unsigned int layer, unsigned int bit)
 
int get_straightness () const
 
value_type get_word (unsigned int layer, unsigned int unit) const
 
unsigned int op_and (const PhiMemoryImage &other) const
 
PhiMemoryImageoperator= (PhiMemoryImage other)
 
 PhiMemoryImage ()
 
 PhiMemoryImage (const PhiMemoryImage &other)
 
 PhiMemoryImage (PhiMemoryImage &&other) noexcept
 
void print (std::ostream &out) const
 
void reset ()
 
void rotl (unsigned int n)
 
void rotr (unsigned int n)
 
void set_bit (unsigned int layer, unsigned int bit)
 
void set_straightness (int s)
 
void set_word (unsigned int layer, unsigned int unit, value_type value)
 
void swap (PhiMemoryImage &other)
 
bool test_bit (unsigned int layer, unsigned int bit) const
 
 ~PhiMemoryImage ()
 

Private Member Functions

void check_input (unsigned int layer, unsigned int bit) const
 

Private Attributes

value_type _buffer [_layers][_units]
 
int _straightness
 

Static Private Attributes

static const unsigned int _layers = 4
 
static const unsigned int _units = 3
 

Detailed Description

Definition at line 10 of file PhiMemoryImage.h.

Member Typedef Documentation

typedef uint64_t PhiMemoryImage::value_type

Definition at line 12 of file PhiMemoryImage.h.

Constructor & Destructor Documentation

PhiMemoryImage::PhiMemoryImage ( )

Definition at line 11 of file PhiMemoryImage.cc.

References reset().

11  {
12  reset();
13 }
PhiMemoryImage::~PhiMemoryImage ( )

Definition at line 15 of file PhiMemoryImage.cc.

15  {
16 
17 }
PhiMemoryImage::PhiMemoryImage ( const PhiMemoryImage other)

Definition at line 19 of file PhiMemoryImage.cc.

References _buffer, _layers, _straightness, _units, and popcon2dropbox::copy().

19  {
20  std::copy(&(other._buffer[0][0]), &(other._buffer[0][0]) + (_layers*_units), &(_buffer[0][0]));
21 
23 }
static const unsigned int _units
value_type _buffer[_layers][_units]
static const unsigned int _layers
PhiMemoryImage::PhiMemoryImage ( PhiMemoryImage &&  other)
noexcept

Definition at line 25 of file PhiMemoryImage.cc.

References trackingPlots::other, and swap().

25  : PhiMemoryImage() {
26  swap(other);
27 }
void swap(PhiMemoryImage &other)

Member Function Documentation

void PhiMemoryImage::check_input ( unsigned int  layer,
unsigned int  bit 
) const
private

Definition at line 78 of file PhiMemoryImage.cc.

References _layers, _units, UINT64_BITS, and csvLumiCalc::unit.

Referenced by clear_bit(), get_straightness(), get_word(), set_bit(), set_word(), and test_bit().

78  {
79  if (layer >= _layers) {
80  char what[128];
81  snprintf(what, sizeof(what), "layer (which is %u) >= _layers (which is %u)", layer, _layers);
82  throw std::out_of_range(what);
83  }
84 
85  unsigned int unit = bit / UINT64_BITS;
86  if (unit >= _units) {
87  char what[128];
88  snprintf(what, sizeof(what), "unit (which is %u) >= _units (which is %u)", unit, _units);
89  throw std::out_of_range(what);
90  }
91 }
static const unsigned int _units
#define UINT64_BITS
static const unsigned int _layers
void PhiMemoryImage::clear_bit ( unsigned int  layer,
unsigned int  bit 
)

Definition at line 54 of file PhiMemoryImage.cc.

References _buffer, check_input(), RecoTauDiscriminantConfiguration::mask, UINT64_BITS, and csvLumiCalc::unit.

54  {
55  check_input(layer, bit);
56  value_type unit = bit / UINT64_BITS;
57  value_type mask = (1ul << (bit % UINT64_BITS));
58  _buffer[layer][unit] &= ~mask;
59 }
uint64_t value_type
void check_input(unsigned int layer, unsigned int bit) const
value_type _buffer[_layers][_units]
#define UINT64_BITS
int PhiMemoryImage::get_straightness ( ) const
inline
PhiMemoryImage::value_type PhiMemoryImage::get_word ( unsigned int  layer,
unsigned int  unit 
) const

Definition at line 73 of file PhiMemoryImage.cc.

References _buffer, check_input(), UINT64_BITS, and csvLumiCalc::unit.

73  {
75  return _buffer[layer][unit];
76 }
void check_input(unsigned int layer, unsigned int bit) const
value_type _buffer[_layers][_units]
#define UINT64_BITS
unsigned int PhiMemoryImage::op_and ( const PhiMemoryImage other) const

Definition at line 151 of file PhiMemoryImage.cc.

References _buffer, _layers, and _units.

Referenced by get_straightness(), and PatternRecognition::process_single_zone().

151  {
152  if (not(_layers == 4 && _units == 3))
153  { edm::LogError("L1T") << "_layers = " << _layers << ", _units = " << _units; return 0; }
154 
155  // Unroll
156  bool b_st1 = (_buffer[0][0] & other._buffer[0][0]) ||
157  (_buffer[0][1] & other._buffer[0][1]) ||
158  (_buffer[0][2] & other._buffer[0][2]);
159  bool b_st2 = (_buffer[1][0] & other._buffer[1][0]) ||
160  (_buffer[1][1] & other._buffer[1][1]) ||
161  (_buffer[1][2] & other._buffer[1][2]);
162  bool b_st3 = (_buffer[2][0] & other._buffer[2][0]) ||
163  (_buffer[2][1] & other._buffer[2][1]) ||
164  (_buffer[2][2] & other._buffer[2][2]);
165  bool b_st4 = (_buffer[3][0] & other._buffer[3][0]) ||
166  (_buffer[3][1] & other._buffer[3][1]) ||
167  (_buffer[3][2] & other._buffer[3][2]);
168 
169  // bit 0: st3 or st4 hit
170  // bit 1: st2 hit
171  // bit 2: st1 hit
172  unsigned int ly = (b_st1 << 2) | (b_st2 << 1) | (b_st3 << 0) | (b_st4 << 0);
173  return ly;
174 }
static const unsigned int _units
value_type _buffer[_layers][_units]
static const unsigned int _layers
PhiMemoryImage & PhiMemoryImage::operator= ( PhiMemoryImage  other)

Definition at line 30 of file PhiMemoryImage.cc.

References swap().

30  {
31  swap(other);
32  return *this;
33 }
void swap(PhiMemoryImage &other)
void PhiMemoryImage::print ( std::ostream &  out) const

Definition at line 176 of file PhiMemoryImage.cc.

References _buffer, constexpr, and N.

Referenced by get_straightness(), and operator<<().

176  {
177  constexpr int N = 160;
178  out << std::bitset<N-128>(_buffer[3][2]) << std::bitset<128-64>(_buffer[3][1]) << std::bitset<64>(_buffer[3][0]) << std::endl;
179  out << std::bitset<N-128>(_buffer[2][2]) << std::bitset<128-64>(_buffer[2][1]) << std::bitset<64>(_buffer[2][0]) << std::endl;
180  out << std::bitset<N-128>(_buffer[1][2]) << std::bitset<128-64>(_buffer[1][1]) << std::bitset<64>(_buffer[1][0]) << std::endl;
181  out << std::bitset<N-128>(_buffer[0][2]) << std::bitset<128-64>(_buffer[0][1]) << std::bitset<64>(_buffer[0][0]);
182 }
#define constexpr
value_type _buffer[_layers][_units]
#define N
Definition: blowfish.cc:9
void PhiMemoryImage::reset ( void  )

Definition at line 41 of file PhiMemoryImage.cc.

References _buffer, _layers, _straightness, _units, and lumiContext::fill.

Referenced by PhiMemoryImage().

41  {
42  std::fill(&(_buffer[0][0]), &(_buffer[0][0]) + (_layers*_units), 0);
43 
44  _straightness = 0;
45 }
static const unsigned int _units
value_type _buffer[_layers][_units]
static const unsigned int _layers
void PhiMemoryImage::rotl ( unsigned int  n)

Definition at line 95 of file PhiMemoryImage.cc.

References _buffer, _layers, _units, popcon2dropbox::copy(), mps_fire::i, RecoTauDiscriminantConfiguration::mask, tmp, and UINT64_BITS.

Referenced by get_straightness(), and PatternRecognition::process_single_zone().

95  {
96  if (n >= _units*UINT64_BITS)
97  return;
98 
100  std::copy(&(_buffer[0][0]), &(_buffer[0][0]) + (_layers*_units), &(tmp[0][0]));
101 
102  const unsigned int mask = UINT64_BITS - 1;
103  const unsigned int n1 = n % UINT64_BITS;
104  const unsigned int n2 = _units - (n / UINT64_BITS);
105  const unsigned int n3 = (n1 == 0) ? n2+1 : n2;
106 
107  unsigned int i = 0, j = 0, j_curr = 0, j_next = 0;
108  for (i = 0; i < _layers; ++i) {
109  for (j = 0; j < _units; ++j) {
110  // if n2 == 0:
111  // j_curr = 0, 1, 2
112  // j_next = 2, 0, 1
113  // if n2 == 1:
114  // j_curr = 2, 0, 1
115  // j_next = 1, 2, 0
116  j_curr = (n2+j) % _units;
117  j_next = (n3+j+_units-1) % _units;
118  _buffer[i][j] = (tmp[i][j_curr] << n1) | (tmp[i][j_next] >> (-n1 & mask));
119  }
120  }
121 }
static const unsigned int _units
uint64_t value_type
value_type _buffer[_layers][_units]
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
#define UINT64_BITS
static const unsigned int _layers
void PhiMemoryImage::rotr ( unsigned int  n)

Definition at line 123 of file PhiMemoryImage.cc.

References _buffer, _layers, _units, popcon2dropbox::copy(), mps_fire::i, RecoTauDiscriminantConfiguration::mask, tmp, and UINT64_BITS.

Referenced by PatternRecognition::configure_details(), get_straightness(), and PatternRecognition::process_single_zone().

123  {
124  if (n >= _units*UINT64_BITS)
125  return;
126 
128  std::copy(&(_buffer[0][0]), &(_buffer[0][0]) + (_layers*_units), &(tmp[0][0]));
129 
130  const unsigned int mask = UINT64_BITS - 1;
131  const unsigned int n1 = n % UINT64_BITS;
132  const unsigned int n2 = n / UINT64_BITS;
133  const unsigned int n3 = (n1 == 0) ? n2+_units-1 : n2;
134 
135  unsigned int i = 0, j = 0, j_curr = 0, j_next = 0;
136  for (i = 0; i < _layers; ++i) {
137  for (j = 0; j < _units; ++j) {
138  // if n2 == 0:
139  // j_curr = 0, 1, 2
140  // j_next = 1, 2, 0
141  // if n2 == 1:
142  // j_curr = 2, 0, 1
143  // j_next = 0, 1, 2
144  j_curr = (n2+j)% _units;
145  j_next = (n3+j+1) % _units;
146  _buffer[i][j] = (tmp[i][j_curr] >> n1) | (tmp[i][j_next] << (-n1 & mask));
147  }
148  }
149 }
static const unsigned int _units
uint64_t value_type
value_type _buffer[_layers][_units]
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
#define UINT64_BITS
static const unsigned int _layers
void PhiMemoryImage::set_bit ( unsigned int  layer,
unsigned int  bit 
)

Definition at line 47 of file PhiMemoryImage.cc.

References _buffer, check_input(), RecoTauDiscriminantConfiguration::mask, UINT64_BITS, and csvLumiCalc::unit.

Referenced by PatternRecognition::configure_details(), and PatternRecognition::make_zone_image().

47  {
48  check_input(layer, bit);
49  value_type unit = bit / UINT64_BITS;
50  value_type mask = (1ul << (bit % UINT64_BITS));
51  _buffer[layer][unit] |= mask;
52 }
uint64_t value_type
void check_input(unsigned int layer, unsigned int bit) const
value_type _buffer[_layers][_units]
#define UINT64_BITS
void PhiMemoryImage::set_straightness ( int  s)
inline

Definition at line 36 of file PhiMemoryImage.h.

References _straightness, and alignCSCRings::s.

Referenced by PatternRecognition::configure_details().

void PhiMemoryImage::set_word ( unsigned int  layer,
unsigned int  unit,
value_type  value 
)

Definition at line 68 of file PhiMemoryImage.cc.

References _buffer, check_input(), UINT64_BITS, csvLumiCalc::unit, and relativeConstraints::value.

68  {
70  _buffer[layer][unit] = value;
71 }
void check_input(unsigned int layer, unsigned int bit) const
value_type _buffer[_layers][_units]
#define UINT64_BITS
void PhiMemoryImage::swap ( PhiMemoryImage other)

Definition at line 35 of file PhiMemoryImage.cc.

References _buffer, _layers, _straightness, _units, and std::swap().

Referenced by operator=(), and PhiMemoryImage().

35  {
36  std::swap_ranges(&(other._buffer[0][0]), &(other._buffer[0][0]) + (_layers*_units), &(_buffer[0][0]));
37 
39 }
static const unsigned int _units
value_type _buffer[_layers][_units]
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
static const unsigned int _layers
bool PhiMemoryImage::test_bit ( unsigned int  layer,
unsigned int  bit 
) const

Definition at line 61 of file PhiMemoryImage.cc.

References _buffer, check_input(), RecoTauDiscriminantConfiguration::mask, UINT64_BITS, and csvLumiCalc::unit.

61  {
62  check_input(layer, bit);
63  value_type unit = bit / UINT64_BITS;
64  value_type mask = (1ul << (bit % UINT64_BITS));
65  return _buffer[layer][unit] & mask;
66 }
uint64_t value_type
void check_input(unsigned int layer, unsigned int bit) const
value_type _buffer[_layers][_units]
#define UINT64_BITS

Member Data Documentation

value_type PhiMemoryImage::_buffer[_layers][_units]
private
const unsigned int PhiMemoryImage::_layers = 4
staticprivate

Definition at line 60 of file PhiMemoryImage.h.

Referenced by check_input(), op_and(), PhiMemoryImage(), reset(), rotl(), rotr(), and swap().

int PhiMemoryImage::_straightness
private

Definition at line 69 of file PhiMemoryImage.h.

Referenced by get_straightness(), PhiMemoryImage(), reset(), set_straightness(), and swap().

const unsigned int PhiMemoryImage::_units = 3
staticprivate

Definition at line 64 of file PhiMemoryImage.h.

Referenced by check_input(), op_and(), PhiMemoryImage(), reset(), rotl(), rotr(), and swap().