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 EventContext& ctx,
132 const std::string& sgKey,
135 const std::vector<uint32_t>& vID(
sourceIDs());
139 ATH_MSG_DEBUG(
"Number of ROB fragments:" << robFrags.size());
140 return convert(sgKey, robFrags, collection);
144 const std::string& sgKey,
154 const EventContext& ctx,
155 const std::string& sgKey,
158 const std::vector<uint32_t>& vID(
sourceIDs());
162 ATH_MSG_DEBUG(
"Number of ROB fragments:" << robFrags.size());
163 return convert(sgKey, robFrags, collection);
167 const std::string& sgKey,
177 const EventContext& ctx,
178 const std::string& sgKey,
181 const std::vector<uint32_t>& vID(
sourceIDs());
185 ATH_MSG_DEBUG(
"Number of ROB fragments:" << robFrags.size());
186 return convert(sgKey, robFrags, collection);
190 const std::string& sgKey,
200 const EventContext& ctx,
201 const std::string& sgKey,
204 const std::vector<uint32_t>& vID(
sourceIDs());
208 ATH_MSG_DEBUG(
"Number of ROB fragments:" << robFrags.size());
209 return convert(sgKey, robFrags, collection);
213 const std::string& sgKey,
224 const EventContext& ctx,
225 const std::string& sgKey,
228 const std::vector<uint32_t>& vID(
sourceIDs());
232 ATH_MSG_DEBUG(
"Number of ROB fragments:" << robFrags.size());
233 return convert(sgKey, robFrags, collection);
237 const std::string& sgKey,
251 return StatusCode::FAILURE;
260 "JepByteStreamV2") );
261 const uint16_t minorVersion =
m_srcIdMap.minorVersion();
299 int timeslicesNew = 1;
304 for (
int module=0;
module < m_modules; ++module) {
308 if (module%modulesPerSlink == 0) {
309 const int daqOrRoi = 0;
310 const int slink =
module/modulesPerSlink;
312 msg() <<
"Treating crate " << hwCrate
313 <<
" slink " << slink <<
endmsg;
326 msg(MSG::ERROR) <<
"Inconsistent number of slices or "
327 <<
"triggered slice offsets in data for crate "
328 << hwCrate <<
" slink " << slink <<
endmsg;
329 return StatusCode::FAILURE;
336 <<
"Slices/offset: " << timeslices <<
" " << trigJem;
337 if (timeslices != timeslicesNew) {
338 msg() <<
" modified to " << timeslicesNew <<
" " << trigJemNew;
343 userHeader.
setJem(trigJemNew);
344 const uint32_t rodIdJem =
m_srcIdMap.getRodID(hwCrate, slink, daqOrRoi,
347 theROD->push_back(userHeader.
header());
349 if (
debug)
msg() <<
"Module " <<
module << endmsg;
355 for (
int slice = 0; slice < timeslicesNew; ++slice) {
358 hwCrate, module, timeslicesNew);
360 if (neutralFormat)
break;
374 std::vector<int> emData;
375 std::vector<int> hadData;
376 std::vector<int> emErrors;
377 std::vector<int> hadErrors;
382 for (
int slice = 0; slice < timeslicesNew; ++slice) {
385 const int index = ( neutralFormat ) ? 0 : slice;
387 const JemJetElement jetEle(chan, emData[slice], hadData[slice],
402 subBlock->
setStatus(failingBCN, gLinkTimeout, gLinkDown,
403 moduleError, fIFOOverflow, bCNMismatch,
404 gLinkProtocol, gLinkParity);
415 std::vector<unsigned int> exVec;
416 std::vector<unsigned int> eyVec;
417 std::vector<unsigned int> etVec;
421 for (
int slice = 0; slice < timeslicesNew; ++slice) {
422 const int index = ( neutralFormat ) ? 0 : slice;
432 for (pos = jemBlocks.
begin(); pos != jemBlocks.
end(); ++pos) {
434 if ( !subBlock->
pack()) {
435 msg(MSG::ERROR) <<
"JEM sub-block packing failed" <<
endmsg;
436 return StatusCode::FAILURE;
439 msg() <<
"JEM sub-block data words: "
442 subBlock->
write(theROD);
457 for (
int slice = 0; slice < timeslicesNew; ++slice) {
459 const int cmxEnergyVersion = 3;
469 if (neutralFormat)
break;
475 for (
int source = 0; source < maxSource; ++source) {
483 std::vector<unsigned int> ex;
484 std::vector<unsigned int> ey;
485 std::vector<unsigned int>
et;
486 std::vector<int> exErr;
487 std::vector<int> eyErr;
488 std::vector<int> etErr;
495 for (
int slice = 0; slice < timeslicesNew; ++slice) {
507 const int index = ( neutralFormat ) ? 0 : slice;
511 ex[slice], ey[slice],
et[slice],
512 exError, eyError, etError);
520 ex[slice], ey[slice],
et[slice],
521 exError, eyError, etError);
523 subBlock->
setEtHits(slice, hitType, sumType,
et[slice]);
530 pos = cmxEnergyBlocks.
begin();
531 for (; pos != cmxEnergyBlocks.
end(); ++pos) {
533 if ( !subBlock->
pack()) {
534 msg(MSG::ERROR) <<
"CMX-Energy sub-block packing failed" <<
endmsg;
535 return StatusCode::FAILURE;
538 msg() <<
"CMX-Energy sub-block data words: "
541 subBlock->
write(theROD);
546 for (
int jem = 0; jem <
m_modules; ++jem) {
547 for (
int frame = 0; frame <
m_frames; ++frame) {
549 const int key =
tobKey(crate, jem, frame, loc);
552 std::vector<int> energyLarge;
553 std::vector<int> energySmall;
554 std::vector<int>
error;
555 std::vector<unsigned int> presence;
560 for (
int slice = 0; slice < timeslicesNew; ++slice) {
567 const int index = ( neutralFormat ) ? 0 : slice;
569 subBlock->
setTob(slice, jem, frame, loc, energyLarge[slice],
570 energySmall[slice], err0);
582 for (
int source = 0; source < maxSource; ++source) {
592 std::vector<unsigned int> hits0;
593 std::vector<unsigned int> hits1;
594 std::vector<int> err0;
595 std::vector<int> err1;
600 for (
int slice = 0; slice < timeslicesNew; ++slice) {
615 const int index = ( neutralFormat ) ? 0 : slice;
617 subBlock->
setHits(slice, sourceId, 0, hits0[slice],
error);
620 subBlock->
setHits(slice, sourceId, 1, hits1[slice],
error);
626 jos = cmxJetBlocks.
begin();
627 for (; jos != cmxJetBlocks.
end(); ++jos) {
629 if ( !subBlock->
pack()) {
630 msg(MSG::ERROR) <<
"CMX-Jet sub-block packing failed" <<
endmsg;
631 return StatusCode::FAILURE;
634 msg() <<
"CMX-Jet sub-block data words: "
637 subBlock->
write(theROD);
641 return StatusCode::SUCCESS;
658 for (
int slink = 0; slink < maxSlinks; ++slink)
660 const int daqOrRoi = 0;
661 const uint32_t rodId =
m_srcIdMap.getRodID(hwCrate, slink, daqOrRoi,
663 const uint32_t robId =
m_srcIdMap.getRobID(rodId);
680 const std::string& sgKey,
687 const std::string flag(
"Overlap");
688 const std::string::size_type pos = sgKey.find(flag);
690 (pos == std::string::npos || pos != sgKey.length() - flag.length()) ? 0 : 1;
705 std::set<uint32_t> dupCheck;
708 for (; rob != robEnd; ++rob) {
712 msg() <<
"Treating ROB fragment " << robCount <<
endmsg;
717 uint32_t robid = (*rob)->source_id();
718 if ((*rob)->nstatus() > 0) {
720 (*rob)->status(robData);
723 if (
debug)
msg() <<
"ROB status error - skipping fragment" <<
endmsg;
730 if (!dupCheck.insert(robid).second) {
741 (*rob)->rod_data(payloadBeg);
742 payloadEnd = payloadBeg + (*rob)->rod_ndata();
743 payload = payloadBeg;
744 if (payload == payloadEnd) {
750 const uint32_t sourceID = (*rob)->rod_source_id();
759 msg() <<
"Wrong source identifier in data: ROD "
760 << MSG::hex << sourceID <<
" ROB " << robid
767 const int minorVersion = (*rob)->rod_version() & 0xffff;
768 if (minorVersion <=
m_srcIdMap.minorVersionPreLS1()) {
772 const int rodCrate =
m_srcIdMap.crate(sourceID);
774 msg() <<
"Treating crate " << rodCrate
786 const int headerWords = userHeader.
words();
787 if (headerWords != 1) {
789 if (
debug)
msg() <<
"Unexpected number of user header words: "
793 for (
int i = 0; i < headerWords; ++i) ++payload;
795 int trigJem = userHeader.
jem();
797 msg() <<
"Minor format version number: " << MSG::hex
798 << minorVersion << MSG::dec <<
endmsg
799 <<
"JEM triggered slice offset: " << trigJem <<
endmsg;
805 while (payload != payloadEnd) {
815 cmxJetSubBlock.
clear();
816 payload = cmxJetSubBlock.
read(payload, payloadEnd);
817 if (cmxJetSubBlock.
crate() != rodCrate) {
818 if (
debug)
msg() <<
"Inconsistent crate number in ROD source ID"
831 cmxEnergySubBlock.
clear();
832 payload = cmxEnergySubBlock.
read(payload, payloadEnd);
833 if (cmxEnergySubBlock.
crate() != rodCrate) {
834 if (
debug)
msg() <<
"Inconsistent crate number in ROD source ID"
854 payload = jemSubBlock.
read(payload, payloadEnd);
855 if (jemSubBlock.
crate() != rodCrate) {
856 if (
debug)
msg() <<
"Inconsistent crate number in ROD source ID"
874 return StatusCode::SUCCESS;
887 const int hwCrate = subBlock->
crate();
891 const int timeslices = subBlock->
timeslices();
892 const int sliceNum = subBlock->
slice();
894 msg() <<
"CMX-Energy: Crate " << hwCrate
895 <<
" Module " << module
896 <<
" Firmware " << firmware
897 <<
" Summing " << summing
898 <<
" Total slices " << timeslices
899 <<
" Slice " << sliceNum <<
endmsg;
901 if (timeslices <= trigJem) {
902 if (
debug)
msg() <<
"Triggered CMX slice from header "
903 <<
"inconsistent with number of slices: "
904 << trigJem <<
", " << timeslices <<
endmsg;
908 if (timeslices <= sliceNum) {
909 if (
debug)
msg() <<
"Total slices inconsistent with slice number: "
910 << timeslices <<
", " << sliceNum <<
endmsg;
918 msg() <<
"CMX-Energy sub-block unpacking failed: " << errMsg <<
endmsg;
930 std::vector<unsigned int>& exVec(ld.uintVec0);
931 std::vector<unsigned int>& eyVec(ld.uintVec1);
932 std::vector<unsigned int>& etVec(ld.uintVec2);
933 std::vector<int>& exErrVec(ld.intVec0);
934 std::vector<int>& eyErrVec(ld.intVec1);
935 std::vector<int>& etErrVec(ld.intVec2);
938 const int ssError = derr.
error();
939 const int sliceBeg = ( neutralFormat ) ? 0 : sliceNum;
940 const int sliceEnd = ( neutralFormat ) ? timeslices : sliceNum + 1;
941 for (
int slice = sliceBeg; slice < sliceEnd; ++slice) {
945 for (
int source = 0; source < maxSource; ++source) {
989 ex = subBlock->
hits(slice, hitType, sumType);
994 exErr = exErrBits.
error();
995 eyErr = eyErrBits.
error();
996 etErr = etErrBits.
error();
997 if (ex || ey ||
et || exErr || eyErr || etErr) {
1000 exVec.assign(timeslices, 0);
1001 eyVec.assign(timeslices, 0);
1002 etVec.assign(timeslices, 0);
1003 exErrVec.assign(timeslices, 0);
1004 eyErrVec.assign(timeslices, 0);
1005 etErrVec.assign(timeslices, 0);
1009 exErrVec[slice] = exErr;
1010 eyErrVec[slice] = eyErr;
1011 etErrVec[slice] = etErr;
1013 std::make_unique<LVL1::CMXEtSums>(swCrate, source, etVec, exVec, eyVec,
1014 etErrVec, exErrVec, eyErrVec, trigJem);
1015 const int key = crate*100 + source;
1016 data.m_cmxEtMap.insert(std::make_pair(key, sumsp.get()));
1017 data.m_cmxEtCollection->push_back(std::move(sumsp));
1019 exVec = sums->
ExVec();
1020 eyVec = sums->
EyVec();
1021 etVec = sums->
EtVec();
1025 const int nsl = exVec.size();
1026 if (timeslices != nsl) {
1027 if (
debug)
msg() <<
"Inconsistent number of slices in sub-blocks"
1032 if (exVec[slice] != 0 || eyVec[slice] != 0 || etVec[slice] != 0 ||
1033 exErrVec[slice] != 0 || eyErrVec[slice] != 0 ||
1034 etErrVec[slice] != 0) {
1035 if (
debug)
msg() <<
"Duplicate data for slice " << slice <<
endmsg;
1042 exErrVec[slice] = exErr;
1043 eyErrVec[slice] = eyErr;
1044 etErrVec[slice] = etErr;
1045 sums->
addEx(exVec, exErrVec);
1046 sums->
addEy(eyVec, eyErrVec);
1047 sums->
addEt(etVec, etErrVec);
1065 const int hwCrate = subBlock->
crate();
1069 const int timeslices = subBlock->
timeslices();
1070 const int sliceNum = subBlock->
slice();
1072 msg() <<
"CMX-Jet: Crate " << hwCrate
1073 <<
" Module " << module
1074 <<
" Firmware " << firmware
1075 <<
" Summing " << summing
1076 <<
" Total slices " << timeslices
1077 <<
" Slice " << sliceNum <<
endmsg;
1079 if (timeslices <= trigJem) {
1080 if (
debug)
msg() <<
"Triggered CMX slice from header "
1081 <<
"inconsistent with number of slices: "
1082 << trigJem <<
", " << timeslices <<
endmsg;
1086 if (timeslices <= sliceNum) {
1087 if (
debug)
msg() <<
"Total slices inconsistent with slice number: "
1088 << timeslices <<
", " << sliceNum <<
endmsg;
1096 msg() <<
"CMX-Jet sub-block unpacking failed: " << errMsg <<
endmsg;
1108 std::vector<int>& energyLgVec(ld.intVec0);
1109 std::vector<int>& energySmVec(ld.intVec1);
1110 std::vector<int>& errorVec(ld.intVec2);
1111 std::vector<unsigned int>& presenceMapVec(ld.uintVec0);
1112 std::vector<unsigned int>& hit0Vec(ld.uintVec0);
1113 std::vector<unsigned int>& hit1Vec(ld.uintVec1);
1114 std::vector<int>& err0Vec(ld.intVec0);
1115 std::vector<int>& err1Vec(ld.intVec1);
1118 const int ssError = derr.
error();
1119 const int sliceBeg = ( neutralFormat ) ? 0 : sliceNum;
1120 const int sliceEnd = ( neutralFormat ) ? timeslices : sliceNum + 1;
1121 for (
int slice = sliceBeg; slice < sliceEnd; ++slice) {
1128 for (
int jem = 0; jem <
m_modules; ++jem) {
1129 const unsigned int presenceMap = subBlock->
presenceMap(slice, jem);
1130 for (
int tob = 0; tob <
m_maxTobs; ++tob) {
1131 const int energyLarge = subBlock->
energyLarge(slice, jem, tob);
1132 const int energySmall = subBlock->
energySmall(slice, jem, tob);
1134 if (energyLarge == 0 && energySmall == 0 &&
error == 0)
break;
1135 const int loc = subBlock->
localCoord(slice, jem, tob);
1136 const int frame = subBlock->
frame(slice, jem, tob);
1140 if (neutralFormat) {
1141 const int parity = subBlock->
parityBits(slice, jem);
1149 const int key =
tobKey(crate, jem, frame, loc);
1152 energyLgVec.assign(timeslices, 0);
1153 energySmVec.assign(timeslices, 0);
1154 errorVec.assign(timeslices, 0);
1155 presenceMapVec.assign(timeslices, 0);
1156 energyLgVec[slice] = energyLarge;
1157 energySmVec[slice] = energySmall;
1158 errorVec[slice] =
error;
1159 presenceMapVec[slice] = presenceMap;
1161 std::make_unique<LVL1::CMXJetTob>(swCrate, jem, frame, loc,
1162 energyLgVec, energySmVec, errorVec,
1163 presenceMapVec, trigJem);
1164 tdata.
m_cmxTobMap.insert(std::make_pair(key, tbp.get()));
1167 energyLgVec = tb->energyLgVec();
1168 energySmVec = tb->energySmVec();
1169 errorVec = tb->errorVec();
1170 presenceMapVec = tb->presenceMapVec();
1171 const int nsl = energyLgVec.size();
1172 if (timeslices != nsl) {
1173 if (
debug)
msg() <<
"Inconsistent number of slices in sub-blocks"
1178 if (energyLgVec[slice] != 0 || energySmVec[slice] != 0 ||
1179 errorVec[slice] != 0 || presenceMapVec[slice] != 0) {
1180 if (
debug)
msg() <<
"Duplicate data for slice " << slice <<
endmsg;
1184 energyLgVec[slice] = energyLarge;
1185 energySmVec[slice] = energySmall;
1186 errorVec[slice] =
error;
1187 presenceMapVec[slice] = presenceMap;
1188 tb->addTob(energyLgVec, energySmVec, errorVec, presenceMapVec);
1199 for (
int source = 0; source < maxSource; ++source) {
1207 const unsigned int hit0 = subBlock->
hits(slice, sourceId, 0);
1208 const unsigned int hit1 = subBlock->
hits(slice, sourceId, 1);
1209 int err0 = subBlock->
hitsError(slice, sourceId, 0);
1210 int err1 = subBlock->
hitsError(slice, sourceId, 1);
1217 err0 = err0Bits.
error();
1218 err1 = err1Bits.
error();
1219 if (hit0 || hit1 || err0 || err1) {
1222 hit0Vec.assign(timeslices, 0);
1223 hit1Vec.assign(timeslices, 0);
1224 err0Vec.assign(timeslices, 0);
1225 err1Vec.assign(timeslices, 0);
1226 hit0Vec[slice] = hit0;
1227 hit1Vec[slice] = hit1;
1228 err0Vec[slice] = err0;
1229 err1Vec[slice] = err1;
1231 std::make_unique<LVL1::CMXJetHits>(swCrate, source, hit0Vec, hit1Vec,
1232 err0Vec, err1Vec, trigJem);
1233 const int key = crate*100 + source;
1234 hdata.
m_cmxHitsMap.insert(std::make_pair(key, jhp.get()));
1241 const int nsl = hit0Vec.size();
1242 if (timeslices != nsl) {
1243 if (
debug)
msg() <<
"Inconsistent number of slices in sub-blocks"
1248 if (hit0Vec[slice] != 0 || hit1Vec[slice] != 0 ||
1249 err0Vec[slice] != 0 || err1Vec[slice] != 0) {
1250 if (
debug)
msg() <<
"Duplicate data for slice " << slice <<
endmsg;
1254 hit0Vec[slice] = hit0;
1255 hit1Vec[slice] = hit1;
1256 err0Vec[slice] = err0;
1257 err1Vec[slice] = err1;
1258 jh->
addHits(hit0Vec, hit1Vec, err0Vec, err1Vec);
1278 const int hwCrate = subBlock->
crate();
1279 const int module = subBlock->
module();
1280 const int timeslices = subBlock->
timeslices();
1281 const int sliceNum = subBlock->
slice();
1283 msg() <<
"JEM: Crate " << hwCrate
1284 <<
" Module " << module
1285 <<
" Total slices " << timeslices
1286 <<
" Slice " << sliceNum <<
endmsg;
1288 if (timeslices <= trigJem) {
1289 if (
debug)
msg() <<
"Triggered JEM slice from header "
1290 <<
"inconsistent with number of slices: "
1291 << trigJem <<
", " << timeslices <<
endmsg;
1295 if (timeslices <= sliceNum) {
1296 if (
debug)
msg() <<
"Total slices inconsistent with slice number: "
1297 << timeslices <<
", " << sliceNum <<
endmsg;
1305 msg() <<
"JEM sub-block unpacking failed: " << errMsg <<
endmsg;
1316 std::vector<unsigned int>& exVec(ld.uintVec0);
1317 std::vector<unsigned int>& eyVec(ld.uintVec1);
1318 std::vector<unsigned int>& etVec(ld.uintVec2);
1321 const int ssError = derr.
error();
1322 std::vector<int> dummy(timeslices);
1323 const int sliceBeg = ( neutralFormat ) ? 0 : sliceNum;
1324 const int sliceEnd = ( neutralFormat ) ? timeslices : sliceNum + 1;
1325 for (
int slice = sliceBeg; slice < sliceEnd; ++slice) {
1332 for (
int chan = 0; chan <
m_channels; ++chan) {
1334 if (jetEle.
data() || ssError) {
1339 if (layer == ld.coreOverlap) {
1343 const unsigned int key = ld.elementKey.jeKey(
phi,
eta);
1345 std::make_unique<LVL1::JetElement>(
phi,
eta, dummy, dummy, key,
1346 dummy, dummy, dummy, trigJem);
1348 jedata.
m_jeMap.insert(std::make_pair(key, jep.get()));
1351 const std::vector<int>& emEnergy(je->
emEnergyVec());
1353 const std::vector<int>& emError(je->
emErrorVec());
1354 const std::vector<int>& hadError(je->
hadErrorVec());
1355 const int nsl = emEnergy.size();
1356 if (timeslices != nsl) {
1358 msg() <<
"Inconsistent number of slices in sub-blocks"
1364 if (emEnergy[slice] != 0 || hadEnergy[slice] != 0 ||
1365 emError[slice] != 0 || hadError[slice] != 0) {
1366 if (
debug)
msg() <<
"Duplicate data for slice "
1374 const int linkError = jetEle.
linkError();
1384 msg(MSG::VERBOSE) <<
"Non-zero data but no channel mapping for channel "
1389 msg(MSG::VERBOSE) <<
"No jet element data for channel "
1390 << chan <<
" slice " << slice <<
endmsg;
1399 const unsigned int ex = subBlock->
ex(slice);
1400 const unsigned int ey = subBlock->
ey(slice);
1401 const unsigned int et = subBlock->
et(slice);
1405 exVec.assign(timeslices, 0);
1406 eyVec.assign(timeslices, 0);
1407 etVec.assign(timeslices, 0);
1412 std::make_unique<LVL1::JEMEtSums>(swCrate, module, etVec, exVec, eyVec,
1414 sumdata.
m_etMap.insert(std::make_pair(crate*
m_modules+module, sumsp.get()));
1417 exVec = sums->
ExVec();
1418 eyVec = sums->
EyVec();
1419 etVec = sums->
EtVec();
1420 const int nsl = exVec.size();
1421 if (timeslices != nsl) {
1423 msg() <<
"Inconsistent number of slices in sub-blocks"
1429 if (exVec[slice] != 0 || eyVec[slice] != 0 || etVec[slice] != 0) {
1430 if (
debug)
msg() <<
"Duplicate data for slice "
1443 msg(MSG::VERBOSE) <<
"No energy sums data for crate/module/slice "
1444 << hwCrate <<
"/" << module <<
"/" << slice
1456 const int frame,
const int loc)
const
1458 return ((((((crate<<4)+jem)<<3)+frame)<<2)+loc);
1469 const unsigned int key = elementKey.
jeKey(
phi,
eta);
1470 ConstJetElementMap::const_iterator mapIter = jeMap.find(key);
1471 if (mapIter != jeMap.end())
return mapIter->second;
1480 const unsigned int key = elementKey.
jeKey(
phi,
eta);
1481 JetElementMap::const_iterator mapIter =
data.m_jeMap.find(key);
1482 if (mapIter !=
data.m_jeMap.end())
return mapIter->second;
1493 ConstEnergySumsMap::const_iterator mapIter = etMap.find(crate*
m_modules + module);
1494 if (mapIter != etMap.end())
return mapIter->second;
1500 const int module)
const
1502 EnergySumsMap::const_iterator mapIter =
data.m_etMap.find(crate*
m_modules + module);
1503 if (mapIter !=
data.m_etMap.end())
return mapIter->second;
1513 ConstCmxTobMap::const_iterator mapIter = cmxTobMap.find(key);
1514 if (mapIter != cmxTobMap.end())
return mapIter->second;
1519 const int key)
const
1521 CmxTobMap::const_iterator mapIter =
data.m_cmxTobMap.find(key);
1522 if (mapIter !=
data.m_cmxTobMap.end())
return mapIter->second;
1533 ConstCmxHitsMap::const_iterator mapIter = cmxHitsMap.find(crate*100 + source);
1534 if (mapIter != cmxHitsMap.end())
return mapIter->second;
1540 const int source)
const
1542 CmxHitsMap::const_iterator mapIter =
data.m_cmxHitsMap.find(crate*100 + source);
1543 if (mapIter !=
data.m_cmxHitsMap.end())
return mapIter->second;
1554 ConstCmxSumsMap::const_iterator mapIter = cmxEtMap.find(crate*100 + source);
1555 if (mapIter != cmxEtMap.end())
return mapIter->second;
1561 const int source)
const
1563 CmxSumsMap::const_iterator mapIter =
data.m_cmxEtMap.find(crate*100 + source);
1564 if (mapIter !=
data.m_cmxEtMap.end())
return mapIter->second;
1579 for (; pos != pose; ++pos) {
1581 const unsigned int key = elementKey.
jeKey(je->
phi(), je->
eta());
1582 jeMap.insert(std::make_pair(key, je));
1597 for (; pos != pose; ++pos) {
1601 etMap.insert(std::make_pair(key, sums));
1609 const tobCollection,
1613 if (tobCollection) {
1616 for (; pos != pose; ++pos) {
1619 const int jem = tob->
jem();
1620 const int frame = tob->
frame();
1622 const int key =
tobKey(crate, jem, frame, loc);
1623 cmxTobMap.insert(std::make_pair(key, tob));
1631 const hitCollection,
1635 if (hitCollection) {
1638 for (; pos != pose; ++pos) {
1641 const int key = crate*100 + hits->source();
1642 cmxHitsMap.insert(std::make_pair(key, hits));
1657 for (; pos != pose; ++pos) {
1660 const int key = crate*100 + sums->
source();
1661 cmxEtMap.insert(std::make_pair(key, sums));
1669 const int modulesPerSlink,
1681 for (
int mod = module; mod < module + modulesPerSlink; ++mod) {
1682 for (
int chan = 0; chan <
m_channels; ++chan) {
1686 if ( !
m_jemMaps->mapping(crate, mod, chan,
eta,
phi, layer))
continue;
1689 if ( !je )
continue;
1690 const int numdat = 5;
1691 std::vector<int> sums(numdat);
1692 std::vector<int> sizes(numdat);
1693 sums[0] = std::accumulate((je->
emEnergyVec()).begin(),
1695 sums[1] = std::accumulate((je->
hadEnergyVec()).begin(),
1697 sums[2] = std::accumulate((je->
emErrorVec()).begin(),
1699 sums[3] = std::accumulate((je->
hadErrorVec()).begin(),
1701 sums[4] = std::accumulate((je->
linkErrorVec()).begin(),
1708 const int peak = je->
peak();
1709 for (
int i = 0; i < numdat; ++i) {
1710 if (sums[i] == 0)
continue;
1714 }
else if (slices != sizes[i] || trigJ != peak)
return false;
1719 const int numdat = 3;
1720 std::vector<unsigned int> sums(numdat);
1721 std::vector<int> sizes(numdat);
1722 sums[0] = std::accumulate((
et->ExVec()).begin(),
1723 (
et->ExVec()).end(), 0);
1724 sums[1] = std::accumulate((
et->EyVec()).begin(),
1725 (
et->EyVec()).end(), 0);
1726 sums[2] = std::accumulate((
et->EtVec()).begin(),
1727 (
et->EtVec()).end(), 0);
1728 sizes[0] = (
et->ExVec()).size();
1729 sizes[1] = (
et->EyVec()).size();
1730 sizes[2] = (
et->EtVec()).size();
1731 const int peak =
et->peak();
1732 for (
int i = 0; i < numdat; ++i) {
1733 if (sums[i] == 0)
continue;
1737 }
else if (slices != sizes[i] || trigJ != peak)
return false;
1742 if (module/modulesPerSlink ==
m_slinks - 1) {
1743 for (
int jem = module; jem < module + modulesPerSlink; ++jem) {
1744 for (
int frame = 0; frame <
m_frames; ++frame) {
1746 const int key =
tobKey(crate, jem, frame, loc);
1749 const int numdat = 4;
1750 std::vector<int> sums(numdat);
1751 std::vector<int> sizes(numdat);
1752 sums[0] = std::accumulate((tob->
energyLgVec()).begin(),
1754 sums[1] = std::accumulate((tob->
energySmVec()).begin(),
1756 sums[2] = std::accumulate((tob->
errorVec()).begin(),
1762 sizes[2] = (tob->
errorVec()).size();
1764 const int peak = tob->
peak();
1765 for (
int i = 0; i < numdat; ++i) {
1766 if (sums[i] == 0)
continue;
1770 }
else if (slices != sizes[i] || trigJ != peak)
return false;
1778 const int maxDataID = (maxDataID1 > maxDataID2) ? maxDataID1 : maxDataID2;
1779 for (
int source = 0; source < maxDataID; ++source) {
1780 const int numdat = 6;
1781 std::vector<unsigned int> sums(numdat);
1782 std::vector<int> sizes(numdat);
1784 if (source < maxDataID1) hits =
findCmxHits(crate, source, cmxHitsMap);
1786 sums[0] = std::accumulate((hits->hitsVec0()).begin(),
1787 (hits->hitsVec0()).end(), 0);
1788 sums[1] = std::accumulate((hits->hitsVec1()).begin(),
1789 (hits->hitsVec1()).end(), 0);
1790 sums[2] = std::accumulate((hits->errorVec0()).begin(),
1791 (hits->errorVec0()).end(), 0);
1792 sums[3] = std::accumulate((hits->errorVec1()).begin(),
1793 (hits->errorVec1()).end(), 0);
1794 sizes[0] = (hits->hitsVec0()).size();
1795 sizes[1] = (hits->hitsVec1()).size();
1796 sizes[2] = (hits->errorVec0()).size();
1797 sizes[3] = (hits->errorVec1()).size();
1798 const int peak = hits->peak();
1799 for (
int i = 0; i < 4; ++i) {
1800 if (sums[i] == 0)
continue;
1804 }
else if (slices != sizes[i] || trigJ != peak)
return false;
1809 sums[0] = std::accumulate((
et->ExVec()).begin(),
1810 (
et->ExVec()).end(), 0);
1811 sums[1] = std::accumulate((
et->EyVec()).begin(),
1812 (
et->EyVec()).end(), 0);
1813 sums[2] = std::accumulate((
et->EtVec()).begin(),
1814 (
et->EtVec()).end(), 0);
1815 sums[3] = std::accumulate((
et->ExErrorVec()).begin(),
1816 (
et->ExErrorVec()).end(), 0);
1817 sums[4] = std::accumulate((
et->EyErrorVec()).begin(),
1818 (
et->EyErrorVec()).end(), 0);
1819 sums[5] = std::accumulate((
et->EtErrorVec()).begin(),
1820 (
et->EtErrorVec()).end(), 0);
1821 sizes[0] = (
et->ExVec()).size();
1822 sizes[1] = (
et->EyVec()).size();
1823 sizes[2] = (
et->EtVec()).size();
1824 sizes[3] = (
et->ExErrorVec()).size();
1825 sizes[4] = (
et->EyErrorVec()).size();
1826 sizes[5] = (
et->EtErrorVec()).size();
1827 const int peak =
et->peak();
1828 for (
int i = 0; i < numdat; ++i) {
1829 if (sums[i] == 0)
continue;
1833 }
else if (slices != sizes[i] || trigJ != peak)
return false;
1839 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.