CMS 3D CMS Logo

DCCDataMapper.cc
Go to the documentation of this file.
1 #include "DCCDataMapper.h"
2 
3 /*--------------------------------------------*/
4 /* DCCTBDataMapper::DCCTBDataMapper */
5 /* class constructor */
6 /*--------------------------------------------*/
7 DCCTBDataMapper::DCCTBDataMapper(DCCTBDataParser *myParser) : parser_(myParser) {
8  dccFields_ = new std::set<DCCTBDataField *, DCCTBDataFieldComparator>;
9  emptyEventFields_ = new std::set<DCCTBDataField *, DCCTBDataFieldComparator>;
10 
11  tcc68Fields_ = new std::set<DCCTBDataField *, DCCTBDataFieldComparator>;
12  tcc32Fields_ = new std::set<DCCTBDataField *, DCCTBDataFieldComparator>;
13  tcc16Fields_ = new std::set<DCCTBDataField *, DCCTBDataFieldComparator>;
14 
15  srp68Fields_ = new std::set<DCCTBDataField *, DCCTBDataFieldComparator>;
16  srp32Fields_ = new std::set<DCCTBDataField *, DCCTBDataFieldComparator>;
17  srp16Fields_ = new std::set<DCCTBDataField *, DCCTBDataFieldComparator>;
18 
19  towerFields_ = new std::set<DCCTBDataField *, DCCTBDataFieldComparator>;
20  xtalFields_ = new std::set<DCCTBDataField *, DCCTBDataFieldComparator>;
21  trailerFields_ = new std::set<DCCTBDataField *, DCCTBDataFieldComparator>;
22 
29 }
30 
31 /*---------------------------------------------*/
32 /* DCCTBDataMapper::~DCCTBDataMapper */
33 /* class destructor (free memory) */
34 /*---------------------------------------------*/
36  std::set<DCCTBDataField *, DCCTBDataFieldComparator>::iterator it;
37 
38  for (it = dccFields_->begin(); it != dccFields_->end(); it++) {
39  delete (*it);
40  }
41  for (it = emptyEventFields_->begin(); it != emptyEventFields_->end(); it++) {
42  delete (*it);
43  }
44 
45  for (it = tcc68Fields_->begin(); it != tcc68Fields_->end(); it++) {
46  delete (*it);
47  }
48  for (it = tcc32Fields_->begin(); it != tcc32Fields_->end(); it++) {
49  delete (*it);
50  }
51  for (it = tcc16Fields_->begin(); it != tcc16Fields_->end(); it++) {
52  delete (*it);
53  }
54 
55  for (it = srp68Fields_->begin(); it != srp68Fields_->end(); it++) {
56  delete (*it);
57  }
58  for (it = srp32Fields_->begin(); it != srp32Fields_->end(); it++) {
59  delete (*it);
60  }
61  for (it = srp16Fields_->begin(); it != srp16Fields_->end(); it++) {
62  delete (*it);
63  }
64 
65  for (it = towerFields_->begin(); it != towerFields_->end(); it++) {
66  delete (*it);
67  }
68  for (it = xtalFields_->begin(); it != xtalFields_->end(); it++) {
69  delete (*it);
70  }
71  for (it = trailerFields_->begin(); it != trailerFields_->end(); it++) {
72  delete (*it);
73  }
74 
75  delete dccFields_;
76  delete emptyEventFields_;
77 
78  delete tcc68Fields_;
79  delete tcc32Fields_;
80  delete tcc16Fields_;
81 
82  delete srp68Fields_;
83  delete srp32Fields_;
84  delete srp16Fields_;
85 
86  delete towerFields_;
87  delete xtalFields_;
88  delete trailerFields_;
89 }
90 
91 /*-------------------------------------------------*/
92 /* DCCTBDataMapper::buildDccFields */
93 /* builds raw data header fields */
94 /*-------------------------------------------------*/
96  //32 Bit word numb 0
99 
102 
105 
108 
109  //32Bit word numb 1
112 
113  dccFields_->insert(
115  emptyEventFields_->insert(
117 
120 
121  //32Bit word numb 2
122  dccFields_->insert(
124  emptyEventFields_->insert(
126 
129 
130  //32Bit word numb 3
133 
134  //32 Bit word numb 4
137 
138  //32Bit word numb 5
139  dccFields_->insert(
141  emptyEventFields_->insert(
143 
144  //32 Bit word numb 6
145  dccFields_->insert(
147 
148  //32 Bit word numb 7
152 
154  dccFields_->insert(
156  dccFields_->insert(
158  dccFields_->insert(
160  dccFields_->insert(
162 
163  //add Headers Qualifiers: 8 words with 6 bits each written on the 2nd 32bit words
164  for (uint32_t i = 1; i <= 8; i++) {
166  dccFields_->insert(new DCCTBDataField(header, HD_WPOSITION + (i - 1) * 2, HD_BPOSITION, HD_MASK));
167 
168  //fill only for empty events
169  if (i < 3) {
171  }
172  }
173 
174  //add FE_CHSTATUS: 5 words each having 14 FE_CHSTATUS
175  for (uint32_t wcount = 1; wcount <= 5; wcount++) {
176  //1st word 32 bit
177  for (uint32_t i = 1; i <= 8; i++) {
178  std::string chStatus = std::string("FE_CHSTATUS#") + parser_->getDecString((wcount - 1) * 14 + i);
179  dccFields_->insert(
180  new DCCTBDataField(chStatus, FE_CHSTATUS_WPOSITION + (wcount - 1) * 2, 4 * (i - 1), FE_CHSTATUS_MASK));
181  }
182 
183  //2nd word 32 bit
184  for (uint32_t i = 9; i <= 14; i++) {
185  std::string chStatus = std::string("FE_CHSTATUS#") + parser_->getDecString((wcount - 1) * 14 + i);
186  dccFields_->insert(
187  new DCCTBDataField(chStatus, FE_CHSTATUS_WPOSITION + (wcount - 1) * 2 + 1, 4 * (i - 9), FE_CHSTATUS_MASK));
188  }
189  }
190 }
191 
192 /*-------------------------------------------------*/
193 /* DCCTBDataMapper::buildTCCFields */
194 /* builds raw data TCC block fields */
195 /*-------------------------------------------------*/
197  std::vector<std::set<DCCTBDataField *, DCCTBDataFieldComparator> *> pVector;
198  pVector.push_back(tcc16Fields_);
199  pVector.push_back(tcc32Fields_);
200  pVector.push_back(tcc68Fields_);
201 
202  for (int i = 0; i < ((int)(pVector.size())); i++) {
203  (pVector[i])->insert(new DCCTBDataField("TCC ID", TCCID_WPOSITION, TCCID_BPOSITION, TCCID_MASK));
208  (pVector[i])->insert(new DCCTBDataField("#TT", NTT_WPOSITION, NTT_BPOSITION, NTT_MASK));
209  (pVector[i])->insert(new DCCTBDataField("#TIME SAMPLES", TCCTSAMP_WPOSITION, TCCTSAMP_BPOSITION, TCCTSAMP_MASK));
212  }
213 
214  uint32_t nTSamples = parser_->numbTriggerSamples();
215 
216  uint32_t totalTT = 68 * nTSamples;
217 
218  uint32_t filter1 = 16 * nTSamples;
219  uint32_t filter2 = 32 * nTSamples;
220 
221  uint32_t count(2);
222 
223  // Fill block with TT definition
224  for (uint32_t tt = 1; tt <= totalTT; tt++) {
225  std::string tpg = std::string("TPG#") + parser_->getDecString(tt);
226  std::string ttFlag = std::string("TTF#") + parser_->getDecString(tt);
227 
228  if (tt <= filter1) {
229  tcc16Fields_->insert(
230  new DCCTBDataField(tpg, TPG_WPOSITION - 1 + count / 2, TPG_BPOSITION + 16 * ((count + 2) % 2), TPG_MASK));
231  tcc16Fields_->insert(
232  new DCCTBDataField(ttFlag, TTF_WPOSITION - 1 + count / 2, TTF_BPOSITION + 16 * ((count + 2) % 2), TTF_MASK));
233  }
234  if (tt <= filter2) {
235  tcc32Fields_->insert(
236  new DCCTBDataField(tpg, TPG_WPOSITION - 1 + count / 2, TPG_BPOSITION + 16 * ((count + 2) % 2), TPG_MASK));
237  tcc32Fields_->insert(
238  new DCCTBDataField(ttFlag, TTF_WPOSITION - 1 + count / 2, TTF_BPOSITION + 16 * ((count + 2) % 2), TTF_MASK));
239  }
240 
241  tcc68Fields_->insert(
242  new DCCTBDataField(tpg, TPG_WPOSITION - 1 + count / 2, TPG_BPOSITION + 16 * ((count + 2) % 2), TPG_MASK));
243  tcc68Fields_->insert(
244  new DCCTBDataField(ttFlag, TTF_WPOSITION - 1 + count / 2, TTF_BPOSITION + 16 * ((count + 2) % 2), TTF_MASK));
245  count++;
246  }
247 }
248 
249 // ---> update with the correct number of SRP fields
251  std::vector<std::set<DCCTBDataField *, DCCTBDataFieldComparator> *> pVector;
252  pVector.push_back(srp68Fields_);
253  pVector.push_back(srp32Fields_);
254  pVector.push_back(srp16Fields_);
255 
256  for (int i = 0; i < ((int)(pVector.size())); i++) {
257  // This method must be modified to take into account the different SRP blocks : 68 SRF in the barrel, 34 ,35 or 36 in the EE
258  (pVector[i])->insert(new DCCTBDataField("SRP ID", SRPID_WPOSITION, SRPID_BPOSITION, SRPID_MASK));
261 
264  (pVector[i])->insert(new DCCTBDataField("#SR FLAGS", NSRF_WPOSITION, NSRF_BPOSITION, NSRF_MASK));
267  }
268 
269  uint32_t srpFlags(68);
270 
271  uint32_t count1(1), count2(1), srSize(3), factor(0), wcount(0);
272  for (uint32_t nsr = 1; nsr <= srpFlags; nsr++) {
273  std::string sr = std::string("SR#") + parser_->getDecString(nsr);
274 
275  srp68Fields_->insert(new DCCTBDataField(
276  sr, SRF_WPOSITION + wcount, SRF_BPOSITION + SRPBOFFSET * factor + (count2 - 1) * srSize, SRF_MASK));
277  if (nsr <= 32) {
278  srp32Fields_->insert(new DCCTBDataField(
279  sr, SRF_WPOSITION + wcount, SRF_BPOSITION + SRPBOFFSET * factor + (count2 - 1) * srSize, SRF_MASK));
280  }
281  if (nsr <= 16) {
282  srp16Fields_->insert(new DCCTBDataField(
283  sr, SRF_WPOSITION + wcount, SRF_BPOSITION + SRPBOFFSET * factor + (count2 - 1) * srSize, SRF_MASK));
284  }
285 
286  count1++;
287  count2++;
288 
289  //update word count
290  if (count1 > 8) {
291  wcount++;
292  count1 = 1;
293  }
294 
295  //update bit offset
296  if (count1 > 4) {
297  factor = 1;
298  } else {
299  factor = 0;
300  }
301 
302  //update bit shift
303  if (count2 > 4) {
304  count2 = 1;
305  }
306  }
307 }
308 
309 /*-------------------------------------------------*/
310 /* DCCTBDataMapper::buildTowerFields */
311 /* builds raw data Tower Data fields */
312 /*-------------------------------------------------*/
314  //32bit word numb 1
316  towerFields_->insert(new DCCTBDataField("#TIME SAMPLES", XSAMP_WPOSITION, XSAMP_BPOSITION, XSAMP_MASK));
319 
320  //32 bit word numb 2
323  towerFields_->insert(
325 }
326 
327 /*-------------------------------------------------*/
328 /* DCCTBDataMapper::buildXtalFields */
329 /* builds raw data Crystal Data fields */
330 /*-------------------------------------------------*/
332  //32bit word numb 1
338 
339  //first ADC is still on 1st word
341 
342  //add the rest of the ADCs
343  for (uint32_t i = 2; i <= parser_->numbXtalSamples(); i++) {
345  if (i % 2) {
347  } else {
348  xtalFields_->insert(new DCCTBDataField(adc, ADC_WPOSITION + i / 2, 0, ADC_MASK));
349  }
350  }
351 
352  //the last word has written the test zero suppression flag and the gain decision bit
353  uint32_t tzsOffset_ = parser_->numbXtalSamples() / 2;
355  xtalFields_->insert(new DCCTBDataField(
357 }
358 
359 /*-------------------------------------------------*/
360 /* DCCTBDataMapper::buildTrailerFields */
361 /* builds raw data Trailer words */
362 /*-------------------------------------------------*/
364  //32bit word numb 1
369 
370  //32bit word numb 2
373 }
std::set< DCCTBDataField *, DCCTBDataFieldComparator > * dccFields_
std::set< DCCTBDataField *, DCCTBDataFieldComparator > * srp32Fields_
std::set< DCCTBDataField *, DCCTBDataFieldComparator > * tcc68Fields_
std::set< DCCTBDataField *, DCCTBDataFieldComparator > * trailerFields_
std::set< DCCTBDataField *, DCCTBDataFieldComparator > * tcc16Fields_
std::string getDecString(uint32_t data)
DCCTBDataMapper(DCCTBDataParser *myParser)
Definition: DCCDataMapper.cc:7
uint32_t numbTriggerSamples()
uint32_t numbXtalSamples()
std::set< DCCTBDataField *, DCCTBDataFieldComparator > * srp16Fields_
std::set< DCCTBDataField *, DCCTBDataFieldComparator > * tcc32Fields_
std::set< DCCTBDataField *, DCCTBDataFieldComparator > * emptyEventFields_
Definition: TTTypes.h:54
void buildTrailerFields()
bool insert(Storage &iStorage, ItemType *iItem, const IdTag &iIdTag)
Definition: HCMethods.h:50
std::set< DCCTBDataField *, DCCTBDataFieldComparator > * xtalFields_
DCCTBDataParser * parser_
std::set< DCCTBDataField *, DCCTBDataFieldComparator > * srp68Fields_
uint16_t *__restrict__ uint16_t const *__restrict__ adc
std::set< DCCTBDataField *, DCCTBDataFieldComparator > * towerFields_