10#include "GaudiKernel/IInterface.h"
11#include "GaudiKernel/MsgStream.h"
12#include "GaudiKernel/StatusCode.h"
53 const std::string& name,
54 const IInterface* parent)
56 m_jemMaps(
"LVL1::JemMappingTool/JemMappingTool"),
57 m_errorTool(
"LVL1BS::L1CaloErrorByteStreamTool/L1CaloErrorByteStreamTool"),
61 declareInterface<JepByteStreamV1Tool>(
this);
64 "Crate/Module/Channel to Eta/Phi/Layer mapping tool");
66 "Tool to collect errors for monitoring");
69 "Offset of JEP crate numbers in bytestream");
71 "Offset of JEP crate numbers in RDOs");
73 "The number of S-Links per crate");
77 "ROB fragment source identifiers");
81 "Format version number in sub-block header");
83 "Format identifier (0-1) in sub-block header");
85 "The number of slices in the simulation");
87 "If >0, the number of slices in bytestream");
89 "Minimum crate number, allows partial output");
91 "Maximum crate number, allows partial output");
112 return StatusCode::SUCCESS;
119 return StatusCode::SUCCESS;
125 const std::string& sgKey,
136 const std::string& sgKey,
147 const std::string& sgKey,
158 const std::string& sgKey,
169 const std::string& sgKey,
187 "JepByteStreamV1") );
188 const uint16_t minorVersion =
m_srcIdMap.minorVersionPreLS1();
226 int timeslicesNew = 1;
231 for (
int module = 0;
module < m_modules; ++module) {
235 if (module % modulesPerSlink == 0) {
236 const int daqOrRoi = 0;
237 const int slink =
module / modulesPerSlink;
239 msg() <<
"Treating crate " << hwCrate
240 <<
" slink " << slink <<
endmsg;
253 msg(MSG::ERROR) <<
"Inconsistent number of slices or "
254 <<
"triggered slice offsets in data for crate "
255 << hwCrate <<
" slink " << slink <<
endmsg;
256 return StatusCode::FAILURE;
263 <<
"Slices/offset: " << timeslices <<
" " << trigJem;
264 if (timeslices != timeslicesNew) {
265 msg() <<
" modified to " << timeslicesNew <<
" " << trigJemNew;
270 userHeader.
setJem(trigJemNew);
271 const uint32_t rodIdJem =
m_srcIdMap.getRodID(hwCrate, slink, daqOrRoi,
274 theROD->push_back(userHeader.
header());
276 if (
debug)
msg() <<
"Module " <<
module << endmsg;
283 for (
int slice = 0; slice < timeslicesNew; ++slice) {
286 hwCrate, module, timeslicesNew);
288 if (neutralFormat)
break;
294 for (
int chan = 0; chan <
m_channels; ++chan) {
301 std::vector<int> emData;
302 std::vector<int> hadData;
303 std::vector<int> emErrors;
304 std::vector<int> hadErrors;
309 for (
int slice = 0; slice < timeslicesNew; ++slice) {
312 const int index = ( neutralFormat ) ? 0 : slice;
314 const JemJetElement jetEle(chan, emData[slice], hadData[slice],
329 std::vector<unsigned int>
vec;
331 for (
int slice = 0; slice < timeslicesNew; ++slice) {
332 const int index = ( neutralFormat ) ? 0 : slice;
339 std::vector<unsigned int> exVec;
340 std::vector<unsigned int> eyVec;
341 std::vector<unsigned int> etVec;
345 for (
int slice = 0; slice < timeslicesNew; ++slice) {
346 const int index = ( neutralFormat ) ? 0 : slice;
356 for (pos = jemBlocks.
begin(); pos != jemBlocks.
end(); ++pos) {
358 if ( !subBlock->
pack()) {
359 msg(MSG::ERROR) <<
"JEM sub-block packing failed" <<
endmsg;
360 return StatusCode::FAILURE;
363 msg() <<
"JEM sub-block data words: "
366 subBlock->
write(theROD);
381 for (
int slice = 0; slice < timeslicesNew; ++slice) {
383 const int cmmEnergyVersion = 2;
393 if (neutralFormat)
break;
399 for (
int dataID = 0; dataID < maxDataID; ++dataID) {
427 std::vector<unsigned int> ex;
428 std::vector<unsigned int> ey;
429 std::vector<unsigned int>
et;
430 std::vector<int> exErr;
431 std::vector<int> eyErr;
432 std::vector<int> etErr;
439 for (
int slice = 0; slice < timeslicesNew; ++slice) {
453 const int index = ( neutralFormat ) ? 0 : slice;
463 ex[slice], ey[slice],
et[slice],
464 exError, eyError, etError);
470 pos = cmmEnergyBlocks.
begin();
471 for (; pos != cmmEnergyBlocks.
end(); ++pos) {
473 if ( !subBlock->
pack()) {
474 msg(MSG::ERROR) <<
"CMM-Energy sub-block packing failed" <<
endmsg;
475 return StatusCode::FAILURE;
478 msg() <<
"CMM-Energy sub-block data words: "
481 subBlock->
write(theROD);
487 for (
int dataID = 0; dataID < maxDataID; ++dataID) {
523 std::vector<unsigned int> hits;
524 std::vector<int> errs;
527 for (
int slice = 0; slice < timeslicesNew; ++slice) {
529 const int index = ( neutralFormat ) ? 0 : slice;
534 subBlock->
setJetHits(slice, source, hits[slice],
541 jos = cmmJetBlocks.
begin();
542 for (; jos != cmmJetBlocks.
end(); ++jos) {
544 if ( !subBlock->
pack()) {
545 msg(MSG::ERROR) <<
"CMM-Jet sub-block packing failed" <<
endmsg;
546 return StatusCode::FAILURE;
549 msg() <<
"CMM-Jet sub-block data words: "
552 subBlock->
write(theROD);
556 return StatusCode::SUCCESS;
573 for (
int slink = 0; slink < maxSlinks; ++slink)
575 const int daqOrRoi = 0;
576 const uint32_t rodId =
m_srcIdMap.getRodID(hwCrate, slink, daqOrRoi,
578 const uint32_t robId =
m_srcIdMap.getRobID(rodId);
595 const std::string& sgKey,
602 const std::string flag(
"Overlap");
603 const std::string::size_type pos = sgKey.find(flag);
605 (pos == std::string::npos || pos != sgKey.length() - flag.length()) ? 0 : 1;
620 std::set<uint32_t> dupCheck;
623 for (; rob != robEnd; ++rob) {
627 msg() <<
"Treating ROB fragment " << robCount <<
endmsg;
632 uint32_t robid = (*rob)->source_id();
633 if ((*rob)->nstatus() > 0) {
635 (*rob)->status(robData);
638 if (
debug)
msg() <<
"ROB status error - skipping fragment" <<
endmsg;
645 if (!dupCheck.insert(robid).second) {
656 (*rob)->rod_data(payloadBeg);
657 payloadEnd = payloadBeg + (*rob)->rod_ndata();
658 payload = payloadBeg;
659 if (payload == payloadEnd) {
665 const uint32_t sourceID = (*rob)->rod_source_id();
674 msg() <<
"Wrong source identifier in data: ROD "
675 << MSG::hex << sourceID <<
" ROB " << robid
682 const int minorVersion = (*rob)->rod_version() & 0xffff;
683 if (minorVersion >
m_srcIdMap.minorVersionPreLS1()) {
687 const int rodCrate =
m_srcIdMap.crate(sourceID);
689 msg() <<
"Treating crate " << rodCrate
701 const int headerWords = userHeader.
words();
702 if (headerWords != 1) {
704 if (
debug)
msg() <<
"Unexpected number of user header words: "
708 for (
int i = 0; i < headerWords; ++i) ++payload;
710 int trigJem = userHeader.
jem();
711 int trigCmm = userHeader.
jepCmm();
713 msg() <<
"Minor format version number: " << MSG::hex
714 << minorVersion << MSG::dec <<
endmsg
715 <<
"JEM triggered slice offset: " << trigJem <<
endmsg
716 <<
"CMM triggered slice offset: " << trigCmm <<
endmsg;
718 if (trigJem != trigCmm) {
719 const int newTrig = (trigJem > trigCmm) ? trigJem : trigCmm;
722 if (
debug)
msg() <<
"Changed both offsets to " << newTrig <<
endmsg;
728 while (payload != payloadEnd) {
738 cmmJetSubBlock.
clear();
739 payload = cmmJetSubBlock.
read(payload, payloadEnd);
740 if (cmmJetSubBlock.
crate() != rodCrate) {
741 if (
debug)
msg() <<
"Inconsistent crate number in ROD source ID"
754 cmmEnergySubBlock.
clear();
755 payload = cmmEnergySubBlock.
read(payload, payloadEnd);
756 if (cmmEnergySubBlock.
crate() != rodCrate) {
757 if (
debug)
msg() <<
"Inconsistent crate number in ROD source ID"
777 payload = jemSubBlock.
read(payload, payloadEnd);
778 if (jemSubBlock.
crate() != rodCrate) {
779 if (
debug)
msg() <<
"Inconsistent crate number in ROD source ID"
798 return StatusCode::SUCCESS;
811 const int hwCrate = subBlock->
crate();
815 const int timeslices = subBlock->
timeslices();
816 const int sliceNum = subBlock->
slice();
818 msg() <<
"CMM-Energy: Crate " << hwCrate
819 <<
" Module " << module
820 <<
" Firmware " << firmware
821 <<
" Summing " << summing
822 <<
" Total slices " << timeslices
823 <<
" Slice " << sliceNum <<
endmsg;
825 if (timeslices <= trigCmm) {
826 if (
debug)
msg() <<
"Triggered CMM slice from header "
827 <<
"inconsistent with number of slices: "
828 << trigCmm <<
", " << timeslices <<
endmsg;
832 if (timeslices <= sliceNum) {
833 if (
debug)
msg() <<
"Total slices inconsistent with slice number: "
834 << timeslices <<
", " << sliceNum <<
endmsg;
842 msg() <<
"CMM-Energy sub-block unpacking failed: " << errMsg <<
endmsg;
856 const int ssError = derr.
error();
857 const int sliceBeg = ( neutralFormat ) ? 0 : sliceNum;
858 const int sliceEnd = ( neutralFormat ) ? timeslices : sliceNum + 1;
859 for (
int slice = sliceBeg; slice < sliceEnd; ++slice) {
863 for (
int source = 0; source < maxSid; ++source) {
882 const unsigned int ex = subBlock->
ex(slice, source);
883 const unsigned int ey = subBlock->
ey(slice, source);
884 const unsigned int et = subBlock->
et(slice, source);
885 int exErr = subBlock->
exError(slice, source);
886 int eyErr = subBlock->
eyError(slice, source);
887 int etErr = subBlock->
etError(slice, source);
905 exErr = exErrBits.
error();
906 eyErr = eyErrBits.
error();
907 etErr = etErrBits.
error();
908 if (ex || ey ||
et || exErr || eyErr || etErr) {
911 ld.exVec.assign(timeslices, 0);
912 ld.eyVec.assign(timeslices, 0);
913 ld.etVec.assign(timeslices, 0);
914 ld.exErrVec.assign(timeslices, 0);
915 ld.eyErrVec.assign(timeslices, 0);
916 ld.etErrVec.assign(timeslices, 0);
917 ld.exVec[slice] = ex;
918 ld.eyVec[slice] = ey;
919 ld.etVec[slice] =
et;
920 ld.exErrVec[slice] = exErr;
921 ld.eyErrVec[slice] = eyErr;
922 ld.etErrVec[slice] = etErr;
924 std::make_unique<LVL1::CMMEtSums>(swCrate, dataID, ld.etVec, ld.exVec, ld.eyVec,
925 ld.etErrVec, ld.exErrVec, ld.eyErrVec, trigCmm);
926 const int key = crate * 100 + dataID;
927 data.m_cmmEtMap.insert(std::make_pair(key, sumsp.get()));
928 data.m_cmmEtCollection->push_back(std::move(sumsp));
930 ld.exVec = sums->
ExVec();
931 ld.eyVec = sums->
EyVec();
932 ld.etVec = sums->
EtVec();
936 const int nsl = ld.exVec.size();
937 if (timeslices != nsl) {
938 if (
debug)
msg() <<
"Inconsistent number of slices in sub-blocks"
943 if (ld.exVec[slice] != 0 || ld.eyVec[slice] != 0 || ld.etVec[slice] != 0 ||
944 ld.exErrVec[slice] != 0 || ld.eyErrVec[slice] != 0 ||
945 ld.etErrVec[slice] != 0) {
946 if (
debug)
msg() <<
"Duplicate data for slice " << slice <<
endmsg;
950 ld.exVec[slice] = ex;
951 ld.eyVec[slice] = ey;
952 ld.etVec[slice] =
et;
953 ld.exErrVec[slice] = exErr;
954 ld.eyErrVec[slice] = eyErr;
955 ld.etErrVec[slice] = etErr;
956 sums->
addEx(ld.exVec, ld.exErrVec);
957 sums->
addEy(ld.eyVec, ld.eyErrVec);
958 sums->
addEt(ld.etVec, ld.etErrVec);
967 if ( missEt || ssError ) {
971 ld.etVec.assign(timeslices, 0);
972 ld.etErrVec.assign(timeslices, 0);
973 ld.etVec[slice] = missEt;
974 ld.etErrVec[slice] = ssError;
976 std::make_unique<LVL1::CMMEtSums>(swCrate, dataID,
977 ld.etVec, ld.etVec, ld.etVec,
978 ld.etErrVec, ld.etErrVec, ld.etErrVec, trigCmm);
979 const int key = crate * 100 + dataID;
980 data.m_cmmEtMap.insert(std::make_pair(key, mapp.get()));
981 data.m_cmmEtCollection->push_back(std::move(mapp));
983 ld.etVec =
map->EtVec();
984 ld.etErrVec =
map->EtErrorVec();
985 const int nsl = ld.etVec.size();
986 if (timeslices != nsl) {
987 if (
debug)
msg() <<
"Inconsistent number of slices in sub-blocks"
992 if (ld.etVec[slice] != 0 || ld.etErrVec[slice] != 0) {
993 if (
debug)
msg() <<
"Duplicate data for slice " << slice <<
endmsg;
997 ld.etVec[slice] = missEt;
998 ld.etErrVec[slice] = ssError;
999 map->addEx(ld.etVec, ld.etErrVec);
1000 map->addEy(ld.etVec, ld.etErrVec);
1001 map->addEt(ld.etVec, ld.etErrVec);
1004 const unsigned int sumEt = subBlock->
sumEtHits(slice);
1005 if ( sumEt || ssError ) {
1009 ld.etVec.assign(timeslices, 0);
1010 ld.etErrVec.assign(timeslices, 0);
1011 ld.etVec[slice] = sumEt;
1012 ld.etErrVec[slice] = ssError;
1014 std::make_unique<LVL1::CMMEtSums>(swCrate, dataID,
1015 ld.etVec, ld.etVec, ld.etVec,
1016 ld.etErrVec, ld.etErrVec, ld.etErrVec, trigCmm);
1017 const int key = crate * 100 + dataID;
1018 data.m_cmmEtMap.insert(std::make_pair(key, mapp.get()));
1019 data.m_cmmEtCollection->push_back(std::move(mapp));
1021 ld.etVec =
map->EtVec();
1022 ld.etErrVec =
map->EtErrorVec();
1023 const int nsl = ld.etVec.size();
1024 if (timeslices != nsl) {
1025 if (
debug)
msg() <<
"Inconsistent number of slices in sub-blocks"
1030 if (ld.etVec[slice] != 0 || ld.etErrVec[slice] != 0) {
1031 if (
debug)
msg() <<
"Duplicate data for slice " << slice <<
endmsg;
1035 ld.etVec[slice] = sumEt;
1036 ld.etErrVec[slice] = ssError;
1037 map->addEx(ld.etVec, ld.etErrVec);
1038 map->addEy(ld.etVec, ld.etErrVec);
1039 map->addEt(ld.etVec, ld.etErrVec);
1042 if (subBlock->
version() > 1) {
1044 if ( missEtSig || ssError ) {
1048 ld.etVec.assign(timeslices, 0);
1049 ld.etErrVec.assign(timeslices, 0);
1050 ld.etVec[slice] = missEtSig;
1051 ld.etErrVec[slice] = ssError;
1053 std::make_unique<LVL1::CMMEtSums>(swCrate, dataID,
1054 ld.etVec, ld.etVec, ld.etVec,
1055 ld.etErrVec, ld.etErrVec, ld.etErrVec, trigCmm);
1056 const int key = crate * 100 + dataID;
1057 data.m_cmmEtMap.insert(std::make_pair(key, mapp.get()));
1058 data.m_cmmEtCollection->push_back(std::move(mapp));
1060 ld.etVec =
map->EtVec();
1061 ld.etErrVec =
map->EtErrorVec();
1062 const int nsl = ld.etVec.size();
1063 if (timeslices != nsl) {
1064 if (
debug)
msg() <<
"Inconsistent number of slices in sub-blocks"
1069 if (ld.etVec[slice] != 0 || ld.etErrVec[slice] != 0) {
1070 if (
debug)
msg() <<
"Duplicate data for slice "
1075 ld.etVec[slice] = missEtSig;
1076 ld.etErrVec[slice] = ssError;
1077 map->addEx(ld.etVec, ld.etErrVec);
1078 map->addEy(ld.etVec, ld.etErrVec);
1079 map->addEt(ld.etVec, ld.etErrVec);
1098 const int hwCrate = subBlock->
crate();
1102 const int timeslices = subBlock->
timeslices();
1103 const int sliceNum = subBlock->
slice();
1105 msg() <<
"CMM-Jet: Crate " << hwCrate
1106 <<
" Module " << module
1107 <<
" Firmware " << firmware
1108 <<
" Summing " << summing
1109 <<
" Total slices " << timeslices
1110 <<
" Slice " << sliceNum <<
endmsg;
1112 if (timeslices <= trigCmm) {
1113 if (
debug)
msg() <<
"Triggered CMM slice from header "
1114 <<
"inconsistent with number of slices: "
1115 << trigCmm <<
", " << timeslices <<
endmsg;
1119 if (timeslices <= sliceNum) {
1120 if (
debug)
msg() <<
"Total slices inconsistent with slice number: "
1121 << timeslices <<
", " << sliceNum <<
endmsg;
1129 msg() <<
"CMM-Jet sub-block unpacking failed: " << errMsg <<
endmsg;
1143 const int ssError = derr.
error();
1144 const int sliceBeg = ( neutralFormat ) ? 0 : sliceNum;
1145 const int sliceEnd = ( neutralFormat ) ? timeslices : sliceNum + 1;
1146 for (
int slice = sliceBeg; slice < sliceEnd; ++slice) {
1150 for (
int source = 0; source < maxSid; ++source) {
1151 int dataID = source;
1182 const unsigned int hits = subBlock->
jetHits(slice, source);
1186 const int err = errBits.
error();
1190 ld.hitsVec.assign(timeslices, 0);
1191 ld.errVec.assign(timeslices, 0);
1192 ld.hitsVec[slice] = hits;
1193 ld.errVec[slice] = err;
1195 std::make_unique<LVL1::CMMJetHits>(swCrate, dataID, ld.hitsVec, ld.errVec, trigCmm);
1196 const int key = crate * 100 + dataID;
1197 data.m_cmmHitsMap.insert(std::make_pair(key, jhp.get()));
1198 data.m_cmmHitCollection->push_back(std::move(jhp));
1202 const int nsl = ld.hitsVec.size();
1203 if (timeslices != nsl) {
1204 if (
debug)
msg() <<
"Inconsistent number of slices in sub-blocks"
1209 if (ld.hitsVec[slice] != 0 || ld.errVec[slice] != 0) {
1210 if (
debug)
msg() <<
"Duplicate data for slice " << slice <<
endmsg;
1214 ld.hitsVec[slice] = hits;
1215 ld.errVec[slice] = err;
1216 jh->
addHits(ld.hitsVec, ld.errVec);
1224 const unsigned int etMap = subBlock->
jetEtMap(slice);
1225 if ( etMap || ssError ) {
1229 ld.hitsVec.assign(timeslices, 0);
1230 ld.errVec.assign(timeslices, 0);
1231 ld.hitsVec[slice] = etMap;
1232 ld.errVec[slice] = ssError;
1234 std::make_unique<LVL1::CMMJetHits>(swCrate, dataID, ld.hitsVec, ld.errVec, trigCmm);
1235 const int key = crate * 100 + dataID;
1236 data.m_cmmHitsMap.insert(std::make_pair(key, mapp.get()));
1237 data.m_cmmHitCollection->push_back(std::move(mapp));
1239 ld.hitsVec =
map->HitsVec();
1240 ld.errVec =
map->ErrorVec();
1241 const int nsl = ld.hitsVec.size();
1242 if (timeslices != nsl) {
1243 if (
debug)
msg() <<
"Inconsistent number of slices in sub-blocks"
1248 if (ld.hitsVec[slice] != 0 || ld.errVec[slice] != 0) {
1249 if (
debug)
msg() <<
"Duplicate data for slice " << slice <<
endmsg;
1253 ld.hitsVec[slice] = etMap;
1254 ld.errVec[slice] = ssError;
1255 map->addHits(ld.hitsVec, ld.errVec);
1274 const int hwCrate = subBlock->
crate();
1275 const int module = subBlock->
module();
1276 const int timeslices = subBlock->
timeslices();
1277 const int sliceNum = subBlock->
slice();
1279 msg() <<
"JEM: Crate " << hwCrate
1280 <<
" Module " << module
1281 <<
" Total slices " << timeslices
1282 <<
" Slice " << sliceNum <<
endmsg;
1284 if (timeslices <= trigJem) {
1285 if (
debug)
msg() <<
"Triggered JEM slice from header "
1286 <<
"inconsistent with number of slices: "
1287 << trigJem <<
", " << timeslices <<
endmsg;
1291 if (timeslices <= sliceNum) {
1292 if (
debug)
msg() <<
"Total slices inconsistent with slice number: "
1293 << timeslices <<
", " << sliceNum <<
endmsg;
1301 msg() <<
"JEM sub-block unpacking failed: " << errMsg <<
endmsg;
1314 const int ssError = derr.
error();
1315 std::vector<int> dummy(timeslices);
1316 const int sliceBeg = ( neutralFormat ) ? 0 : sliceNum;
1317 const int sliceEnd = ( neutralFormat ) ? timeslices : sliceNum + 1;
1318 for (
int slice = sliceBeg; slice < sliceEnd; ++slice) {
1325 for (
int chan = 0; chan <
m_channels; ++chan) {
1327 if (jetEle.
data() || ssError) {
1332 if (layer == ld.coreOverlap) {
1335 const unsigned int key = ld.elementKey.jeKey(
phi,
eta);
1337 std::make_unique<LVL1::JetElement>(
phi,
eta, dummy, dummy, key,
1338 dummy, dummy, dummy, trigJem);
1340 jedata.
m_jeMap.insert(std::make_pair(key, jep.get()));
1343 const std::vector<int>& emEnergy(je->
emEnergyVec());
1345 const std::vector<int>& emError(je->
emErrorVec());
1346 const std::vector<int>& hadError(je->
hadErrorVec());
1347 const int nsl = emEnergy.size();
1348 if (timeslices != nsl) {
1350 msg() <<
"Inconsistent number of slices in sub-blocks"
1356 if (emEnergy[slice] != 0 || hadEnergy[slice] != 0 ||
1357 emError[slice] != 0 || hadError[slice] != 0) {
1358 if (
debug)
msg() <<
"Duplicate data for slice "
1366 const int linkError = jetEle.
linkError();
1376 msg(MSG::VERBOSE) <<
"Non-zero data but no channel mapping for channel "
1381 msg(MSG::VERBOSE) <<
"No jet element data for channel "
1382 << chan <<
" slice " << slice <<
endmsg;
1391 const unsigned int hits = subBlock->
jetHits(slice);
1395 ld.hitsVec.assign(timeslices, 0);
1396 ld.hitsVec[slice] = hits;
1398 std::make_unique<LVL1::JEMHits>(swCrate, module, ld.hitsVec, trigJem);
1403 const int nsl = ld.hitsVec.size();
1404 if (timeslices != nsl) {
1406 msg() <<
"Inconsistent number of slices in sub-blocks"
1412 if (ld.hitsVec[slice] != 0) {
1413 if (
debug)
msg() <<
"Duplicate data for slice "
1418 ld.hitsVec[slice] = hits;
1422 msg(MSG::VERBOSE) <<
"No jet hits data for crate/module/slice "
1423 << hwCrate <<
"/" << module <<
"/" << slice
1432 const unsigned int ex = subBlock->
ex(slice);
1433 const unsigned int ey = subBlock->
ey(slice);
1434 const unsigned int et = subBlock->
et(slice);
1438 ld.exVec.assign(timeslices, 0);
1439 ld.eyVec.assign(timeslices, 0);
1440 ld.etVec.assign(timeslices, 0);
1441 ld.exVec[slice] = ex;
1442 ld.eyVec[slice] = ey;
1443 ld.etVec[slice] =
et;
1445 std::make_unique<LVL1::JEMEtSums>(swCrate, module, ld.etVec, ld.exVec, ld.eyVec,
1447 sumdata.
m_etMap.insert(std::make_pair(crate *
m_modules + module, sumsp.get()));
1450 ld.exVec = sums->
ExVec();
1451 ld.eyVec = sums->
EyVec();
1452 ld.etVec = sums->
EtVec();
1453 const int nsl = ld.exVec.size();
1454 if (timeslices != nsl) {
1456 msg() <<
"Inconsistent number of slices in sub-blocks"
1462 if (ld.exVec[slice] != 0 || ld.eyVec[slice] != 0 || ld.etVec[slice] != 0) {
1463 if (
debug)
msg() <<
"Duplicate data for slice "
1468 ld.exVec[slice] = ex;
1469 ld.eyVec[slice] = ey;
1470 ld.etVec[slice] =
et;
1471 sums->
addEx(ld.exVec);
1472 sums->
addEy(ld.eyVec);
1473 sums->
addEt(ld.etVec);
1476 msg(MSG::VERBOSE) <<
"No energy sums data for crate/module/slice "
1477 << hwCrate <<
"/" << module <<
"/" << slice
1494 const unsigned int key = elementKey.
jeKey(
phi,
eta);
1495 ConstJetElementMap::const_iterator mapIter = jeMap.find(key);
1496 if (mapIter != jeMap.end())
return mapIter->second;
1505 const unsigned int key = elementKey.
jeKey(
phi,
eta);
1506 JetElementMap::const_iterator mapIter =
data.m_jeMap.find(key);
1507 if (mapIter !=
data.m_jeMap.end())
return mapIter->second;
1518 ConstJetHitsMap::const_iterator mapIter = hitsMap.find(crate *
m_modules + module);
1519 if (mapIter != hitsMap.end())
return mapIter->second;
1525 const int module)
const
1527 JetHitsMap::const_iterator mapIter =
data.m_hitsMap.find(crate *
m_modules + module);
1528 if (mapIter !=
data.m_hitsMap.end())
return mapIter->second;
1539 ConstEnergySumsMap::const_iterator mapIter = etMap.find(crate *
m_modules + module);
1540 if (mapIter != etMap.end())
return mapIter->second;
1546 const int module)
const
1548 EnergySumsMap::const_iterator mapIter =
data.m_etMap.find(crate *
m_modules + module);
1549 if (mapIter !=
data.m_etMap.end())
return mapIter->second;
1560 ConstCmmHitsMap::const_iterator mapIter = cmmHitsMap.find(crate * 100 + dataID);
1561 if (mapIter != cmmHitsMap.end())
return mapIter->second;
1567 const int dataID)
const
1569 CmmHitsMap::const_iterator mapIter =
data.m_cmmHitsMap.find(crate * 100 + dataID);
1570 if (mapIter !=
data.m_cmmHitsMap.end())
return mapIter->second;
1581 ConstCmmSumsMap::const_iterator mapIter = cmmEtMap.find(crate * 100 + dataID);
1582 if (mapIter != cmmEtMap.end())
return mapIter->second;
1588 const int dataID)
const
1590 CmmSumsMap::const_iterator mapIter =
data.m_cmmEtMap.find(crate * 100 + dataID);
1591 if (mapIter !=
data.m_cmmEtMap.end())
return mapIter->second;
1606 for (; pos != pose; ++pos) {
1608 const unsigned int key = elementKey.
jeKey(je->
phi(), je->
eta());
1609 jeMap.insert(std::make_pair(key, je));
1618 const hitCollection,
1622 if (hitCollection) {
1625 for (; pos != pose; ++pos) {
1628 const int key =
m_modules * crate + hits->module();
1629 hitsMap.insert(std::make_pair(key, hits));
1644 for (; pos != pose; ++pos) {
1648 etMap.insert(std::make_pair(key, sums));
1656 const hitCollection,
1660 if (hitCollection) {
1663 for (; pos != pose; ++pos) {
1666 const int key = crate * 100 + hits->dataID();
1667 cmmHitsMap.insert(std::make_pair(key, hits));
1682 for (; pos != pose; ++pos) {
1685 const int key = crate * 100 + sums->
dataID();
1686 cmmEtMap.insert(std::make_pair(key, sums));
1694 const int modulesPerSlink,
1706 for (
int mod = module; mod < module + modulesPerSlink; ++mod) {
1707 for (
int chan = 0; chan <
m_channels; ++chan) {
1711 if ( !
m_jemMaps->mapping(crate, mod, chan,
eta,
phi, layer))
continue;
1713 if ( !je )
continue;
1714 const int numdat = 5;
1715 std::vector<int> sums(numdat);
1716 std::vector<int> sizes(numdat);
1717 sums[0] = std::accumulate((je->
emEnergyVec()).begin(),
1719 sums[1] = std::accumulate((je->
hadEnergyVec()).begin(),
1721 sums[2] = std::accumulate((je->
emErrorVec()).begin(),
1723 sums[3] = std::accumulate((je->
hadErrorVec()).begin(),
1725 sums[4] = std::accumulate((je->
linkErrorVec()).begin(),
1732 const int peak = je->
peak();
1733 for (
int i = 0; i < numdat; ++i) {
1734 if (sums[i] == 0)
continue;
1738 }
else if (slices != sizes[i] || trigJ != peak)
return false;
1743 const unsigned int sum = std::accumulate((hits->JetHitsVec()).begin(),
1744 (hits->JetHitsVec()).end(), 0);
1746 const int size = (hits->JetHitsVec()).size();
1747 const int peak = hits->peak();
1751 }
else if (slices != size || trigJ != peak)
return false;
1756 const int numdat = 3;
1757 std::vector<unsigned int> sums(numdat);
1758 std::vector<int> sizes(numdat);
1759 sums[0] = std::accumulate((
et->ExVec()).begin(),
1760 (
et->ExVec()).end(), 0);
1761 sums[1] = std::accumulate((
et->EyVec()).begin(),
1762 (
et->EyVec()).end(), 0);
1763 sums[2] = std::accumulate((
et->EtVec()).begin(),
1764 (
et->EtVec()).end(), 0);
1765 sizes[0] = (
et->ExVec()).size();
1766 sizes[1] = (
et->EyVec()).size();
1767 sizes[2] = (
et->EtVec()).size();
1768 const int peak =
et->peak();
1769 for (
int i = 0; i < numdat; ++i) {
1770 if (sums[i] == 0)
continue;
1774 }
else if (slices != sizes[i] || trigJ != peak)
return false;
1779 if (module / modulesPerSlink ==
m_slinks - 1) {
1782 const int maxDataID = (maxDataID1 > maxDataID2) ? maxDataID1 : maxDataID2;
1783 for (
int dataID = 0; dataID < maxDataID; ++dataID) {
1784 const int numdat = 6;
1785 std::vector<unsigned int> sums(numdat);
1786 std::vector<int> sizes(numdat);
1788 if (dataID < maxDataID1) hits =
findCmmHits(crate, dataID, cmmHitsMap);
1790 sums[0] = std::accumulate((hits->HitsVec()).begin(),
1791 (hits->HitsVec()).end(), 0);
1792 sums[1] = std::accumulate((hits->ErrorVec()).begin(),
1793 (hits->ErrorVec()).end(), 0);
1794 sizes[0] = (hits->HitsVec()).size();
1795 sizes[1] = (hits->ErrorVec()).size();
1796 const int peak = hits->peak();
1797 for (
int i = 0; i < 2; ++i) {
1798 if (sums[i] == 0)
continue;
1802 }
else if (slices != sizes[i] || trigJ != peak)
return false;
1806 if (dataID < maxDataID2)
et =
findCmmSums(crate, dataID, cmmEtMap);
1808 sums[0] = std::accumulate((
et->ExVec()).begin(),
1809 (
et->ExVec()).end(), 0);
1810 sums[1] = std::accumulate((
et->EyVec()).begin(),
1811 (
et->EyVec()).end(), 0);
1812 sums[2] = std::accumulate((
et->EtVec()).begin(),
1813 (
et->EtVec()).end(), 0);
1814 sums[3] = std::accumulate((
et->ExErrorVec()).begin(),
1815 (
et->ExErrorVec()).end(), 0);
1816 sums[4] = std::accumulate((
et->EyErrorVec()).begin(),
1817 (
et->EyErrorVec()).end(), 0);
1818 sums[5] = std::accumulate((
et->EtErrorVec()).begin(),
1819 (
et->EtErrorVec()).end(), 0);
1820 sizes[0] = (
et->ExVec()).size();
1821 sizes[1] = (
et->EyVec()).size();
1822 sizes[2] = (
et->EtVec()).size();
1823 sizes[3] = (
et->ExErrorVec()).size();
1824 sizes[4] = (
et->EyErrorVec()).size();
1825 sizes[5] = (
et->EtErrorVec()).size();
1826 const int peak =
et->peak();
1827 for (
int i = 0; i < numdat; ++i) {
1828 if (sums[i] == 0)
continue;
1832 }
else if (slices != sizes[i] || trigJ != peak)
return false;
1838 timeslices = slices;
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
std::vector< size_t > vec
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 CMM-Energy data.
int exError(int slice, int source) const
Return Ex subsum error for given JEM or source ID.
void setMissingEtSigHits(int slice, unsigned int map)
Store Missing-ET-Sig Hits map.
unsigned int ey(int slice, int source) const
Return Ey subsum for given JEM or source ID.
unsigned int et(int slice, int source) const
Return Et subsum for given JEM or source ID.
void setSumEtHits(int slice, unsigned int map)
Store Sum-Et Hits map.
void clear()
Clear all data.
unsigned int sumEtHits(int slice) const
Return Sum-Et Hits map.
int eyError(int slice, int source) const
Return Ey subsum error for given JEM or source ID.
unsigned int missingEtSigHits(int slice) const
Return Missing-ET-Sig Hits map.
bool unpack()
Unpack data.
void setSubsums(int slice, int source, unsigned int ex, unsigned int ey, unsigned int et, int exError, int eyError, int etError)
Store energy subsums and errors for given JEM or source ID.
unsigned int missingEtHits(int slice) const
Return Missing-ET Hits map.
int etError(int slice, int source) const
Return Et subsum error for given JEM or source ID.
void setMissingEtHits(int slice, unsigned int map)
Store Missing-ET Hits map.
unsigned int ex(int slice, int source) const
Return Ex subsum for given JEM or source ID.
Sub-Block class for CMM-Jet data.
unsigned int jetHits(int slice, int source) const
Return jet hit counts for given jem or source ID.
int jetHitsError(int slice, int source) const
Return jet hit error for given jem or source ID.
void setJetHits(int slice, int source, unsigned int hits, int error)
Store jet hit counts and error for given jem or source ID.
void setJetEtMap(int slice, unsigned int map)
Store jet ET map.
unsigned int jetEtMap(int slice) const
Return jet ET map.
void clear()
Clear all data.
bool unpack()
Unpack data.
static bool cmmBlock(uint32_t word)
Determine if header word corresponds to CMM.
void setCmmHeader(int version, int format, int slice, int crate, int summing, int firmware, int position, int timeslices)
Store CMM header.
static CmmFirmwareCode cmmType(uint32_t word)
CMM differentiation (CMM_CP, CMM_JET, or CMM_ENERGY)
JEM jet element dataword class.
Sub-Block class for JEM data pre-LS1.
int timeslices() const
Return number of timeslices.
void clear()
Clear all data.
void fillJetElement(int slice, const JemJetElement &jetEle)
Store jet element data.
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.
unsigned int jetHits(int slice) const
Return jet hit counts.
JemJetElement jetElement(int slice, int channel) const
Return jet element for given channel.
unsigned int ex(int slice) const
Return energy subsum Ex.
bool unpack()
Unpack data.
void setJetHits(int slice, unsigned int hits)
Store jet hit counts.
void setEnergySubsums(int slice, unsigned int ex, unsigned int ey, unsigned int et)
Store energy subsum data.
unsigned int ey(int slice) const
Return energy subsum Ey.
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.
CMMEtSums object stores Et sums from the Energy CMMs.
const std::vector< int > & EtErrorVec() const
returns module ET errors
void addEx(const std::vector< unsigned int > &Ex, const std::vector< int > &ExError)
Update Ex sum.
const std::vector< int > & ExErrorVec() const
returns module Ex errors
int dataID() const
returns data ID
void addEt(const std::vector< unsigned int > &Et, const std::vector< int > &EtError)
Add data to existing objects.
int crate() const
Data accessors.
const std::vector< unsigned int > & EtVec() const
Access multi-slice data.
void addEy(const std::vector< unsigned int > &Ey, const std::vector< int > &EyError)
Update Ey sum.
const std::vector< unsigned int > & ExVec() const
returns module Ex sum
const std::vector< int > & EyErrorVec() const
returns module Ey errors
const std::vector< unsigned int > & EyVec() const
returns module Ey sum
CMMJetHits class stores Jet hit multiplicities received by and read out from the Jet CMMs.
const std::vector< int > & ErrorVec() const
returns errors
void addHits(const std::vector< unsigned int > &hits, const std::vector< int > &errors)
Add hits to existing object.
const std::vector< unsigned int > & HitsVec() const
Multi-slice accessors.
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.
const std::vector< unsigned int > & JetHitsVec() const
returns jet hits
void addJetHits(const std::vector< unsigned int > &hits)
Set Jet hits.
Jet/Energy Processor container for writing bytestream pre-LS1.
const DataVector< CMMEtSums > * CmmSums() const
Return pointer to CMM energy sums collection.
const DataVector< CMMJetHits > * CmmHits() const
Return pointer to CMM hit sums collection.
const DataVector< JetElement > * JetElements() const
Return pointer to jet element collection.
const DataVector< JEMHits > * JetHits() const
Return pointer to hit sums collection.
const DataVector< JEMEtSums > * EnergySums() const
Return pointer to energy sums 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_IJepByteStreamV1Tool("JepByteStreamV1Tool", 1, 1)
Extra patterns decribing particle interation process.