38 {0x0ff,
"All RCT Calo Regions"},
40 {0x583,
"ConcJet: Jet Cands and Counts Output to GT"},
42 {0x683,
"ConcElec: EM Cands and Energy Sums Output to GT"},
44 {0x804,
"Leaf0ElecPosEtaU1: Raw Input"},
45 {0x884,
"Leaf0ElecPosEtaU2: Raw Input"},
46 {0xc04,
"Leaf0ElecNegEtaU1: Raw Input"},
47 {0xc84,
"Leaf0ElecNegEtaU2: Raw Input"}
98 uint32_t hdr = data[0] + (data[1]<<8) + (data[2]<<16) + (data[3]<<24);
110 uint32_t blockId = hdr & 0xfff;
111 uint32_t blockLength = 0;
112 uint32_t
nSamples = (hdr>>16) & 0xf;
113 uint32_t bxId = (hdr>>20) & 0xfff;
114 uint32_t eventId = (hdr>>12) & 0xf;
117 if(valid) { blockLength =
blockLengthMap().find(blockId)->second; }
119 return GctBlockHeader(blockId, blockLength, nSamples, bxId, eventId, valid);
126 if ( hdr.
nSamples() < 1 ) {
return true; }
160 unsigned&
offset = bx0EmCandOffsets.at(iCat);
161 if(!
findBx0OffsetInCollection(offset, cands)) {
LogDebug(
"GCT") <<
"No EM candidates with bx=0!\nAborting packing of GCT EM Cand and Energy Sum Output!";
return; }
162 if((cands->size()-
offset) < 4) {
LogDebug(
"GCT") <<
"Insufficient EM candidates with bx=0!\nAborting packing of GCT EM Cand and Energy Sum Output!";
return; }
165 unsigned bx0EtTotalOffset, bx0EtHadOffset, bx0EtMissOffset;
166 if(!
findBx0OffsetInCollection(bx0EtTotalOffset, etTotal)) {
LogDebug(
"GCT") <<
"No Et Total value for bx=0!\nAborting packing of GCT EM Cand and Energy Sum Output!";
return; }
167 if(!
findBx0OffsetInCollection(bx0EtHadOffset, etHad)) {
LogDebug(
"GCT") <<
"No Et Hadronic value for bx=0!\nAborting packing of GCT EM Cand and Energy Sum Output!";
return; }
168 if(!
findBx0OffsetInCollection(bx0EtMissOffset, etMiss)) {
LogDebug(
"GCT") <<
"No Et Miss value for bx=0!\nAborting packing of GCT EM Cand and Energy Sum Output!";
return; }
182 uint16_t * p16 =
reinterpret_cast<uint16_t *
>(
d);
187 const unsigned bx0Offset = bx0EmCandOffsets.at(iCat);
189 uint16_t * cand = p16 + (iCat*4);
191 *cand = em->at(bx0Offset).raw();
193 *cand = em->at(bx0Offset + 2).raw();
195 *cand = em->at(bx0Offset + 1).raw();
197 *cand = em->at(bx0Offset + 3).raw();
203 *p16 = etTotal->at(bx0EtTotalOffset).raw();
205 *p16 = etHad->at(bx0EtHadOffset).raw();
207 uint32_t * p32 =
reinterpret_cast<uint32_t *
>(p16);
208 *p32 = etMiss->at(bx0EtMissOffset).raw();
234 unsigned&
offset = bx0JetCandOffsets.at(iCat);
236 if((jetCands->size()-
offset) < 4) {
LogDebug(
"GCT") <<
"Insufficient jet candidates with bx=0!\nAborting packing of GCT Jet Output!";
return; }
240 unsigned bx0HfRingSumsOffset, bx0HfBitCountsOffset, bx0HtMissOffset;
242 if(!
findBx0OffsetInCollection(bx0HfBitCountsOffset, hfBitCounts)) {
LogDebug(
"GCT") <<
"No bit counts with bx=0!\nAborting packing of GCT Jet Output!";
return; }
252 uint16_t * p16 =
reinterpret_cast<uint16_t *
>(
d);
254 const unsigned categoryOffset = 4;
255 const unsigned nextCandPairOffset = 2;
261 const unsigned cand0Offset = iCat*categoryOffset;
262 const unsigned bx0Offset = bx0JetCandOffsets.at(iCat);
264 p16[cand0Offset] = jetCands->at(bx0Offset).raw();
265 p16[cand0Offset + nextCandPairOffset] = jetCands->at(bx0Offset + 1).raw();
266 p16[cand0Offset + 1] = jetCands->at(bx0Offset + 2).raw();
267 p16[cand0Offset + nextCandPairOffset + 1] = jetCands->at(bx0Offset + 3).raw();
274 uint32_t * p32 =
reinterpret_cast<uint32_t *
>(
d);
276 uint32_t
tmp = hfBitCounts->at(bx0HfBitCountsOffset).raw() & 0xfff;
277 tmp |= hfRingSums->at(bx0HfRingSumsOffset).etSum(0)<<12;
278 tmp |= hfRingSums->at(bx0HfRingSumsOffset).etSum(1)<<16;
279 tmp |= hfRingSums->at(bx0HfRingSumsOffset).etSum(2)<<19;
280 tmp |= hfRingSums->at(bx0HfRingSumsOffset).etSum(3)<<22;
283 const L1GctHtMiss& bx0HtMiss = htMiss->at(bx0HtMissOffset);
284 uint32_t htMissRaw = 0x5555c000 |
285 (bx0HtMiss.
overFlow() ? 0x1000 : 0x0000) |
286 ((bx0HtMiss.
et() & 0x7f) << 5) |
287 ((bx0HtMiss.
phi() & 0x1f));
296 if(rctEm->size() == 0 || rctEm->size()%144 != 0)
298 LogDebug(
"GCT") <<
"Block pack error: bad L1CaloEmCollection size detected!\n"
299 <<
"Aborting packing of RCT EM Cand data!";
307 for(
unsigned i=0,
size=rctEm->size();
i <
size ; ++
i)
310 if(cand.
bx() != 0) {
continue; }
311 unsigned crateNum = cand.
rctCrate();
337 for(
unsigned c = 0 ;
c < 18 ; ++
c)
340 emuToSfpData[
c].eNonIsoRank, emuToSfpData[
c].eNonIsoCardId, emuToSfpData[
c].eNonIsoRegionId,
341 emuToSfpData[
c].mipBits, emuToSfpData[
c].qBits, emuToSfpData[
c].sfp);
347 unsigned blockId = blockStartCrateIter->first;
348 unsigned startCrate = blockStartCrateIter->second;
351 unsigned blockLength_32bit =
found->second;
358 uint16_t * p16 =
reinterpret_cast<uint16_t *
>(
const_cast<unsigned char *
>(
d));
360 for(
unsigned iCrate=startCrate,
end=startCrate + blockLength_32bit/3 ; iCrate <
end ; ++iCrate)
362 for(
unsigned iOutput = 1 ; iOutput < 4 ; ++iOutput)
364 for(
unsigned iCycle = 0 ; iCycle < 2 ; ++iCycle)
366 *p16 = emuToSfpData[iCrate].
sfp[iCycle][iOutput];
373 d+=(blockLength_32bit*4);
381 if(rctCalo->size() == 0 || rctCalo->size()%396 != 0)
383 LogDebug(
"GCT") <<
"Block pack error: bad L1CaloRegionCollection size detected!\n"
384 <<
"Aborting packing of RCT Calo Region data!";
392 uint16_t * p16 =
reinterpret_cast<uint16_t *
>(
const_cast<unsigned char *
>(
d));
394 for(
unsigned i=0,
size=rctCalo->size();
i <
size ; ++
i)
397 if(reg.
bx() != 0) {
continue; }
398 const unsigned crateNum = reg.
rctCrate();
403 const uint16_t raw = reg.
et() |
406 (reg.
mip() ? 0x1000 : 0x0) |
407 (reg.
quiet() ? 0x2000 : 0x0);
412 const unsigned cardNum = reg.
rctCard();
417 offset = crateNum*22 + cardNum*2 + regionIndex;
422 offset = crateNum*22 + 14 + regionIndex;
434 const uint32_t eventId)
const
446 return ((bxId & 0xfff) << 20) | ((nSamples & 0xf) << 16) | ((eventId & 0xf) << 12) | (blockId & 0xfff);
455 const unsigned int id = hdr.
blockId();
460 const uint16_t * p16 =
reinterpret_cast<const uint16_t *
>(
d);
464 const unsigned int emCandCategoryOffset = nSamples * 4;
465 const unsigned int timeSampleOffset = nSamples * 2;
467 unsigned int samplesToUnpack = 1;
470 for (
unsigned int iso=0; iso<2; ++iso)
472 bool isoFlag = (iso==1);
479 for (
unsigned int bx=0; bx<samplesToUnpack; ++bx)
483 const unsigned int cand0Offset = iso*emCandCategoryOffset + bx*2;
485 em->push_back(
L1GctEmCand(p16[cand0Offset], isoFlag,
id, 0, bx));
486 em->push_back(
L1GctEmCand(p16[cand0Offset + timeSampleOffset], isoFlag,
id, 1, bx));
487 em->push_back(
L1GctEmCand(p16[cand0Offset + 1], isoFlag,
id, 2, bx));
488 em->push_back(
L1GctEmCand(p16[cand0Offset + timeSampleOffset + 1], isoFlag,
id, 3, bx));
492 p16 += emCandCategoryOffset * 2;
501 const uint32_t * p32 =
reinterpret_cast<const uint32_t *
>(p16);
508 const unsigned int id = hdr.
blockId();
513 const uint16_t * p16 =
reinterpret_cast<const uint16_t *
>(
d);
517 const unsigned int jetCandCategoryOffset = nSamples * 4;
518 const unsigned int timeSampleOffset = nSamples * 2;
520 unsigned int samplesToUnpack = 1;
533 for(
unsigned int bx = 0 ; bx < samplesToUnpack ; ++bx)
536 const unsigned int cand0Offset = iCat*jetCandCategoryOffset + bx*2;
539 jets->push_back(
L1GctJetCand(p16[cand0Offset], tauflag, forwardFlag,
id, 0, bx));
541 jets->push_back(
L1GctJetCand(p16[cand0Offset + timeSampleOffset], tauflag, forwardFlag,
id, 1, bx));
543 jets->push_back(
L1GctJetCand(p16[cand0Offset + 1], tauflag, forwardFlag,
id, 2, bx));
545 jets->push_back(
L1GctJetCand(p16[cand0Offset + timeSampleOffset + 1], tauflag, forwardFlag,
id, 3, bx));
549 p16 += NUM_JET_CATEGORIES * jetCandCategoryOffset;
555 const uint32_t * p32 =
reinterpret_cast<const uint32_t *
>(p16);
570 if(
hltMode()) {
LogDebug(
"GCT") <<
"HLT mode - skipping unpack of RCT EM Cands";
return; }
572 unsigned int id = hdr.
blockId();
577 uint16_t *
p =
reinterpret_cast<uint16_t *
>(
const_cast<unsigned char *
>(
d));
581 uint16_t eIsoRank[4];
582 uint16_t eIsoCard[4];
584 uint16_t eNonIsoRank[4];
585 uint16_t eNonIsoCard[4];
586 uint16_t eNonIsoRgn[4];
587 uint16_t MIPbits[7][2];
588 uint16_t QBits[7][2];
595 for (
unsigned int crate=
found->second; crate<found->
second+length/3; ++crate) {
598 for (
unsigned short iSfp=0 ; iSfp<4 ; ++iSfp) {
599 for (
unsigned short cyc=0 ; cyc<2 ; ++cyc) {
600 if (iSfp==0) { sfp[cyc][iSfp] = 0; }
606 p = p + 2*(nSamples-1);
610 srcCardRouting().
SFPtoEMU(eIsoRank, eIsoCard, eIsoRgn, eNonIsoRank, eNonIsoCard, eNonIsoRgn, MIPbits, QBits, sfp);
613 for (
unsigned short int i=0;
i<4; ++
i) {
616 for (
unsigned short int i=0;
i<4; ++
i) {
617 colls()->
rctEm()->push_back(
L1CaloEmCand( eNonIsoRank[
i], eNonIsoRgn[i], eNonIsoCard[i], crate,
false, i, bx) );
626 if(
hltMode()) {
LogDebug(
"GCT") <<
"HLT mode - skipping unpack of GCT Fibres";
return; }
628 unsigned int id = hdr.
blockId();
633 uint32_t *
p =
reinterpret_cast<uint32_t *
>(
const_cast<unsigned char *
>(
d));
635 for (
unsigned int i=0;
i<length; ++
i) {
636 for (
unsigned int bx=0; bx<
nSamples; ++bx) {
652 if(
hltMode()) {
LogDebug(
"GCT") <<
"HLT mode - skipping unpack of RCT Calo Regions";
return; }
660 const uint16_t * p16 =
reinterpret_cast<const uint16_t *
>(
d);
662 for(
unsigned iCrate = 0 ; iCrate < 18 ; ++iCrate)
665 for(
unsigned iCard = 0 ; iCard < 7 ; ++iCard)
668 for(int16_t iSample = 0 ; iSample <
nSamples ; ++iSample)
671 for(
unsigned iRegion = 0 ; iRegion < 2 ; ++iRegion)
680 for(
unsigned iRegionPairNum = 0 ; iRegionPairNum < 4 ; ++iRegionPairNum)
683 for(int16_t iSample = 0 ; iSample <
nSamples ; ++iSample)
686 for(
unsigned iPair = 0 ; iPair < 2 ; ++iPair)
698 template <
typename Collection>
701 bool foundBx0 =
false;
702 unsigned size = coll->size();
703 for(bx0Offset = 0 ; bx0Offset <
size ; ++bx0Offset)
705 if(coll->at(bx0Offset).bx() == 0) { foundBx0 =
true;
break; }
unsigned short eIsoCardId[4]
int16_t bx() const
get bunch-crossing index
L1GctHFBitCountsCollection *const gctHfBitCounts() const
GCT output: Hadronic-Forward bit-counts collection.
std::vector< L1CaloEmCand > L1CaloEmCollection
unsigned et() const
get Et
unsigned short eIsoRank[4]
L1GctEmCandCollection *const gctNonIsoEm() const
GCT output: Non-isolated EM candidate collection.
Global Calorimeter Trigger SC -> CC fibre data word.
bool overFlow() const
get overflow
L1CaloEmCollection *const rctEm() const
Input electrons from the RCT to the GCT.
std::vector< L1GctEtMiss > L1GctEtMissCollection
unsigned rctCrate() const
get RCT crate ID
L1GctHtMissCollection *const gctHtMiss() const
GCT output: Missing Ht collection.
std::vector< L1GctHFRingEtSums > L1GctHFRingEtSumsCollection
unsigned rctCard() const
get RCT reciever card ID (valid output for HB/HE)
void SFPtoEMU(unsigned short(&eIsoRank)[4], unsigned short(&eIsoCardId)[4], unsigned short(&eIsoRegionId)[4], unsigned short(&eNonIsoRank)[4], unsigned short(&eNonIsoCardId)[4], unsigned short(&eNonIsoRegionId)[4], unsigned short(&MIPbits)[7][2], unsigned short(&Qbits)[7][2], unsigned short(&SFP)[2][4]) const
Struct of all data needed for running the emulator to SFP (sourcecard optical output) conversion...
std::vector< L1GctEtHad > L1GctEtHadCollection
Level-1 Trigger jet candidate.
Level-1 Region Calorimeter Trigger EM candidate.
Persistable copy of missing Et measured at Level-1.
unsigned rctRegionIndex() const
get RCT region index
Level-1 Trigger EM candidate at output of GCT.
std::vector< L1GctEtTotal > L1GctEtTotalCollection
bool quiet() const
get quiet bit
void EMUtoSFP(unsigned short(&eIsoRank)[4], unsigned short(&eIsoCardId)[4], unsigned short(&eIsoRegionId)[4], unsigned short(&eNonIsoRank)[4], unsigned short(&eNonIsoCardId)[4], unsigned short(&eNonIsoRegionId)[4], unsigned short(&MIPbits)[7][2], unsigned short(&Qbits)[7][2], unsigned short(&SFP)[2][4]) const
std::vector< L1GctHFBitCounts > L1GctHFBitCountsCollection
U second(std::pair< T, U > const &p)
std::vector< L1GctJetCand > L1GctJetCandCollection
L1GctEtTotalCollection *const gctEtTot() const
GCT output: Total Et collection.
bool overFlow() const
get the overflow
Persistable copy of total Et measured at Level-1.
unsigned rctCrate() const
get RCT crate
bool isolated() const
which stream did this come from
int16_t bx() const
get bunch-crossing index
bool mip() const
get MIP bit
unsigned rank() const
get rank bits
unsigned rctCard() const
get RCT receiver card
unsigned et() const
get the magnitude
L1GctEtMissCollection *const gctEtMiss() const
GCT output: Missing Et collection.
constexpr size_t nSamples
tuple unpackSharedRegions
Persistable copy of total Ht measured at Level-1.
static L1GctHFRingEtSums fromConcRingSums(const uint16_t capBlock, const uint16_t capIndex, const int16_t bx, const uint32_t data)
unsigned short eNonIsoRank[4]
unsigned short eIsoRegionId[4]
std::vector< L1GctHtMiss > L1GctHtMissCollection
L1GctHFRingEtSumsCollection *const gctHfRingEtSums() const
GCT output: Hadronic-Forward ring-sums collection.
Persistable copy of missing Et measured at Level-1.
unsigned short eNonIsoCardId[4]
bool fineGrain() const
get fine grain bit
unsigned index() const
get index on cable
std::vector< std::vector< double > > tmp
L1GctFibreCollection *const gctFibres() const
Raw fibre input to the GCT.
L1GctEmCandCollection *const gctIsoEm() const
GCT output: Isolated EM candidate collection.
unsigned rctRegion() const
get RCT region ID
char data[epos_bytes_allocation]
L1GctEtHadCollection *const gctEtHad() const
GCT output: Hadronic transverse-energy (Ht) collection.
A calorimeter trigger region (sum of 4x4 trigger towers)
static L1GctHFBitCounts fromConcHFBitCounts(const uint16_t capBlock, const uint16_t capIndex, const int16_t bx, const uint32_t data)
std::vector< L1CaloRegion > L1CaloRegionCollection
unsigned short eNonIsoRegionId[4]
tuple size
Write out results.
unsigned phi() const
get the Et
L1CaloRegionCollection *const rctCalo() const
Input calo regions from the RCT to the GCT.
std::vector< L1GctEmCand > L1GctEmCandCollection