ATLAS Offline Software
Loading...
Searching...
No Matches
CpByteStreamTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
5
6#include <numeric>
7#include <set>
8#include <utility>
9
10#include "GaudiKernel/IInterface.h"
11#include "GaudiKernel/MsgStream.h"
12#include "GaudiKernel/StatusCode.h"
13
15
23
24#include "CmmCpSubBlock.h"
25#include "CmmSubBlock.h"
26#include "CpmSubBlock.h"
28#include "L1CaloSrcIdMap.h"
29#include "L1CaloSubBlock.h"
30#include "L1CaloUserHeader.h"
31#include "ModifySlices.h"
32
33#include "CpByteStreamTool.h"
34
35namespace LVL1BS {
36
37// Interface ID
38
39static const InterfaceID IID_ICpByteStreamTool("CpByteStreamTool", 1, 1);
40
42{
44}
45
46// Constructor
47
49 const std::string& name,
50 const IInterface* parent)
51 : AthAlgTool(type, name, parent),
52 m_cpmMaps("LVL1::CpmMappingTool/CpmMappingTool"),
53 m_errorTool("LVL1BS::L1CaloErrorByteStreamTool/L1CaloErrorByteStreamTool"),
54 m_channels(80), m_crates(4), m_modules(14),
55 m_subDetector(eformat::TDAQ_CALO_CLUSTER_PROC_DAQ)
56{
57 declareInterface<CpByteStreamTool>(this);
58
59 declareProperty("CpmMappingTool", m_cpmMaps,
60 "Crate/Module/Channel to Eta/Phi/Layer mapping tool");
61
62 declareProperty("CrateOffsetHw", m_crateOffsetHw = 8,
63 "Offset of CP crate numbers in bytestream");
64 declareProperty("CrateOffsetSw", m_crateOffsetSw = 0,
65 "Offset of CP crate numbers in RDOs");
66
67 // Properties for reading bytestream only
68 declareProperty("ROBSourceIDs", m_sourceIDsProp,
69 "ROB fragment source identifiers");
70
71 // Properties for writing bytestream only
72 declareProperty("DataVersion", m_version = 1,
73 "Format version number in sub-block header");
74 declareProperty("DataFormat", m_dataFormat = 1,
75 "Format identifier (0-1) in sub-block header");
76 declareProperty("SlinksPerCrate", m_slinks = 2,
77 "The number of S-Links per crate");
78 declareProperty("SimulSlices", m_dfltSlices = 1,
79 "The number of slices in the simulation");
80 declareProperty("ForceSlices", m_forceSlices = 0,
81 "If >0, the number of slices in bytestream");
82
83}
84
85// Destructor
86
90
91// Initialize
92
93
95{
96 ATH_MSG_INFO( "Initializing " << name() );
97
98 ATH_CHECK( m_cpmMaps.retrieve() );
99 ATH_CHECK( m_errorTool.retrieve() );
100 ATH_CHECK( m_byteStreamCnvSvc.retrieve() );
101
102 return StatusCode::SUCCESS;
103}
104
105// Conversion bytestream to CPM towers
106
108 const std::string& sgKey,
109 const IROBDataProviderSvc::VROBFRAG& robFrags,
110 DataVector<LVL1::CPMTower>* const ttCollection) const
111{
112 CpmTowerData data (ttCollection);
113 return convertBs(sgKey, robFrags, data);
114}
115
116// Conversion bytestream to CPM hits
117
119 const std::string& sgKey,
120 const IROBDataProviderSvc::VROBFRAG& robFrags,
121 DataVector<LVL1::CPMHits>* const hitCollection) const
122{
123 CpmHitsData data (hitCollection);
124 return convertBs(sgKey, robFrags, data);
125}
126
127// Conversion bytestream to CMM-CP hits
128
130 const std::string& sgKey,
131 const IROBDataProviderSvc::VROBFRAG& robFrags,
132 DataVector<LVL1::CMMCPHits>* const hitCollection) const
133{
134 CmmHitsData data (hitCollection);
135 return convertBs(sgKey, robFrags, data);
136}
137
138// Conversion of CP container to bytestream
139
140StatusCode CpByteStreamTool::convert(const LVL1::CPBSCollection* const cp) const
141{
142 const bool debug = msgLvl(MSG::DEBUG);
143 if (debug) msg(MSG::DEBUG);
144
145 // Get the event assembler
147 ATH_CHECK( m_byteStreamCnvSvc->getFullEventAssembler (fea,
148 "CpByteStream") );
149 const uint16_t minorVersion = m_srcIdMap.minorVersion();
150 fea->setRodMinorVersion(minorVersion);
151
152 // Pointer to ROD data vector
153
155
156 // Set up the container maps
157
158 LVL1::TriggerTowerKey towerKey;
159
160 // CPM tower map
161 ConstCpmTowerMap ttMap;
162 setupCpmTowerMap(cp->towers(), ttMap, towerKey);
163
164 // CPM hits map
165 ConstCpmHitsMap hitsMap;
166 setupCpmHitsMap(cp->hits(), hitsMap);
167
168 // CMM-CP hits map
169 ConstCmmCpHitsMap cmmHitsMap;
170 setupCmmCpHitsMap(cp->cmmHits(), cmmHitsMap);
171
172 // Loop over data
173
174 const bool neutralFormat = m_dataFormat == L1CaloSubBlock::NEUTRAL;
175 const int modulesPerSlink = m_modules / m_slinks;
176 int timeslices = 1;
177 int trigCpm = 0;
178 int timeslicesNew = 1;
179 int trigCpmNew = 0;
180 for (int crate=0; crate < m_crates; ++crate) {
181 const int hwCrate = crate + m_crateOffsetHw;
182
183 // CPM modules are numbered 1 to m_modules
184 for (int module=1; module <= m_modules; ++module) {
185 const int mod = module - 1;
186
187 // Pack required number of modules per slink
188
189 if (mod%modulesPerSlink == 0) {
190 const int daqOrRoi = 0;
191 const int slink = (m_slinks == 2) ? 2*(mod/modulesPerSlink)
192 : mod/modulesPerSlink;
193 if (debug) {
194 msg() << "Treating crate " << hwCrate
195 << " slink " << slink << endmsg;
196 }
197 // Get number of CPM slices and triggered slice offset
198 // for this slink
199 if ( ! slinkSlices(crate, module, modulesPerSlink,
200 timeslices, trigCpm,
201 ttMap,
202 hitsMap,
203 cmmHitsMap,
204 towerKey))
205 {
206 msg(MSG::ERROR) << "Inconsistent number of slices or "
207 << "triggered slice offsets in data for crate "
208 << hwCrate << " slink " << slink << endmsg;
209 return StatusCode::FAILURE;
210 }
211 timeslicesNew = (m_forceSlices) ? m_forceSlices : timeslices;
212 trigCpmNew = ModifySlices::peak(trigCpm, timeslices, timeslicesNew);
213 if (debug) {
214 msg() << "Data Version/Format: " << m_version
215 << " " << m_dataFormat << endmsg
216 << "Slices/offset: " << timeslices << " " << trigCpm;
217 if (timeslices != timeslicesNew) {
218 msg() << " modified to " << timeslicesNew << " " << trigCpmNew;
219 }
220 msg() << endmsg;
221 }
222 L1CaloUserHeader userHeader;
223 userHeader.setCpm(trigCpmNew);
224 const uint32_t rodIdCpm = m_srcIdMap.getRodID(hwCrate, slink, daqOrRoi,
226 theROD = fea->getRodData(rodIdCpm);
227 theROD->push_back(userHeader.header());
228 }
229 if (debug) msg() << "Module " << module << endmsg;
230
231 // Create a sub-block for each slice (except Neutral format)
232
233 // Vector for current CPM sub-blocks
234 DataVector<CpmSubBlock> cpmBlocks;
235
236 for (int slice = 0; slice < timeslicesNew; ++slice) {
237 CpmSubBlock* const subBlock = new CpmSubBlock();
238 subBlock->setCpmHeader(m_version, m_dataFormat, slice,
239 hwCrate, module, timeslicesNew);
240 cpmBlocks.push_back(subBlock);
241 if (neutralFormat) break;
242 }
243
244 // Find CPM towers corresponding to each eta/phi pair and fill
245 // sub-blocks
246
247 for (int chan=0; chan < m_channels; ++chan) {
248 double eta = 0.;
249 double phi = 0.;
250 int layer = 0;
251 if (m_cpmMaps->mapping(crate, module, chan, eta, phi, layer)) {
252 const unsigned int key = towerKey.ttKey(phi, eta);
253 const LVL1::CPMTower* const tt = findCpmTower(key, ttMap);
254 if (tt ) {
255 std::vector<int> emData;
256 std::vector<int> hadData;
257 std::vector<int> emError;
258 std::vector<int> hadError;
259 ModifySlices::data(tt->emEnergyVec(), emData, timeslicesNew);
260 ModifySlices::data(tt->hadEnergyVec(), hadData, timeslicesNew);
261 ModifySlices::data(tt->emErrorVec(), emError, timeslicesNew);
262 ModifySlices::data(tt->hadErrorVec(), hadError, timeslicesNew);
263 for (int slice = 0; slice < timeslicesNew; ++slice) {
264 const LVL1::DataError emErrBits(emError[slice]);
265 const LVL1::DataError hadErrBits(hadError[slice]);
266 const int emErr =
267 (emErrBits.get(LVL1::DataError::LinkDown) << 1) |
268 emErrBits.get(LVL1::DataError::Parity);
269 const int hadErr =
270 (hadErrBits.get(LVL1::DataError::LinkDown) << 1) |
271 hadErrBits.get(LVL1::DataError::Parity);
272 const int index = ( neutralFormat ) ? 0 : slice;
273 CpmSubBlock* const subBlock = cpmBlocks[index];
274 subBlock->fillTowerData(slice, chan, emData[slice],
275 hadData[slice], emErr, hadErr);
276 }
277 }
278 }
279 }
280
281 // Add CPM hits
282
283 const LVL1::CPMHits* const hits = findCpmHits(crate, module, hitsMap);
284 if (hits) {
285 std::vector<unsigned int> vec0;
286 std::vector<unsigned int> vec1;
287 ModifySlices::data(hits->HitsVec0(), vec0, timeslicesNew);
288 ModifySlices::data(hits->HitsVec1(), vec1, timeslicesNew);
289 for (int slice = 0; slice < timeslicesNew; ++slice) {
290 const int index = ( neutralFormat ) ? 0 : slice;
291 CpmSubBlock* const subBlock = cpmBlocks[index];
292 subBlock->setHits(slice, vec0[slice], vec1[slice]);
293 }
294 }
295
296 // Pack and write the sub-blocks
297
299 for (pos = cpmBlocks.begin(); pos != cpmBlocks.end(); ++pos) {
300 CpmSubBlock* const subBlock = *pos;
301 if ( !subBlock->pack()) {
302 msg(MSG::ERROR) << "CPM sub-block packing failed" << endmsg;
303 return StatusCode::FAILURE;
304 }
305 if (debug) {
306 msg() << "CPM sub-block data words: "
307 << subBlock->dataWords() << endmsg;
308 }
309 subBlock->write(theROD);
310 }
311 }
312
313 // Append CMMs to last S-Link of the crate
314
315 // Create a sub-block for each slice (except Neutral format)
316
318 DataVector<CmmCpSubBlock> cmmHit0Blocks;
320 DataVector<CmmCpSubBlock> cmmHit1Blocks;
321
322 const int summing = (crate == m_crates - 1) ? CmmSubBlock::SYSTEM
324 for (int slice = 0; slice < timeslicesNew; ++slice) {
325 CmmCpSubBlock* const h0Block = new CmmCpSubBlock();
326 h0Block->setCmmHeader(m_version, m_dataFormat, slice, hwCrate,
327 summing, CmmSubBlock::CMM_CP,
328 CmmSubBlock::RIGHT, timeslicesNew);
329 cmmHit0Blocks.push_back(h0Block);
330 CmmCpSubBlock* const h1Block = new CmmCpSubBlock();
331 h1Block->setCmmHeader(m_version, m_dataFormat, slice, hwCrate,
332 summing, CmmSubBlock::CMM_CP,
333 CmmSubBlock::LEFT, timeslicesNew);
334 cmmHit1Blocks.push_back(h1Block);
335 if (neutralFormat) break;
336 }
337
338 // CMM-CP
339
340 const int maxDataID = LVL1::CMMCPHits::MAXID;
341 for (int dataID = 1; dataID < maxDataID; ++dataID) {
342 int source = dataID;
343 if (dataID > m_modules) {
344 if (summing == CmmSubBlock::CRATE &&
345 dataID != LVL1::CMMCPHits::LOCAL) continue;
346 switch (dataID) {
348 source = CmmCpSubBlock::LOCAL;
349 break;
352 break;
355 break;
358 break;
360 source = CmmCpSubBlock::TOTAL;
361 break;
362 default:
363 continue;
364 }
365 }
366 const LVL1::CMMCPHits* const ch = findCmmCpHits(crate, dataID, cmmHitsMap);
367 if ( ch ) {
368 std::vector<unsigned int> hits0;
369 std::vector<unsigned int> hits1;
370 std::vector<int> err0;
371 std::vector<int> err1;
372 ModifySlices::data(ch->HitsVec0(), hits0, timeslicesNew);
373 ModifySlices::data(ch->HitsVec1(), hits1, timeslicesNew);
374 ModifySlices::data(ch->ErrorVec0(), err0, timeslicesNew);
375 ModifySlices::data(ch->ErrorVec1(), err1, timeslicesNew);
376 for (int slice = 0; slice < timeslicesNew; ++slice) {
377 const LVL1::DataError err0Bits(err0[slice]);
378 const LVL1::DataError err1Bits(err1[slice]);
379 const int index = ( neutralFormat ) ? 0 : slice;
380 CmmCpSubBlock* subBlock = cmmHit0Blocks[index];
381 subBlock->setHits(slice, source, hits0[slice],
382 err0Bits.get(LVL1::DataError::Parity));
383 subBlock = cmmHit1Blocks[index];
384 subBlock->setHits(slice, source, hits1[slice],
385 err1Bits.get(LVL1::DataError::Parity));
386 }
387 }
388 }
389 DataVector<CmmCpSubBlock>::iterator cos = cmmHit0Blocks.begin();
390 for (; cos != cmmHit0Blocks.end(); ++cos) {
391 CmmCpSubBlock* const subBlock = *cos;
392 if ( !subBlock->pack()) {
393 msg(MSG::ERROR) << "CMM-Cp sub-block packing failed" << endmsg;
394 return StatusCode::FAILURE;
395 }
396 if (debug) {
397 msg() << "CMM-Cp sub-block data words: "
398 << subBlock->dataWords() << endmsg;
399 }
400 subBlock->write(theROD);
401 }
402 cos = cmmHit1Blocks.begin();
403 for (; cos != cmmHit1Blocks.end(); ++cos) {
404 CmmCpSubBlock* const subBlock = *cos;
405 if ( !subBlock->pack()) {
406 msg(MSG::ERROR) << "CMM-Cp sub-block packing failed" << endmsg;
407 return StatusCode::FAILURE;
408 }
409 if (debug) {
410 msg() << "CMM-Cp sub-block data words: "
411 << subBlock->dataWords() << endmsg;
412 }
413 subBlock->write(theROD);
414 }
415 }
416
417 return StatusCode::SUCCESS;
418}
419
420// Return reference to vector with all possible Source Identifiers
421
422std::vector<uint32_t> CpByteStreamTool::makeSourceIDs() const
423{
424 std::vector<uint32_t> sourceIDs;
425
426 if (!m_sourceIDsProp.empty()) {
428 }
429 else {
430 const int maxCrates = m_crates + m_crateOffsetHw;
431 const int maxSlinks = m_srcIdMap.maxSlinks();
432 for (int hwCrate = m_crateOffsetHw; hwCrate < maxCrates; ++hwCrate)
433 {
434 for (int slink = 0; slink < maxSlinks; ++slink)
435 {
436 const int daqOrRoi = 0;
437 const uint32_t rodId = m_srcIdMap.getRodID(hwCrate, slink, daqOrRoi,
439 const uint32_t robId = m_srcIdMap.getRobID(rodId);
440 sourceIDs.push_back(robId);
441 }
442 }
443 }
444 return sourceIDs;
445}
446
447const std::vector<uint32_t>& CpByteStreamTool::sourceIDs() const
448{
449 static const std::vector<uint32_t> sourceIDs = makeSourceIDs();
450 return sourceIDs;
451}
452
453// Convert bytestream to given container type
454
456 const std::string& sgKey,
457 const IROBDataProviderSvc::VROBFRAG& robFrags,
459{
460 LocalData ld;
461
462 // Check if overlap tower channels wanted
463 const static std::string flag("Overlap");
464 const std::string::size_type pos = sgKey.find(flag);
465 ld.coreOverlap =
466 (pos == std::string::npos || pos != sgKey.length() - flag.length()) ? 0 : 1;
467
468 const bool debug = msgLvl(MSG::DEBUG);
469 if (debug) msg(MSG::DEBUG);
470
471 // Loop over ROB fragments
472
473 CmmCpSubBlock cmmCpSubBlock;
474 CpmSubBlock cpmSubBlock;
475
476 int robCount = 0;
477 std::set<uint32_t> dupCheck;
478 ROBIterator rob = robFrags.begin();
479 ROBIterator robEnd = robFrags.end();
480 for (; rob != robEnd; ++rob) {
481
482 if (debug) {
483 ++robCount;
484 msg() << "Treating ROB fragment " << robCount << endmsg;
485 }
486
487 // Skip fragments with ROB status errors
488
489 uint32_t robid = (*rob)->source_id();
490 if ((*rob)->nstatus() > 0) {
491 ROBPointer robData;
492 (*rob)->status(robData);
493 if (*robData != 0) {
494 m_errorTool->robError(robid, *robData);
495 if (debug) msg() << "ROB status error - skipping fragment" << endmsg;
496 continue;
497 }
498 }
499
500 // Skip duplicate fragments
501
502 if (!dupCheck.insert(robid).second) {
504 if (debug) msg() << "Skipping duplicate ROB fragment" << endmsg;
505 continue;
506 }
507
508 // Unpack ROD data (slinks)
509
510 RODPointer payloadBeg;
511 RODPointer payload;
512 RODPointer payloadEnd;
513 (*rob)->rod_data(payloadBeg);
514 payloadEnd = payloadBeg + (*rob)->rod_ndata();
515 payload = payloadBeg;
516 if (payload == payloadEnd) {
517 if (debug) msg() << "ROB fragment empty" << endmsg;
518 continue;
519 }
520
521 // Check identifier
522 const uint32_t sourceID = (*rob)->rod_source_id();
523 if (m_srcIdMap.getRobID(sourceID) != robid ||
524 m_srcIdMap.subDet(sourceID) != m_subDetector ||
525 m_srcIdMap.daqOrRoi(sourceID) != 0 ||
526 (m_srcIdMap.slink(sourceID) != 0 && m_srcIdMap.slink(sourceID) != 2) ||
527 m_srcIdMap.crate(sourceID) < m_crateOffsetHw ||
528 m_srcIdMap.crate(sourceID) >= m_crateOffsetHw + m_crates) {
530 if (debug) {
531 msg() << "Wrong source identifier in data: ROD "
532 << MSG::hex << sourceID << " ROB " << robid
533 << MSG::dec << endmsg;
534 }
535 continue;
536 }
537 const int rodCrate = m_srcIdMap.crate(sourceID);
538 if (debug) {
539 msg() << "Treating crate " << rodCrate
540 << " slink " << m_srcIdMap.slink(sourceID) << endmsg;
541 }
542
543 // First word should be User Header
544 if ( !L1CaloUserHeader::isValid(*payload) ) {
546 if (debug) msg() << "Invalid or missing user header" << endmsg;
547 continue;
548 }
549 L1CaloUserHeader userHeader(*payload);
550 const int minorVersion = (*rob)->rod_version() & 0xffff;
551 userHeader.setVersion(minorVersion);
552 const int headerWords = userHeader.words();
553 if (headerWords != 1) {
555 if (debug) msg() << "Unexpected number of user header words: "
556 << headerWords << endmsg;
557 continue;
558 }
559 for (int i = 0; i < headerWords; ++i) ++payload;
560 // triggered slice offsets
561 int trigCpm = userHeader.cpm();
562 int trigCmm = userHeader.cpCmm();
563 if (debug) {
564 msg() << "Minor format version number: " << MSG::hex
565 << minorVersion << MSG::dec << endmsg
566 << "CPM triggered slice offset: " << trigCpm << endmsg
567 << "CMM triggered slice offset: " << trigCmm << endmsg;
568 }
569 if (trigCpm != trigCmm) {
570 const int newTrig = (trigCpm > trigCmm) ? trigCpm : trigCmm;
571 trigCpm = newTrig;
572 trigCmm = newTrig;
573 if (debug) msg() << "Changed both offsets to " << newTrig << endmsg;
574 }
575
576 // Loop over sub-blocks
577
578 ld.rodErr = L1CaloSubBlock::ERROR_NONE;
579 while (payload != payloadEnd) {
580
582 if (debug) msg() << "Unexpected data sequence" << endmsg;
584 break;
585 }
586 if (CmmSubBlock::cmmBlock(*payload)) {
587 // CMM
588 if (CmmSubBlock::cmmType(*payload) == CmmSubBlock::CMM_CP) {
589 cmmCpSubBlock.clear();
590 payload = cmmCpSubBlock.read(payload, payloadEnd);
591 if (cmmCpSubBlock.crate() != rodCrate) {
592 if (debug) msg() << "Inconsistent crate number in ROD source ID"
593 << endmsg;
595 break;
596 }
597 if (data.m_collection == CMM_CP_HITS) {
598 decodeCmmCp(&cmmCpSubBlock, trigCmm, static_cast<CmmHitsData&>(data),
599 ld);
600 if (ld.rodErr != L1CaloSubBlock::ERROR_NONE) {
601 if (debug) msg() << "decodeCmmCp failed" << endmsg;
602 break;
603 }
604 }
605 } else {
606 if (debug) msg() << "Invalid CMM type in module field" << endmsg;
608 break;
609 }
610 } else {
611 // CPM
612 CpmSubBlock subBlock;
613 cpmSubBlock.clear();
614 payload = cpmSubBlock.read(payload, payloadEnd);
615 if (cpmSubBlock.crate() != rodCrate) {
616 if (debug) msg() << "Inconsistent crate number in ROD source ID"
617 << endmsg;
619 break;
620 }
621 if (data.m_collection == CPM_TOWERS || data.m_collection == CPM_HITS) {
622 decodeCpm(&cpmSubBlock, trigCpm, data, ld);
623 if (ld.rodErr != L1CaloSubBlock::ERROR_NONE) {
624 if (debug) msg() << "decodeCpm failed" << endmsg;
625 break;
626 }
627 }
628 }
629 }
630 if (ld.rodErr != L1CaloSubBlock::ERROR_NONE)
631 m_errorTool->rodError(robid, ld.rodErr);
632 }
633
634 return StatusCode::SUCCESS;
635}
636
637// Unpack CMM-CP sub-block
638
641 LocalData& ld) const
642{
643 const bool debug = msgLvl(MSG::DEBUG);
644 if (debug) msg(MSG::DEBUG);
645
646 const int hwCrate = subBlock->crate();
647 const int module = subBlock->cmmPosition();
648 const int firmware = subBlock->cmmFirmware();
649 const int summing = subBlock->cmmSumming();
650 const int timeslices = subBlock->timeslices();
651 const int sliceNum = subBlock->slice();
652 if (debug) {
653 msg() << "CMM-CP: Crate " << hwCrate
654 << " Module " << module
655 << " Firmware " << firmware
656 << " Summing " << summing
657 << " Total slices " << timeslices
658 << " Slice " << sliceNum << endmsg;
659 }
660 if (timeslices <= trigCmm) {
661 if (debug) msg() << "Triggered CMM slice from header "
662 << "inconsistent with number of slices: "
663 << trigCmm << ", " << timeslices << endmsg;
665 return;
666 }
667 if (timeslices <= sliceNum) {
668 if (debug) msg() << "Total slices inconsistent with slice number: "
669 << timeslices << ", " << sliceNum << endmsg;
671 return;
672 }
673 // Unpack sub-block
674 if (subBlock->dataWords() && !subBlock->unpack()) {
675 if (debug) {
676 std::string errMsg(subBlock->unpackErrorMsg());
677 msg() << "CMM-CP sub-block unpacking failed: " << errMsg << endmsg;
678 }
679 ld.rodErr = subBlock->unpackErrorCode();
680 return;
681 }
682
683 // Retrieve required data
684
685 const bool neutralFormat = subBlock->format() == L1CaloSubBlock::NEUTRAL;
686 const uint32_t subStatus = subBlock->subStatus();
687 const int crate = hwCrate - m_crateOffsetHw;
688 const int swCrate = crate + m_crateOffsetSw;
689 const int maxSid = CmmCpSubBlock::MAX_SOURCE_ID;
690 const int sliceBeg = ( neutralFormat ) ? 0 : sliceNum;
691 const int sliceEnd = ( neutralFormat ) ? timeslices : sliceNum + 1;
692 for (int slice = sliceBeg; slice < sliceEnd; ++slice) {
693
694 // Jet hit counts
695
696 for (int source = 1; source < maxSid; ++source) {
697 int dataID = source;
698 if (source > m_modules) {
699 if (summing == CmmSubBlock::CRATE &&
700 source != CmmCpSubBlock::LOCAL) continue;
701 switch (source) {
703 dataID = LVL1::CMMCPHits::LOCAL;
704 break;
707 break;
710 break;
713 break;
715 dataID = LVL1::CMMCPHits::TOTAL;
716 break;
717 default:
718 continue;
719 }
720 }
721 const unsigned int hits = subBlock->hits(slice, source);
722 int err = subBlock->hitsError(slice, source);
723 LVL1::DataError errorBits;
724 errorBits.set(LVL1::DataError::Parity, err & 0x1);
725 errorBits.set(LVL1::DataError::SubStatusWord, subStatus);
726 err = errorBits.error();
727 if (hits || err) {
728 LVL1::CMMCPHits* ch = findCmmCpHits(data, crate, dataID);
729 if ( ! ch ) { // create new CMM hits
730 ld.hitsVec0.assign(timeslices, 0);
731 ld.hitsVec1.assign(timeslices, 0);
732 ld.errVec0.assign(timeslices, 0);
733 ld.errVec1.assign(timeslices, 0);
734 if (module == CmmSubBlock::RIGHT) {
735 ld.hitsVec0[slice] = hits;
736 ld.errVec0[slice] = err;
737 } else {
738 ld.hitsVec1[slice] = hits;
739 ld.errVec1[slice] = err;
740 }
741 auto chp =
742 std::make_unique<LVL1::CMMCPHits>(swCrate, dataID, ld.hitsVec0, ld.hitsVec1,
743 ld.errVec0, ld.errVec1, trigCmm);
744 const int key = crate*100 + dataID;
745 data.m_cmmHitsMap.insert(std::make_pair(key, chp.get()));
746 data.m_cmmHitCollection->push_back(std::move(chp));
747 } else {
748 ld.hitsVec0 = ch->HitsVec0();
749 ld.hitsVec1 = ch->HitsVec1();
750 ld.errVec0 = ch->ErrorVec0();
751 ld.errVec1 = ch->ErrorVec1();
752 const int nsl = ld.hitsVec0.size();
753 if (timeslices != nsl) {
754 if (debug) msg() << "Inconsistent number of slices in sub-blocks"
755 << endmsg;
757 return;
758 }
759 if ((module == CmmSubBlock::RIGHT && (ld.hitsVec0[slice] != 0 ||
760 ld.errVec0[slice] != 0)) || (module == CmmSubBlock::LEFT &&
761 (ld.hitsVec1[slice] != 0 || ld.errVec1[slice] != 0))) {
762 if (debug) msg() << "Duplicate data for slice " << slice << endmsg;
764 return;
765 }
766 if (module == CmmSubBlock::RIGHT) {
767 ld.hitsVec0[slice] = hits;
768 ld.errVec0[slice] = err;
769 } else {
770 ld.hitsVec1[slice] = hits;
771 ld.errVec1[slice] = err;
772 }
773 ch->addHits(ld.hitsVec0, ld.hitsVec1, ld.errVec0, ld.errVec1);
774 }
775 }
776 }
777 }
778
779 return;
780}
781
782// Unpack CPM sub-block
783
785 int trigCpm, CpByteStreamToolData& data,
786 LocalData& ld) const
787{
788 const bool debug = msgLvl(MSG::DEBUG);
789 const bool verbose = msgLvl(MSG::VERBOSE);
790 if (debug) msg(MSG::DEBUG);
791
792 const int hwCrate = subBlock->crate();
793 const int module = subBlock->module();
794 const int timeslices = subBlock->timeslices();
795 const int sliceNum = subBlock->slice();
796 if (debug) {
797 msg() << "CPM: Crate " << hwCrate
798 << " Module " << module
799 << " Total slices " << timeslices
800 << " Slice " << sliceNum << endmsg;
801 }
802 if (module < 1 || module > m_modules) {
803 if (debug) msg() << "Unexpected module number: " << module << endmsg;
805 return;
806 }
807 if (timeslices <= trigCpm) {
808 if (debug) msg() << "Triggered CPM slice from header "
809 << "inconsistent with number of slices: "
810 << trigCpm << ", " << timeslices << endmsg;
812 return;
813 }
814 if (timeslices <= sliceNum) {
815 if (debug) msg() << "Total slices inconsistent with slice number: "
816 << timeslices << ", " << sliceNum << endmsg;
818 return;
819 }
820 // Unpack sub-block
821 if (subBlock->dataWords() && !subBlock->unpack()) {
822 if (debug) {
823 std::string errMsg(subBlock->unpackErrorMsg());
824 msg() << "CPM sub-block unpacking failed: " << errMsg << endmsg;
825 }
826 ld.rodErr = subBlock->unpackErrorCode();
827 return;
828 }
829
830 // Retrieve required data
831
832 const bool neutralFormat = subBlock->format() == L1CaloSubBlock::NEUTRAL;
833 LVL1::DataError dErr;
835 const int ssError = dErr.error();
836 const int crate = hwCrate - m_crateOffsetHw;
837 const int swCrate = crate + m_crateOffsetSw;
838 const int sliceBeg = ( neutralFormat ) ? 0 : sliceNum;
839 const int sliceEnd = ( neutralFormat ) ? timeslices : sliceNum + 1;
840 for (int slice = sliceBeg; slice < sliceEnd; ++slice) {
841
842 if (data.m_collection == CPM_TOWERS) {
843 CpmTowerData& tdata = static_cast<CpmTowerData&> (data);
844
845 // Loop over tower channels and fill CPM towers
846
847 for (int chan = 0; chan < m_channels; ++chan) {
848 if (!ssError && !subBlock->anyTowerData(chan)) continue;
849 const int em = subBlock->emData(slice, chan);
850 const int had = subBlock->hadData(slice, chan);
851 const int emErr = subBlock->emError(slice, chan);
852 const int hadErr = subBlock->hadError(slice, chan);
853 int emErr1 = ssError;
854 if (emErr) {
855 LVL1::DataError emErrBits(emErr1);
856 emErrBits.set(LVL1::DataError::Parity, emErr & 0x1);
857 emErrBits.set(LVL1::DataError::LinkDown, (emErr >> 1) & 0x1);
858 emErr1 = emErrBits.error();
859 }
860 int hadErr1 = ssError;
861 if (hadErr) {
862 LVL1::DataError hadErrBits(hadErr1);
863 hadErrBits.set(LVL1::DataError::Parity, hadErr & 0x1);
864 hadErrBits.set(LVL1::DataError::LinkDown, (hadErr >> 1) & 0x1);
865 hadErr1 = hadErrBits.error();
866 }
867 if (em || had || emErr1 || hadErr1) {
868 double eta = 0.;
869 double phi = 0.;
870 int layer = 0;
871 if (m_cpmMaps->mapping(crate, module, chan, eta, phi, layer)) {
872 if (layer == ld.coreOverlap) {
873 const unsigned int key = ld.towerKey->ttKey(phi, eta);
874 LVL1::CPMTower* tt = findCpmTower(tdata, key);
875 if ( ! tt ) { // create new CPM tower
876 ld.emVec.assign(timeslices, 0);
877 ld.hadVec.assign(timeslices, 0);
878 ld.emErrVec.assign(timeslices, 0);
879 ld.hadErrVec.assign(timeslices, 0);
880 ld.emVec[slice] = em;
881 ld.hadVec[slice] = had;
882 ld.emErrVec[slice] = emErr1;
883 ld.hadErrVec[slice] = hadErr1;
884 auto ttp =
885 std::make_unique<LVL1::CPMTower>(phi, eta, ld.emVec, ld.emErrVec,
886 ld.hadVec, ld.hadErrVec, trigCpm);
887 tdata.m_ttMap.insert(std::make_pair(key, ttp.get()));
888 tdata.m_ttCollection->push_back(std::move(ttp));
889 } else {
890 ld.emVec = tt->emEnergyVec();
891 ld.hadVec = tt->hadEnergyVec();
892 ld.emErrVec = tt->emErrorVec();
893 ld.hadErrVec = tt->hadErrorVec();
894 const int nsl = ld.emVec.size();
895 if (timeslices != nsl) {
896 if (debug) {
897 msg() << "Inconsistent number of slices in sub-blocks"
898 << endmsg;
899 }
901 return;
902 }
903 if (ld.emVec[slice] != 0 || ld.hadVec[slice] != 0 ||
904 ld.emErrVec[slice] != 0 || ld.hadErrVec[slice] != 0) {
905 if (debug) msg() << "Duplicate data for slice "
906 << slice << endmsg;
908 return;
909 }
910 ld.emVec[slice] = em;
911 ld.hadVec[slice] = had;
912 ld.emErrVec[slice] = emErr1;
913 ld.hadErrVec[slice] = hadErr1;
914 tt->fill(ld.emVec, ld.emErrVec, ld.hadVec, ld.hadErrVec, trigCpm);
915 }
916 }
917 } else if (verbose && (em || had || emErr || hadErr)) {
918 msg(MSG::VERBOSE) << "Non-zero data but no channel mapping for channel "
919 << chan << endmsg;
920 msg(MSG::DEBUG);
921 }
922 } else if (verbose) {
923 msg(MSG::VERBOSE) << "No CPM tower data for channel "
924 << chan << " slice " << slice << endmsg;
925 msg(MSG::DEBUG);
926 }
927 }
928 } else if (data.m_collection == CPM_HITS) {
929 CpmHitsData& hdata = static_cast<CpmHitsData&> (data);
930
931 // Get CPM hits
932
933 const unsigned int hits0 = subBlock->hits0(slice);
934 const unsigned int hits1 = subBlock->hits1(slice);
935 if (hits0 || hits1) {
936 LVL1::CPMHits* ch = findCpmHits(hdata, crate, module);
937 if ( ! ch ) { // create new CPM hits
938 ld.hitsVec0.assign(timeslices, 0);
939 ld.hitsVec1.assign(timeslices, 0);
940 ld.hitsVec0[slice] = hits0;
941 ld.hitsVec1[slice] = hits1;
942 auto chp =
943 std::make_unique<LVL1::CPMHits>(swCrate, module, ld.hitsVec0, ld.hitsVec1, trigCpm);
944 hdata.m_hitsMap.insert(std::make_pair(crate*m_modules+module-1, chp.get()));
945 hdata.m_hitCollection->push_back(std::move(chp));
946 } else {
947 ld.hitsVec0 = ch->HitsVec0();
948 ld.hitsVec1 = ch->HitsVec1();
949 const int nsl = ld.hitsVec0.size();
950 if (timeslices != nsl) {
951 if (debug) msg() << "Inconsistent number of slices in sub-blocks"
952 << endmsg;
954 return;
955 }
956 if (ld.hitsVec0[slice] != 0 || ld.hitsVec1[slice] != 0) {
957 if (debug) msg() << "Duplicate data for slice " << slice << endmsg;
959 return;
960 }
961 ld.hitsVec0[slice] = hits0;
962 ld.hitsVec1[slice] = hits1;
963 ch->addHits(ld.hitsVec0, ld.hitsVec1);
964 }
965 } else if (verbose) {
966 msg(MSG::VERBOSE) << "No CPM hits data for crate/module/slice "
967 << hwCrate << "/" << module << "/" << slice
968 << endmsg;
969 msg(MSG::DEBUG);
970 }
971 }
972 }
973 return;
974}
975
976// Find a CPM tower for given key
977
978const
980 const ConstCpmTowerMap& ttMap) const
981{
982 ConstCpmTowerMap::const_iterator mapIter = ttMap.find(key);
983 if (mapIter != ttMap.end()) return mapIter->second;
984 return nullptr;
985}
986
988 const unsigned int key) const
989{
990 CpmTowerMap::const_iterator mapIter = data.m_ttMap.find(key);
991 if (mapIter != data.m_ttMap.end()) return mapIter->second;
992 return nullptr;
993}
994
995// Find CPM hits for given crate, module
996
997const
999 const int module,
1000 const ConstCpmHitsMap& hitsMap) const
1001{
1002 ConstCpmHitsMap::const_iterator mapIter =
1003 hitsMap.find(crate*m_modules + module - 1);
1004 if (mapIter != hitsMap.end()) return mapIter->second;
1005 return nullptr;
1006}
1007
1009 const int crate, const int module) const
1010{
1011 CpmHitsMap::const_iterator mapIter =
1012 data.m_hitsMap.find(crate*m_modules + module - 1);
1013 if (mapIter != data.m_hitsMap.end()) return mapIter->second;
1014 return nullptr;
1015}
1016
1017// Find CMM-CP hits for given crate, dataID
1018
1019const
1021 const int dataID,
1022 const ConstCmmCpHitsMap& cmmHitsMap) const
1023{
1024 ConstCmmCpHitsMap::const_iterator mapIter = cmmHitsMap.find(crate*100 + dataID);
1025 if (mapIter != cmmHitsMap.end()) return mapIter->second;
1026 return nullptr;
1027}
1028
1030 const int crate,
1031 const int dataID) const
1032{
1033 CmmCpHitsMap::const_iterator mapIter = data.m_cmmHitsMap.find(crate*100 + dataID);
1034 if (mapIter != data.m_cmmHitsMap.end()) return mapIter->second;
1035 return nullptr;
1036}
1037
1038// Set up CPM tower map
1039
1041 const ttCollection,
1042 ConstCpmTowerMap& ttMap,
1043 LVL1::TriggerTowerKey& towerKey) const
1044{
1045 ttMap.clear();
1046 if (ttCollection) {
1047 CpmTowerCollection::const_iterator pos = ttCollection->begin();
1048 CpmTowerCollection::const_iterator pose = ttCollection->end();
1049 for (; pos != pose; ++pos) {
1050 const LVL1::CPMTower* const tt = *pos;
1051 const unsigned int key = towerKey.ttKey(tt->phi(), tt->eta());
1052 ttMap.insert(std::make_pair(key, tt));
1053 }
1054 }
1055}
1056
1057// Set up CPM hits map
1058
1060 const hitCollection,
1061 ConstCpmHitsMap& hitsMap) const
1062{
1063 hitsMap.clear();
1064 if (hitCollection) {
1065 CpmHitsCollection::const_iterator pos = hitCollection->begin();
1066 CpmHitsCollection::const_iterator pose = hitCollection->end();
1067 for (; pos != pose; ++pos) {
1068 const LVL1::CPMHits* const hits = *pos;
1069 const int crate = hits->crate() - m_crateOffsetSw;
1070 const int key = m_modules * crate + hits->module() - 1;
1071 hitsMap.insert(std::make_pair(key, hits));
1072 }
1073 }
1074}
1075
1076// Set up CMM-CP hits map
1077
1079 const hitCollection,
1080 ConstCmmCpHitsMap& cmmHitsMap) const
1081{
1082 cmmHitsMap.clear();
1083 if (hitCollection) {
1084 CmmCpHitsCollection::const_iterator pos = hitCollection->begin();
1085 CmmCpHitsCollection::const_iterator pose = hitCollection->end();
1086 for (; pos != pose; ++pos) {
1087 const LVL1::CMMCPHits* const hits = *pos;
1088 const int crate = hits->crate() - m_crateOffsetSw;
1089 const int key = crate*100 + hits->dataID();
1090 cmmHitsMap.insert(std::make_pair(key, hits));
1091 }
1092 }
1093}
1094
1095// Get number of slices and triggered slice offset for next slink
1096
1097bool CpByteStreamTool::slinkSlices(const int crate, const int module,
1098 const int modulesPerSlink,
1099 int& timeslices,
1100 int& trigCpm,
1101 const ConstCpmTowerMap& ttMap,
1102 const ConstCpmHitsMap& hitsMap,
1103 const ConstCmmCpHitsMap& cmmHitsMap,
1104 LVL1::TriggerTowerKey& towerKey) const
1105{
1106 int slices = -1;
1107 int trigC = m_dfltSlices/2;
1108 for (int mod = module; mod < module + modulesPerSlink; ++mod) {
1109 for (int chan = 0; chan < m_channels; ++chan) {
1110 double eta = 0.;
1111 double phi = 0.;
1112 int layer = 0;
1113 if ( !m_cpmMaps->mapping(crate, mod, chan, eta, phi, layer)) continue;
1114 const unsigned int key = towerKey.ttKey(phi, eta);
1115 const LVL1::CPMTower* const tt = findCpmTower(key, ttMap);
1116 if ( !tt ) continue;
1117 const int numdat = 4;
1118 std::vector<int> sums(numdat);
1119 std::vector<int> sizes(numdat);
1120 sums[0] = std::accumulate((tt->emEnergyVec()).begin(),
1121 (tt->emEnergyVec()).end(), 0);
1122 sums[1] = std::accumulate((tt->hadEnergyVec()).begin(),
1123 (tt->hadEnergyVec()).end(), 0);
1124 sums[2] = std::accumulate((tt->emErrorVec()).begin(),
1125 (tt->emErrorVec()).end(), 0);
1126 sums[3] = std::accumulate((tt->hadErrorVec()).begin(),
1127 (tt->hadErrorVec()).end(), 0);
1128 sizes[0] = (tt->emEnergyVec()).size();
1129 sizes[1] = (tt->hadEnergyVec()).size();
1130 sizes[2] = (tt->emErrorVec()).size();
1131 sizes[3] = (tt->hadErrorVec()).size();
1132 const int peak = tt->peak();
1133 for (int i = 0; i < numdat; ++i) {
1134 if (sums[i] == 0) continue;
1135 if (slices < 0) {
1136 slices = sizes[i];
1137 trigC = peak;
1138 } else if (slices != sizes[i] || trigC != peak) return false;
1139 }
1140 }
1141 const LVL1::CPMHits* const hits = findCpmHits(crate, mod, hitsMap);
1142 if (hits) {
1143 const int numdat = 2;
1144 std::vector<unsigned int> sums(numdat);
1145 std::vector<int> sizes(numdat);
1146 sums[0] = std::accumulate((hits->HitsVec0()).begin(),
1147 (hits->HitsVec0()).end(), 0);
1148 sums[1] = std::accumulate((hits->HitsVec1()).begin(),
1149 (hits->HitsVec1()).end(), 0);
1150 sizes[0] = (hits->HitsVec0()).size();
1151 sizes[1] = (hits->HitsVec1()).size();
1152 const int peak = hits->peak();
1153 for (int i = 0; i < numdat; ++i) {
1154 if (sums[i] == 0) continue;
1155 if (slices < 0) {
1156 slices = sizes[i];
1157 trigC = peak;
1158 } else if (slices != sizes[i] || trigC != peak) return false;
1159 }
1160 }
1161 }
1162 // CMM last slink of crate
1163 if (module/modulesPerSlink == m_slinks - 1) {
1164 const int maxDataID = LVL1::CMMCPHits::MAXID;
1165 for (int dataID = 0; dataID < maxDataID; ++dataID) {
1166 const int numdat = 4;
1167 std::vector<unsigned int> sums(numdat);
1168 std::vector<int> sizes(numdat);
1169 const LVL1::CMMCPHits* const hits = findCmmCpHits(crate, dataID, cmmHitsMap);
1170 if (hits) {
1171 sums[0] = std::accumulate((hits->HitsVec0()).begin(),
1172 (hits->HitsVec0()).end(), 0);
1173 sums[1] = std::accumulate((hits->HitsVec1()).begin(),
1174 (hits->HitsVec1()).end(), 0);
1175 sums[2] = std::accumulate((hits->ErrorVec0()).begin(),
1176 (hits->ErrorVec0()).end(), 0);
1177 sums[3] = std::accumulate((hits->ErrorVec1()).begin(),
1178 (hits->ErrorVec1()).end(), 0);
1179 sizes[0] = (hits->HitsVec0()).size();
1180 sizes[1] = (hits->HitsVec1()).size();
1181 sizes[2] = (hits->ErrorVec0()).size();
1182 sizes[3] = (hits->ErrorVec1()).size();
1183 const int peak = hits->peak();
1184 for (int i = 0; i < numdat; ++i) {
1185 if (sums[i] == 0) continue;
1186 if (slices < 0) {
1187 slices = sizes[i];
1188 trigC = peak;
1189 } else if (slices != sizes[i] || trigC != peak) return false;
1190 }
1191 }
1192 }
1193 }
1194 if (slices < 0) slices = m_dfltSlices;
1195 timeslices = slices;
1196 trigCpm = trigC;
1197 return true;
1198}
1199
1200} // end namespace
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
const bool debug
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
bool msgLvl(const MSG::Level lvl) const
MsgStream & msg() const
Derived DataVector<T>.
Definition DataVector.h:795
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
value_type push_back(value_type pElem)
Add an element to the end of the collection.
DataModel_detail::iterator< DataVector > iterator
Standard iterator.
Definition DataVector.h:842
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
Template class for assembling a full atlas raw event from subfragments.
void setRodMinorVersion(uint16_t m)
change the ROD minor version
std::vector< uint32_t > RODDATA
ROD data as a vector of unsigned int.
RODDATA * getRodData(uint32_t id)
get a block of ROD data
std::vector< const ROBF * > VROBFRAG
Sub-Block class for CMM-CP data.
bool unpack()
Unpack data.
void clear()
Clear all data.
unsigned int hits(int slice, int source) const
Return hit counts for given CPM or source ID.
void setHits(int slice, int source, unsigned int hits, int error)
Store hit counts for given CPM or source ID.
int hitsError(int slice, int source) const
Return hit error for given CPM or source ID.
bool pack()
Pack data.
static bool cmmBlock(uint32_t word)
Determine if header word corresponds to CMM.
int timeslices() const
int cmmPosition() const
Definition CmmSubBlock.h:73
void setCmmHeader(int version, int format, int slice, int crate, int summing, int firmware, int position, int timeslices)
Store CMM header.
int cmmFirmware() const
Definition CmmSubBlock.h:68
static CmmFirmwareCode cmmType(uint32_t word)
CMM differentiation (CMM_CP, CMM_JET, or CMM_ENERGY)
int cmmSumming() const
Definition CmmSubBlock.h:63
std::vector< uint32_t > m_sourceIDsProp
Property: ROB source IDs.
virtual StatusCode initialize() override
DataVector< LVL1::CPMTower > CpmTowerCollection
int m_dataFormat
Property: Data compression format.
StatusCode convert(const std::string &sgKey, const IROBDataProviderSvc::VROBFRAG &robFrags, DataVector< LVL1::CPMTower > *ttCollection) const
Convert ROB fragments to CPM towers.
void setupCmmCpHitsMap(const CmmCpHitsCollection *hitCollection, ConstCmmCpHitsMap &cmmHitsMap) const
Set up CMM-CP hits map.
void decodeCmmCp(CmmCpSubBlock *subBlock, int trigCmm, CmmHitsData &data, LocalData &ld) const
Unpack CMM-CP sub-block.
ServiceHandle< IByteStreamCnvSvc > m_byteStreamCnvSvc
int m_dfltSlices
Property: Default number of slices in simulation.
ToolHandle< LVL1::IL1CaloMappingTool > m_cpmMaps
Property: Channel mapping tool.
const LVL1::CMMCPHits * findCmmCpHits(int crate, int dataID, const ConstCmmCpHitsMap &cmmHitsMap) const
Find CMM-CP hits for given crate, data ID.
int m_slinks
Property: Number of slinks per crate when writing out bytestream.
OFFLINE_FRAGMENTS_NAMESPACE::PointerType ROBPointer
const LVL1::CPMTower * findCpmTower(unsigned int key, const ConstCpmTowerMap &ttMap) const
Find a CPM tower for given key.
bool slinkSlices(int crate, int module, int modulesPerSlink, int &timeslices, int &trigJem, const ConstCpmTowerMap &ttMap, const ConstCpmHitsMap &hitsMap, const ConstCmmCpHitsMap &cmmHitsMap, LVL1::TriggerTowerKey &towerKey) const
Get number of slices and triggered slice offset for next slink.
void setupCpmTowerMap(const CpmTowerCollection *ttCollection, ConstCpmTowerMap &ttMap, LVL1::TriggerTowerKey &towerKey) const
Set up CPM tower map.
const eformat::SubDetector m_subDetector
Sub-detector type.
StatusCode convertBs(const std::string &sgKey, const IROBDataProviderSvc::VROBFRAG &robFrags, CpByteStreamToolData &data) const
Convert bytestream to given container type.
OFFLINE_FRAGMENTS_NAMESPACE::PointerType RODPointer
int m_version
Property: Sub_block header version.
std::vector< uint32_t > makeSourceIDs() const
Create list of all source IDs.
int m_crateOffsetSw
Property: Software crate number offset.
int m_forceSlices
Property: Force number of slices in bytestream.
const L1CaloSrcIdMap m_srcIdMap
Source ID converter.
const int m_channels
Number of channels per module.
ToolHandle< LVL1BS::L1CaloErrorByteStreamTool > m_errorTool
Error collection tool.
void setupCpmHitsMap(const CpmHitsCollection *hitCollection, ConstCpmHitsMap &hitsMap) const
Set up CPM hits map.
IROBDataProviderSvc::VROBFRAG::const_iterator ROBIterator
static const InterfaceID & interfaceID()
AlgTool InterfaceID.
const LVL1::CPMHits * findCpmHits(int crate, int module, const ConstCpmHitsMap &hitsMap) const
Find CPM hits for given crate, module.
std::map< int, const LVL1::CPMHits * > ConstCpmHitsMap
int m_crateOffsetHw
Property: Hardware crate number offset.
CpByteStreamTool(const std::string &type, const std::string &name, const IInterface *parent)
std::map< int, const LVL1::CMMCPHits * > ConstCmmCpHitsMap
DataVector< LVL1::CPMHits > CpmHitsCollection
const int m_crates
Number of crates.
void decodeCpm(CpmSubBlock *subBlock, int trigCpm, CpByteStreamToolData &data, LocalData &ld) const
Unpack CPM sub-block.
std::map< unsigned int, const LVL1::CPMTower * > ConstCpmTowerMap
const std::vector< uint32_t > & sourceIDs() const
Return reference to vector with all possible Source Identifiers.
const int m_modules
Number of CPM modules per crate.
DataVector< LVL1::CMMCPHits > CmmCpHitsCollection
Sub-Block class for CPM data.
Definition CpmSubBlock.h:23
bool unpack()
Unpack data.
int timeslices() const
Return number of timeslices.
void setCpmHeader(int version, int format, int slice, int crate, int module, int timeslices)
Store CPM header.
int emData(int slice, int channel) const
Return Em data for given channel.
bool anyTowerData(int channel) const
Return true if there is tower data for given channel.
int emError(int slice, int channel) const
Return Em error for given channel.
void clear()
Clear all data.
int hadError(int slice, int channel) const
Return Had error for given channel.
unsigned int hits0(int slice) const
Return e/gamma hit counts.
unsigned int hits1(int slice) const
Return tau hit counts.
int hadData(int slice, int channel) const
Return Had data for given channel.
void setHits(int slice, unsigned int hit0, unsigned int hit1)
Store hit counts.
void fillTowerData(int slice, int channel, int em, int had, int emErr, int hadErr)
Store trigger tower data.
bool pack()
Pack data.
int unpackErrorCode() const
Return the unpacking error code.
uint32_t subStatus() const
Return Sub-status word.
int dataWords() const
Return number of data words.
static SubBlockWordType wordType(uint32_t word)
Word identification.
void write(FullEventAssembler< L1CaloSrcIdMap >::RODDATA *theROD) const
Output complete packed sub-block to ROD vector.
std::string unpackErrorMsg() const
Return the unpacking error message for printing.
OFFLINE_FRAGMENTS_NAMESPACE::PointerType read(const OFFLINE_FRAGMENTS_NAMESPACE::PointerType beg, const OFFLINE_FRAGMENTS_NAMESPACE::PointerType end)
Input complete packed sub-block from ROD array.
L1Calo User Header class.
static bool isValid(uint32_t word)
Test for valid header word.
void setVersion(int minorVersion)
Set version flag.
int words() const
Return number of header words (should be one)
uint32_t header() const
Return packed header.
static void data(const std::vector< int > &oldVec, std::vector< int > &newVec, int newSlices)
Return modified data vector<int>
static int peak(int oldPeak, int oldSlices, int newSlices)
Return new triggered slice offset.
Summary of CP (EM/tau) hits received by the merger modules.
Cluster Processor container for writing bytestream.
The CPMHits object contains the hit data produced by a given Cluster Processor Module,...
The CPMTower class contains the TriggerTower information received by the Cluster Processor Modules.
Error data.
Definition DataError.h:27
int error() const
Return the full error word.
Definition DataError.h:78
void set(ErrorBit bit, int value=1)
Set an error bit or data.
Definition DataError.cxx:28
int get(ErrorBit bit) const
Return an error bit or data.
Definition DataError.cxx:48
The TriggerTowerKey object provides the key for each trigger tower depending on its eta-phi coords.
virtual unsigned int ttKey(const TriggerTower &tower)
returns the key of the passed tower
bool verbose
Definition hcg.cxx:73
static const InterfaceID IID_ICpByteStreamTool("CpByteStreamTool", 1, 1)
Definition index.py:1
CpmHitsCollection *const m_hitCollection
CpmTowerCollection *const m_ttCollection