25 #include <arpa/inet.h>
27 #define DO_NOT_USE_MUON_TAG true
29 static const InterfaceID IID_ITileROD_Decoder(
"TileROD_Decoder", 1, 0);
42 , m_ampMinThresh_pC(-1.)
43 , m_ampMinThresh_MeV(-1.)
45 , m_WarningCounter (0)
48 , m_hid2reHLT(nullptr)
50 , m_checkMaskedDrawers(false)
53 declareInterface<TileROD_Decoder>(
this);
55 for (std::atomic<const uint32_t*>&
p : m_OFPtrs) {
84 return IID_ITileROD_Decoder;
145 std::ostringstream
os;
148 std::vector<int>
v = { 0x10d };
156 os <<
" (frag IDs):";
159 os <<
" 0x" << std::hex <<
fragID << std::dec;
163 ATH_MSG_INFO(
"Enable channel remapping for demonstrator modules" <<
os.str());
187 for (
int i=0;
i<24; ++
i) {
191 for (
int i=24;
i<48;
i+=3) {
208 for (
int i=24;
i<30; ++
i) {
211 for (
int i=42;
i<48; ++
i) {
216 return StatusCode::SUCCESS;
221 for (
unsigned int i = 0;
i < 4; ++
i) {
228 return StatusCode::SUCCESS;
237 return *(
p +
a) & (1 <<
r);
250 int frag_id,
int drawer_type)
const {
262 int size = *(
p) - sizeOverhead;
264 int frag = (frag_id>0) ? frag_id : *(
p + 1) & 0xFFFF;
271 uint32_t all00 = TileFragStatus::ALL_00;
272 uint32_t allFF = TileFragStatus::ALL_FF;
274 for (
int i = 0;
i <
size; ++
i) {
280 if (all00 &&
w != 0) {
287 digitsMetaData[6].push_back(
status );
309 int channelCount = chipCount * 3;
312 int blockSize =
size / chipCount;
316 int wordsPerChip = 0;
318 int dataWordsPerChip = 0;
323 static std::atomic<int> savedDigiMode = -1;
325 int digiMode = savedDigiMode;
327 if (digiMode < 0 && size > 0) {
329 savedDigiMode = digiMode;
332 if (digiMode > 0 || (digiMode < 0 && blockSize == 17)) {
339 wordsPerChip = (blockSize - 1) / 2;
341 dataWordsPerChip = wordsPerChip - 1;
346 gainOffset = wordsPerChip;
350 wordsPerChip = blockSize - 1;
352 dataWordsPerChip = wordsPerChip - 1;
379 std::array< std::vector<float>, 3 > digiVec;
384 if (gainOffset > 0) {
387 std::vector<uint32_t>& chipHeaderLow = digitsMetaData[2];
388 std::vector<uint32_t>& chipCRCLow = digitsMetaData[3];
389 std::vector<uint32_t>& chipHeaderHigh = digitsMetaData[4];
390 std::vector<uint32_t>& chipCRCHigh = digitsMetaData[5];
393 for (chip = 0; chip < chipCount; ++chip) {
399 for (
n = 0;
n < 3; ++
n) {
407 pDigits.push_back(td);
415 for (
n = 0;
n < 3; ++
n) {
423 pDigits.push_back(td);
429 chipHeaderLow.push_back(*
data);
430 chipCRCLow.push_back(*(
data + gainOffset - 1));
431 chipHeaderHigh.push_back(*(
data + gainOffset));
432 chipCRCHigh.push_back(*(
data + blockSize - 1));
439 pDigits.reserve(pDigits.size() + 48);
440 std::vector<uint32_t>& chipHeader = digitsMetaData[2];
441 std::vector<uint32_t>& chipCRC = digitsMetaData[3];
444 for (chip = 0; chip < chipCount; ++chip) {
449 <<
" CRC $" << *(
data + blockSize - 1) );
451 for (
n = 0;
n < 3; ++
n) {
465 <<
" Data={" << (
int) digiVec[
n][0]
466 <<
"," << (
int) digiVec[
n][1]
467 <<
"," << (
int) digiVec[
n][2]
468 <<
"," << (
int) digiVec[
n][3]
469 <<
"," << (
int) digiVec[
n][4]
470 <<
"," << (
int) digiVec[
n][5]
471 <<
"," << (
int) digiVec[
n][6] <<
"}" );
474 pDigits.push_back(td);
479 chipHeader.push_back(*
data);
480 chipCRC.push_back(*(
data + blockSize - 1));
485 if (
remap) std::sort(pDigits.end()-channelCount,pDigits.end(),
chan_order);
494 <<
" data words, while size from header is " <<
size
495 <<
" data words (plus " << sizeOverhead <<
" words overhead)" );
509 if ((
data[0] & 0xffff) != (
data[0] >> 16)) {
513 if ((
data[0] & 0xffff) == 0xffff)
515 else if ((
data[0] & 0xffff) == 0xfff)
525 if ((
data[1] & 0xffff) != (
data[1] >> 16)) {
536 digitsMetaData[0].push_back(
size);
537 digitsMetaData[0].push_back(frag);
538 digitsMetaData[0].push_back(
bcid);
540 digitsMetaData[1].push_back(
data[
i]);
543 digitsMetaData[1].push_back(
p[2]);
546 if (dataWordsPerChip > 15) {
556 int frag_id,
int drawer_type)
const {
558 int size = *(
p) - sizeOverhead;
560 int frag = (frag_id>0) ? frag_id : *(
p + 1) & 0xFFFF;
563 int frag1version = (*(
p + 1) >> 31) & 0x1;
564 int nbchanformat1 = ((*(
p + 1)) >> 24) & 0x3F;
568 digitsMetaData[0].push_back(
size);
569 digitsMetaData[0].push_back(frag);
570 digitsMetaData[0].push_back(0);
572 if (frag1version == 0) {
575 int nsamp = (*(
p) >> 8) & 0x0F;
576 int words_per_chan = nsamp + 1;
579 if (2 *
size !=
nchan * words_per_chan || nchan <= 0 || nchan > 48) {
581 ATH_MSG_WARNING(
"Digi frag type=1 fragId=0x" << MSG::hex << frag << MSG::dec
582 <<
" Nsamp=" << nsamp
583 <<
" Nchan=" <<
nchan
584 <<
" Wrong Size=" <<
size );
590 std::vector<float> digiVec(nsamp);
591 pDigits.reserve(
nchan);
599 int nsamp1 = (*(p16) >> 8) & 0x0F;
600 int gain = (*p16) >> 15;
603 for (
int samp = 0; samp < nsamp; ++samp) {
604 digiVec[samp] = *p16++;
607 if (
channel < 48 && nsamp1 == nsamp) {
610 pDigits.push_back(td);
613 ATH_MSG_WARNING(
"Digi frag type=1 fragId=0x" << MSG::hex << frag << MSG::dec
616 <<
" nsamp=" << nsamp1 <<
"/" << nsamp );
625 for (
int samp = 0; samp < nsamp; ++samp) {
629 for (
int samp = 0; samp < nsamp / 2 + 1; ++samp) {
637 else if (frag1version == 1) {
641 int SizeOfFrag1 =
size * 2;
642 int nbchanformat2 = (SizeOfFrag1 - (3 * nbchanformat1)) / 5;
644 int nchan = nbchanformat1 + nbchanformat2;
646 if ((
nchan) > 48 || ((nbchanformat1 * 3) + (nbchanformat2 * 5) > SizeOfFrag1)) {
648 ATH_MSG_WARNING(
"Digi frag type=1 fragId=0x" << MSG::hex << frag << MSG::dec
649 <<
" frag1Version=" << frag1version
650 <<
" Nsamp=" << nsamp
651 <<
" NchanFormat1=" << nbchanformat1
652 <<
" NchanFormat2=" << nbchanformat2
653 <<
" Wrong Size=" <<
size);
659 std::vector<float> digiVec(nsamp);
660 pDigits.reserve(
nchan);
671 for (
int chf1 = 0; chf1 < nbchanformat1; ++chf1) {
680 if (ptr16index == 1) {
683 word3 = (
uint16_t) ((*(
p + 1) >> 16) & 0xFFFF);
687 else if (ptr16index == 0) {
689 word2 = (
uint16_t) ((*(
p + 1) >> 16) & 0xFFFF);
696 digiVec[0] = ((word3 >> 4) & 0xF) + Smin;
697 digiVec[1] = ((word3 >> 0) & 0xF) + Smin;
698 digiVec[2] = ((word3 >> 8) & 0xF) + Smin;
699 digiVec[3] = ((word3 >> 12) & 0xF) + Smin;
700 digiVec[4] = ((word2 >> 4) & 0xF) + Smin;
701 digiVec[5] = ((word2 >> 0) & 0xF) + Smin;
702 digiVec[6] = ((word2 >> 8) & 0xF) + Smin;
714 for (
int samp = 0; samp < 7; ++samp) {
718 <<
" WORD1: " <<
word1
719 <<
" WORD2: " << word2
720 <<
" WORD3: " << word3 << MSG::dec <<
endmsg;
724 for (
int chf2 = 0; chf2 < nbchanformat2; ++chf2) {
728 channel = ((*(
p + 1) >> 16) & 0x3F);
731 if (ptr16index == 1) {
734 word3 = (
uint16_t) ((*(
p + 1) >> 16) & 0xFFFF);
736 word5 = (
uint16_t) ((*(
p + 2) >> 16) & 0xFFFF);
738 }
else if (ptr16index == 0) {
740 word2 = (
uint16_t) ((*(
p + 1) >> 16) & 0xFFFF);
742 word4 = (
uint16_t) ((*(
p + 2) >> 16) & 0xFFFF);
747 int gain = ((word2 >> 6) & 0
x1);
749 digiVec[0] = ((
word1 << 9) & 0x200) + ((word2 >> 7) & 0x1FF);
750 digiVec[1] = (
word1 >> 1) & 0x3FF;
751 digiVec[2] = (word4 << 5 & 0x3E0) + ((
word1 >> 11) & 0x1F);
752 digiVec[3] = (word4 >> 5) & 0x3FF;
753 digiVec[4] = ((word3 << 1) & 0x3FE) + ((word4 >> 15) & 0
x1);
754 digiVec[5] = ((word5 << 7) & 0x380) + ((word3 >> 9) & 0x7F);
755 digiVec[6] = (word5 >> 3) & 0x3FF;
760 p += (2 + ptr16index);
767 for (
int samp = 0; samp < nsamp; ++samp) {
771 <<
" WORD1: " <<
word1
772 <<
" WORD2: " << word2
773 <<
" WORD3: " << word3
774 <<
" WORD4: " << word4
775 <<
" WORD5: " << word5 << MSG::dec <<
endmsg;
779 for (
uint i = 0;
i < sDigits.size();
i++) {
781 if (td) pDigits.push_back(td);
791 int frag_id,
int )
const {
795 int frag = (frag_id>0) ? frag_id : *(
p + 1) & 0xFFFF;
805 int wc = sizeOverhead;
811 unsigned int w = (*p);
823 pChannel.push_back(rc);
841 << wc <<
" != " <<
count );
854 int frag_id,
int )
const {
858 int frag = (frag_id>0) ? frag_id : *(
p + 1) & 0xFFFF;
869 const short* p16 = (
const short *)
p;
872 short wc16 = 4 + sizeOverhead * 2;
886 pChannel.push_back(rc);
889 <<
" ch " <<
ch <<
" " << MSG::hex
890 <<
"0x" << *p16 << *(p16+1) << *(p16+2) << MSG::dec
905 if (wc16 != 2 *
count) {
909 << wc16 <<
" != 2*" <<
count );
924 int frag_id,
int drawer_type)
const
929 int frag = (frag_id>0) ? frag_id : *(
p + 1) & 0xFFFF;
940 int wc = sizeOverhead;
944 uint32_t all00 = TileFragStatus::ALL_00;
945 uint32_t allFF = TileFragStatus::ALL_FF;
948 unsigned int w = (*p);
965 pChannel.push_back(rc);
980 rawchannelMetaData[6].push_back( all00 | allFF );
986 << wc <<
" != " <<
count );
1003 int frag_id,
int drawer_type)
const
1008 int frag = (frag_id>0) ? frag_id : *(
p + 1) & 0xFFFF;
1011 int size_L2 = (*(
p + 1) >> (32 - 2 - 3)) & 0x7;
1015 digitsMetaData[0].push_back(
count);
1016 digitsMetaData[0].push_back(frag);
1017 digitsMetaData[0].push_back(0);
1024 int wc = sizeOverhead;
1025 int bc = (size_L2 * 32 + 48) / 8;
1029 std::vector<float> digiVec(7);
1033 for (
int ch = 0;
ch < 48; ++
ch) {
1040 for (
int i = 0;
i < 7; ++
i) digiVec[
i] = ChanData[
ch].
s[
i];
1042 pDigits.push_back(td);
1048 float ene = ChanData[
ch].
ene;
1052 pChannel.push_back(rc);
1066 << wc <<
" != " <<
count );
1070 }
else if (wc <
count) {
1073 <<
" words in frag" );
1077 <<
" words in frag" );
1087 std::vector<uint32_t>
data;
1093 data.push_back(*(++
p));
1096 while (
p < data_end) {
1099 data.push_back(*(
p));
1100 data.push_back(*(++
p));
1104 data.push_back((ntohs(
v >> 16) << 16) | (ntohs(
v & 0xFFFF)));
1117 int frag_id,
int drawer_type)
const
1119 int size = *(
p)- sizeOverhead;
1122 int frag = (frag_id>0) ? frag_id : *(
p + 1) & 0xFFFF;
1129 uint32_t all00 = TileFragStatus::ALL_00;
1130 uint32_t allFF = TileFragStatus::ALL_FF;
1132 for (
int i = 0;
i <
size; ++
i) {
1138 if (all00 &&
w != 0) {
1145 digitsMetaData[6].push_back(
status );
1154 unsigned int moduleID[Tile::MAX_MINIDRAWER] = {0};
1155 unsigned int runType[Tile::MAX_MINIDRAWER] = {0};
1157 unsigned int runNumber[Tile::MAX_MINIDRAWER] = {0};
1159 unsigned int pedestalHi[Tile::MAX_MINIDRAWER] = {0};
1160 unsigned int pedestalLo[Tile::MAX_MINIDRAWER] = {0};
1162 unsigned int chargeInjected[Tile::MAX_MINIDRAWER] = {0};
1163 unsigned int timeInjected[Tile::MAX_MINIDRAWER] = {0};
1164 unsigned int capacitor[Tile::MAX_MINIDRAWER] = {0};
1167 uint32_t l1id[Tile::MAX_MINIDRAWER] = {0};
1169 uint32_t ecr[Tile::MAX_MINIDRAWER] = {0};
1170 uint32_t bcr[Tile::MAX_MINIDRAWER] = {0};
1172 uint32_t fragmentID[Tile::MAX_MINIDRAWER] = {0};
1173 uint32_t packetVersion[Tile::MAX_MINIDRAWER] = {0};
1177 int mdFragmentSize = (*data) & 0xFFFF;
1178 int sampleNumber = mdFragmentSize / Tile::MAX_MINIDRAWER_CHAN;
1180 std::vector<std::vector<std::vector<float>>> samples(Tile::MAX_GAIN,
1181 std::vector<std::vector<float>>(Tile::MAX_CHAN,
1182 std::vector<float>(sampleNumber)));
1185 while (
data < end_data) {
1186 if (*
data == 0x12345678 ) {
1187 mdFragmentSize = (*(
data - 2)) & 0xFFFF;
1189 if ((++
data < end_data)) {
1191 version = (((*
data >> 16) & 0xFFFF) == 0) ? 1 : 0;
1192 int mdSizeOverhead = (
version == 0) ? 10 : 11;
1193 int delta = mdFragmentSize - (sampleNumber * Tile::MAX_MINIDRAWER_CHAN + mdSizeOverhead);
1195 ATH_MSG_WARNING(
"FRAG6: Unexpected MD fragment size " << mdFragmentSize <<
" => "
1196 << sampleNumber <<
" samples will be unpacked and last "
1197 << delta <<
" words will be ignored ");
1200 unsigned int miniDrawer = -1;
1204 if (trailer < end_data && *trailer == 0x87654321) {
1206 unsigned int paramsSize = 3;
1208 unsigned int fragSize = *
data & 0xFF;
1209 paramsSize = (*
data >> 8 ) & 0xFF;
1211 miniDrawer = *(
data + 4) & 0xFF;
1213 moduleID[miniDrawer] = (*
data >> 16) & 0xFF;
1215 if (fragSize != sampleNumber * Tile::MAX_MINIDRAWER_CHAN) {
1217 <<
"] has unexpected fragment size: " << fragSize
1218 <<
" correct value for " << sampleNumber
1219 <<
" samples is " << sampleNumber * Tile::MAX_MINIDRAWER_CHAN);
1222 if (paramsSize == 3){
1225 pedestalLo[miniDrawer] = *(++
data) & 0xFFF;
1226 pedestalHi[miniDrawer] = (*
data >> 12 ) & 0xFFF;
1228 chargeInjected[miniDrawer] = *(++
data) & 0xFFF;
1229 timeInjected[miniDrawer] = (*
data >> 12) & 0xFF;
1230 capacitor[miniDrawer] = (*
data >> 20) & 0
x1;
1234 <<
"] has unexpected number of parameter words: " << paramsSize
1235 <<
" => ignore them !!!");
1239 bcid[miniDrawer] = (*(++
data) >> 16) & 0xFFFF;
1240 l1id[miniDrawer] = *(++
data) & 0xFFFFFF;
1241 ecr[miniDrawer] = (*
data >> 24) & 0xFF;
1245 miniDrawer = *(
data + 1) & 0xFF;
1247 packetVersion[miniDrawer] = (*data) & 0xFF;
1248 fragmentID[miniDrawer] = (*
data >> 8) & 0xFF;
1250 bcid[miniDrawer] = (*(++
data) >> 8) & 0xFFF;
1251 moduleID[miniDrawer] = (*
data >> 20) & 0xFFF;
1253 l1id[miniDrawer] = *(++
data) & 0xFFFFFF;
1254 ecr[miniDrawer] = (*
data >> 24) & 0xFF;
1256 bcr[miniDrawer] = *(++
data);
1259 if (packetVersion[miniDrawer] == 1) {
1260 pedestalLo[miniDrawer] = *(++
data) & 0xFFF;
1261 pedestalHi[miniDrawer] = (*
data >> 12 ) & 0xFFF;
1268 pedestalLo[miniDrawer] = *(++
data) & 0xFFF;
1269 pedestalHi[miniDrawer] = (*
data >> 12 ) & 0xFFF;
1273 chargeInjected[miniDrawer] = *(++
data) & 0xFFF;
1274 timeInjected[miniDrawer] = (*
data >> 12) & 0xFF;
1275 capacitor[miniDrawer] = (*
data >> 20) & 0
x1;
1280 <<
", Run type: " <<
runType[miniDrawer]
1281 <<
", Module ID: " << moduleID[miniDrawer]
1282 <<
", BCID: " <<
bcid[miniDrawer]
1283 <<
", L1ID: " << l1id[miniDrawer]
1284 <<
", ECR: " << ecr[miniDrawer];
1287 <<
", Packet version: " << packetVersion[miniDrawer]
1288 <<
", Fragment ID: " << fragmentID[miniDrawer];
1293 if (paramsSize == 3) {
1295 <<
" Run number: " <<
runNumber[miniDrawer]
1296 <<
", Ppedestal Lo: " << pedestalLo[miniDrawer]
1297 <<
", Ppedestal Hi: " << pedestalHi[miniDrawer]
1298 <<
", Charge injected: " << chargeInjected[miniDrawer]
1299 <<
", Time injected: " << timeInjected[miniDrawer]
1300 <<
", Capacitor: " << capacitor[miniDrawer] <<
endmsg;
1307 int start_channel(miniDrawer * Tile::MAX_MINIDRAWER_CHAN);
1308 int end_channel(start_channel + Tile::MAX_MINIDRAWER_CHAN);
1311 for (
int samplesIdx = 0; samplesIdx<sampleNumber; ++samplesIdx) {
1322 ATH_MSG_WARNING(
"FRAG6: Not found correct MD[" << miniDrawer <<
"] fragment trailer: => skip it!!!");
1330 pDigits.reserve(Tile::MAX_GAIN * Tile::MAX_CHAN);
1333 for (
unsigned int gain = 0;
gain < Tile::MAX_GAIN; ++
gain) {
1340 pDigits.push_back(
new TileDigits(adcID, digiVec));
1344 if (
remap) std::sort(pDigits.end() - Tile::MAX_CHAN, pDigits.end(),
chan_order);
1347 digitsMetaData[1].insert(digitsMetaData[1].
end(), &l1id[0], &l1id[Tile::MAX_MINIDRAWER]);
1348 digitsMetaData[1].insert(digitsMetaData[1].
end(), &
bcid[0], &
bcid[Tile::MAX_MINIDRAWER]);
1349 digitsMetaData[1].insert(digitsMetaData[1].
end(), &moduleID[0], &moduleID[Tile::MAX_MINIDRAWER]);
1350 digitsMetaData[1].insert(digitsMetaData[1].
end(), &
runType[0], &
runType[Tile::MAX_MINIDRAWER]);
1352 digitsMetaData[1].insert(digitsMetaData[1].
end(), &pedestalLo[0], &pedestalLo[Tile::MAX_MINIDRAWER]);
1353 digitsMetaData[1].insert(digitsMetaData[1].
end(), &pedestalHi[0], &pedestalHi[Tile::MAX_MINIDRAWER]);
1354 digitsMetaData[1].insert(digitsMetaData[1].
end(), &chargeInjected[0], &chargeInjected[Tile::MAX_MINIDRAWER]);
1355 digitsMetaData[1].insert(digitsMetaData[1].
end(), &timeInjected[0], &timeInjected[Tile::MAX_MINIDRAWER]);
1356 digitsMetaData[1].insert(digitsMetaData[1].
end(), &capacitor[0], &capacitor[Tile::MAX_MINIDRAWER]);
1357 digitsMetaData[1].insert(digitsMetaData[1].
end(), &ecr[0], &ecr[Tile::MAX_MINIDRAWER]);
1359 digitsMetaData[1].insert(digitsMetaData[1].
end(), &bcr[0], &bcr[Tile::MAX_MINIDRAWER]);
1360 digitsMetaData[1].insert(digitsMetaData[1].
end(), &packetVersion[0], &packetVersion[Tile::MAX_MINIDRAWER]);
1361 digitsMetaData[1].insert(digitsMetaData[1].
end(), &fragmentID[0], &fragmentID[Tile::MAX_MINIDRAWER]);
1369 int ,
int drawer_type)
const {
1378 rawchannelMetaData[0].push_back(
w & 0xFFFF);
1380 rawchannelMetaData[0].push_back((
w >> 16) & 0x7FFF);
1382 rawchannelMetaData[0].push_back(0xDEAD);
1385 if (drawer_type == 2) {
1386 ATH_MSG_WARNING(
"Demo->Legacy remapping for Ext.Barrel not yet implemented for DQ fragment");
1389 for (
int i = 0;
i < (
size - 4); ++
i) {
1391 rawchannelMetaData[
i + 1].push_back(
w & 0xFFFF);
1392 rawchannelMetaData[
i + 1].push_back(
w >> 16);
1403 if (
size < 9)
return;
1430 if (
mask != rob_bcid &&
mask > 0) {
1436 if (
mask & 0x0002) {
1441 if (drawer_type == 2) {
1442 ATH_MSG_WARNING(
"Demo->Legacy remapping for Ext.Barrel not yet implemented for DQ fragment");
1445 if (
mask & 0x00F0) {
1449 if ((frag == 0x30E) || frag == 0x411) {
1456 if (BCIDerr & 0xF) ++n_badMB;
1478 if ((frag > 0x2FF)) {
1479 if ((frag == 0x30E) || frag == 0x411) fe_mask <<= 1;
1480 fe_mask = (fe_mask & 0xFF) | ((fe_mask & 0xF00) << 2);
1492 int frag_id,
int )
const {
1497 int frag = (frag_id>0) ? frag_id : *(
p + 1) & 0xFFFF;
1500 nDrawer[0] = frag & 0x3F;
1501 nDrawer[1] = (frag & 0xFC0) >> 6;
1513 std::vector<float> sumE[2];
1514 std::vector<unsigned int> word[2];
1515 std::vector<float>
eta[2];
1516 std::vector<float> energy0[2];
1517 std::vector<float> energy1[2];
1518 std::vector<float> energy2[2];
1519 std::vector<unsigned int> quality[2];
1522 constexpr
float eta_LB[9] = {
1523 ((0.00f + 2 * 0.05f) / 3),
1524 ((0.20f + 2 * 0.15f) / 3),
1525 ((0.20f + 2 * 0.25f) / 3),
1526 ((0.40f + 2 * 0.35f) / 3),
1527 ((0.40f + 2 * 0.45f) / 3),
1528 ((0.40f + 2 * 0.55f) / 3),
1529 ((0.60f + 2 * 0.55f) / 3),
1530 ((0.60f + 2 * 0.65f) / 3),
1531 ((0.60f + 2 * 0.75f) / 3)
1534 constexpr
float eta_EB[17] = {
1535 ((1.00f + 1.05f + 1.15f) / 3),
1536 ((1.00f + 1.15f + 1.15f) / 3),
1537 ((1.00f + 1.15f + 1.25f) / 3),
1538 ((1.00f + 1.25f + 1.15f) / 3),
1539 ((1.00f + 1.25f + 1.25f) / 3),
1540 ((1.00f + 1.25f + 1.35f) / 3),
1541 ((1.20f + 1.05f + 1.15f) / 3),
1542 ((1.20f + 1.15f + 1.15f) / 3),
1543 ((1.20f + 1.15f + 1.25f) / 3),
1544 ((1.20f + 1.25f + 1.15f) / 3),
1545 ((1.20f + 1.25f + 1.25f) / 3),
1546 ((1.20f + 1.25f + 1.35f) / 3),
1547 ((1.20f + 1.35f + 1.25f) / 3),
1548 ((1.20f + 1.35f + 1.35f) / 3),
1549 ((1.20f + 1.35f + 1.45f) / 3),
1550 ((1.20f + 1.45f + 1.35f) / 3),
1551 ((1.20f + 1.45f + 1.45f) / 3)
1555 sumE[0].push_back((
float) ((int32_t) (*
p++) - 9000));
1556 sumE[1].push_back((
float) ((int32_t) (*
p++) - 9000));
1560 int NMuons = (
int) (
size - 5) / 2;
1562 for (
int mu = 0;
mu < NMuons; ++
mu) {
1566 Mu_energy2 =
w & 0x1FFFFFF;
1567 Mu_pattern = (
w >> 25) & 0x1F;
1568 Mu_drawer = (
w >> 30) & 1;
1569 Mu_quality =
w >> 31;
1571 word[Mu_drawer].push_back(
w);
1575 Mu_energy0 =
w & 0xFFFF;
1576 Mu_energy1 =
w >> 16;
1578 word[Mu_drawer].push_back(
w);
1581 switch (frag >> 12) {
1583 eta[Mu_drawer].push_back(eta_LB[Mu_pattern]);
1586 eta[Mu_drawer].push_back(-eta_LB[Mu_pattern]);
1589 eta[Mu_drawer].push_back(eta_EB[Mu_pattern]);
1592 eta[Mu_drawer].push_back(-eta_EB[Mu_pattern]);
1600 energy0[Mu_drawer].push_back(Mu_energy0 / 2.);
1601 energy1[Mu_drawer].push_back(Mu_energy1 / 2.);
1602 energy2[Mu_drawer].push_back(Mu_energy2 / 2.);
1605 quality[Mu_drawer].push_back(Mu_quality);
1610 for (
unsigned int i = 0;
i < 2; ++
i) {
1613 int fragId = (((frag & 0xF000) >> 4) | nDrawer[
i]);
1616 (*pL2[
m_hashFunc(fragId)]).setEt(std::move(sumE[
i]));
1619 (*pL2[
m_hashFunc(fragId)]).setMu(std::move(
eta[
i]), std::move(energy0[
i]), std::move(energy1[
i]), std::move(energy2[
i]),
1620 std::move(quality[
i]), std::move(word[
i]));
1628 int frag_id,
int )
const {
1633 int frag = (frag_id>0) ? frag_id : *(
p + 1) & 0xFFFF;
1645 std::vector<unsigned int> word;
1646 std::vector<float>
eta;
1647 std::vector<float> energy0;
1648 std::vector<float> energy1;
1649 std::vector<float> energy2;
1650 std::vector<unsigned int> quality;
1652 constexpr
float eta_LB[9] = {
1653 ((0.00f + 2 * 0.05f) / 3),
1654 ((0.20f + 2 * 0.15f) / 3),
1655 ((0.20f + 2 * 0.25f) / 3),
1656 ((0.40f + 2 * 0.35f) / 3),
1657 ((0.40f + 2 * 0.45f) / 3),
1658 ((0.40f + 2 * 0.55f) / 3),
1659 ((0.60f + 2 * 0.55f) / 3),
1660 ((0.60f + 2 * 0.65f) / 3),
1661 ((0.60f + 2 * 0.75f) / 3)
1664 constexpr
float eta_EB[17] = {
1665 ((1.00f + 1.05f + 1.15f) / 3),
1666 ((1.00f + 1.15f + 1.15f) / 3),
1667 ((1.00f + 1.15f + 1.25f) / 3),
1668 ((1.00f + 1.25f + 1.15f) / 3),
1669 ((1.00f + 1.25f + 1.25f) / 3),
1670 ((1.00f + 1.25f + 1.35f) / 3),
1671 ((1.20f + 1.05f + 1.15f) / 3),
1672 ((1.20f + 1.15f + 1.15f) / 3),
1673 ((1.20f + 1.15f + 1.25f) / 3),
1674 ((1.20f + 1.25f + 1.15f) / 3),
1675 ((1.20f + 1.25f + 1.25f) / 3),
1676 ((1.20f + 1.25f + 1.35f) / 3),
1677 ((1.20f + 1.35f + 1.25f) / 3),
1678 ((1.20f + 1.35f + 1.35f) / 3),
1679 ((1.20f + 1.35f + 1.45f) / 3),
1680 ((1.20f + 1.45f + 1.35f) / 3),
1681 ((1.20f + 1.45f + 1.45f) / 3)
1685 std::vector<float> sumE(1, (
float) ((int32_t) (*
p++) - 9000));
1686 (*pL2[
m_hashFunc(frag)]).setEt(std::move(sumE));
1690 int NMuons = (
int) (
size - 4) / 2;
1692 for (
int mu = 0;
mu < NMuons; ++
mu) {
1696 Mu_energy2 =
w & 0x1FFFFFF;
1697 Mu_pattern = (
w >> 25) & 0x1F;
1699 Mu_quality =
w >> 31;
1705 Mu_energy0 =
w & 0xFFFF;
1706 Mu_energy1 =
w >> 16;
1711 switch (frag >> 8) {
1713 eta.push_back(eta_LB[Mu_pattern]);
1716 eta.push_back(-eta_LB[Mu_pattern]);
1719 eta.push_back(eta_EB[Mu_pattern]);
1722 eta.push_back(-eta_EB[Mu_pattern]);
1730 energy0.push_back(Mu_energy0 / 2.);
1731 energy1.push_back(Mu_energy1 / 2.);
1732 energy2.push_back(Mu_energy2 / 2.);
1735 quality.push_back(Mu_quality);
1740 (*pL2[
m_hashFunc(frag)]).setMu(std::move(
eta), std::move(energy0),
1741 std::move(energy1), std::move(energy2), std::move(quality), std::move(word));
1748 int frag_id,
int )
const {
1753 int frag = (frag_id>0) ? frag_id : *(
p + 1) & 0xFFFF;
1756 nDrawer[0] = frag & 0x3F;
1757 nDrawer[1] = (frag & 0xFC0) >> 6;
1769 std::vector<unsigned int> word[2];
1770 std::vector<float>
eta[2];
1771 std::vector<float> energy0[2];
1772 std::vector<float> energy1[2];
1773 std::vector<float> energy2[2];
1774 std::vector<unsigned int> quality[2];
1776 constexpr
float eta_LB[9] = {
1777 ((0.00f + 2 * 0.05f) / 3),
1778 ((0.20f + 2 * 0.15f) / 3),
1779 ((0.20f + 2 * 0.25f) / 3),
1780 ((0.40f + 2 * 0.35f) / 3),
1781 ((0.40f + 2 * 0.45f) / 3),
1782 ((0.40f + 2 * 0.55f) / 3),
1783 ((0.60f + 2 * 0.55f) / 3),
1784 ((0.60f + 2 * 0.65f) / 3),
1785 ((0.60f + 2 * 0.75f) / 3)
1788 constexpr
float eta_EB[17] = {
1789 ((1.00f + 1.05f + 1.15f) / 3),
1790 ((1.00f + 1.15f + 1.15f) / 3),
1791 ((1.00f + 1.15f + 1.25f) / 3),
1792 ((1.00f + 1.25f + 1.15f) / 3),
1793 ((1.00f + 1.25f + 1.25f) / 3),
1794 ((1.00f + 1.25f + 1.35f) / 3),
1795 ((1.20f + 1.05f + 1.15f) / 3),
1796 ((1.20f + 1.15f + 1.15f) / 3),
1797 ((1.20f + 1.15f + 1.25f) / 3),
1798 ((1.20f + 1.25f + 1.15f) / 3),
1799 ((1.20f + 1.25f + 1.25f) / 3),
1800 ((1.20f + 1.25f + 1.35f) / 3),
1801 ((1.20f + 1.35f + 1.25f) / 3),
1802 ((1.20f + 1.35f + 1.35f) / 3),
1803 ((1.20f + 1.35f + 1.45f) / 3),
1804 ((1.20f + 1.45f + 1.35f) / 3),
1805 ((1.20f + 1.45f + 1.45f) / 3)
1808 int NMuons = (
int) (
size - 3) / 2;
1810 for (
int mu = 0;
mu < NMuons; ++
mu) {
1814 Mu_energy2 =
w & 0x1FFFFFF;
1815 Mu_pattern = (
w >> 25) & 0x1F;
1816 Mu_drawer = (
w >> 30) & 1;
1817 Mu_quality =
w >> 31;
1819 word[Mu_drawer].push_back(
w);
1823 Mu_energy0 =
w & 0xFFFF;
1824 Mu_energy1 =
w >> 16;
1826 word[Mu_drawer].push_back(
w);
1829 switch (frag >> 12) {
1831 eta[Mu_drawer].push_back(eta_LB[Mu_pattern]);
1834 eta[Mu_drawer].push_back(-eta_LB[Mu_pattern]);
1837 eta[Mu_drawer].push_back(eta_EB[Mu_pattern]);
1840 eta[Mu_drawer].push_back(-eta_EB[Mu_pattern]);
1848 energy0[Mu_drawer].push_back(Mu_energy0 / 2.);
1849 energy1[Mu_drawer].push_back(Mu_energy1 / 2.);
1850 energy2[Mu_drawer].push_back(Mu_energy2 / 2.);
1853 quality[Mu_drawer].push_back(Mu_quality);
1858 for (
unsigned int i = 0;
i < 2; ++
i) {
1861 int fragId = (((frag & 0xF000) >> 4) | nDrawer[
i]);
1863 (*pL2[
m_hashFunc(fragId)]).setMu(std::move(
eta[
i]), std::move(energy0[
i]), std::move(energy1[
i]), std::move(energy2[
i]),
1864 std::move(quality[
i]), std::move(word[
i]));
1873 int frag_id,
int )
const {
1878 int frag = (frag_id>0) ? frag_id : *(
p + 1) & 0xFFFF;
1890 std::vector<unsigned int> word;
1891 std::vector<float>
eta;
1892 std::vector<float> energy0;
1893 std::vector<float> energy1;
1894 std::vector<float> energy2;
1895 std::vector<unsigned int> quality;
1897 constexpr
float eta_LB[9] = {
1898 ((0.00f + 2 * 0.05f) / 3),
1899 ((0.20f + 2 * 0.15f) / 3),
1900 ((0.20f + 2 * 0.25f) / 3),
1901 ((0.40f + 2 * 0.35f) / 3),
1902 ((0.40f + 2 * 0.45f) / 3),
1903 ((0.40f + 2 * 0.55f) / 3),
1904 ((0.60f + 2 * 0.55f) / 3),
1905 ((0.60f + 2 * 0.65f) / 3),
1906 ((0.60f + 2 * 0.75f) / 3)
1909 constexpr
float eta_EB[17] = {
1910 ((1.00f + 1.05f + 1.15f) / 3),
1911 ((1.00f + 1.15f + 1.15f) / 3),
1912 ((1.00f + 1.15f + 1.25f) / 3),
1913 ((1.00f + 1.25f + 1.15f) / 3),
1914 ((1.00f + 1.25f + 1.25f) / 3),
1915 ((1.00f + 1.25f + 1.35f) / 3),
1916 ((1.20f + 1.05f + 1.15f) / 3),
1917 ((1.20f + 1.15f + 1.15f) / 3),
1918 ((1.20f + 1.15f + 1.25f) / 3),
1919 ((1.20f + 1.25f + 1.15f) / 3),
1920 ((1.20f + 1.25f + 1.25f) / 3),
1921 ((1.20f + 1.25f + 1.35f) / 3),
1922 ((1.20f + 1.35f + 1.25f) / 3),
1923 ((1.20f + 1.35f + 1.35f) / 3),
1924 ((1.20f + 1.35f + 1.45f) / 3),
1925 ((1.20f + 1.45f + 1.35f) / 3),
1926 ((1.20f + 1.45f + 1.45f) / 3)
1929 int NMuons = (
int) (
size - 3) / 2;
1931 for (
int mu = 0;
mu < NMuons; ++
mu) {
1935 Mu_energy2 =
w & 0x1FFFFFF;
1936 Mu_pattern = (
w >> 25) & 0x1F;
1938 Mu_quality =
w >> 31;
1944 Mu_energy0 =
w & 0xFFFF;
1945 Mu_energy1 =
w >> 16;
1950 switch (frag >> 8) {
1952 eta.push_back(eta_LB[Mu_pattern]);
1955 eta.push_back(-eta_LB[Mu_pattern]);
1958 eta.push_back(eta_EB[Mu_pattern]);
1961 eta.push_back(-eta_EB[Mu_pattern]);
1969 energy0.push_back(Mu_energy0 / 2.);
1970 energy1.push_back(Mu_energy1 / 2.);
1971 energy2.push_back(Mu_energy2 / 2.);
1974 quality.push_back(Mu_quality);
1979 (*pL2[
m_hashFunc(frag)]).setMu(std::move(
eta), std::move(energy0),
1980 std::move(energy1), std::move(energy2), std::move(quality), std::move(word));
1987 int frag_id,
int )
const {
1991 int frag = (frag_id>0) ? frag_id : *(
p + 1) & 0xFFFF;
1994 nDrawer[0] = frag & 0x3F;
1995 nDrawer[1] = (frag & 0xFC0) >> 6;
1999 for (
unsigned int i = 0;
i < 2; ++
i) {
2001 int fragId = (((frag & 0xF000) >> 4) | nDrawer[
i]);
2003 float sumE = (
float) ((int32_t) (*p) - 9000);
2004 (*pL2[
m_hashFunc(fragId)]).setEt(std::vector<float>{sumE});
2014 int frag_id,
int )
const {
2018 int frag = (frag_id>0) ? frag_id : *(
p + 1) & 0xFFFF;
2022 std::vector<float> sumE(1);
2024 sumE[0] = (
float) ((int32_t) (*p) - 9000);
2025 (*pL2[
m_hashFunc(frag)]).setEt(std::move(sumE));
2055 bool errorFlag =
false;
2057 if ((*pData & 0xFF000000) == 0x20000000) {
2061 reqAmp = *pData & 0xFFFF;
2065 reqAmp = *pData & 0xFFFF;
2070 filt = (((*pData >> 16) & 7) ^ 7) + 2;
2072 filt = 9 - (((*pData >> 17) & 1) * 4 + ((*pData >> 18) & 1) * 2 + ((*pData >> 19) & 1));
2075 if (((*pData >> 16) & 1) == 1) filt = 0;
2077 if (filt > 8) filt -= 8;
2092 if ((*pData & 0xFF000000) == 0x21000000) {
2094 measAmp = *pData & 0xFFF;
2109 if ((*pData & 0xFF000000) == 0x22000000) {
2113 tdc1 = (*pData >> 16) & 0xF;
2114 tdc2 = (*pData >> 20) & 0xF;
2117 tdc1 = *pData & 0xFFFF;
2133 if ((*pData & 0xFF000000) == 0x23000000) {
2137 tdc2 = (*pData >> 12) & 0xFFF;
2138 tdc1 = *pData & 0xFFF;
2142 tdc2 = *pData & 0xFFFF;
2158 if ((*pData & 0xFF000000) == 0x44000000) {
2160 chan0 = 4095 - (*pData & 0xFFF);
2161 chan1 = 4095 - ((*pData >> 12) & 0xFFF);
2174 if ((*pData & 0xFF000000) == 0x45000000) {
2176 chan2 = 4095 - (*pData & 0xFFF);
2177 chan3 = 4095 - ((*pData >> 12) & 0xFFF);
2190 if ((*pData & 0xFF000000) == 0x46000000) {
2192 chan4 = 4095 - (*pData & 0xFFF);
2193 chan5 = 4095 - ((*pData >> 12) & 0xFFF);
2206 if ((*pData & 0xFF000000) == 0x47000000) {
2219 int meanPed_diode1 = 0;
2220 int rmsPed_diode1 = 0;
2222 double MeanPed_diode1 = 0;
2223 double RmsPed_diode1 = 0;
2225 rmsPed_diode1 = *pData & 0xFFFF;
2226 meanPed_diode1 = (*pData >> 16) & 0xFFFF;
2228 MeanPed_diode1 =
static_cast<double>(meanPed_diode1) * 0.1;
2230 RmsPed_diode1 =
static_cast<double>(rmsPed_diode1) * 0.01;
2234 int meanPed_diode2 = 0;
2235 int rmsPed_diode2 = 0;
2237 double MeanPed_diode2 = 0;
2238 double RmsPed_diode2 = 0;
2240 rmsPed_diode2 = *pData & 0xFFFF;
2241 meanPed_diode2 = (*pData >> 16) & 0xFFFF;
2243 MeanPed_diode2 =
static_cast<double>(meanPed_diode2) * 0.1;
2245 RmsPed_diode2 =
static_cast<double>(rmsPed_diode2) * 0.01;
2249 int meanPed_diode3 = 0;
2250 int rmsPed_diode3 = 0;
2252 double MeanPed_diode3 = 0;
2253 double RmsPed_diode3 = 0;
2255 rmsPed_diode3 = *pData & 0xFFFF;
2256 meanPed_diode3 = (*pData >> 16) & 0xFFFF;
2258 MeanPed_diode3 =
static_cast<double>(meanPed_diode3) * 0.1;
2260 RmsPed_diode3 =
static_cast<double>(rmsPed_diode3) * 0.01;
2264 int meanPed_diode4 = 0;
2265 int rmsPed_diode4 = 0;
2267 double MeanPed_diode4 = 0;
2268 double RmsPed_diode4 = 0;
2270 rmsPed_diode4 = *pData & 0xFFFF;
2271 meanPed_diode4 = (*pData >> 16) & 0xFFFF;
2273 MeanPed_diode4 =
static_cast<double>(meanPed_diode4) * 0.1;
2275 RmsPed_diode4 =
static_cast<double>(rmsPed_diode4) * 0.01;
2279 int meanPed_pmt1 = 0;
2280 int rmsPed_pmt1 = 0;
2282 double MeanPed_pmt1 = 0;
2283 double RmsPed_pmt1 = 0;
2285 rmsPed_pmt1 = *pData & 0xFFFF;
2286 meanPed_pmt1 = (*pData >> 16) & 0xFFFF;
2288 MeanPed_pmt1 =
static_cast<double>(meanPed_pmt1) * 0.1;
2290 RmsPed_pmt1 =
static_cast<double>(rmsPed_pmt1) * 0.01;
2294 int meanPed_pmt2 = 0;
2295 int rmsPed_pmt2 = 0;
2297 double MeanPed_pmt2 = 0;
2298 double RmsPed_pmt2 = 0;
2300 rmsPed_pmt2 = *pData & 0xFFFF;
2301 meanPed_pmt2 = (*pData >> 16) & 0xFFFF;
2303 MeanPed_pmt2 =
static_cast<double>(meanPed_pmt2) * 0.1;
2305 RmsPed_pmt2 =
static_cast<double>(rmsPed_pmt2) * 0.01;
2309 time_t lastPedMeas = *pData;
2316 int meanAlpha_diode1 = 0;
2317 int rmsAlpha_diode1 = 0;
2319 double MeanAlpha_diode1 = 0;
2320 double RmsAlpha_diode1 = 0;
2322 rmsAlpha_diode1 = *pData & 0xFFFF;
2323 meanAlpha_diode1 = (*pData >> 16) & 0xFFFF;
2325 MeanAlpha_diode1 =
static_cast<double>(meanAlpha_diode1) * 0.1;
2327 RmsAlpha_diode1 =
static_cast<double>(rmsAlpha_diode1) * 0.01;
2331 int meanAlpha_diode2 = 0;
2332 int rmsAlpha_diode2 = 0;
2334 double MeanAlpha_diode2 = 0;
2335 double RmsAlpha_diode2 = 0;
2337 rmsAlpha_diode2 = *pData & 0xFFFF;
2338 meanAlpha_diode2 = (*pData >> 16) & 0xFFFF;
2340 MeanAlpha_diode2 =
static_cast<float>(meanAlpha_diode2) * 0.1;
2342 RmsAlpha_diode2 =
static_cast<float>(rmsAlpha_diode2) * 0.01;
2348 int meanAlpha_diode3 = 0;
2349 int rmsAlpha_diode3 = 0;
2351 double MeanAlpha_diode3 = 0;
2352 double RmsAlpha_diode3 = 0;
2354 rmsAlpha_diode3 = *pData & 0xFFFF;
2355 meanAlpha_diode3 = (*pData >> 16) & 0xFFFF;
2357 MeanAlpha_diode3 =
static_cast<double>(meanAlpha_diode3) * 0.1;
2359 RmsAlpha_diode3 =
static_cast<double>(rmsAlpha_diode3) * 0.01;
2363 int meanAlpha_diode4 = 0;
2364 int rmsAlpha_diode4 = 0;
2366 double MeanAlpha_diode4 = 0;
2367 double RmsAlpha_diode4 = 0;
2369 rmsAlpha_diode4 = *pData & 0xFFFF;
2370 meanAlpha_diode4 = (*pData >> 16) & 0xFFFF;
2372 MeanAlpha_diode4 =
static_cast<double>(meanAlpha_diode4) * 0.1;
2374 RmsAlpha_diode4 =
static_cast<double>(rmsAlpha_diode4) * 0.01;
2378 time_t lastAlphaMeas = *pData;
2455 double DiodeTemp = 0;
2457 diodeTemp = *pData & 0xFFF;
2458 seconds1 = (*pData >> 12) & 0xFFFFF;
2460 DiodeTemp =
static_cast<double>(diodeTemp) * 0.1;
2469 boxTemp = *pData & 0xFFF;
2470 seconds2 = (*pData >> 12) & 0xFFFFF;
2472 BoxTemp =
static_cast<double>(boxTemp) * 0.1;
2481 hum = *pData & 0xFFF;
2482 seconds3 = (*pData >> 12) & 0xFFFFF;
2484 Hum =
static_cast<double>(hum) * 0.1;
2493 gasFlow = *pData & 0xFFF;
2494 seconds4 = (*pData >> 12) & 0xFFFFF;
2496 GasFlow =
static_cast<double>(gasFlow) * 0.1;
2503 PLCstatus = *pData & 0xFFF;
2505 int alphaPos = PLCstatus & 0x7;
2506 int LVdiodes = (PLCstatus >> 0x3) & 0
x1;
2507 int HVpmts = (PLCstatus >> 0x4) & 0x3;
2508 int shutter = (PLCstatus >> 0x6) & 0x3;
2509 int interLock = (PLCstatus >> 0x8) & 0
x1;
2510 int alarm = (PLCstatus >> 0x9) & 0x7;
2512 laserObject.
setPmt(0, chan4, tdc1, MeanPed_pmt1, RmsPed_pmt1, 0);
2514 laserObject.
setPmt(1, chan5, tdc2, MeanPed_pmt2, RmsPed_pmt2, 0);
2516 laserObject.
setDiode(0, chan0, MeanPed_diode1, RmsPed_diode1, MeanAlpha_diode1, RmsAlpha_diode1, 0, 0, 0);
2518 laserObject.
setDiode(1,
chan1, MeanPed_diode2, RmsPed_diode2, MeanAlpha_diode2, RmsAlpha_diode2, 0, 0, 0);
2520 laserObject.
setDiode(2, chan2, MeanPed_diode3, RmsPed_diode3, MeanAlpha_diode3, RmsAlpha_diode3, 0, 0, 0);
2522 laserObject.
setDiode(3, chan3, MeanPed_diode4, RmsPed_diode4, MeanAlpha_diode4, RmsAlpha_diode4, 0, 0, 0);
2524 laserObject.
setControl(DiodeTemp, seconds1, BoxTemp, seconds2, GasFlow, seconds4, Hum, seconds3, lastPedMeas, lastAlphaMeas);
2528 laserObject.
setPLC(alphaPos, LVdiodes, HVpmts, shutter, interLock, alarm);
2548 int maxn=
size+2-sizeOverhead;
2549 for(
int n=0;
n<maxn; ++
n){
2550 ATH_MSG_DEBUG(
"WORD " <<
n <<
" (" <<
n+11 <<
") : (DEC) " <<
p[
n] <<
" (HEX) 0x" << MSG::hex <<
p[
n] << MSG::dec );
2560 ATH_MSG_DEBUG(
"SETTING DAQ TYPE IN DECODER = " << MSG::hex <<
"0x" <<
int(
p[2]) <<
" " << MSG::dec <<
int(
p[2]));
2563 int idiode = (
p[4]>>16);
2564 int intensity = (
p[4]&0xFFFF);
2565 int filter = (
p[5]>>16) & 0x000F;
2566 bool qdctimeout = !((
p[5]>>31) & 0
x1);
2567 bool tdctimeout = !((
p[5]>>30) & 0
x1);
2573 laserObject.
setControl(-99,-99,-99,-99,-99,-99,-99,-99,-99,-99);
2574 laserObject.
setPLC(-99,-99,-99,-99,-99,-99);
2582 ATH_MSG_DEBUG(
"laserObject.setLaser: " << MSG::dec <<
"COUNTER=" << countr <<
" | "
2583 <<
"I_DIODE=" << idiode <<
" | "
2584 <<
"FILTERN=" <<
filter <<
" | "
2585 <<
"TIMINGD=" <<
timing <<
" | "
2586 <<
"DAQTYPE=" << daqtyp );
2593 static const int HG=0;
2594 static const int LG=1;
2601 las[
adc++] = 8500 - ((*word) & 0xFFFF);
2602 las[
adc++] = 8500 - ((*word) >> 16);
2607 int TDC0 = (*word) & 0xFFFF;
2608 int TDC1 = (*word) >> 16;
2617 if(
p[128]==0 || (
p[128]==3072 &&
p[32]<21504000) ) {
2670 ATH_MSG_DEBUG(
"PED CHAN=" <<
channel <<
" GAIN=LG" <<
" TYPE=" << laserObject.
getType(
channel,
TileID::LOWGAIN,0) <<
" MEAN=" << laserObject.
getMean(
channel,
TileID::LOWGAIN,0) <<
" SIGMA=" << laserObject.
getSigma(
channel,
TileID::LOWGAIN,0) <<
" N=" << laserObject.
getN(
channel,
TileID::LOWGAIN,0) <<
" isSet?=" << laserObject.
isSet(
channel,
TileID::LOWGAIN,0) );
2671 ATH_MSG_DEBUG(
"PED CHAN=" <<
channel <<
" GAIN=HG" <<
" TYPE=" << laserObject.
getType(
channel,
TileID::HIGHGAIN,0) <<
" MEAN=" << laserObject.
getMean(
channel,
TileID::HIGHGAIN,0) <<
" SIGMA=" << laserObject.
getSigma(
channel,
TileID::HIGHGAIN,0) <<
" N=" << laserObject.
getN(
channel,
TileID::HIGHGAIN,0) <<
" isSet?=" << laserObject.
isSet(
channel,
TileID::HIGHGAIN,0) );
2673 ATH_MSG_DEBUG(
"PED CHAN=" <<
channel <<
" GAIN=LG" <<
" TYPE=" << laserObject.
getType(
channel,
TileID::LOWGAIN,1) <<
" MEAN=" << laserObject.
getMean(
channel,
TileID::LOWGAIN,1) <<
" SIGMA=" << laserObject.
getSigma(
channel,
TileID::LOWGAIN,1) <<
" N=" << laserObject.
getN(
channel,
TileID::LOWGAIN,1) <<
" isSet?=" << laserObject.
isSet(
channel,
TileID::LOWGAIN,1) );
2674 ATH_MSG_DEBUG(
"PED CHAN=" <<
channel <<
" GAIN=HG" <<
" TYPE=" << laserObject.
getType(
channel,
TileID::HIGHGAIN,1) <<
" MEAN=" << laserObject.
getMean(
channel,
TileID::HIGHGAIN,1) <<
" SIGMA=" << laserObject.
getSigma(
channel,
TileID::HIGHGAIN,1) <<
" N=" << laserObject.
getN(
channel,
TileID::HIGHGAIN,1) <<
" isSet?=" << laserObject.
isSet(
channel,
TileID::HIGHGAIN,1) );
2676 ATH_MSG_DEBUG(
"LED CHAN=" <<
channel <<
" GAIN=LG" <<
" TYPE=" << laserObject.
getType(
channel,
TileID::LOWGAIN,2) <<
" MEAN=" << laserObject.
getMean(
channel,
TileID::LOWGAIN,2) <<
" SIGMA=" << laserObject.
getSigma(
channel,
TileID::LOWGAIN,2) <<
" N=" << laserObject.
getN(
channel,
TileID::LOWGAIN,2) <<
" isSet?=" << laserObject.
isSet(
channel,
TileID::LOWGAIN,2) );
2677 ATH_MSG_DEBUG(
"LED CHAN=" <<
channel <<
" GAIN=HG" <<
" TYPE=" << laserObject.
getType(
channel,
TileID::HIGHGAIN,2) <<
" MEAN=" << laserObject.
getMean(
channel,
TileID::HIGHGAIN,2) <<
" SIGMA=" << laserObject.
getSigma(
channel,
TileID::HIGHGAIN,2) <<
" N=" << laserObject.
getN(
channel,
TileID::HIGHGAIN,2) <<
" isSet?=" << laserObject.
isSet(
channel,
TileID::HIGHGAIN,2) );
2679 ATH_MSG_DEBUG(
"ALP CHAN=" <<
channel <<
" GAIN=LG" <<
" TYPE=" << laserObject.
getType(
channel,
TileID::LOWGAIN,3) <<
" MEAN=" << laserObject.
getMean(
channel,
TileID::LOWGAIN,3) <<
" SIGMA=" << laserObject.
getSigma(
channel,
TileID::LOWGAIN,3) <<
" N=" << laserObject.
getN(
channel,
TileID::LOWGAIN,3) <<
" isSet?=" << laserObject.
isSet(
channel,
TileID::LOWGAIN,3) );
2680 ATH_MSG_DEBUG(
"ALP CHAN=" <<
channel <<
" GAIN=HG" <<
" TYPE=" << laserObject.
getType(
channel,
TileID::HIGHGAIN,3) <<
" MEAN=" << laserObject.
getMean(
channel,
TileID::HIGHGAIN,3) <<
" SIGMA=" << laserObject.
getSigma(
channel,
TileID::HIGHGAIN,3) <<
" N=" << laserObject.
getN(
channel,
TileID::HIGHGAIN,3) <<
" isSet?=" << laserObject.
isSet(
channel,
TileID::HIGHGAIN,3) );
2682 ATH_MSG_DEBUG(MSG::hex << msb0 <<
" + " << lsb0 <<
" => " << SSQ0 <<
2683 MSG::dec <<
" >>> D" <<
channel <<
"(HG)"
2694 ATH_MSG_DEBUG(MSG::hex << msb1 <<
" + " << lsb1 <<
" => " << SSQ1 <<
2695 MSG::dec <<
" >>> D" <<
channel <<
"(LG)"
2714 memset(
ped,0,
sizeof(
ped));
2715 memset(std,0,
sizeof(std));
2726 ATH_MSG_DEBUG(
"SHORT FRAGMENT, size=" <<
p[0] <<
" type=0x" << MSG::hex <<
p[1] << MSG::dec);
2727 memset(
ped,0,
sizeof(
ped));
2728 memset(std,0,
sizeof(std));
2742 for(
int diode=0;diode<10;++diode){
2798 int bs_frag = idAndType & 0xFFFF;
2799 bool is16ChannelType = (idAndType >> 16) & 1;
2800 bool is32ChannelType = (idAndType >> 17) & 1;
2803 int datasize =
count - sizeOverhead;
2806 msg(
MSG::VERBOSE) <<
"Unpacking Beam Elements, ID=0x" << MSG::hex << frag_id <<
" BS frag=0x" << bs_frag
2807 <<
", size=" << MSG::dec << datasize;
2808 for (
int ch = 0;
ch < datasize; ++
ch) {
2815 if (datasize <= 0)
return;
2817 int frag = (frag_id>=0) ? frag_id : bs_frag;
2829 if (!(is16ChannelType || is32ChannelType)) {
2831 std::vector<uint32_t>
adc;
2832 for (
int c = 0;
c < datasize; ++
c) {
2841 pBeam.push_back(rc);
2852 pBeam.push_back(rc);
2865 std::vector<uint32_t>
adc;
2866 for (
int c = 0;
c < datasize; ++
c) {
2868 : (*
p >> 16) & 0x7FF;
2873 if (prev !=
chan && ((is16ChannelType &&
chan < 16) || (is32ChannelType &&
chan < 32))) {
2877 pBeam.push_back(rc);
2885 if ((is16ChannelType && prev < 16) || (is32ChannelType && prev < 32)) {
2888 pBeam.push_back(rc);
2898 int nmodule = 4,
nchan, nsamp,
ch;
2900 nchan = nmodule * 4;
2901 nsamp = datasize / nmodule;
2904 <<
", nsamp=" << nsamp);
2906 if (nmodule * nsamp == datasize) {
2908 for (
int m = 0;
m < nmodule; ++
m) {
2910 for (
int s = 0;
s < nsamp; ++
s) {
2912 for (
int c = 0;
c < 4; ++
c) {
2924 std::vector<uint32_t>
adc;
2926 for (
int s = 0;
s < nsamp; ++
s) {
2930 pBeam.push_back(rc);
2939 #ifndef LASER_OBJ_FRAG
2940 #define LASER_OBJ_FRAG 0x016
2942 #ifndef LASER2_OBJ_FRAG
2943 #define LASER2_OBJ_FRAG 0x017
2949 std::vector<uint32_t> digits;
2950 for (
int ch = 0;
ch < datasize; ++
ch) {
2951 digits.push_back((*
p));
2956 pBeam.push_back(rc);
2965 if (is16ChannelType || is32ChannelType) {
2967 std::vector<uint32_t>
adc;
2968 for (
int c = 0;
c < datasize; ++
c) {
2970 : (*
p >> 16) & 0x7FF;
2976 if (prev !=
chan && ((is16ChannelType &&
chan < 16) || (is32ChannelType &&
chan < 32))) {
2980 pBeam.push_back(rc);
2985 adc.push_back(amplitude);
2988 if ((is16ChannelType && prev < 16) || (is32ChannelType && prev < 32)) {
2991 pBeam.push_back(rc);
3003 int chmax = (datasize > 16) ? 15 : datasize;
3007 pBeam.push_back(rc);
3010 if (
chmax != datasize) {
3011 std::vector<uint32_t> digits;
3013 digits.push_back((*
p));
3018 pBeam.push_back(rc);
3032 ATH_MSG_FATAL(
"RawEvent passed to 'convert'-function is a null pointer!" );
3033 return StatusCode::FAILURE;
3050 for (
uint32_t i_rob = 0; i_rob < total_sub; ++i_rob) {
3052 re->child(p_rob, i_rob);
3055 eformat::helper::SourceIdentifier
id = eformat::helper::SourceIdentifier(robFrag.source_id());
3056 unsigned int subDetId =
id.subdetector_id();
3058 if (subDetId >= 0x50 && subDetId < 0x60) {
3067 <<
" TileL2 objects created" <<
endmsg;
3072 for (;
ind != last; ++
ind) {
3077 return StatusCode::SUCCESS;
3087 int fragmin = 0xFFF, fragmax = -1;
3093 bool V3format = (*(
p) == 0xff1234ff);
3094 if (!V3format &&
version>0xff) {
3097 ATH_MSG_WARNING(
"fillCollectionL2( corrupted frag separator 0x" << MSG::hex << (*
p) <<
" instead of 0xff1234ff in ROB 0x" << rob->rod_source_id() << MSG::dec );
3116 uint32_t bs_frag_id = idAndType & 0xFFFF;
3117 int frag = hid2re->getOfflineFragID(bs_frag_id);
3118 if (frag<0) frag = bs_frag_id;
3119 const std::vector<uint32_t> & drawer_info = hid2re->getDrawerInfo(frag);
3120 int drawer_type = drawer_info.size()>2 ? drawer_info[2] : -1;
3121 if (frag < fragmin) fragmin = frag;
3122 if (frag > fragmax) fragmax = frag;
3123 DataType = (idAndType & 0x30000000) >> 28;
3125 int type = (*(
p + 1) >> 16) & 0xFF;
3127 if (count < sizeOverhead || count >
size - wc) {
3129 for (; wc <
size; ++wc, ++
cnt, ++
p) {
3130 if ((*
p) == 0xff1234ff) {
3138 msg(MSG::WARNING) <<
"Frag " << MSG::hex <<
"0x" << frag
3139 << MSG::dec <<
" has unexpected size: " <<
count;
3141 msg(MSG::WARNING) <<
" skipping " <<
cnt <<
" words to the next frag" <<
endmsg;
3143 msg(MSG::WARNING) <<
" ignoring " <<
cnt <<
" words till the end of ROD frag" <<
endmsg;
3161 }
else if ((
type >> 4) == 1) {
3187 int frag = *(
p + 1) & 0xFFFF;
3188 ATH_MSG_WARNING(
"Unknown frag type=" <<
type <<
" for frag=" << frag <<
" bs_frag=" << bs_frag_id);
3208 if (
m_L2Builder->process(fragmin, fragmax, &
v).isFailure()) {
3221 const uint32_t ROB_to_decode = ((*p) & 0xFFFF);
3222 const uint32_t virtualROBJump = ((*p) >> 16) >> 2;
3223 if (
size < ROB_to_decode * virtualROBJump + 1) {
3225 <<
"; virtualROBJump=" << virtualROBJump
3226 <<
"; ROB_to_decode=" << ROB_to_decode );
3233 std::vector<float> sumE(3, 0.0);
3237 for (
size_t irob = 0; irob < ROB_to_decode; ++irob) {
3238 for (
size_t drawInRob = 0; drawInRob < virtualROBJump; ++drawInRob) {
3241 bs_frag_id = idAndType & 0xFFF;
3242 frag = hid2re->getOfflineFragID(bs_frag_id);
3243 if (frag<0) frag = bs_frag_id;
3247 unit = (idAndType >> (32 - 2)) & 0x3;
3252 (
v[
hash])->setEt(std::vector<float>(sumE));
3268 ATH_MSG_FATAL(
"RawEvent passed to 'convert'-function is a null pointer!" );
3269 return StatusCode::FAILURE;
3285 for (
uint32_t i_rob = 0; i_rob < total_sub; ++i_rob) {
3287 re->child(p_rob, i_rob);
3290 eformat::helper::SourceIdentifier
id = eformat::helper::SourceIdentifier(
3291 robFrag.rod_source_id());
3292 unsigned int subDetId =
id.subdetector_id();
3294 if (subDetId >= 0x50 && subDetId < 0x60) {
3299 return StatusCode::SUCCESS;
3314 " size = " <<
size <<
3315 " pointer = " <<
p );
3323 bool V3format = (*(
p) == 0xff1234ff);
3327 ATH_MSG_WARNING(
"fillTileLaserObj: corrupted frag separator 0x" << MSG::hex << (*
p) <<
" instead of 0xff1234ff in ROB 0x" << rob->rod_source_id() << MSG::dec );
3336 if(V3format)
ATH_MSG_DEBUG(
"tile flag found! size overhead = " << sizeOverhead);
3337 else ATH_MSG_DEBUG(
"tile flag not found! size overhead = " << sizeOverhead);
3343 int frag = *(
p + 1) & 0xFFFF;
3344 int type = *(
p + 1) >> 16;
3346 ATH_MSG_DEBUG( wc <<
" / " <<
size <<
" HEX = 0x" << MSG::hex <<
count <<
" DEC = " << MSG::dec <<
count <<
" ( FRAG , TYPE ) = " << frag <<
" , " <<
type );
3348 if (count < sizeOverhead || count >
size - wc) {
3350 for (; wc <
size; ++wc, ++
cnt, ++
p) {
3351 if ((*
p) == 0xff1234ff) {
3352 ATH_MSG_DEBUG(
"DATA POINTER: HEX = " << MSG::hex << (*
p) <<
" DEC = " << MSG::dec << (*
p) );
3360 msg(MSG::WARNING) <<
"Frag: " << MSG::hex <<
"0x" << frag << MSG::dec
3361 <<
" has unexpected size: " <<
count;
3363 msg(MSG::WARNING) <<
" skiping " <<
cnt <<
" words to the next frag" <<
endmsg;
3365 msg(MSG::WARNING) <<
" ignoring " <<
cnt <<
" words till the end of ROD frag" <<
endmsg;
3371 ATH_MSG_DEBUG(
"DECODER" <<
" " <<
"FRAG=" << frag <<
" TYPE=" <<
type <<
" SIZE=" <<
size <<
" FOUND!" );
3373 if (frag == 0x16 &&
type == 0x20){
3375 const int LASTROD_BCID = rob->rod_bc_id();
3376 v.setBCID(LASTROD_BCID);
3381 }
else if (
size>24) {
3387 if (frag == 0x17 &&
type == 0x20){
3389 const int LASTROD_BCID = rob->rod_bc_id();
3390 v.setBCID(LASTROD_BCID);
3422 const std::vector<uint32_t> & drawer_info = hid2reHLT->
getDrawerInfo(frag_id);
3423 int bs_frag_id = drawer_info.size()>1 ? drawer_info[1] : frag_id;
3424 int drawer_type = drawer_info.size()>2 ? drawer_info[2] : -1;
3437 uint16_t rob_bcid = ((rob->rod_bc_id() & 0x7FFF) | 0x8000);
3441 bool V3format = (*(
p) == 0xff1234ff);
3442 if (!V3format &&
version>0xff) {
3445 ATH_MSG_WARNING(
"fillCollectionHLT: corrupted frag separator 0x" << MSG::hex << (*
p) <<
" instead of 0xff1234ff in ROB 0x" << rob->rod_source_id() << MSG::dec );
3458 bool fragFound =
false;
3459 bool DQfragMissing =
true;
3470 int frag = (idAndType & 0xFFFF);
3471 int type = (idAndType & 0xFF0000) >> 16;
3473 if (count < sizeOverhead || count >
size - wc) {
3475 for (; wc <
size; ++wc, ++
cnt, ++
p) {
3476 if ((*
p) == 0xff1234ff) {
3484 msg(MSG::WARNING) <<
"Frag: " << MSG::hex <<
"0x" << frag << MSG::dec
3485 <<
" has unexpected size: " <<
count;
3487 msg(MSG::WARNING) <<
" skipping " <<
cnt <<
" words to the next frag" <<
endmsg;
3489 msg(MSG::WARNING) <<
" ignoring " <<
cnt <<
" words till the end of ROD frag" <<
endmsg;
3497 if (frag == bs_frag_id) {
3502 DQfragMissing =
false;
3508 DQfragMissing =
false;
3515 int unit = (idAndType & 0xC0000000) >> 30;
3517 int DataType = (idAndType & 0x30000000) >> 28;
3521 of2 = ((idAndType & 0x4000000) != 0);
3522 int nIter = (idAndType & 0x3000000) >> 24;
3528 DQfragMissing =
false;
3532 const_cast<Gaudi::Property<std::vector<int>
> &> (
m_demoFragIDs ) = {};
3533 ATH_MSG_INFO(
"Disable channel remapping for demonstrator in MC");
3544 int unit = (idAndType & 0xC0000000) >> 30;
3546 of2 = ((idAndType & 0x4000000) != 0);
3555 DQfragMissing =
false;
3570 if (DQfragMissing && !masked_drawer)
error |= 0x40000;
3573 if (masked_drawer) DQuality = 0x0;
3575 pChannel,
v, DQuality, d0cells, MBTS);
3576 }
else if (!masked_drawer)
error |= 0x20000;
3590 typedef FRwChVec::const_iterator ITERATOR;
3594 std::vector<TileCell*> cell2Double;
3595 cell2Double.reserve(23);
3599 if (DQuality == 0xffff)
error |= 0x80000;
3602 int ros = (frag_id >> 8);
3603 int drawer = (frag_id & 0x3F);
3605 unsigned int channelIdx;
3606 unsigned int adcIdx;
3611 if (pChannel.size() > 0) {
3625 cell->setTime_nonvirt(-100.0
F);
3626 cell->setQuality_nonvirt(
static_cast<unsigned char>(255), 0, 0);
3627 cell->setQuality_nonvirt(
static_cast<unsigned char>(255), 0, 1);
3633 ITERATOR rawItr = pChannel.begin();
3634 ITERATOR
end = pChannel.end();
3638 channelIdx = rawItr->channel();
3639 bool no_dmu_mask =
true;
3641 if (DQuality >> (channelIdx / 3) & 0x1) no_dmu_mask =
false;
3644 adcIdx = rawItr->adc();
3645 qual = rawItr->quality();
3646 bool do_mask =
false;
3648 ener = rawItr->amplitude();
3649 time = rawItr->time();
3652 if (recalibrate && ener!=0.0
F) {
3653 ener =
m_tileToolEmscale->channelCalib(drawerIdx, channelIdx, adcIdx, ener, rChUnit,
3687 int MBTS_chan=((
ros>2)?-1:43);
3689 for (; rawItr !=
end; ++rawItr) {
3691 const int rw2cell =
m_Rw2Cell[sec][idxraw];
3692 if (rw2cell != -1) {
3695 channelIdx = rawPtr->
channel();
3696 bool no_dmu_mask =
true;
3698 if (DQuality >> (channelIdx / 3) & 0x1) no_dmu_mask =
false;
3700 adcIdx = rawPtr->
adc();
3709 if (recalibrate && ener!=0.0
F) {
3710 ener =
m_tileToolEmscale->channelCalib(drawerIdx, channelIdx, adcIdx, ener, rChUnit,
3737 cell2Double.push_back(pCell);
3743 }
else if (MBTS_chan<0) MBTS_chan=rawPtr->
channel();
3753 if (MBTS && MBTS_chan >= 0) {
3756 if (
idx < (*MBTS).size()) {
3760 adcIdx = rawCh.
adc();
3798 for (std::vector<TileCell*>::const_iterator d_it = cell2Double.begin();
3799 d_it != cell2Double.end(); ++d_it) {
3803 int gain = (*d_it)->gain1() | (*d_it)->gain2();
3804 unsigned char qual = (*d_it)->qual1() & (*d_it)->qual2();
3806 float ener = (*d_it)->e();
3807 float time = (*d_it)->time();
3810 (*d_it)->setEnergy_nonvirt(ener, ener,
gain,
gain);
3811 (*d_it)->setQuality_nonvirt(
qual, qbit, 0);
3812 (*d_it)->setQuality_nonvirt(
qual, qbit, 1);
3813 if (
time == -100.0
F) (*d_it)->setTime_nonvirt(0.0
F);
3820 unsigned sizeOverhead,
3829 int wc = sizeOverhead;
3832 unsigned int w = (*p);
3836 pChannel.emplace_back(
ch
3843 pChannel.emplace_back(
ch, 1U, 0.0
F, 0.0
F, 0.0
F);
3880 const short* p16 = (
const short *)
p;
3883 short wc16 = 4 + sizeOverhead * 2;
3885 for (
unsigned int ch = 0U;
ch < 48U; ++
ch) {
3888 pChannel.emplace_back(
ch
3906 pChannel.emplace_back(
ch, 1U, 0.0
F, 0.0
F, 0.0
F);
3910 if (wc16 % 2 == 1) {
3914 if (wc16 != 2 *
count) {
3918 << wc16 <<
" != 2*" <<
count );
3932 int frag_id,
int drawer_type)
const
3937 int frag = (frag_id>0) ? frag_id : *(
p + 1) & 0xFFFF;
3942 int wc = sizeOverhead;
3944 unsigned int ch1 = (
remap) ? chmap[
ch] :
ch;
3945 unsigned int w = (*p);
3947 pChannel.emplace_back(ch1
3954 pChannel.emplace_back(ch1, 1U, 0.0
F, 0.0
F, 0.0
F);
3965 << wc <<
" != " <<
count );
3979 int frag_id,
int drawer_type)
const
3984 int frag = (frag_id>0) ? frag_id : *(
p + 1) & 0xFFFF;
3987 int size_L2 = (*(
p + 1) >> (32 - 2 - 3)) & 0x7;
3990 int wc = sizeOverhead;
3992 uint16_t bad_bits[3] = { ptr_bad[1], ptr_bad[0], ptr_bad[3] };
3995 int fmt,
bad,
gain(0), ene_bin(0), time_bin(0), quality;
3997 float ene(0.0),
time(0.0);
3999 unsigned int ch = 0U;
4000 for (
unsigned int i = 0U;
i < 3U; ++
i) {
4002 for (
unsigned int j = 0U; j < 16U; ++j) {
4011 bad = (bad16 & 0x1);
4014 unsigned int ch1 = (
remap) ? chmap[
ch] :
ch;
4015 pChannel.emplace_back(ch1,
gain, ene,
time, quality);
4028 << wc <<
" != " <<
count );
4041 int frag_id,
int )
const {
4046 int frag = (frag_id>0) ? frag_id : idAndType & 0xFFFF;
4047 int unit = (idAndType >> (32 - 2)) & 0x3;
4049 #ifdef DO_NOT_USE_MUON_TAG
4064 int size_L2 =
size - sizeOverhead - 48;
4067 std::vector<float> sumE;
4068 sumE.reserve(size_L2);
4072 (*pL2[
m_hashFunc(frag)]).setEt(std::move(sumE));
4084 int frag_id,
int )
const {
4087 int frag = (frag_id>0) ? frag_id : idAndType & 0xFFFF;
4088 int unit = (idAndType >> (32 - 2)) & 0x3;
4089 int size_L2 = (idAndType >> (32 - 2 - 3)) & 0x7;
4091 #ifdef DO_NOT_USE_MUON_TAG
4104 int drawer = (frag & 0x3F);
4105 int ros = (frag >> 8);
4114 uint16_t bad_bits[3] = {ptr_bad[1], ptr_bad[0], ptr_bad[3]};
4117 int fmt,
gain(0), ene_bin(0), time_bin(0);
4119 float ene(0.0),
time(0.0);
4122 for (
int i = 0;
i < 3; ++
i) {
4124 for (
int j = 0; j < 16; ++j) {
4133 bad[
ch] = (bad16 & 0x1); bad16 >>= 1;
4145 std::vector<double> EtaMuons;
4146 std::vector<double> EMuons0;
4147 std::vector<double> EMuons1;
4148 std::vector<double> EMuons2;
4149 std::vector<unsigned int> qf;
4150 std::vector<unsigned int> word;
4153 case TileHWID::BARREL_POS:
m_L2Builder->MTagLB(
ros,
drawer,E_MeV,
Gain,
bad,EtaMuons,EMuons0,EMuons1,EMuons2,qf,word);
break;
4154 case TileHWID::BARREL_NEG:
m_L2Builder->MTagLB(
ros,
drawer,E_MeV,
Gain,
bad,EtaMuons,EMuons0,EMuons1,EMuons2,qf,word);
break;
4155 case TileHWID::EXTBAR_POS:
m_L2Builder->MTagEB(
ros,
drawer,E_MeV,
Gain,
bad,EtaMuons,EMuons0,EMuons1,EMuons2,qf,word);
break;
4156 case TileHWID::EXTBAR_NEG:
m_L2Builder->MTagEB(
ros,
drawer,E_MeV,
Gain,
bad,EtaMuons,EMuons0,EMuons1,EMuons2,qf,word);
break;
4160 (*pL2[
m_hashFunc(frag)]).setMu(std::move(EtaMuons), std::move(EMuons0),
4161 std::move(EMuons1), std::move(EMuons2), std::move(qf), std::move(word));
4167 std::vector<float> sumE;
4168 sumE.reserve(size_L2);
4172 (*pL2[
m_hashFunc(frag)]).setEt(std::move(sumE));
4183 for (
int i = 0;
i < 64; ++
i) {
4196 int ros = (frag_id >> 8);
4199 int drawer = (frag_id & 0xFF);
4201 if ( !pCell )
return;
4206 (pCell)->setEnergy_nonvirt(0.0
F, 0.0
F, 0, 0);
4207 (pCell)->setTime_nonvirt(0.0
F);
4208 (pCell)->setQuality_nonvirt(
static_cast<unsigned char>(255), 0, 0);
4209 (pCell)->setQuality_nonvirt(
static_cast<unsigned char>(255), 0, 1);
4220 (pCell)->setEnergy(amp2, amp2,
gain2,
gain2);
4221 (pCell)->setTime(time2);
4222 (pCell)->setQuality(qual2, qbit2, 0);
4223 (pCell)->setQuality(qual2, qbit2, 1);
4237 (pCell)->setEnergy(amp1, amp1,
gain1,
gain1);
4238 (pCell)->setTime(time1);
4239 (pCell)->setQuality(qual1, qbit1, 0);
4240 (pCell)->setQuality(qual1, qbit1, 1);
4252 (pCell)->setEnergy(amp1, amp2,
gain1,
gain2);
4253 (pCell)->setTime(time1);
4254 (pCell)->setTime(time2, 1);
4255 (pCell)->setQuality(qual1, qbit1, 0);
4256 (pCell)->setQuality(qual2, qbit2, 1);
4276 SmartIF<IProperty> propertyServer{service(
"ByteStreamCnvSvc")};
4277 if (propertyServer) {
4279 std::vector<std::string> vecProp;
4280 StringArrayProperty vecProperty(
"ROD2ROBmap", vecProp);
4282 if (propertyServer->getProperty(&vecProperty).isSuccess()) {
4284 if (vecProperty.value().size() % 2 == 1) {
4286 <<
" means that we'll scan event for all fragments to create proper map" );
4288 SmartIF<IROBDataProviderSvc> robSvc{service(
"ROBDataProviderSvc")};
4290 const eformat::FullEventFragment<const uint32_t*> *
event = robSvc->getEvent(Gaudi::Hive::currentContext());
4292 event->check_tree();
4295 ATH_MSG_DEBUG(
"Bad event, mapping might be incomplete! " );
4300 }
else if (vecProperty.value().size() == 0) {
4302 <<
" means that predefined mapping for run " <<
m_fullTileRODs <<
" will be used " );
4304 ATH_MSG_DEBUG(
"Apply additional remapping for " << vecProperty.value().size()/2 <<
" fragments from jobOptions ");
4326 <<
" => assume unit=" << (
unit & 3) );
4331 size_t id = (drawerIdx << 2 |
unit);
4338 ofptr = m_OFPtrs[
id];
4343 const EventContext &ctx = Gaudi::Hive::currentContext();
4345 std::vector<uint32_t>& ofw = m_OFWeights[
id];
4347 ATH_MSG_DEBUG(
"getOFC fragId: 0x" << MSG::hex << fragId << MSG::dec <<
" Unit: " <<
unit);
4352 std::vector<double>
a(7),
b(7),
c(7),
g(7),
dg(7);
4354 for (
int ch = 0;
ch < 48; ++
ch) {
4368 for (
int i = 0;
i < 7; ++
i) {
4385 ofptr = m_OFPtrs[
id] = ofw.data();
4400 ATH_MSG_DEBUG(
" TileROD_Decoder::fillCollection_TileMuRcv_Digi " );
4404 bool b_digiTmdb =
false;
4407 uint32_t sourceid = rob->rod_source_id();
4408 int size = rob->rod_ndata();
4416 ATH_MSG_DEBUG(
" Trying DECODER over source ID: "<<MSG::hex<<
" 0x"<<sourceid<<MSG::dec<<
" size of full fragment: "<<
size );
4418 while ( wc <
size ) {
4420 if ((*
p) == 0xff1234ff) b_sof=
true;
4422 ATH_MSG_DEBUG(
" Start of sub-fragment word: "<<MSG::hex<<(*
p)<<MSG::dec<<
" false/true: "<<b_sof );
4426 sfrag_size = *(
p+1);
4428 sfrag_version = *(
p+2) & 0xFFFF;
4429 sfrag_type = *(
p+2) >> 16;
4433 if (sfrag_type==0x40) {
4435 ATH_MSG_DEBUG( MSG::hex<<
" DECODER sub-fragment VERSION= 0x"<<sfrag_version<<
" TYPE= 0x"<<sfrag_type<< MSG::dec<<
" SIZE="<<sfrag_size<<
" FOUND! " );
4460 ATH_MSG_DEBUG(
" TileROD_Decoder::fillCollection_TileMuRcv_RawChannel " );
4464 bool b_rcTmdb =
false;
4467 uint32_t sourceid = rob->rod_source_id();
4468 int size = rob->rod_ndata();
4477 ATH_MSG_DEBUG(
" Trying DECODER over source ID: "<<MSG::hex<<
" 0x"<<sourceid<<MSG::dec<<
" size of full fragment: "<<
size );
4479 while ( wc <
size ) {
4481 if ((*
p) == 0xff1234ff) b_sof=
true;
4482 ATH_MSG_DEBUG(
" Start of sub-fragment word : "<<MSG::hex<< (*
p)<<MSG::dec<<
" false/true : "<<b_sof );
4486 sfrag_size = *(
p+1);
4488 sfrag_version = *(
p+2) & 0xFFFF;
4489 sfrag_type = *(
p+2) >> 16;
4496 if (sfrag_type==0x40) {
4497 ATH_MSG_DEBUG(MSG::hex<<
" DECODER sub-fragment VERSION= 0x"<<sfrag_version<<
" TYPE= 0x"<<sfrag_type<<MSG::dec<<
" SIZE="<<sfrag_size<<
" FOUND! Keep on looking for 0x41.");
4501 }
else if (sfrag_type==0x41) {
4503 ATH_MSG_DEBUG(MSG::hex<<
" DECODER sub-fragment VERSION= 0x"<<sfrag_version<<
" TYPE= 0x"<<sfrag_type<<MSG::dec<<
" SIZE="<<sfrag_size<<
" FOUND!");
4508 ATH_MSG_DEBUG(MSG::hex<<
" DECODER sub-fragment VERSION= 0x"<<sfrag_version<<
" TYPE= 0x"<<sfrag_type<<MSG::dec<<
" SIZE="<<sfrag_size<<
" FOUND!");
4530 ATH_MSG_DEBUG(
"TileROD_Decoder::fillCollection_FELIX_Digi" );
4550 const std::vector<uint32_t> & drawer_info = hid2re->getDrawerInfo(frag_id);
4551 int bs_frag_id = drawer_info.size()>1 ? drawer_info[1] : frag_id;
4552 int drawer_type = drawer_info.size()>2 ? drawer_info[2] : -1;
4554 while (
data < end_data) {
4556 if ((*
data) == 0xff1234ff) {
4559 int frag = (idAndType & 0x0FFF);
4560 int type = (idAndType>>16)& 0xFF;
4561 if (
type == 0x06 && (frag == bs_frag_id)) {
4563 ATH_MSG_DEBUG( MSG::hex <<
"Found FELIX sub-fragment ID=0x" << frag
4564 <<
" type=0x" <<
type << MSG::dec
4565 <<
" size=" <<
count );
4567 unpack_frag6(
version, sizeOverhead, digitsMetaData, correct_data.data(), pDigits, frag_id, drawer_type);
4570 digitsMetaData[0].push_back(
count);
4571 digitsMetaData[0].push_back(frag);
4572 digitsMetaData[0].push_back(0);
4586 make_copy(bsflags, rChType, rChUnit, digitsMetaData, rawchannelMetaData,
4587 rob, pDigits, pChannel, coll,
nullptr);
4599 ATH_MSG_FATAL(
"RawEvent passed to 'convert'-function is a null pointer!" );
4600 return StatusCode::FAILURE;
4605 for (
uint32_t i_rob = 0; i_rob < total_sub; ++i_rob) {
4607 re->child(p_rob, i_rob);
4611 uint32_t sourceid = robFrag.source_id();
4615 if ((modid == 0x51 || modid == 0x52 || modid == 0x53 || modid == 0x54) && (sourceid & 0xf00)) {
4620 return StatusCode::SUCCESS;
4625 ATH_MSG_DEBUG(
"TileROD_Decoder::fillContainer_TileMuRcv_Decision" );
4629 bool b_deciTmdb =
false;
4632 uint32_t sourceid = rob->rod_source_id();
4633 int size = rob->rod_ndata();
4641 std::vector<const uint32_t *> pFragTmdb;
4643 ATH_MSG_DEBUG(
" Trying DECODER over source ID: " << MSG::hex
4644 <<
" 0x" << sourceid << MSG::dec
4645 <<
" full fragment size " <<
size );
4647 while ( wc <
size ) {
4649 if ((*
p) == 0xff1234ff) b_sof=
true;
4651 ATH_MSG_DEBUG(
" start of sub-fragment word : " << MSG::hex << (*
p) << MSG::dec <<
" false/true : " << b_sof );
4655 sfrag_size = *(
p + 1);
4657 sfrag_version = *(
p + 2) & 0xFFFF;
4658 sfrag_type = *(
p + 2) >> 16;
4664 if (sfrag_type == 0x40) {
4665 ATH_MSG_DEBUG( MSG::hex <<
" DECODER sub-fragment VERSION=" << sfrag_version
4666 <<
" TYPE=" << sfrag_type << MSG::dec
4667 <<
" SIZE=" << sfrag_size
4668 <<
" FOUND! Keep on looking for 0x42.");
4672 }
else if (sfrag_type == 0x41) {
4673 ATH_MSG_DEBUG( MSG::hex <<
" DECODER sub-fragment VERSION=" << sfrag_version
4674 <<
" TYPE=" << sfrag_type << MSG::dec
4675 <<
" SIZE=" << sfrag_size
4676 <<
" FOUND! Keep on looking for 0x42.");
4680 }
else if (sfrag_type == 0x42) {
4682 ATH_MSG_DEBUG( MSG::hex <<
" DECODER sub-fragment VERSION=" << sfrag_version
4683 <<
" TYPE=" << sfrag_type << MSG::dec
4684 <<
" SIZE=" <<sfrag_size <<
" FOUND!");
4702 int ros = (collid >> 8);
4703 int drawer = collid & 0xff;
4706 int nmod = (
ros > 2) ? 8 : 4;
4707 int nchan = 4 * datasize / nmod / nsamp;
4709 int nsamp1 = nsamp - 1;
4711 std::vector<float> digits(nsamp);
4721 int wpos = (collid % nmod) *
nchan;
4722 int jump =
nchan * nmod;
4723 const unsigned char *
adc =
reinterpret_cast<const unsigned char *
>(
p);
4726 for (
int j = 0; j < nsamp; ++j) {
4727 digits[nsamp1 - j] =
adc[wpos + jump * j];
4736 msg(
MSG::DEBUG) <<
"TileROD_Decoder::unpack_frag40 frag: 0x" << MSG::hex << collid << MSG::dec
4740 const char * strchannel[13] = {
" d5L ",
" d5R ",
" d6L ",
" d6R ",
4741 " xxx ",
" d0x ",
" d1L ",
" d1R ",
" d2L ",
" d2R ",
" d3L ",
" d3R ",
" xxx " };
4742 int nchmax = (
ros > 2) ? 4 : 8;
4745 std::stringstream
ss;
4760 int ros=(collid>>8);
4763 float calFactorADC2MeV = 1.0;
4765 int nmod = (
ros>2)?8:4;
4766 int nchan = datasize / nmod;
4768 int wpos = (collid % nmod) *
nchan;
4781 const int32_t * pp =
reinterpret_cast<const int32_t *
>(
p);
4811 msg(
MSG::DEBUG) <<
" TileROD_Decoder::unpack_frag41 frag: 0x" << MSG::hex << collid << MSG::dec
4814 int nbits = (
version == 0) ? 32 : 16;
4815 msg(
MSG::DEBUG) <<
" position of " << nbits <<
"-bit word inside sub-fragment 0x41: " << wpos <<
endmsg;
4817 const char * strchannel[13] = {
" d5L ",
" d5R ",
" d6L ",
" d6R ",
4818 " xxx ",
" d0x ",
" d1L ",
" d1R ",
" d2L ",
" d2R ",
" d3L ",
" d3R ",
" xxx " };
4819 int nchmax = (
ros > 2) ? 4 : 8;
4871 int drawer = (sourceid & 0xf0000) >> 8;
4875 drawer |= ((sourceid & 0x0000f) << 2);
4876 word = (datasize > 0) ?
p[0] : 0;
4880 drawer |= ((sourceid & 0x0000f) << 3);
4883 word = (
p[1] << 20) | ((
p[0] >> 8) & 0xff000) | ((
p[0] >> 4) & 0xfff);
4885 word = ((
p[1] & 0xfff) << 12) | (
p[0] & 0xfff);
4887 bcid = ((
p[1] >> 4) & 0xf00) | ((
p[0] >> 24) & 0xf0) | ((
p[0] >> 12) & 0xf);
4894 std::vector<bool>
result(nbit);
4895 for (
int j = 0; j < nmod; ++j) {
4896 for (
int k = nbit-1;
k >= 0; --
k) {
4918 msg(
MSG::DEBUG) <<
" TileROD_Decoder::unpack_frag42 source ID: 0x" << MSG::hex << sourceid << MSG::dec
4921 for (
size_t j =
v.size() - nmod; j <
v.size(); ++j) {
4922 const std::vector<bool> &
r =
v[j]->GetDecision();
4923 std::stringstream
ss;
4924 for (
const bool val :
r) {
4925 ss << std::setw(2) <<
val;