test
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.

20  {
21  _buffer[0] = s1a;_buffer[1] = s1b;_buffer[2] = s1c;_buffer[3] = s2a;_buffer[4] = s2b;_buffer[5] = s2c;_buffer[6] = s3a;_buffer[7] = s3b;_buffer[8] = s3c;_buffer[9] = s4a;_buffer[10] = s4b;_buffer[11] = s4c;
22  }
PhiMemoryImage::value_type _buffer[PhiMemoryImage::TOTAL_UNITS]

Member Function Documentation

void PhiMemoryImage::BitShift ( int  nBits)

Definition at line 107 of file PhiMemoryImage.cc.

References _buffer, i, and STATIONS.

Referenced by DetectPatterns().

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

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

Referenced by Print().

77  {
78 
80  int size = sizeof (PhiMemoryImage::value_type) * 8;// should be hardcoded total units?
81 
82  if (bitNumber > (size * PhiMemoryImage::TOTAL_UNITS)){
83  // complain in some way .. to be implemented..
84  return false;
85  }
86 
87  bitNumber -= 1;
88  station -=1;
89 
90  int chunkNumber = station*PhiMemoryImage::UNITS + ((bitNumber-1) / size);
91  int bitOffset = bitNumber % size;
92  if(bitNumber == 64 || bitNumber == 128){chunkNumber += 1;}
93 
94  tmp <<= bitOffset;
95 
96  // std::cout << "chunkNumber: " << chunkNumber << "bitOffset:"
97  // << bitOffset << "tmp: " << tmp << std::endl;
98  //std::cout<<"buffer["<<chunkNumber<<"] = "<<_buffer[chunkNumber]<<std::endl;
99  // std::cout<<"buffer["<<chunkNumber + 1<<"] = "<<_buffer[chunkNumber+1]<<std::endl;
100 
101  return ((_buffer[chunkNumber] & tmp) != 0);
102 
103 }
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 40 of file PhiMemoryImage.h.

References _buffer, and cmsHarvester::index.

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

Definition at line 196 of file PhiMemoryImage.cc.

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

196  {
197 
198  int size = PhiMemoryImage::UNITS * sizeof(PhiMemoryImage::value_type)*8;//should be hardcoded total units>?
199 
200  for (int i = 1; i <= PhiMemoryImage::STATIONS; i++){
201 
202  // std::cout << _buffer[(i-1)*2] << " " << _buffer [(i-1)*2+1] << std::endl;
203 
204  for (int j = size; j > 0; j--){
205 
206  if ((j%(sizeof(PhiMemoryImage::value_type)*8)) == 0)//should be hardcoded total units>? ->no
207  std::cout << std::endl;
208 
209 
210  if ((j%8)==0) std::cout << " ";
211  if(GetBit(i,j)) std::cout << "1";
212  else std::cout << "0";
213 
214  }
215  std::cout << std::endl;
216  }
217 
218 }
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 220 of file PhiMemoryImage.cc.

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

220  {
221 
222  for(int i=0;i<PhiMemoryImage::TOTAL_UNITS;i++){
223  std::cout<<"buffer["<<i<<"] = "<<_buffer[i]<<std::endl;
224  }
225  std::cout<<std::endl;
226 }
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 
50  // std::cout<<"bitnumber = "<<bitNumber<<std::endl;
51  // std::cout<<"station = "<<station<<std::endl;
52 
53  int chunkNumber = station*PhiMemoryImage::UNITS + (bitNumber-1) / size;
54  int bitOffset = bitNumber % size;
55  if(bitNumber == 64 || bitNumber == 128){chunkNumber += 1;}
56 
57 
58  // std::cout<<"chunknumber = "<<chunkNumber<<std::endl;
59  // std::cout<<"bitOffset = "<<bitOffset<<std::endl;
60 
61  //std::cout<<"tmp = "<<tmp<<std::endl;
62  tmp = tmp << bitOffset;//
63  //std::cout<<"tmp = "<<tmp<<std::endl;
64 
65  if (bitValue)
66  _buffer[chunkNumber] |= tmp;
67  else{
68  tmp = ~tmp;
69  _buffer[chunkNumber] &= tmp;
70  }
71 
72  //std::cout<<"buffer["<<chunkNumber<<"] = "<<_buffer[chunkNumber]<<std::endl;
73  //std::cout<<"buffer["<<chunkNumber + 1<<"] = "<<_buffer[chunkNumber+1]<<std::endl;
74 
75 }
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 33 of file PhiMemoryImage.h.

References _buffer, and relativeConstraints::value.

33 {_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 47 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().