8#include "GaudiKernel/IInterface.h"
9#include "GaudiKernel/MsgStream.h"
10#include "GaudiKernel/StatusCode.h"
54 const std::string& name,
55 const IInterface* parent)
58 m_jemMaps(
"LVL1::JemMappingTool/JemMappingTool"),
59 m_errorTool(
"LVL1BS::L1CaloErrorByteStreamTool/L1CaloErrorByteStreamTool"),
64 declareInterface<JepByteStreamV2Tool>(
this);
67 "Crate/Module/Channel to Eta/Phi/Layer mapping tool");
69 "Tool to collect errors for monitoring");
72 "Offset of JEP crate numbers in bytestream");
74 "Offset of JEP crate numbers in RDOs");
76 "The number of S-Links per crate");
80 "ROB fragment source identifiers");
84 "Format version number in sub-block header");
86 "Format identifier (0-1) in sub-block header");
88 "The number of slices in the simulation");
90 "If >0, the number of slices in bytestream");
92 "Minimum crate number, allows partial output");
94 "Maximum crate number, allows partial output");
118 return StatusCode::SUCCESS;
125 return StatusCode::SUCCESS;
131 const std::string& sgKey,
134 const std::vector<uint32_t>& vID(
sourceIDs());
137 m_robDataProvider->getROBData(Gaudi::Hive::currentContext(), vID, robFrags,
"JepByteStreamV2Tool");
138 ATH_MSG_DEBUG(
"Number of ROB fragments:" << robFrags.size());
139 return convert(sgKey, robFrags, collection);
143 const std::string& sgKey,
153 const std::string& sgKey,
156 const std::vector<uint32_t>& vID(
sourceIDs());
159 m_robDataProvider->getROBData(Gaudi::Hive::currentContext(), vID, robFrags,
"JepByteStreamV2Tool");
160 ATH_MSG_DEBUG(
"Number of ROB fragments:" << robFrags.size());
161 return convert(sgKey, robFrags, collection);
165 const std::string& sgKey,
175 const std::string& sgKey,
178 const std::vector<uint32_t>& vID(
sourceIDs());
181 m_robDataProvider->getROBData(Gaudi::Hive::currentContext(), vID, robFrags,
"JepByteStreamV2Tool");
182 ATH_MSG_DEBUG(
"Number of ROB fragments:" << robFrags.size());
183 return convert(sgKey, robFrags, collection);
187 const std::string& sgKey,
197 const std::string& sgKey,
200 const std::vector<uint32_t>& vID(
sourceIDs());
203 m_robDataProvider->getROBData(Gaudi::Hive::currentContext(), vID, robFrags,
"JepByteStreamV2Tool");
204 ATH_MSG_DEBUG(
"Number of ROB fragments:" << robFrags.size());
205 return convert(sgKey, robFrags, collection);
209 const std::string& sgKey,
220 const std::string& sgKey,
223 const std::vector<uint32_t>& vID(
sourceIDs());
226 m_robDataProvider->getROBData(Gaudi::Hive::currentContext(), vID, robFrags,
"JepByteStreamV2Tool");
227 ATH_MSG_DEBUG(
"Number of ROB fragments:" << robFrags.size());
228 return convert(sgKey, robFrags, collection);
232 const std::string& sgKey,
246 return StatusCode::FAILURE;
255 "JepByteStreamV2") );
256 const uint16_t minorVersion =
m_srcIdMap.minorVersion();
294 int timeslicesNew = 1;
299 for (
int module=0;
module < m_modules; ++module) {
303 if (module%modulesPerSlink == 0) {
304 const int daqOrRoi = 0;
305 const int slink =
module/modulesPerSlink;
307 msg() <<
"Treating crate " << hwCrate
308 <<
" slink " << slink <<
endmsg;
321 msg(MSG::ERROR) <<
"Inconsistent number of slices or "
322 <<
"triggered slice offsets in data for crate "
323 << hwCrate <<
" slink " << slink <<
endmsg;
324 return StatusCode::FAILURE;
331 <<
"Slices/offset: " << timeslices <<
" " << trigJem;
332 if (timeslices != timeslicesNew) {
333 msg() <<
" modified to " << timeslicesNew <<
" " << trigJemNew;
338 userHeader.
setJem(trigJemNew);
339 const uint32_t rodIdJem =
m_srcIdMap.getRodID(hwCrate, slink, daqOrRoi,
342 theROD->push_back(userHeader.
header());
344 if (
debug)
msg() <<
"Module " <<
module << endmsg;
350 for (
int slice = 0; slice < timeslicesNew; ++slice) {
353 hwCrate, module, timeslicesNew);
355 if (neutralFormat)
break;
369 std::vector<int> emData;
370 std::vector<int> hadData;
371 std::vector<int> emErrors;
372 std::vector<int> hadErrors;
377 for (
int slice = 0; slice < timeslicesNew; ++slice) {
380 const int index = ( neutralFormat ) ? 0 : slice;
382 const JemJetElement jetEle(chan, emData[slice], hadData[slice],
397 subBlock->
setStatus(failingBCN, gLinkTimeout, gLinkDown,
398 moduleError, fIFOOverflow, bCNMismatch,
399 gLinkProtocol, gLinkParity);
410 std::vector<unsigned int> exVec;
411 std::vector<unsigned int> eyVec;
412 std::vector<unsigned int> etVec;
416 for (
int slice = 0; slice < timeslicesNew; ++slice) {
417 const int index = ( neutralFormat ) ? 0 : slice;
427 for (pos = jemBlocks.
begin(); pos != jemBlocks.
end(); ++pos) {
429 if ( !subBlock->
pack()) {
430 msg(MSG::ERROR) <<
"JEM sub-block packing failed" <<
endmsg;
431 return StatusCode::FAILURE;
434 msg() <<
"JEM sub-block data words: "
437 subBlock->
write(theROD);
452 for (
int slice = 0; slice < timeslicesNew; ++slice) {
454 const int cmxEnergyVersion = 3;
464 if (neutralFormat)
break;
470 for (
int source = 0; source < maxSource; ++source) {
478 std::vector<unsigned int> ex;
479 std::vector<unsigned int> ey;
480 std::vector<unsigned int>
et;
481 std::vector<int> exErr;
482 std::vector<int> eyErr;
483 std::vector<int> etErr;
490 for (
int slice = 0; slice < timeslicesNew; ++slice) {
502 const int index = ( neutralFormat ) ? 0 : slice;
506 ex[slice], ey[slice],
et[slice],
507 exError, eyError, etError);
515 ex[slice], ey[slice],
et[slice],
516 exError, eyError, etError);
518 subBlock->
setEtHits(slice, hitType, sumType,
et[slice]);
525 pos = cmxEnergyBlocks.
begin();
526 for (; pos != cmxEnergyBlocks.
end(); ++pos) {
528 if ( !subBlock->
pack()) {
529 msg(MSG::ERROR) <<
"CMX-Energy sub-block packing failed" <<
endmsg;
530 return StatusCode::FAILURE;
533 msg() <<
"CMX-Energy sub-block data words: "
536 subBlock->
write(theROD);
541 for (
int jem = 0; jem <
m_modules; ++jem) {
542 for (
int frame = 0; frame <
m_frames; ++frame) {
544 const int key =
tobKey(crate, jem, frame, loc);
547 std::vector<int> energyLarge;
548 std::vector<int> energySmall;
549 std::vector<int>
error;
550 std::vector<unsigned int> presence;
555 for (
int slice = 0; slice < timeslicesNew; ++slice) {
562 const int index = ( neutralFormat ) ? 0 : slice;
564 subBlock->
setTob(slice, jem, frame, loc, energyLarge[slice],
565 energySmall[slice], err0);
577 for (
int source = 0; source < maxSource; ++source) {
587 std::vector<unsigned int> hits0;
588 std::vector<unsigned int> hits1;
589 std::vector<int> err0;
590 std::vector<int> err1;
595 for (
int slice = 0; slice < timeslicesNew; ++slice) {
610 const int index = ( neutralFormat ) ? 0 : slice;
612 subBlock->
setHits(slice, sourceId, 0, hits0[slice],
error);
615 subBlock->
setHits(slice, sourceId, 1, hits1[slice],
error);
621 jos = cmxJetBlocks.
begin();
622 for (; jos != cmxJetBlocks.
end(); ++jos) {
624 if ( !subBlock->
pack()) {
625 msg(MSG::ERROR) <<
"CMX-Jet sub-block packing failed" <<
endmsg;
626 return StatusCode::FAILURE;
629 msg() <<
"CMX-Jet sub-block data words: "
632 subBlock->
write(theROD);
636 return StatusCode::SUCCESS;
653 for (
int slink = 0; slink < maxSlinks; ++slink)
655 const int daqOrRoi = 0;
656 const uint32_t rodId =
m_srcIdMap.getRodID(hwCrate, slink, daqOrRoi,
658 const uint32_t robId =
m_srcIdMap.getRobID(rodId);
675 const std::string& sgKey,
682 const std::string flag(
"Overlap");
683 const std::string::size_type pos = sgKey.find(flag);
685 (pos == std::string::npos || pos != sgKey.length() - flag.length()) ? 0 : 1;
700 std::set<uint32_t> dupCheck;
703 for (; rob != robEnd; ++rob) {
707 msg() <<
"Treating ROB fragment " << robCount <<
endmsg;
712 uint32_t robid = (*rob)->source_id();
713 if ((*rob)->nstatus() > 0) {
715 (*rob)->status(robData);
718 if (
debug)
msg() <<
"ROB status error - skipping fragment" <<
endmsg;
725 if (!dupCheck.insert(robid).second) {
736 (*rob)->rod_data(payloadBeg);
737 payloadEnd = payloadBeg + (*rob)->rod_ndata();
738 payload = payloadBeg;
739 if (payload == payloadEnd) {
745 const uint32_t sourceID = (*rob)->rod_source_id();
754 msg() <<
"Wrong source identifier in data: ROD "
755 << MSG::hex << sourceID <<
" ROB " << robid
762 const int minorVersion = (*rob)->rod_version() & 0xffff;
763 if (minorVersion <=
m_srcIdMap.minorVersionPreLS1()) {
767 const int rodCrate =
m_srcIdMap.crate(sourceID);
769 msg() <<
"Treating crate " << rodCrate
781 const int headerWords = userHeader.
words();
782 if (headerWords != 1) {
784 if (
debug)
msg() <<
"Unexpected number of user header words: "
788 for (
int i = 0; i < headerWords; ++i) ++payload;
790 int trigJem = userHeader.
jem();
792 msg() <<
"Minor format version number: " << MSG::hex
793 << minorVersion << MSG::dec <<
endmsg
794 <<
"JEM triggered slice offset: " << trigJem <<
endmsg;
800 while (payload != payloadEnd) {
810 cmxJetSubBlock.
clear();
811 payload = cmxJetSubBlock.
read(payload, payloadEnd);
812 if (cmxJetSubBlock.
crate() != rodCrate) {
813 if (
debug)
msg() <<
"Inconsistent crate number in ROD source ID"
826 cmxEnergySubBlock.
clear();
827 payload = cmxEnergySubBlock.
read(payload, payloadEnd);
828 if (cmxEnergySubBlock.
crate() != rodCrate) {
829 if (
debug)
msg() <<
"Inconsistent crate number in ROD source ID"
849 payload = jemSubBlock.
read(payload, payloadEnd);
850 if (jemSubBlock.
crate() != rodCrate) {
851 if (
debug)
msg() <<
"Inconsistent crate number in ROD source ID"
869 return StatusCode::SUCCESS;
882 const int hwCrate = subBlock->
crate();
886 const int timeslices = subBlock->
timeslices();
887 const int sliceNum = subBlock->
slice();
889 msg() <<
"CMX-Energy: Crate " << hwCrate
890 <<
" Module " << module
891 <<
" Firmware " << firmware
892 <<
" Summing " << summing
893 <<
" Total slices " << timeslices
894 <<
" Slice " << sliceNum <<
endmsg;
896 if (timeslices <= trigJem) {
897 if (
debug)
msg() <<
"Triggered CMX slice from header "
898 <<
"inconsistent with number of slices: "
899 << trigJem <<
", " << timeslices <<
endmsg;
903 if (timeslices <= sliceNum) {
904 if (
debug)
msg() <<
"Total slices inconsistent with slice number: "
905 << timeslices <<
", " << sliceNum <<
endmsg;
913 msg() <<
"CMX-Energy sub-block unpacking failed: " << errMsg <<
endmsg;
925 std::vector<unsigned int>& exVec(ld.uintVec0);
926 std::vector<unsigned int>& eyVec(ld.uintVec1);
927 std::vector<unsigned int>& etVec(ld.uintVec2);
928 std::vector<int>& exErrVec(ld.intVec0);
929 std::vector<int>& eyErrVec(ld.intVec1);
930 std::vector<int>& etErrVec(ld.intVec2);
933 const int ssError = derr.
error();
934 const int sliceBeg = ( neutralFormat ) ? 0 : sliceNum;
935 const int sliceEnd = ( neutralFormat ) ? timeslices : sliceNum + 1;
936 for (
int slice = sliceBeg; slice < sliceEnd; ++slice) {
940 for (
int source = 0; source < maxSource; ++source) {
984 ex = subBlock->
hits(slice, hitType, sumType);
989 exErr = exErrBits.
error();
990 eyErr = eyErrBits.
error();
991 etErr = etErrBits.
error();
992 if (ex || ey ||
et || exErr || eyErr || etErr) {
995 exVec.assign(timeslices, 0);
996 eyVec.assign(timeslices, 0);
997 etVec.assign(timeslices, 0);
998 exErrVec.assign(timeslices, 0);
999 eyErrVec.assign(timeslices, 0);
1000 etErrVec.assign(timeslices, 0);
1004 exErrVec[slice] = exErr;
1005 eyErrVec[slice] = eyErr;
1006 etErrVec[slice] = etErr;
1008 std::make_unique<LVL1::CMXEtSums>(swCrate, source, etVec, exVec, eyVec,
1009 etErrVec, exErrVec, eyErrVec, trigJem);
1010 const int key = crate*100 + source;
1011 data.m_cmxEtMap.insert(std::make_pair(key, sumsp.get()));
1012 data.m_cmxEtCollection->push_back(std::move(sumsp));
1014 exVec = sums->
ExVec();
1015 eyVec = sums->
EyVec();
1016 etVec = sums->
EtVec();
1020 const int nsl = exVec.size();
1021 if (timeslices != nsl) {
1022 if (
debug)
msg() <<
"Inconsistent number of slices in sub-blocks"
1027 if (exVec[slice] != 0 || eyVec[slice] != 0 || etVec[slice] != 0 ||
1028 exErrVec[slice] != 0 || eyErrVec[slice] != 0 ||
1029 etErrVec[slice] != 0) {
1030 if (
debug)
msg() <<
"Duplicate data for slice " << slice <<
endmsg;
1037 exErrVec[slice] = exErr;
1038 eyErrVec[slice] = eyErr;
1039 etErrVec[slice] = etErr;
1040 sums->
addEx(exVec, exErrVec);
1041 sums->
addEy(eyVec, eyErrVec);
1042 sums->
addEt(etVec, etErrVec);
1060 const int hwCrate = subBlock->
crate();
1064 const int timeslices = subBlock->
timeslices();
1065 const int sliceNum = subBlock->
slice();
1067 msg() <<
"CMX-Jet: Crate " << hwCrate
1068 <<
" Module " << module
1069 <<
" Firmware " << firmware
1070 <<
" Summing " << summing
1071 <<
" Total slices " << timeslices
1072 <<
" Slice " << sliceNum <<
endmsg;
1074 if (timeslices <= trigJem) {
1075 if (
debug)
msg() <<
"Triggered CMX slice from header "
1076 <<
"inconsistent with number of slices: "
1077 << trigJem <<
", " << timeslices <<
endmsg;
1081 if (timeslices <= sliceNum) {
1082 if (
debug)
msg() <<
"Total slices inconsistent with slice number: "
1083 << timeslices <<
", " << sliceNum <<
endmsg;
1091 msg() <<
"CMX-Jet sub-block unpacking failed: " << errMsg <<
endmsg;
1103 std::vector<int>& energyLgVec(ld.intVec0);
1104 std::vector<int>& energySmVec(ld.intVec1);
1105 std::vector<int>& errorVec(ld.intVec2);
1106 std::vector<unsigned int>& presenceMapVec(ld.uintVec0);
1107 std::vector<unsigned int>& hit0Vec(ld.uintVec0);
1108 std::vector<unsigned int>& hit1Vec(ld.uintVec1);
1109 std::vector<int>& err0Vec(ld.intVec0);
1110 std::vector<int>& err1Vec(ld.intVec1);
1113 const int ssError = derr.
error();
1114 const int sliceBeg = ( neutralFormat ) ? 0 : sliceNum;
1115 const int sliceEnd = ( neutralFormat ) ? timeslices : sliceNum + 1;
1116 for (
int slice = sliceBeg; slice < sliceEnd; ++slice) {
1123 for (
int jem = 0; jem <
m_modules; ++jem) {
1124 const unsigned int presenceMap = subBlock->
presenceMap(slice, jem);
1125 for (
int tob = 0; tob <
m_maxTobs; ++tob) {
1126 const int energyLarge = subBlock->
energyLarge(slice, jem, tob);
1127 const int energySmall = subBlock->
energySmall(slice, jem, tob);
1129 if (energyLarge == 0 && energySmall == 0 &&
error == 0)
break;
1130 const int loc = subBlock->
localCoord(slice, jem, tob);
1131 const int frame = subBlock->
frame(slice, jem, tob);
1135 if (neutralFormat) {
1136 const int parity = subBlock->
parityBits(slice, jem);
1144 const int key =
tobKey(crate, jem, frame, loc);
1147 energyLgVec.assign(timeslices, 0);
1148 energySmVec.assign(timeslices, 0);
1149 errorVec.assign(timeslices, 0);
1150 presenceMapVec.assign(timeslices, 0);
1151 energyLgVec[slice] = energyLarge;
1152 energySmVec[slice] = energySmall;
1153 errorVec[slice] =
error;
1154 presenceMapVec[slice] = presenceMap;
1156 std::make_unique<LVL1::CMXJetTob>(swCrate, jem, frame, loc,
1157 energyLgVec, energySmVec, errorVec,
1158 presenceMapVec, trigJem);
1159 tdata.
m_cmxTobMap.insert(std::make_pair(key, tbp.get()));
1162 energyLgVec = tb->energyLgVec();
1163 energySmVec = tb->energySmVec();
1164 errorVec = tb->errorVec();
1165 presenceMapVec = tb->presenceMapVec();
1166 const int nsl = energyLgVec.size();
1167 if (timeslices != nsl) {
1168 if (
debug)
msg() <<
"Inconsistent number of slices in sub-blocks"
1173 if (energyLgVec[slice] != 0 || energySmVec[slice] != 0 ||
1174 errorVec[slice] != 0 || presenceMapVec[slice] != 0) {
1175 if (
debug)
msg() <<
"Duplicate data for slice " << slice <<
endmsg;
1179 energyLgVec[slice] = energyLarge;
1180 energySmVec[slice] = energySmall;
1181 errorVec[slice] =
error;
1182 presenceMapVec[slice] = presenceMap;
1183 tb->addTob(energyLgVec, energySmVec, errorVec, presenceMapVec);
1194 for (
int source = 0; source < maxSource; ++source) {
1202 const unsigned int hit0 = subBlock->
hits(slice, sourceId, 0);
1203 const unsigned int hit1 = subBlock->
hits(slice, sourceId, 1);
1204 int err0 = subBlock->
hitsError(slice, sourceId, 0);
1205 int err1 = subBlock->
hitsError(slice, sourceId, 1);
1212 err0 = err0Bits.
error();
1213 err1 = err1Bits.
error();
1214 if (hit0 || hit1 || err0 || err1) {
1217 hit0Vec.assign(timeslices, 0);
1218 hit1Vec.assign(timeslices, 0);
1219 err0Vec.assign(timeslices, 0);
1220 err1Vec.assign(timeslices, 0);
1221 hit0Vec[slice] = hit0;
1222 hit1Vec[slice] = hit1;
1223 err0Vec[slice] = err0;
1224 err1Vec[slice] = err1;
1226 std::make_unique<LVL1::CMXJetHits>(swCrate, source, hit0Vec, hit1Vec,
1227 err0Vec, err1Vec, trigJem);
1228 const int key = crate*100 + source;
1229 hdata.
m_cmxHitsMap.insert(std::make_pair(key, jhp.get()));
1236 const int nsl = hit0Vec.size();
1237 if (timeslices != nsl) {
1238 if (
debug)
msg() <<
"Inconsistent number of slices in sub-blocks"
1243 if (hit0Vec[slice] != 0 || hit1Vec[slice] != 0 ||
1244 err0Vec[slice] != 0 || err1Vec[slice] != 0) {
1245 if (
debug)
msg() <<
"Duplicate data for slice " << slice <<
endmsg;
1249 hit0Vec[slice] = hit0;
1250 hit1Vec[slice] = hit1;
1251 err0Vec[slice] = err0;
1252 err1Vec[slice] = err1;
1253 jh->
addHits(hit0Vec, hit1Vec, err0Vec, err1Vec);
1273 const int hwCrate = subBlock->
crate();
1274 const int module = subBlock->
module();
1275 const int timeslices = subBlock->
timeslices();
1276 const int sliceNum = subBlock->
slice();
1278 msg() <<
"JEM: Crate " << hwCrate
1279 <<
" Module " << module
1280 <<
" Total slices " << timeslices
1281 <<
" Slice " << sliceNum <<
endmsg;
1283 if (timeslices <= trigJem) {
1284 if (
debug)
msg() <<
"Triggered JEM slice from header "
1285 <<
"inconsistent with number of slices: "
1286 << trigJem <<
", " << timeslices <<
endmsg;
1290 if (timeslices <= sliceNum) {
1291 if (
debug)
msg() <<
"Total slices inconsistent with slice number: "
1292 << timeslices <<
", " << sliceNum <<
endmsg;
1300 msg() <<
"JEM sub-block unpacking failed: " << errMsg <<
endmsg;
1311 std::vector<unsigned int>& exVec(ld.uintVec0);
1312 std::vector<unsigned int>& eyVec(ld.uintVec1);
1313 std::vector<unsigned int>& etVec(ld.uintVec2);
1316 const int ssError = derr.
error();
1317 std::vector<int> dummy(timeslices);
1318 const int sliceBeg = ( neutralFormat ) ? 0 : sliceNum;
1319 const int sliceEnd = ( neutralFormat ) ? timeslices : sliceNum + 1;
1320 for (
int slice = sliceBeg; slice < sliceEnd; ++slice) {
1327 for (
int chan = 0; chan <
m_channels; ++chan) {
1329 if (jetEle.
data() || ssError) {
1334 if (layer == ld.coreOverlap) {
1338 const unsigned int key = ld.elementKey.jeKey(
phi,
eta);
1340 std::make_unique<LVL1::JetElement>(
phi,
eta, dummy, dummy, key,
1341 dummy, dummy, dummy, trigJem);
1343 jedata.
m_jeMap.insert(std::make_pair(key, jep.get()));
1346 const std::vector<int>& emEnergy(je->
emEnergyVec());
1348 const std::vector<int>& emError(je->
emErrorVec());
1349 const std::vector<int>& hadError(je->
hadErrorVec());
1350 const int nsl = emEnergy.size();
1351 if (timeslices != nsl) {
1353 msg() <<
"Inconsistent number of slices in sub-blocks"
1359 if (emEnergy[slice] != 0 || hadEnergy[slice] != 0 ||
1360 emError[slice] != 0 || hadError[slice] != 0) {
1361 if (
debug)
msg() <<
"Duplicate data for slice "
1369 const int linkError = jetEle.
linkError();
1379 msg(MSG::VERBOSE) <<
"Non-zero data but no channel mapping for channel "
1384 msg(MSG::VERBOSE) <<
"No jet element data for channel "
1385 << chan <<
" slice " << slice <<
endmsg;
1394 const unsigned int ex = subBlock->
ex(slice);
1395 const unsigned int ey = subBlock->
ey(slice);
1396 const unsigned int et = subBlock->
et(slice);
1400 exVec.assign(timeslices, 0);
1401 eyVec.assign(timeslices, 0);
1402 etVec.assign(timeslices, 0);
1407 std::make_unique<LVL1::JEMEtSums>(swCrate, module, etVec, exVec, eyVec,
1409 sumdata.
m_etMap.insert(std::make_pair(crate*
m_modules+module, sumsp.get()));
1412 exVec = sums->
ExVec();
1413 eyVec = sums->
EyVec();
1414 etVec = sums->
EtVec();
1415 const int nsl = exVec.size();
1416 if (timeslices != nsl) {
1418 msg() <<
"Inconsistent number of slices in sub-blocks"
1424 if (exVec[slice] != 0 || eyVec[slice] != 0 || etVec[slice] != 0) {
1425 if (
debug)
msg() <<
"Duplicate data for slice "
1438 msg(MSG::VERBOSE) <<
"No energy sums data for crate/module/slice "
1439 << hwCrate <<
"/" << module <<
"/" << slice
1451 const int frame,
const int loc)
const
1453 return ((((((crate<<4)+jem)<<3)+frame)<<2)+loc);
1464 const unsigned int key = elementKey.
jeKey(
phi,
eta);
1465 ConstJetElementMap::const_iterator mapIter = jeMap.find(key);
1466 if (mapIter != jeMap.end())
return mapIter->second;
1475 const unsigned int key = elementKey.
jeKey(
phi,
eta);
1476 JetElementMap::const_iterator mapIter =
data.m_jeMap.find(key);
1477 if (mapIter !=
data.m_jeMap.end())
return mapIter->second;
1488 ConstEnergySumsMap::const_iterator mapIter = etMap.find(crate*
m_modules + module);
1489 if (mapIter != etMap.end())
return mapIter->second;
1495 const int module)
const
1497 EnergySumsMap::const_iterator mapIter =
data.m_etMap.find(crate*
m_modules + module);
1498 if (mapIter !=
data.m_etMap.end())
return mapIter->second;
1508 ConstCmxTobMap::const_iterator mapIter = cmxTobMap.find(key);
1509 if (mapIter != cmxTobMap.end())
return mapIter->second;
1514 const int key)
const
1516 CmxTobMap::const_iterator mapIter =
data.m_cmxTobMap.find(key);
1517 if (mapIter !=
data.m_cmxTobMap.end())
return mapIter->second;
1528 ConstCmxHitsMap::const_iterator mapIter = cmxHitsMap.find(crate*100 + source);
1529 if (mapIter != cmxHitsMap.end())
return mapIter->second;
1535 const int source)
const
1537 CmxHitsMap::const_iterator mapIter =
data.m_cmxHitsMap.find(crate*100 + source);
1538 if (mapIter !=
data.m_cmxHitsMap.end())
return mapIter->second;
1549 ConstCmxSumsMap::const_iterator mapIter = cmxEtMap.find(crate*100 + source);
1550 if (mapIter != cmxEtMap.end())
return mapIter->second;
1556 const int source)
const
1558 CmxSumsMap::const_iterator mapIter =
data.m_cmxEtMap.find(crate*100 + source);
1559 if (mapIter !=
data.m_cmxEtMap.end())
return mapIter->second;
1574 for (; pos != pose; ++pos) {
1576 const unsigned int key = elementKey.
jeKey(je->
phi(), je->
eta());
1577 jeMap.insert(std::make_pair(key, je));
1592 for (; pos != pose; ++pos) {
1596 etMap.insert(std::make_pair(key, sums));
1604 const tobCollection,
1608 if (tobCollection) {
1611 for (; pos != pose; ++pos) {
1614 const int jem = tob->
jem();
1615 const int frame = tob->
frame();
1617 const int key =
tobKey(crate, jem, frame, loc);
1618 cmxTobMap.insert(std::make_pair(key, tob));
1626 const hitCollection,
1630 if (hitCollection) {
1633 for (; pos != pose; ++pos) {
1636 const int key = crate*100 + hits->source();
1637 cmxHitsMap.insert(std::make_pair(key, hits));
1652 for (; pos != pose; ++pos) {
1655 const int key = crate*100 + sums->
source();
1656 cmxEtMap.insert(std::make_pair(key, sums));
1664 const int modulesPerSlink,
1676 for (
int mod = module; mod < module + modulesPerSlink; ++mod) {
1677 for (
int chan = 0; chan <
m_channels; ++chan) {
1681 if ( !
m_jemMaps->mapping(crate, mod, chan,
eta,
phi, layer))
continue;
1684 if ( !je )
continue;
1685 const int numdat = 5;
1686 std::vector<int> sums(numdat);
1687 std::vector<int> sizes(numdat);
1688 sums[0] = std::accumulate((je->
emEnergyVec()).begin(),
1690 sums[1] = std::accumulate((je->
hadEnergyVec()).begin(),
1692 sums[2] = std::accumulate((je->
emErrorVec()).begin(),
1694 sums[3] = std::accumulate((je->
hadErrorVec()).begin(),
1696 sums[4] = std::accumulate((je->
linkErrorVec()).begin(),
1703 const int peak = je->
peak();
1704 for (
int i = 0; i < numdat; ++i) {
1705 if (sums[i] == 0)
continue;
1709 }
else if (slices != sizes[i] || trigJ != peak)
return false;
1714 const int numdat = 3;
1715 std::vector<unsigned int> sums(numdat);
1716 std::vector<int> sizes(numdat);
1717 sums[0] = std::accumulate((
et->ExVec()).begin(),
1718 (
et->ExVec()).end(), 0);
1719 sums[1] = std::accumulate((
et->EyVec()).begin(),
1720 (
et->EyVec()).end(), 0);
1721 sums[2] = std::accumulate((
et->EtVec()).begin(),
1722 (
et->EtVec()).end(), 0);
1723 sizes[0] = (
et->ExVec()).size();
1724 sizes[1] = (
et->EyVec()).size();
1725 sizes[2] = (
et->EtVec()).size();
1726 const int peak =
et->peak();
1727 for (
int i = 0; i < numdat; ++i) {
1728 if (sums[i] == 0)
continue;
1732 }
else if (slices != sizes[i] || trigJ != peak)
return false;
1737 if (module/modulesPerSlink ==
m_slinks - 1) {
1738 for (
int jem = module; jem < module + modulesPerSlink; ++jem) {
1739 for (
int frame = 0; frame <
m_frames; ++frame) {
1741 const int key =
tobKey(crate, jem, frame, loc);
1744 const int numdat = 4;
1745 std::vector<int> sums(numdat);
1746 std::vector<int> sizes(numdat);
1747 sums[0] = std::accumulate((tob->
energyLgVec()).begin(),
1749 sums[1] = std::accumulate((tob->
energySmVec()).begin(),
1751 sums[2] = std::accumulate((tob->
errorVec()).begin(),
1757 sizes[2] = (tob->
errorVec()).size();
1759 const int peak = tob->
peak();
1760 for (
int i = 0; i < numdat; ++i) {
1761 if (sums[i] == 0)
continue;
1765 }
else if (slices != sizes[i] || trigJ != peak)
return false;
1773 const int maxDataID = (maxDataID1 > maxDataID2) ? maxDataID1 : maxDataID2;
1774 for (
int source = 0; source < maxDataID; ++source) {
1775 const int numdat = 6;
1776 std::vector<unsigned int> sums(numdat);
1777 std::vector<int> sizes(numdat);
1779 if (source < maxDataID1) hits =
findCmxHits(crate, source, cmxHitsMap);
1781 sums[0] = std::accumulate((hits->hitsVec0()).begin(),
1782 (hits->hitsVec0()).end(), 0);
1783 sums[1] = std::accumulate((hits->hitsVec1()).begin(),
1784 (hits->hitsVec1()).end(), 0);
1785 sums[2] = std::accumulate((hits->errorVec0()).begin(),
1786 (hits->errorVec0()).end(), 0);
1787 sums[3] = std::accumulate((hits->errorVec1()).begin(),
1788 (hits->errorVec1()).end(), 0);
1789 sizes[0] = (hits->hitsVec0()).size();
1790 sizes[1] = (hits->hitsVec1()).size();
1791 sizes[2] = (hits->errorVec0()).size();
1792 sizes[3] = (hits->errorVec1()).size();
1793 const int peak = hits->peak();
1794 for (
int i = 0; i < 4; ++i) {
1795 if (sums[i] == 0)
continue;
1799 }
else if (slices != sizes[i] || trigJ != peak)
return false;
1804 sums[0] = std::accumulate((
et->ExVec()).begin(),
1805 (
et->ExVec()).end(), 0);
1806 sums[1] = std::accumulate((
et->EyVec()).begin(),
1807 (
et->EyVec()).end(), 0);
1808 sums[2] = std::accumulate((
et->EtVec()).begin(),
1809 (
et->EtVec()).end(), 0);
1810 sums[3] = std::accumulate((
et->ExErrorVec()).begin(),
1811 (
et->ExErrorVec()).end(), 0);
1812 sums[4] = std::accumulate((
et->EyErrorVec()).begin(),
1813 (
et->EyErrorVec()).end(), 0);
1814 sums[5] = std::accumulate((
et->EtErrorVec()).begin(),
1815 (
et->EtErrorVec()).end(), 0);
1816 sizes[0] = (
et->ExVec()).size();
1817 sizes[1] = (
et->EyVec()).size();
1818 sizes[2] = (
et->EtVec()).size();
1819 sizes[3] = (
et->ExErrorVec()).size();
1820 sizes[4] = (
et->EyErrorVec()).size();
1821 sizes[5] = (
et->EtErrorVec()).size();
1822 const int peak =
et->peak();
1823 for (
int i = 0; i < numdat; ++i) {
1824 if (sums[i] == 0)
continue;
1828 }
else if (slices != sizes[i] || trigJ != peak)
return false;
1834 timeslices = slices;
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
char data[hepevt_bytes_allocation_ATLAS]
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
bool msgLvl(const MSG::Level lvl) const
DataModel_detail::const_iterator< DataVector > const_iterator
value_type push_back(value_type pElem)
Add an element to the end of the collection.
DataModel_detail::iterator< DataVector > iterator
Standard iterator.
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 CMX-Energy data post LS1.
unsigned int hits(int slice, HitsType hType, SumType sType) const
Return hits map for given hits type and sum type.
void setSubsums(int slice, int jem, unsigned int ex, unsigned int ey, unsigned int et, int exError, int eyError, int etError)
Store energy subsums and errors for given JEM.
void setEtHits(int slice, HitsType hType, SumType sType, unsigned int map)
Store hits map for given hits type and sum type.
bool unpack()
Unpack data.
unsigned int energy(int slice, int jem, EnergyType eType) const
Return energy subsum for given JEM and energy type.
void clear()
Clear all data.
int error(int slice, int jem, EnergyType eType) const
Return energy subsum error for given JEM and energy type.
Sub-Block class for CMX-Jet data post LS1.
int energyLarge(int slice, int jem, int tob) const
Return energy large window size for given jem and tob.
int localCoord(int slice, int jem, int tob) const
Return Local coordinate for given jem and tob.
void setParityBits(int slice, int jem, int parity)
Store parity bits for neutral format.
bool unpack()
Unpack data.
int frame(int slice, int jem, int tob) const
Return frame for given jem and tob.
int energySmall(int slice, int jem, int tob) const
Return energy small window size for given jem and tob.
unsigned int hits(int slice, int source, int flag) const
Return hit/topo counts for given source ID and HL flag.
unsigned int presenceMap(int slice, int jem) const
Return presence map for given JEM.
int parityBits(int slice, int jem) const
Return parity bits for given JEM.
void setHits(int slice, int source, int flag, unsigned int hits, int error)
Store hit counts for given source ID and HL flag.
void setPresenceMap(int slice, int jem, unsigned int map)
Store presence map.
void setTob(int slice, int jem, int frame, int loc, int energyLarge, int energySmall, int error)
Store TOB (RoI) data for given JEM, frame, local coord.
void clear()
Clear all data.
int hitsError(int slice, int source, int flag) const
Return hit error for given source ID and HL flag.
int tobError(int slice, int jem, int tob) const
Return error bit for given jem and tob.
static bool cmxBlock(uint32_t word)
Determine if header word corresponds to CMX.
void setCmxHeader(int version, int format, int slice, int crate, int summing, int firmware, int position, int timeslices)
Store CMX header.
static CmxFirmwareCode cmxType(uint32_t word)
CMX differentiation (CMX_CP, CMX_JET, or CMX_ENERGY)
JEM jet element dataword class.
Sub-Block class for JEM data post LS1.
int timeslices() const
Return number of timeslices.
void fillJetElement(int slice, const JemJetElement &jetEle)
Store jet element data.
void clear()
Clear all data.
bool unpack()
Unpack data.
unsigned int ey(int slice) const
Return energy subsum Ey.
void setEnergySubsums(int slice, unsigned int ex, unsigned int ey, unsigned int et)
Store energy subsum data.
unsigned int ex(int slice) const
Return energy subsum Ex.
void setJemHeader(int version, int format, int slice, int crate, int module, int timeslices)
Store JEM header.
unsigned int et(int slice) const
Return energy subsum Et.
JemJetElement jetElement(int slice, int channel) const
Return jet element for given channel.
void setStatus(uint32_t failingBCN, bool glinkTimeout, bool glinkDown, bool upstreamError, bool daqOverflow, bool bcnMismatch, bool glinkProtocol, bool glinkParity)
Store error status trailer.
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.
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.
CMXEtSums object stores Et sums from the Energy CMXs.
const std::vector< unsigned int > & ExVec() const
returns module Ex sum
void addEt(const std::vector< unsigned int > &Et, const std::vector< int > &EtError)
Add data to existing objects.
void addEx(const std::vector< unsigned int > &Ex, const std::vector< int > &ExError)
Update Ex sum.
void addEy(const std::vector< unsigned int > &Ey, const std::vector< int > &EyError)
Update Ey sum.
int source() const
returns data source
const std::vector< unsigned int > & EyVec() const
returns module Ey sum
const std::vector< int > & EyErrorVec() const
returns module Ey errors
int crate() const
Data accessors.
const std::vector< int > & ExErrorVec() const
returns module Ex errors
const std::vector< int > & EtErrorVec() const
returns module ET errors
const std::vector< unsigned int > & EtVec() const
Access multi-slice data.
@ MISSING_ET_SIG_STANDARD
Summary of JEP (Jet) hits produced by the merger modules.
const std::vector< int > & errorVec1() const
returns error1
const std::vector< int > & errorVec0() const
returns error0
const std::vector< unsigned int > & hitsVec0() const
For multi-slice readout.
void addHits(const std::vector< unsigned int > &hits0, const std::vector< unsigned int > &hits1, const std::vector< int > &error0, const std::vector< int > &error1)
Add data to existing object.
const std::vector< unsigned int > & hitsVec1() const
returns hits1
TOB data received by the merger modules.
int peak() const
returns peak slice number
const std::vector< int > & energySmVec() const
returns energy small window
int jem() const
returns JEM number
int crate() const
Data accessors.
int frame() const
returns frame number
int location() const
returns location
const std::vector< int > & energyLgVec() const
For multi-slice readout.
const std::vector< unsigned int > & presenceMapVec() const
returns presence maps
const std::vector< int > & errorVec() const
returns error
int error() const
Return the full error word.
void set(ErrorBit bit, int value=1)
Set an error bit or data.
int get(ErrorBit bit) const
Return an error bit or data.
int module() const
returns module number
const std::vector< unsigned int > & EyVec() const
returns module Ey sum
void addEx(const std::vector< unsigned int > &Ex)
Update Ex sum.
const std::vector< unsigned int > & ExVec() const
returns module Ex sum
void addEt(const std::vector< unsigned int > &Et)
Update ET sum.
const std::vector< unsigned int > & EtVec() const
returns module ET sum
int crate() const
returns crate number
void addEy(const std::vector< unsigned int > &Ey)
Update Ey sum.
Jet/Energy Processor container for writing bytestream post-LS1.
const DataVector< CMXEtSums > * CmxSums() const
Return pointer to CMX energy sums collection.
const DataVector< CMXJetHits > * CmxHits() const
Return pointer to CMX hit sums collection.
const DataVector< CMXJetTob > * CmxTobs() const
Return pointer to CMX TOBs collection.
const DataVector< JEMEtSums > * EnergySums() const
Return pointer to energy sums collection.
const DataVector< JetElement > * JetElements() const
Return pointer to jet element collection.
virtual unsigned int jeKey(const xAOD::TriggerTower &tower)
returns key of passed tower
The JetElementKey object provides the key for each JetElement depending on its eta,...
Jet elements are the inputs to the Jet, ETmiss and ETsum triggers.
double eta() const
Eta of centre of JetElement.
const std::vector< int > & hadEnergyVec() const
return Had energy vector reference (all timeslices)
double phi() const
Phi of centre of JetElement.
const std::vector< int > & linkErrorVec() const
return link error vector reference (all timeslices)
void addSlice(int slice, int emEnergy, int hadEnergy, int emError, int hadError, int linkError)
add data for one timeslice.
const std::vector< int > & emErrorVec() const
return Em error vector reference (all timeslices)
int peak() const
return triggered slice offset
const std::vector< int > & hadErrorVec() const
return Had error vector reference (all timeslices)
const std::vector< int > & emEnergyVec() const
Return data for all slices.
static const InterfaceID IID_IJepByteStreamV2Tool("JepByteStreamV2Tool", 1, 1)
Extra patterns decribing particle interation process.