CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Static Public Attributes | Private Attributes
PhiMemoryImage Class Reference

#include <PhiMemoryImage.h>

Public Types

typedef
PhiMemoryImage::value_type
value_ptr
 
typedef unsigned long int value_type
 

Public Member Functions

void BitShift (int nBits)
 
void CopyFromBuffer (PhiMemoryImage::value_ptr rhs, int offset)
 functions/// More...
 
bool GetBit (int station, int bitNumber) const
 
PhiMemoryImage::value_typeoperator[] (int index)
 
 PhiMemoryImage ()
 constructors/// More...
 
 PhiMemoryImage (PhiMemoryImage::value_ptr buffer, int offset)
 
 PhiMemoryImage (value_type s1a, value_type s1b, value_type s1c, value_type s2a, value_type s2b, value_type s2c, value_type s3a, value_type s3b, value_type s3c, value_type s4a, value_type s4b, value_type s4c)
 
void Print ()
 
void printbuff ()
 
void SetBit (int station, int bitNumber, bool value=true)
 
void SetBuff (int chunk, int value)
 

Static Public Attributes

static const int STATIONS = 4
 
static const int TOTAL_UNITS = UNITS * STATIONS
 
static const int UNITS = 3
 

Private Attributes

PhiMemoryImage::value_type _buffer [PhiMemoryImage::TOTAL_UNITS]
 
int _keyStationOffset
 

Detailed Description

Definition at line 4 of file PhiMemoryImage.h.

Member Typedef Documentation

Definition at line 9 of file PhiMemoryImage.h.

typedef unsigned long int PhiMemoryImage::value_type

Definition at line 8 of file PhiMemoryImage.h.

Constructor & Destructor Documentation

PhiMemoryImage::PhiMemoryImage ( )

constructors///

Definition at line 4 of file PhiMemoryImage.cc.

References _buffer, i, and TOTAL_UNITS.

5  for (int i = 0; i < PhiMemoryImage::TOTAL_UNITS; i++) _buffer[i] = 0;
6 }
int i
Definition: DBlmapReader.cc:9
PhiMemoryImage::value_type _buffer[PhiMemoryImage::TOTAL_UNITS]
static const int TOTAL_UNITS
PhiMemoryImage::PhiMemoryImage ( PhiMemoryImage::value_ptr  buffer,
int  offset 
)

Definition at line 8 of file PhiMemoryImage.cc.

References CopyFromBuffer().

9 
10  CopyFromBuffer( buffer, offset );
11 
12 }
void CopyFromBuffer(PhiMemoryImage::value_ptr rhs, int offset)
functions///
PhiMemoryImage::PhiMemoryImage ( value_type  s1a,
value_type  s1b,
value_type  s1c,
value_type  s2a,
value_type  s2b,
value_type  s2c,
value_type  s3a,
value_type  s3b,
value_type  s3c,
value_type  s4a,
value_type  s4b,
value_type  s4c 
)
inline

Definition at line 20 of file PhiMemoryImage.h.

References _buffer.

23  {
24  _buffer[0] = s1a;_buffer[1] = s1b;_buffer[2] = s1c;
25  _buffer[3] = s2a;_buffer[4] = s2b;_buffer[5] = s2c;
26  _buffer[6] = s3a;_buffer[7] = s3b;_buffer[8] = s3c;
27  _buffer[9] = s4a;_buffer[10] = s4b;_buffer[11] = s4c;
28  }
PhiMemoryImage::value_type _buffer[PhiMemoryImage::TOTAL_UNITS]

Member Function Documentation

void PhiMemoryImage::BitShift ( int  nBits)

Definition at line 103 of file PhiMemoryImage.cc.

References _buffer, i, and STATIONS.

Referenced by DetectPatterns().

103  {
104 
105  if (nBits == 0) return;
106 
107  bool negShift = (nBits < 0);
108 
109  if (negShift) nBits = -nBits;
110 
111  PhiMemoryImage::value_type transferBits, transferBits2;
112  int value_size = sizeof(transferBits)*8;//should be hardcoded total units?
113 
114  //std::cout<<"value_size = "<<value_size<<"\n";
115 
116  for (int i = 0; i < PhiMemoryImage::STATIONS; i++){
117 
118  if (negShift){
119 
120  transferBits = (0x1 << nBits) - 1;
121  transferBits &= _buffer[3*i+1];
122 
123  transferBits2 = (0x1 << nBits) - 1;
124  transferBits2 &= _buffer[3*i+2];
125 
126  _buffer[3*i+2] >>= nBits;
127  _buffer[3*i+1] >>= nBits;
128  _buffer[3*i] >>= nBits;
129 
130  transferBits <<= (value_size - nBits);
131  transferBits2 <<= (value_size - nBits);
132 
133  _buffer[3*i] |= transferBits;
134  _buffer[3*i+1] |= transferBits2;
135 
136  } else {
137 
138  transferBits = (0x1 << nBits) - 1;
139  transferBits <<= (value_size - nBits);
140 
141  transferBits2 = (0x1 << nBits) - 1;
142  transferBits2 <<= (value_size - nBits);
143 
144  // if(!i){
145 
146  // std::cout<<"tb = "<<transferBits<<"\n";
147  //std::cout<<"tb2 = "<<transferBits2<<"\n";
148 
149  // std::cout<<"buf+0 = "<<_buffer[3*i]<<"\n";
150  // std::cout<<"buf+1 = "<<_buffer[3*i+1]<<"\n";
151  // std::cout<<"buf+2 = "<<_buffer[3*i+2]<<"\n";
152  // }
153 
154  transferBits &= _buffer[3*i];
155  transferBits >>= (value_size - nBits);
156 
157  transferBits2 &= _buffer[3*i+1];
158  transferBits2 >>= (value_size - nBits);
159 
160  //if(!i){
161  // std::cout<<"tb = "<<transferBits<<"\n";
162  // std::cout<<"tb2 = "<<transferBits2<<"\n";
163  // }
164  _buffer[3*i] <<= nBits;
165  _buffer[3*i+1] <<= nBits;
166  _buffer[3*i+2] <<= nBits;
167 
168  // if(!i){
169  // std::cout<<"buf+0 = "<<_buffer[3*i]<<"\n";
170  // std::cout<<"buf+1 = "<<_buffer[3*i+1]<<"\n";
171  // std::cout<<"buf+2 = "<<_buffer[3*i+2]<<"\n";
172  // }
173 
174  _buffer[3*i+1] |= transferBits;
175  _buffer[3*i+2] |= transferBits2;
176 
177  // if(!i){
178 
179  // std::cout<<"tb = "<<transferBits<<"\n";
180  // std::cout<<"tb2 = "<<transferBits2<<"\n";
181  //
182  // std::cout<<"buf+0 = "<<_buffer[3*i]<<"\n";
183  // std::cout<<"buf+1 = "<<_buffer[3*i+1]<<"\n";
184  // std::cout<<"buf+2 = "<<_buffer[3*i+2]<<"\n";
185  //}
186  }
187  }
188 
189 }
int i
Definition: DBlmapReader.cc:9
static const int STATIONS
PhiMemoryImage::value_type _buffer[PhiMemoryImage::TOTAL_UNITS]
unsigned long int value_type
Definition: PhiMemoryImage.h:8
void PhiMemoryImage::CopyFromBuffer ( PhiMemoryImage::value_ptr  rhs,
int  offset 
)

functions///

Definition at line 14 of file PhiMemoryImage.cc.

References _buffer, _keyStationOffset, i, hltrates_dqm_sourceclient-live_cfg::offset, and TOTAL_UNITS.

Referenced by PhiMemoryImage().

14  {
15 
17 
18  for (int i = 0; i < PhiMemoryImage::TOTAL_UNITS; i++){
19  _buffer[i] = rhs[i];
20 
21  }
22 
23 }
int i
Definition: DBlmapReader.cc:9
PhiMemoryImage::value_type _buffer[PhiMemoryImage::TOTAL_UNITS]
static const int TOTAL_UNITS
bool PhiMemoryImage::GetBit ( int  station,
int  bitNumber 
) const

changed this

Definition at line 75 of file PhiMemoryImage.cc.

References _buffer, findQualityFiles::size, tmp, TOTAL_UNITS, and UNITS.

Referenced by Print().

75  {
76 
78  int size = sizeof (PhiMemoryImage::value_type) * 8;// should be hardcoded total units?
79 
80  if (bitNumber > (size * PhiMemoryImage::TOTAL_UNITS)){
81  // complain in some way .. to be implemented..
82  return false;
83  }
84 
85  bitNumber -= 1;
86  station -=1;
87 
88  int chunkNumber = station*PhiMemoryImage::UNITS + ((bitNumber-1) / size);
89  int bitOffset = bitNumber % size;
90  if(bitNumber == 64 || bitNumber == 128){chunkNumber += 1;}
91 
92  tmp <<= bitOffset;
93 
94  // std::cout << "chunkNumber: " << chunkNumber << "bitOffset:"
95  // << bitOffset << "tmp: " << tmp << std::endl;
96  //std::cout<<"buffer["<<chunkNumber<<"] = "<<_buffer[chunkNumber]<<std::endl;
97  // std::cout<<"buffer["<<chunkNumber + 1<<"] = "<<_buffer[chunkNumber+1]<<std::endl;
98 
99  return ((_buffer[chunkNumber] & tmp) != 0);
100 
101 }
static const int UNITS
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
PhiMemoryImage::value_type _buffer[PhiMemoryImage::TOTAL_UNITS]
unsigned long int value_type
Definition: PhiMemoryImage.h:8
static const int TOTAL_UNITS
tuple size
Write out results.
PhiMemoryImage::value_type& PhiMemoryImage::operator[] ( int  index)
inline

Definition at line 46 of file PhiMemoryImage.h.

References _buffer, and cmsHarvester::index.

47  {return _buffer[index];}
PhiMemoryImage::value_type _buffer[PhiMemoryImage::TOTAL_UNITS]
void PhiMemoryImage::Print ( void  )

Definition at line 191 of file PhiMemoryImage.cc.

References gather_cfg::cout, GetBit(), i, j, findQualityFiles::size, STATIONS, and UNITS.

191  {
192 
193  int size = PhiMemoryImage::UNITS * sizeof(PhiMemoryImage::value_type)*8;//should be hardcoded total units>?
194 
195  for (int i = 1; i <= PhiMemoryImage::STATIONS; i++){
196 
197  // std::cout << _buffer[(i-1)*2] << " " << _buffer [(i-1)*2+1] << std::endl;
198 
199  for (int j = size; j > 0; j--){
200 
201  if ((j%(sizeof(PhiMemoryImage::value_type)*8)) == 0)//should be hardcoded total units>? ->no
202  std::cout << std::endl;
203 
204 
205  if ((j%8)==0) std::cout << " ";
206  if(GetBit(i,j)) std::cout << "1";
207  else std::cout << "0";
208 
209  }
210  std::cout << std::endl;
211  }
212 
213 }
int i
Definition: DBlmapReader.cc:9
static const int STATIONS
int j
Definition: DBlmapReader.cc:9
static const int UNITS
bool GetBit(int station, int bitNumber) const
unsigned long int value_type
Definition: PhiMemoryImage.h:8
tuple cout
Definition: gather_cfg.py:145
tuple size
Write out results.
void PhiMemoryImage::printbuff ( )

Definition at line 215 of file PhiMemoryImage.cc.

References _buffer, gather_cfg::cout, i, and TOTAL_UNITS.

215  {
216 
217  for(int i=0;i<PhiMemoryImage::TOTAL_UNITS;i++){
218  std::cout<<"buffer["<<i<<"] = "<<_buffer[i]<<std::endl;
219  }
220  std::cout<<std::endl;
221 }
int i
Definition: DBlmapReader.cc:9
PhiMemoryImage::value_type _buffer[PhiMemoryImage::TOTAL_UNITS]
tuple cout
Definition: gather_cfg.py:145
static const int TOTAL_UNITS
void PhiMemoryImage::SetBit ( int  station,
int  bitNumber,
bool  value = true 
)

Definition at line 31 of file PhiMemoryImage.cc.

References _buffer, gather_cfg::cout, findQualityFiles::size, tmp, TOTAL_UNITS, and UNITS.

31  {
32 
33  //std::cout<<"bitnumber = "<<bitNumber<<std::endl;
34  // std::cout<<"station = "<<station<<std::endl;
35 
36  PhiMemoryImage::value_type tmp = 1;//64 bit word
37  int size = sizeof (PhiMemoryImage::value_type) * 8;//64 // <- should be hard coded total units?
38 
39  if (bitNumber > size * PhiMemoryImage::TOTAL_UNITS){
40  // complain in some way .. to be implemented..
41 
42  std::cout<<"bit number is greater than total size. Don't do that!\n";
43  return;
44  }
45 
46  station = station-1;
47  bitNumber = bitNumber-1;
48 
49  // std::cout<<"bitnumber = "<<bitNumber<<std::endl;
50  // std::cout<<"station = "<<station<<std::endl;
51 
52  int chunkNumber = station*PhiMemoryImage::UNITS + (bitNumber-1) / size;
53  int bitOffset = bitNumber % size;
54  if(bitNumber == 64 || bitNumber == 128){chunkNumber += 1;}
55 
56  // std::cout<<"chunknumber = "<<chunkNumber<<std::endl;
57  // std::cout<<"bitOffset = "<<bitOffset<<std::endl;
58 
59  //std::cout<<"tmp = "<<tmp<<std::endl;
60  tmp = tmp << bitOffset;//
61  //std::cout<<"tmp = "<<tmp<<std::endl;
62 
63  if (bitValue)
64  _buffer[chunkNumber] |= tmp;
65  else{
66  tmp = ~tmp;
67  _buffer[chunkNumber] &= tmp;
68  }
69 
70  //std::cout<<"buffer["<<chunkNumber<<"] = "<<_buffer[chunkNumber]<<std::endl;
71  //std::cout<<"buffer["<<chunkNumber + 1<<"] = "<<_buffer[chunkNumber+1]<<std::endl;
72 
73 }
static const int UNITS
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
PhiMemoryImage::value_type _buffer[PhiMemoryImage::TOTAL_UNITS]
unsigned long int value_type
Definition: PhiMemoryImage.h:8
tuple cout
Definition: gather_cfg.py:145
static const int TOTAL_UNITS
tuple size
Write out results.
void PhiMemoryImage::SetBuff ( int  chunk,
int  value 
)
inline

Definition at line 39 of file PhiMemoryImage.h.

References _buffer, and relativeConstraints::value.

39 {_buffer[chunk] = value;}
PhiMemoryImage::value_type _buffer[PhiMemoryImage::TOTAL_UNITS]

Member Data Documentation

PhiMemoryImage::value_type PhiMemoryImage::_buffer[PhiMemoryImage::TOTAL_UNITS]
private
int PhiMemoryImage::_keyStationOffset
private

Definition at line 53 of file PhiMemoryImage.h.

Referenced by CopyFromBuffer().

const int PhiMemoryImage::STATIONS = 4
static

Definition at line 11 of file PhiMemoryImage.h.

Referenced by BitShift(), and Print().

const int PhiMemoryImage::TOTAL_UNITS = UNITS * STATIONS
static

Definition at line 13 of file PhiMemoryImage.h.

Referenced by CopyFromBuffer(), GetBit(), PhiMemoryImage(), printbuff(), and SetBit().

const int PhiMemoryImage::UNITS = 3
static

Definition at line 12 of file PhiMemoryImage.h.

Referenced by GetBit(), Print(), and SetBit().