SLTData.cc
Go to the documentation of this file.
1 #include <vector>
2 
3 #include <fevt/SLTData.h>
4 
5 #include <utl/ErrorLogger.h>
6 #include <utl/AugerException.h>
7 
8 using namespace fevt;
9 using namespace utl;
10 using namespace std;
11 
12 
13 SLTData::SLTData(const vector<unsigned int>& sltDataWord) :
14  fColSize(sltDataWord.size())
15 {
16  for (unsigned int col = 0; col < fColSize; ++col)
17  SetSLTDataWord(col+1, sltDataWord[col]);
18 }
19 
20 
22  fColSize(0)
23 {
24 }
25 
26 
27 SLTData::SLTData(const int size)
28 {
29  fColSize = size;
30  fRowMask.resize(size);
31  fSLTPattern.resize(size);
32  fParityErrorBit.resize(size);
33  fTrigger.resize(size);
34  fSpare.resize(size);
35 }
36 
37 
38 void
39 SLTData::SetColumn(unsigned int col, const int rowMask, const int SLTpattern,
40  const bool pe, const bool trigger, const bool spare)
41 {
42  CheckBounds(col);
43  --col;
44 
45  fRowMask[col] = rowMask;
46  fSLTPattern[col] = SLTpattern;
47  fParityErrorBit[col] = pe;
48  fTrigger[col] = trigger;
49  fSpare[col] = spare;
50 }
51 
52 
53 int
54 SLTData::GetSLTDataWord(unsigned int col)
55  const
56 {
57  CheckBounds(col);
58  --col;
59 
60  return fRowMask[col] |
61  (fParityErrorBit[col] << 22) |
62  (fSLTPattern[col] << 23) |
63  (fTrigger[col] << 30) |
64  (fSpare[col] << 31);
65 }
66 
67 
68 bool
69 SLTData::HasPixel(unsigned int col, const unsigned int row)
70  const
71 {
72  CheckBounds(col);
73  --col;
74 
75  /*
76  cout << " HasPixel col=" << col+1 << " row=" << row
77  << " mask: ";
78  for (int i=1; i<22; i++) {
79  int row_mask = 1 << (i - 1);
80  if ((fRowMask[col]&row_mask)) cout << "1";
81  else cout << "0";
82  }
83  cout << endl;
84  */
85 
86  const int row_mask = 1 << (row - 1);
87  return (fRowMask[col] & row_mask);
88 }
89 
90 
91 bool
92 SLTData::HasPixel(const unsigned int pixelId)
93  const
94 {
95  const int col = (pixelId-1)/22 + 1;
96  const int row = (pixelId-1)%22 + 1;
97  return HasPixel(col, row);
98 }
99 
100 
101 void
102 SLTData::SetSLTDataWord(unsigned int col, const unsigned int sltDataWord)
103 {
104  CheckBounds(col);
105  --col;
106 
107  fRowMask[col] = sltDataWord & ((1 << 22) - 1); // first 22 bits
108  fSLTPattern[col] = (sltDataWord >> 23) & ((1 << 7) - 1); // bit 24 - 30 = 7 bits
109  fParityErrorBit[col] = sltDataWord & (1 << (23 - 1)); // bit 23
110  fTrigger[col] = sltDataWord & (1 << (31 - 1)); // bit 31
111  fSpare[col] = sltDataWord & (1 << (32 - 1)); // bit 32
112 }
113 
114 
115 void
116 SLTData::SetSLTPattern(unsigned int col, const int pattern)
117 {
118  CheckBounds(col);
119  --col;
120 
121  fSLTPattern[col] = pattern;
122 }
123 
124 
125 void
126 SLTData::SetRowMask(unsigned int col, const int rowMask)
127 {
128  CheckBounds(col);
129  --col;
130 
131  fRowMask[col] = rowMask;
132 
133  /*
134  cout << " SetRowMask col=" << col+1;
135  for (int row=1; row<=22; ++row) {
136  int pixelMask = 1 << (row-1);
137  if (rowMask&pixelMask) cout << "|";
138  else cout << ".";
139  }
140  cout << endl;
141  */
142 }
143 
144 
145 void
146 SLTData::SetParityError(unsigned int col, const bool bit)
147 {
148  CheckBounds(col);
149  --col;
150 
151  fParityErrorBit[col] = bit;
152 }
153 
154 
155 void
156 SLTData::SetTrigger(unsigned int col, const bool bit)
157 {
158  CheckBounds(col);
159  --col;
160 
161  fTrigger[col] = bit;
162 }
163 
164 
165 void
166 SLTData::SetSpare(unsigned int col, const bool bit)
167 {
168  CheckBounds(col);
169  --col;
170 
171  fSpare[col] = bit;
172 }
173 
174 
175 void
176 SLTData::CheckBounds(unsigned int col)
177  const
178 {
179  --col;
180  if (col >= fColSize) {
181  ostringstream err;
182  err << " Column index col=" << col+1
183  << " out of bounds. Max col=" << fColSize;
184  ERROR(err.str());
185  throw NonExistentComponentException(err.str());
186  }
187 }
unsigned int fColSize
Definition: SLTData.h:76
Base class for exceptions trying to access non-existing components.
std::vector< int > fSLTPattern
Definition: SLTData.h:69
void SetParityError(unsigned int col, const bool bit)
Definition: SLTData.cc:146
bool HasPixel(const unsigned int id) const
Definition: SLTData.cc:92
std::vector< bool > fSpare
Definition: SLTData.h:73
std::vector< bool > fParityErrorBit
Definition: SLTData.h:71
int GetSLTDataWord(unsigned int col) const
Definition: SLTData.cc:54
std::vector< bool > fTrigger
Definition: SLTData.h:72
std::vector< int > fRowMask
Definition: SLTData.h:67
void SetSpare(unsigned int col, const bool bit)
Definition: SLTData.cc:166
void SetSLTPattern(unsigned int col, const int pattern)
Definition: SLTData.cc:116
void SetSLTDataWord(unsigned int col, const unsigned int sltDataWord)
Definition: SLTData.cc:102
void SetColumn(unsigned int col, const int row, const int pattern, const bool pe, const bool trigger, const bool spare)
Definition: SLTData.cc:39
void SetTrigger(unsigned int col, const bool bit)
Definition: SLTData.cc:156
void SetRowMask(unsigned int col, const int mask)
Definition: SLTData.cc:126
#define ERROR(message)
Macro for logging error messages.
Definition: ErrorLogger.h:165
void CheckBounds(unsigned int col) const
Definition: SLTData.cc:176

, generated on Tue Sep 26 2023.