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 9 of file PhiMemoryImage.h.

Member Typedef Documentation

◆ value_type

typedef uint64_t PhiMemoryImage::value_type

Definition at line 11 of file PhiMemoryImage.h.

Constructor & Destructor Documentation

◆ PhiMemoryImage() [1/3]

PhiMemoryImage::PhiMemoryImage ( )

Definition at line 10 of file PhiMemoryImage.cc.

References reset().

10 { reset(); }

◆ ~PhiMemoryImage()

PhiMemoryImage::~PhiMemoryImage ( )

Definition at line 12 of file PhiMemoryImage.cc.

12 {}

◆ PhiMemoryImage() [2/3]

PhiMemoryImage::PhiMemoryImage ( const PhiMemoryImage other)

Definition at line 14 of file PhiMemoryImage.cc.

References _buffer, _layers, _straightness, _units, filterCSVwithJSON::copy, and trackingPlots::other.

14  {
15  std::copy(&(other._buffer[0][0]), &(other._buffer[0][0]) + (_layers * _units), &(_buffer[0][0]));
16 
17  _straightness = other._straightness;
18 }
static const unsigned int _units
value_type _buffer[_layers][_units]
static const unsigned int _layers

◆ PhiMemoryImage() [3/3]

PhiMemoryImage::PhiMemoryImage ( PhiMemoryImage &&  other)
noexcept

Definition at line 20 of file PhiMemoryImage.cc.

References trackingPlots::other, and edm::swap().

20 : PhiMemoryImage() { swap(other); }
void swap(PhiMemoryImage &other)

Member Function Documentation

◆ check_input()

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

Definition at line 71 of file PhiMemoryImage.cc.

References _layers, _units, triggerObjects_cff::bit, nano_mu_digi_cff::layer, UINT64_BITS, and unit().

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

71  {
72  if (layer >= _layers) {
73  char what[128];
74  snprintf(what, sizeof(what), "layer (which is %u) >= _layers (which is %u)", layer, _layers);
75  throw std::out_of_range(what);
76  }
77 
78  unsigned int unit = bit / UINT64_BITS;
79  if (unit >= _units) {
80  char what[128];
81  snprintf(what, sizeof(what), "unit (which is %u) >= _units (which is %u)", unit, _units);
82  throw std::out_of_range(what);
83  }
84 }
static const unsigned int _units
Basic3DVector unit() const
#define UINT64_BITS
static const unsigned int _layers

◆ clear_bit()

void PhiMemoryImage::clear_bit ( unsigned int  layer,
unsigned int  bit 
)

Definition at line 47 of file PhiMemoryImage.cc.

References _buffer, triggerObjects_cff::bit, check_input(), nano_mu_digi_cff::layer, ALPAKA_ACCELERATOR_NAMESPACE::pixelClustering::pixelStatus::mask, UINT64_BITS, and unit().

47  {
50  value_type mask = (1ul << (bit % UINT64_BITS));
51  _buffer[layer][unit] &= ~mask;
52 }
uint64_t value_type
value_type _buffer[_layers][_units]
Basic3DVector unit() const
void check_input(unsigned int layer, unsigned int bit) const
#define UINT64_BITS

◆ get_straightness()

int PhiMemoryImage::get_straightness ( ) const
inline

Definition at line 37 of file PhiMemoryImage.h.

References _straightness.

37 { return _straightness; }

◆ get_word()

PhiMemoryImage::value_type PhiMemoryImage::get_word ( unsigned int  layer,
unsigned int  unit 
) const

Definition at line 66 of file PhiMemoryImage.cc.

References _buffer, check_input(), nano_mu_digi_cff::layer, UINT64_BITS, and unit().

66  {
68  return _buffer[layer][unit];
69 }
value_type _buffer[_layers][_units]
Basic3DVector unit() const
void check_input(unsigned int layer, unsigned int bit) const
#define UINT64_BITS

◆ op_and()

unsigned int PhiMemoryImage::op_and ( const PhiMemoryImage other) const

Definition at line 144 of file PhiMemoryImage.cc.

References _buffer, _layers, _units, and trackingPlots::other.

144  {
145  static_assert((_layers == 4 && _units == 3), "This function assumes (_layers == 4 && _units == 3)");
146 
147  // Unroll
148  bool b_st1 = (_buffer[0][0] & other._buffer[0][0]) || (_buffer[0][1] & other._buffer[0][1]) ||
149  (_buffer[0][2] & other._buffer[0][2]);
150  bool b_st2 = (_buffer[1][0] & other._buffer[1][0]) || (_buffer[1][1] & other._buffer[1][1]) ||
151  (_buffer[1][2] & other._buffer[1][2]);
152  bool b_st3 = (_buffer[2][0] & other._buffer[2][0]) || (_buffer[2][1] & other._buffer[2][1]) ||
153  (_buffer[2][2] & other._buffer[2][2]);
154  bool b_st4 = (_buffer[3][0] & other._buffer[3][0]) || (_buffer[3][1] & other._buffer[3][1]) ||
155  (_buffer[3][2] & other._buffer[3][2]);
156 
157  // bit 0: st3 or st4 hit
158  // bit 1: st2 hit
159  // bit 2: st1 hit
160  unsigned int ly = (b_st1 << 2) | (b_st2 << 1) | (b_st3 << 0) | (b_st4 << 0);
161  return ly;
162 }
static const unsigned int _units
value_type _buffer[_layers][_units]
static const unsigned int _layers

◆ operator=()

PhiMemoryImage & PhiMemoryImage::operator= ( PhiMemoryImage  other)

Definition at line 23 of file PhiMemoryImage.cc.

References trackingPlots::other, and swap().

23  {
24  swap(other);
25  return *this;
26 }
void swap(PhiMemoryImage &other)

◆ print()

void PhiMemoryImage::print ( std::ostream &  out) const

Definition at line 164 of file PhiMemoryImage.cc.

References _buffer, nanoDQM_cfi::bitset, ALPAKA_ACCELERATOR_NAMESPACE::brokenline::constexpr(), N, and MillePedeFileConverter_cfg::out.

164  {
165  constexpr int N = 160;
166  out << std::bitset<N - 128>(_buffer[3][2]) << std::bitset<128 - 64>(_buffer[3][1]) << std::bitset<64>(_buffer[3][0])
167  << std::endl;
168  out << std::bitset<N - 128>(_buffer[2][2]) << std::bitset<128 - 64>(_buffer[2][1]) << std::bitset<64>(_buffer[2][0])
169  << std::endl;
170  out << std::bitset<N - 128>(_buffer[1][2]) << std::bitset<128 - 64>(_buffer[1][1]) << std::bitset<64>(_buffer[1][0])
171  << std::endl;
172  out << std::bitset<N - 128>(_buffer[0][2]) << std::bitset<128 - 64>(_buffer[0][1]) << std::bitset<64>(_buffer[0][0]);
173 }
value_type _buffer[_layers][_units]
#define N
Definition: blowfish.cc:9

◆ reset()

void PhiMemoryImage::reset ( void  )

Definition at line 34 of file PhiMemoryImage.cc.

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

Referenced by PhiMemoryImage().

34  {
35  std::fill(&(_buffer[0][0]), &(_buffer[0][0]) + (_layers * _units), 0);
36 
37  _straightness = 0;
38 }
static const unsigned int _units
value_type _buffer[_layers][_units]
static const unsigned int _layers

◆ rotl()

void PhiMemoryImage::rotl ( unsigned int  n)

Definition at line 88 of file PhiMemoryImage.cc.

References _buffer, _layers, _units, filterCSVwithJSON::copy, mps_fire::i, dqmiolumiharvest::j, ALPAKA_ACCELERATOR_NAMESPACE::pixelClustering::pixelStatus::mask, create_idmaps::n, createJobs::tmp, and UINT64_BITS.

Referenced by PatternRecognition::process_single_zone().

88  {
89  if (n >= _units * UINT64_BITS)
90  return;
91 
93  std::copy(&(_buffer[0][0]), &(_buffer[0][0]) + (_layers * _units), &(tmp[0][0]));
94 
95  const unsigned int mask = UINT64_BITS - 1;
96  const unsigned int n1 = n % UINT64_BITS;
97  const unsigned int n2 = _units - (n / UINT64_BITS);
98  const unsigned int n3 = (n1 == 0) ? n2 + 1 : n2;
99 
100  unsigned int i = 0, j = 0, j_curr = 0, j_next = 0;
101  for (i = 0; i < _layers; ++i) {
102  for (j = 0; j < _units; ++j) {
103  // if n2 == 0:
104  // j_curr = 0, 1, 2
105  // j_next = 2, 0, 1
106  // if n2 == 1:
107  // j_curr = 2, 0, 1
108  // j_next = 1, 2, 0
109  j_curr = (n2 + j) % _units;
110  j_next = (n3 + j + _units - 1) % _units;
111  _buffer[i][j] = (tmp[i][j_curr] << n1) | (tmp[i][j_next] >> (-n1 & mask));
112  }
113  }
114 }
static const unsigned int _units
uint64_t value_type
value_type _buffer[_layers][_units]
#define UINT64_BITS
tmp
align.sh
Definition: createJobs.py:716
static const unsigned int _layers

◆ rotr()

void PhiMemoryImage::rotr ( unsigned int  n)

Definition at line 116 of file PhiMemoryImage.cc.

References _buffer, _layers, _units, filterCSVwithJSON::copy, mps_fire::i, dqmiolumiharvest::j, ALPAKA_ACCELERATOR_NAMESPACE::pixelClustering::pixelStatus::mask, create_idmaps::n, createJobs::tmp, and UINT64_BITS.

Referenced by PatternRecognition::process_single_zone().

116  {
117  if (n >= _units * UINT64_BITS)
118  return;
119 
121  std::copy(&(_buffer[0][0]), &(_buffer[0][0]) + (_layers * _units), &(tmp[0][0]));
122 
123  const unsigned int mask = UINT64_BITS - 1;
124  const unsigned int n1 = n % UINT64_BITS;
125  const unsigned int n2 = n / UINT64_BITS;
126  const unsigned int n3 = (n1 == 0) ? n2 + _units - 1 : n2;
127 
128  unsigned int i = 0, j = 0, j_curr = 0, j_next = 0;
129  for (i = 0; i < _layers; ++i) {
130  for (j = 0; j < _units; ++j) {
131  // if n2 == 0:
132  // j_curr = 0, 1, 2
133  // j_next = 1, 2, 0
134  // if n2 == 1:
135  // j_curr = 2, 0, 1
136  // j_next = 0, 1, 2
137  j_curr = (n2 + j) % _units;
138  j_next = (n3 + j + 1) % _units;
139  _buffer[i][j] = (tmp[i][j_curr] >> n1) | (tmp[i][j_next] << (-n1 & mask));
140  }
141  }
142 }
static const unsigned int _units
uint64_t value_type
value_type _buffer[_layers][_units]
#define UINT64_BITS
tmp
align.sh
Definition: createJobs.py:716
static const unsigned int _layers

◆ set_bit()

void PhiMemoryImage::set_bit ( unsigned int  layer,
unsigned int  bit 
)

Definition at line 40 of file PhiMemoryImage.cc.

References _buffer, triggerObjects_cff::bit, check_input(), nano_mu_digi_cff::layer, ALPAKA_ACCELERATOR_NAMESPACE::pixelClustering::pixelStatus::mask, UINT64_BITS, and unit().

Referenced by PatternRecognition::make_zone_image().

40  {
43  value_type mask = (1ul << (bit % UINT64_BITS));
44  _buffer[layer][unit] |= mask;
45 }
uint64_t value_type
value_type _buffer[_layers][_units]
Basic3DVector unit() const
void check_input(unsigned int layer, unsigned int bit) const
#define UINT64_BITS

◆ set_straightness()

void PhiMemoryImage::set_straightness ( int  s)
inline

Definition at line 35 of file PhiMemoryImage.h.

References _straightness, and alignCSCRings::s.

◆ set_word()

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

Definition at line 61 of file PhiMemoryImage.cc.

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

61  {
63  _buffer[layer][unit] = value;
64 }
value_type _buffer[_layers][_units]
Basic3DVector unit() const
void check_input(unsigned int layer, unsigned int bit) const
#define UINT64_BITS

◆ swap()

void PhiMemoryImage::swap ( PhiMemoryImage other)

Definition at line 28 of file PhiMemoryImage.cc.

References _buffer, _layers, _straightness, _units, trackingPlots::other, and edm::swap().

Referenced by operator=().

28  {
29  std::swap_ranges(&(other._buffer[0][0]), &(other._buffer[0][0]) + (_layers * _units), &(_buffer[0][0]));
30 
31  std::swap(other._straightness, _straightness);
32 }
static const unsigned int _units
void swap(Association< C > &lhs, Association< C > &rhs)
Definition: Association.h:112
value_type _buffer[_layers][_units]
static const unsigned int _layers

◆ test_bit()

bool PhiMemoryImage::test_bit ( unsigned int  layer,
unsigned int  bit 
) const

Definition at line 54 of file PhiMemoryImage.cc.

References _buffer, triggerObjects_cff::bit, check_input(), nano_mu_digi_cff::layer, ALPAKA_ACCELERATOR_NAMESPACE::pixelClustering::pixelStatus::mask, UINT64_BITS, and unit().

54  {
57  value_type mask = (1ul << (bit % UINT64_BITS));
58  return _buffer[layer][unit] & mask;
59 }
uint64_t value_type
value_type _buffer[_layers][_units]
Basic3DVector unit() const
void check_input(unsigned int layer, unsigned int bit) const
#define UINT64_BITS

Member Data Documentation

◆ _buffer

value_type PhiMemoryImage::_buffer[_layers][_units]
private

◆ _layers

const unsigned int PhiMemoryImage::_layers = 4
staticprivate

Definition at line 59 of file PhiMemoryImage.h.

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

◆ _straightness

int PhiMemoryImage::_straightness
private

Definition at line 68 of file PhiMemoryImage.h.

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

◆ _units

const unsigned int PhiMemoryImage::_units = 3
staticprivate

Definition at line 63 of file PhiMemoryImage.h.

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