130 {
131 ATH_MSG_DEBUG(
"#####################################################################################");
133
134
135 std::vector<const PixelRDORawData*>::iterator rdo_it = RDOs.begin();
136 std::vector<const PixelRDORawData*>::iterator rdo_it_end = RDOs.end();
137
138 bool is_ibl_present = false;
139
140 const InDetDD::SiNumerology& pixSiNum =
m_pixelManager->numerology();
141 is_ibl_present = (pixSiNum.
numLayers() == 4);
144
145 bool is_ibl_module = false;
146 bool is_dbm_module = false;
147 ATH_MSG_DEBUG(
"in fillROD with " << BCs_per_LVL1ID <<
" LVL1As");
148 ATH_MSG_DEBUG(
"Dimension of the RDO vector: " << RDOs.size());
149
150 int hitDiscCnfg = 2;
151
153 std::unique_ptr<SG::ReadCondHandle<PixelHitDiscCnfgData> > pixHitDiscCnfg;
154
155
156 if (rdo_it != rdo_it_end) {
158 std::sort(rdo_it, rdo_it_end, orderInitialRdos);
159 }
160
161
162
163 rdo_it = RDOs.begin();
164 if (rdo_it!=rdo_it_end) {
165 const PixelRDORawData* rawdata;
166 Identifier offlineId;
167 Identifier prev_offlineId(0x0);
168 Identifier pixelId;
169 bool timing_error = false;
170 bool condensedMode = false;
171 bool linkMasked = false;
177
178 int last_BCID = 0;
179 while (rdo_it!=rdo_it_end) {
181
182 rawdata = (*rdo_it);
184 offlineId =
m_PixelID->wafer_id(pixelId);
185
186 uint32_t robId = pixCabling->find_entry_offrob(offlineId);
187 uint64_t onlineId = pixCabling->find_entry_offon(offlineId);
188
189 linknumber = (onlineId >> 24) & 0xFFFF;
190
191
192 int TOT = rawdata->
getToT();
196
198 is_ibl_module = true;
199 }
201 is_dbm_module = true;
202 }
203
204 ATH_MSG_DEBUG(
" ********************* robId retrieved: 0x" << std::hex << robId << std::dec);
206 ATH_MSG_DEBUG(
"onlineId retrieved: 0x" << std::hex << onlineId <<
", linknumber retrieved: 0x" << linknumber << std::dec
207 << ", ToT: " << TOT << ", BCID: " << BCID << ", LVL1ID: " << LVL1ID << ", LVL1A: " << LVL1A);
208 ATH_MSG_DEBUG(
"Is IBL = " << is_ibl_module <<
" or is DBM = " << is_dbm_module);
209
210
211
212
213 if (!(is_ibl_module||is_dbm_module)) {
214 ATH_MSG_DEBUG(
"This is the PixelCase of the PixelRodEncoder");
215
216
217
218 if (prev_offlineId!=offlineId) {
219 int fake_BCID;
220 timing_error = false;
221 if (BCs_per_LVL1ID<LVL1A) {
222 ATH_MSG_DEBUG(
"LVL1A > BCs_per_LVL1ID, timing corrupt, ignoring timing." <<
" Set BCs per LVL1ID: " << BCs_per_LVL1ID);
223 timing_error = true;
224 }
225 if (prev_offlineId!=0x0) {
228 ATH_MSG_DEBUG(
" ------------------------------------------------------------------------------------------");
229
230
231
232
233 fake_BCID = last_BCID;
234 int max_BCID = fake_BCID+BCs_per_LVL1ID-LVL1A-1;
235
236 while ((fake_BCID<max_BCID) && !timing_error) {
237 fake_BCID++;
238 v32rod.push_back(
packLinkHeader(linknumber, fake_BCID, LVL1ID, (LVL1ID>>4), 0x0));
240 ATH_MSG_DEBUG(
"(after) empty Pixel Module header/trailer pair written for BCID " << fake_BCID);
241 }
242 }
243
244
245
246
247 fake_BCID =
BCID-LVL1A;
248
249 while ((fake_BCID<BCID) && !timing_error) {
250 v32rod.push_back(
packLinkHeader(linknumber, fake_BCID, LVL1ID, (LVL1ID>>4), 0x0));
252 ATH_MSG_DEBUG(
"(before) empty Pixel Module header/trailer pair written for BCID " << fake_BCID);
253 fake_BCID++;
254 }
255
256 v32rod.push_back(
packLinkHeader(linknumber, BCID, LVL1ID, (LVL1ID>>4), 0x0));
258 }
259
260
261
262
267
268
269#ifdef PLOTS
270 int eta_i =
m_PixelID->eta_index(pixelId);
271 int phi_i =
m_PixelID->phi_index(pixelId);
272 std::cout << "[PlotB]: " << robId << " " << eta_i << " " << phi_i << " " << TOT << std::endl;
273 std::cout <<
"[PlotC]: " << robId <<
" " <<
column <<
" " <<
row <<
" " << TOT << std::endl;
274
275 std::cout << "[VAL] " << std::hex << pixelId << " 0x" << robId << " 0x" << onlineId
276 << std::dec <<
" " <<
m_PixelID->eta_module(pixelId) <<
" " <<
m_PixelID->phi_module(pixelId)
277 <<
" " <<
m_PixelID->eta_index(pixelId) <<
" " <<
m_PixelID->phi_index(pixelId) << std::endl;
278#endif
279
280 ++rdo_it;
282
283 ATH_MSG_DEBUG(
"Found hit in PIXEL with PixelID: 0x" << std::hex << pixelId << std::dec <<
" FE: " << FE <<
" Row: " << row <<
" Column: " << column
284 << " TOT: " << TOT << " BCID: " << BCID << " LVL1ID: " << LVL1ID << " LVL1A: " << LVL1A);
285 ATH_MSG_DEBUG(
"Encoded Pixel OfflineID: 0x" << std::hex << offlineId <<
" OnlineID: 0x" << onlineId <<
" -> Linknumber: 0x" << linknumber << std::dec);
286
287 prev_offlineId = offlineId;
288 }
289
290
291
292 else {
293 ATH_MSG_DEBUG(
"Inside the IBL/DBM case of the PixelRodEncoder");
294
295 uint32_t linkNum = (onlineId>>24) & 0xFFFF;
297 FE = (linkNum>>(localFE*8)) & 0xF;
298
299 sLink = onlineId & 0xF;
300 if (sLink > 0x3) {
301 ATH_MSG_WARNING(
"The SLink is not in the correct range [0,3]. This is due to the non-correct onlineId/ROBID definition. Skipping this RDO");
302 continue;
303 }
304 n5 = ((sLink & 0x3)<<3) | (FE & 0x7);
305 ATH_MSG_DEBUG(
"FE (w.r.t. SLink) = 0x" << std::hex << FE <<
" sLink: 0x" << sLink <<
" => n5: 0x" << n5 << std::dec);
306
307 if (!pixHitDiscCnfg) {
308 pixHitDiscCnfg = std::make_unique<SG::ReadCondHandle<PixelHitDiscCnfgData> >(
m_condHitDiscCnfgKey);
309 }
311 hitDiscCnfg = (*pixHitDiscCnfg)->getHitDiscCnfgPL();
312 }
314 hitDiscCnfg = (*pixHitDiscCnfg)->getHitDiscCnfg3D();
315 }
316
317
318
319
320 ATH_MSG_DEBUG(
"(prev_offlineId != offlineId) = " << (prev_offlineId != offlineId) <<
" (prev_n5 != n5) = " << (prev_n5 != n5) <<
" ");
322
323 if ((prev_offlineId!=offlineId) || (prev_n5!=n5)) {
324 int fake_BCID;
325 timing_error = false;
326 if (BCs_per_LVL1ID < LVL1A) {
327 ATH_MSG_DEBUG(
"LVL1A > BCs_per_LVL1ID, timing corrupt, ignoring timing." <<
" Set BCs per LVL1ID: " << BCs_per_LVL1ID);
328 timing_error = true;
329 }
330
331 if (prev_offlineId != 0x0) {
333 condensedMode = false;
334 ATH_MSG_DEBUG(
"IBL Module trailer (because prev_offlineId != 0x0)");
335
336
337
338
339 fake_BCID = last_BCID;
340 int max_BCID = fake_BCID+BCs_per_LVL1ID-LVL1A-1;
341
342 while ((fake_BCID < max_BCID) && !timing_error) {
343 fake_BCID++;
346
347 ATH_MSG_DEBUG(
"(after) empty IBL Module header/trailer pair written for BCID " << fake_BCID);
348 }
349 }
350
351
352
353
354 fake_BCID =
BCID-LVL1A;
355
356 while ((fake_BCID<BCID) && !timing_error) {
359 ATH_MSG_DEBUG(
"(before) empty IBL Module header/trailer pair written for BCID " << fake_BCID);
360 fake_BCID++;
361 }
362
365 }
366
367
368
369
370 std::vector<const PixelRDORawData*> rdos_sameIBL_offlineId;
371
372
376
377 Identifier pixelId_probe = (*rdo_it)->identify();
378 Identifier offlineId_probe =
m_PixelID->wafer_id(pixelId_probe);
379
380 uint32_t linkNum = (onlineId>>24) & 0xFFFF;
381 unsigned int localFE =
m_pixelReadout->getFE(pixelId_probe, offlineId_probe);
382 uint32_t fe_probe = (linkNum>>(localFE*8)) & 0xF;
383
384
385 ATH_MSG_DEBUG(
"offlineId: " << offlineId <<
" offlineId_probe: " << offlineId_probe <<
", fe: " << FE <<
" fe_probe: " << fe_probe);
386
387 if ((offlineId_probe == offlineId) && (FE == fe_probe)) {
389 rdos_sameIBL_offlineId.push_back((*rdo_it));
390 }
391 else {
393 break;
394 }
395 }
396
397 std::vector<const PixelRDORawData*>::iterator rdo_same_it = rdos_sameIBL_offlineId.begin();
398 std::vector<const PixelRDORawData*>::iterator rdo_same_it_end = rdos_sameIBL_offlineId.end();
399
400#ifdef PIXEL_DEBUG
401
402 for (; rdo_same_it != rdo_same_it_end; ++rdo_same_it) {
403 Identifier pixelId_probe = (*rdo_same_it)->identify();
406 int tot = (*rdo_same_it)->getToT();
407 ATH_MSG_DEBUG(
"col: " << col <<
" (0x" << std::hex << col << std::dec <<
")\trow: "<< row <<
" (0x" << std::hex << row << std::dec <<
")\ttot: " << tot <<
"(0x" <<std::hex << tot << std::dec <<
")");
408 }
409
410 rdo_same_it = rdos_sameIBL_offlineId.begin();
411 rdo_same_it_end = rdos_sameIBL_offlineId.end();
412#endif
413
414
416 std::sort(rdo_same_it, rdo_same_it_end, orderRdos);
417
418
419#ifdef PIXEL_DEBUG
420 rdo_same_it = rdos_sameIBL_offlineId.begin();
421 rdo_same_it_end = rdos_sameIBL_offlineId.end();
422
424 for (; rdo_same_it != rdo_same_it_end; ++rdo_same_it) {
425 Identifier pixelId_probe = (*rdo_same_it)->identify();
428 int tot = (*rdo_same_it)->getToT();
429 int eta_i =
m_PixelID->eta_index(pixelId_probe);
430 int phi_i =
m_PixelID->phi_index(pixelId_probe);
431 int eta_m =
m_PixelID->eta_module(pixelId_probe);
432 int phi_m =
m_PixelID->phi_module(pixelId_probe);
433 ATH_MSG_DEBUG(
"pixelId: " << pixelId_probe <<
", eta_i: " << eta_i <<
", phi_i: " << phi_i <<
", eta_m: " << eta_m <<
", phi_m: ");
434 ATH_MSG_DEBUG(
"col: 0x" << std::hex << col << std::dec <<
", row: 0x" <<std::hex << row << std::dec <<
", tot = 0x" << std::hex << tot << std::dec);
435 }
436 ATH_MSG_DEBUG(
"rdos_sameIBL_offlineId.size() = " << rdos_sameIBL_offlineId.size());
437#endif
438#ifdef PLOTS
439 rdo_same_it = rdos_sameIBL_offlineId.begin();
440 rdo_same_it_end = rdos_sameIBL_offlineId.end();
441 for (; rdo_same_it != rdo_same_it_end; ++rdo_same_it) {
442 Identifier pixelId_probe = (*rdo_same_it)->identify();
445 int tot = (*rdo_same_it)->getToT();
446 int eta_i =
m_PixelID->eta_index(pixelId_probe);
447 int phi_i =
m_PixelID->phi_index(pixelId_probe);
448 std::cout <<
"[Plot2]: " << robId <<
" " << eta_i <<
" " << phi_i <<
" " <<
tot << std::endl;
449 std::cout <<
"[Plot3]: " << robId <<
" " << col <<
" " <<
row <<
" " <<
tot << std::endl;
450 }
451#endif
452
454
455
456
457
458
459
461
462 std::vector <uint32_t> vRows;
463 std::vector <uint32_t> vCols;
464 std::vector <int> vTots;
465 bool doubleHit = false;
466 static const uint32_t rowsPerFE = 336;
467
468 rdo_same_it = rdos_sameIBL_offlineId.begin();
469 rdo_same_it_end = rdos_sameIBL_offlineId.end();
470
471 std::vector<const PixelRDORawData*>::iterator rdo_test_it = rdos_sameIBL_offlineId.begin();
472 ATH_MSG_DEBUG(
"Looking for adjacent pixels and saving col, row and tot information.");
473
474 for (; rdo_same_it!=rdo_same_it_end; ++rdo_same_it) {
475 doubleHit = false;
476 Identifier pixelId_probe = (*rdo_same_it)->identify();
479 int totInHitWord (0);
480#ifdef PLOTS
481 std::cout << "[VAL] " << std::hex << pixelId_probe << " 0x" << robId << " 0x" << onlineId
482 << std::dec <<
" " <<
m_PixelID->eta_module(pixelId_probe) <<
" " <<
m_PixelID->phi_module(pixelId_probe)
483 <<
" " <<
m_PixelID->eta_index(pixelId_probe) <<
" " <<
m_PixelID->phi_index(pixelId_probe) << std::endl;
484#endif
485
486 if (row0==rowsPerFE) {
487 ATH_MSG_DEBUG(
"Hit in the last row (== 336) of the IBL FE.");
488 }
489 else {
490 if ((rdo_same_it+1)!=rdo_same_it_end) {
491 rdo_test_it = rdo_same_it + 1;
492 Identifier pixelId_probe = (*rdo_test_it)->identify();
495#ifdef PLOTS
496 std::cout << "[VAL] " << std::hex << pixelId_probe << " 0x" << robId << " 0x" << onlineId
497 << std::dec <<
" " <<
m_PixelID->eta_module(pixelId_probe) <<
" " <<
m_PixelID->phi_module(pixelId_probe)
498 <<
" " <<
m_PixelID->eta_index(pixelId_probe) <<
" " <<
m_PixelID->phi_index(pixelId_probe) << std::endl;
499#endif
500
501 ATH_MSG_DEBUG(
"Comparing rdo[i] = " << (*rdo_same_it) <<
" with rdo[i+1] = " << (*rdo_test_it));
502 ATH_MSG_DEBUG(
" col0 = 0x" << std::hex << col0 <<
" col1 = 0x" << col1 <<
" row0 = 0x" << row0 <<
"\t row1 = 0x" << row1 << std::dec);
503
504 if ((col1==col0) && (row1==(row0+1))) {
505 doubleHit = true;
507
508 int tot0 = (*rdo_same_it)->getToT();
509 int tot1 = (*rdo_test_it)->getToT();
510
511
512 if (hitDiscCnfg==2 && tot0==16) { tot0=2; }
513 if (hitDiscCnfg==2 && tot1==16) { tot1=2; }
514
515 int overflow = 14;
516 if (hitDiscCnfg==1) { overflow=15; }
517 if (hitDiscCnfg==2) { overflow=16; }
518
519 if (tot0>overflow) { tot0=overflow; }
520 if (tot1>overflow) { tot1=overflow; }
521
522 totInHitWord = (tot0<<4) | tot1;
523
524 ATH_MSG_DEBUG(
"doubleHit = " << std::boolalpha << doubleHit << std::noboolalpha <<
" ===> (col0 == col1) : 0x" << std::hex << col0 <<
" = 0x" << col1
525 << "; (row0 = row1 - 1) : 0x" << row0 << " => 0x" << row1 <<"; (tot0) : 0x" << tot0 << ", (tot1) : 0x" << tot1 << " => totInHitWord: 0x" << totInHitWord << std::dec);
526 ++rdo_same_it;
527 }
528 }
529 else {
531 }
532 }
533
534 if (!doubleHit) {
535 int tot0 = (*rdo_same_it)->getToT();
536
537
538 if (hitDiscCnfg==2 && tot0==16) { tot0=2; }
539
540 int overflow = 14;
541 if (hitDiscCnfg==1) { overflow=15; }
542 if (hitDiscCnfg==2) { overflow=16; }
543 if (tot0>overflow) { tot0=overflow; }
544
545 totInHitWord = (tot0<<4) | 0x0;
546
547 ATH_MSG_DEBUG(
"doubleHit = " << std::boolalpha << doubleHit << std::noboolalpha <<
" ===> col0: 0x" << std::hex << col0 << std::dec <<
"; row0: 0x" << std::hex << row0 << std::dec <<
" totInHitWord: 0x" << std::hex << totInHitWord << std::dec);
548 }
549 vCols.push_back(col0);
550 vRows.push_back(row0);
551 vTots.push_back(totInHitWord);
552 }
553
554
555#ifdef PIXEL_DEBUG
556 ATH_MSG_DEBUG(
"CHECKs over the vectors storing columns, rows, ToTs of IBL/DBM hits:");
558 std::vector<uint32_t>::iterator vCols_it = vCols.begin();
559 std::vector<uint32_t>::iterator vCols_it_end = vCols.end();
560 for (; vCols_it != vCols_it_end; ++vCols_it) {
561 ATH_MSG_DEBUG(
"0x" << std::hex << *vCols_it << std::dec <<
" ");
562 }
564 std::vector<uint32_t>::iterator vRows_it = vRows.begin();
565 std::vector<uint32_t>::iterator vRows_it_end = vRows.end();
566 for (; vRows_it != vRows_it_end; ++vRows_it) {
567 ATH_MSG_DEBUG(
"0x" << std::hex << *vRows_it << std::dec <<
" ");
568 }
570 std::vector<int>::iterator vTots_it = vTots.begin();
571 std::vector<int>::iterator vTots_it_end = vTots.end();
572 for (; vTots_it != vTots_it_end; ++vTots_it) {
573 ATH_MSG_DEBUG(
"0x" << std::hex << *vTots_it << std::dec <<
" ");
574 }
575 ATH_MSG_DEBUG(
"rdos_sameIBL_offlineId.size() = " << rdos_sameIBL_offlineId.size() <<
" vRows.size() = " << vRows.size() <<
" vCols.size() = " << vCols.size() <<
" vTots.size() = " << vTots.size());
576#endif
577
578
579 if (vRows.size() >= 5) {
580 ATH_MSG_DEBUG(
"5 (or more) IBL hits have been consequently found. They can be written as condensed hits");
581 while (vRows.size()>=5) {
583 condensedMode= true;
584 }
585 }
586 if (vRows.size()!=0) {
587
588 for (; vRows.size() != 0; ) {
590 vRows.erase(vRows.begin());
591 vCols.erase(vCols.begin());
592 vTots.erase(vTots.begin());
593 }
594 }
596
597 ATH_MSG_DEBUG(
"Encoded IBL OfflineID: " << std::hex << offlineId <<
" OnlineID: 0x" << onlineId << std::dec);
598
599 prev_offlineId = offlineId;
600 prev_n5 = n5;
601
602 }
603 }
604
605 if (is_ibl_module || is_dbm_module) {
607 condensedMode = false;
608 ATH_MSG_DEBUG(
"Module IBL/DBM trailer (at end of the loop)");
609 }
610 else {
613 }
614 }
615 else {
617 }
618 return;
619}
int numLayers() const
Number of layers.
virtual Identifier identify() const override final
virtual int getToT() const =0
virtual int getBCID() const =0
virtual int getLVL1ID() const =0
virtual int getLVL1A() const =0
row
Appending html table to final .html summary file.
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.