31 static bool initClass =
true;
55 m_blockName.insert(make_pair(0x0ff,
"All RCT Calo Regions"));
57 m_blockName.insert(make_pair(0x583,
"ConcJet: Jet Cands and Counts Output to GT"));
59 m_blockName.insert(make_pair(0x683,
"ConcElec: EM Cands and Energy Sums Output to GT"));
61 m_blockName.insert(make_pair(0x804,
"Leaf0ElecPosEtaU1: Raw Input"));
62 m_blockName.insert(make_pair(0x884,
"Leaf0ElecPosEtaU2: Raw Input"));
63 m_blockName.insert(make_pair(0xc04,
"Leaf0ElecNegEtaU1: Raw Input"));
64 m_blockName.insert(make_pair(0xc84,
"Leaf0ElecNegEtaU2: Raw Input"));
105 uint32_t hdr = data[0] + (data[1]<<8) + (data[2]<<16) + (data[3]<<24);
117 uint32_t blockId = hdr & 0xfff;
118 uint32_t blockLength = 0;
119 uint32_t nSamples = (hdr>>16) & 0xf;
120 uint32_t bxId = (hdr>>20) & 0xfff;
121 uint32_t eventId = (hdr>>12) & 0xf;
124 if(valid) { blockLength =
blockLengthMap().find(blockId)->second; }
126 return GctBlockHeader(blockId, blockLength, nSamples, bxId, eventId, valid);
133 if ( hdr.
nSamples() < 1 ) {
return true; }
167 unsigned&
offset = bx0EmCandOffsets.at(iCat);
168 if(!
findBx0OffsetInCollection(offset, cands)) {
LogDebug(
"GCT") <<
"No EM candidates with bx=0!\nAborting packing of GCT EM Cand and Energy Sum Output!";
return; }
169 if((cands->size()-
offset) < 4) {
LogDebug(
"GCT") <<
"Insufficient EM candidates with bx=0!\nAborting packing of GCT EM Cand and Energy Sum Output!";
return; }
172 unsigned bx0EtTotalOffset, bx0EtHadOffset, bx0EtMissOffset;
173 if(!
findBx0OffsetInCollection(bx0EtTotalOffset, etTotal)) {
LogDebug(
"GCT") <<
"No Et Total value for bx=0!\nAborting packing of GCT EM Cand and Energy Sum Output!";
return; }
174 if(!
findBx0OffsetInCollection(bx0EtHadOffset, etHad)) {
LogDebug(
"GCT") <<
"No Et Hadronic value for bx=0!\nAborting packing of GCT EM Cand and Energy Sum Output!";
return; }
175 if(!
findBx0OffsetInCollection(bx0EtMissOffset, etMiss)) {
LogDebug(
"GCT") <<
"No Et Miss value for bx=0!\nAborting packing of GCT EM Cand and Energy Sum Output!";
return; }
179 unsigned nSamples = 1;
189 uint16_t * p16 =
reinterpret_cast<uint16_t *
>(d);
194 const unsigned bx0Offset = bx0EmCandOffsets.at(iCat);
196 uint16_t * cand = p16 + (iCat*4);
198 *cand = em->at(bx0Offset).raw();
200 *cand = em->at(bx0Offset + 2).raw();
202 *cand = em->at(bx0Offset + 1).raw();
204 *cand = em->at(bx0Offset + 3).raw();
210 *p16 = etTotal->at(bx0EtTotalOffset).raw();
212 *p16 = etHad->at(bx0EtHadOffset).raw();
214 uint32_t * p32 =
reinterpret_cast<uint32_t *
>(p16);
215 *p32 = etMiss->at(bx0EtMissOffset).raw();
241 unsigned&
offset = bx0JetCandOffsets.at(iCat);
243 if((jetCands->size()-
offset) < 4) {
LogDebug(
"GCT") <<
"Insufficient jet candidates with bx=0!\nAborting packing of GCT Jet Output!";
return; }
247 unsigned bx0HfRingSumsOffset, bx0HfBitCountsOffset, bx0HtMissOffset;
249 if(!
findBx0OffsetInCollection(bx0HfBitCountsOffset, hfBitCounts)) {
LogDebug(
"GCT") <<
"No bit counts with bx=0!\nAborting packing of GCT Jet Output!";
return; }
259 uint16_t * p16 =
reinterpret_cast<uint16_t *
>(d);
261 const unsigned categoryOffset = 4;
262 const unsigned nextCandPairOffset = 2;
268 const unsigned cand0Offset = iCat*categoryOffset;
269 const unsigned bx0Offset = bx0JetCandOffsets.at(iCat);
271 p16[cand0Offset] = jetCands->at(bx0Offset).raw();
272 p16[cand0Offset + nextCandPairOffset] = jetCands->at(bx0Offset + 1).raw();
273 p16[cand0Offset + 1] = jetCands->at(bx0Offset + 2).raw();
274 p16[cand0Offset + nextCandPairOffset + 1] = jetCands->at(bx0Offset + 3).raw();
281 uint32_t * p32 =
reinterpret_cast<uint32_t *
>(d);
283 uint32_t
tmp = hfBitCounts->at(bx0HfBitCountsOffset).raw() & 0xfff;
284 tmp |= hfRingSums->at(bx0HfRingSumsOffset).etSum(0)<<12;
285 tmp |= hfRingSums->at(bx0HfRingSumsOffset).etSum(1)<<16;
286 tmp |= hfRingSums->at(bx0HfRingSumsOffset).etSum(2)<<19;
287 tmp |= hfRingSums->at(bx0HfRingSumsOffset).etSum(3)<<22;
290 const L1GctHtMiss& bx0HtMiss = htMiss->at(bx0HtMissOffset);
291 uint32_t htMissRaw = 0x5555c000 |
292 (bx0HtMiss.
overFlow() ? 0x1000 : 0x0000) |
293 ((bx0HtMiss.
et() & 0x7f) << 5) |
294 ((bx0HtMiss.
phi() & 0x1f));
303 if(rctEm->size() == 0 || rctEm->size()%144 != 0)
305 LogDebug(
"GCT") <<
"Block pack error: bad L1CaloEmCollection size detected!\n"
306 <<
"Aborting packing of RCT EM Cand data!";
314 for(
unsigned i=0,
size=rctEm->size();
i <
size ; ++
i)
317 if(cand.
bx() != 0) {
continue; }
318 unsigned crateNum = cand.
rctCrate();
322 assert(crateNum < 18);
344 for(
unsigned c = 0 ;
c < 18 ; ++
c)
347 emuToSfpData[
c].eNonIsoRank, emuToSfpData[
c].eNonIsoCardId, emuToSfpData[
c].eNonIsoRegionId,
348 emuToSfpData[
c].mipBits, emuToSfpData[
c].qBits, emuToSfpData[
c].sfp);
352 BlkToRctCrateMap::iterator blockStartCrateIter;
355 unsigned blockId = blockStartCrateIter->first;
356 unsigned startCrate = blockStartCrateIter->second;
363 uint16_t * p16 =
reinterpret_cast<uint16_t *
>(
const_cast<unsigned char *
>(d));
365 for(
unsigned iCrate=startCrate,
end=startCrate + blockLength_32bit/3 ; iCrate <
end ; ++iCrate)
367 for(
unsigned iOutput = 1 ; iOutput < 4 ; ++iOutput)
369 for(
unsigned iCycle = 0 ; iCycle < 2 ; ++iCycle)
371 *p16 = emuToSfpData[iCrate].
sfp[iCycle][iOutput];
378 d+=(blockLength_32bit*4);
386 if(rctCalo->size() == 0 || rctCalo->size()%396 != 0)
388 LogDebug(
"GCT") <<
"Block pack error: bad L1CaloRegionCollection size detected!\n"
389 <<
"Aborting packing of RCT Calo Region data!";
397 uint16_t * p16 =
reinterpret_cast<uint16_t *
>(
const_cast<unsigned char *
>(d));
399 for(
unsigned i=0,
size=rctCalo->size();
i <
size ; ++
i)
402 if(reg.
bx() != 0) {
continue; }
403 const unsigned crateNum = reg.
rctCrate();
405 assert(crateNum < 18);
408 const uint16_t raw = reg.
et() |
411 (reg.
mip() ? 0x1000 : 0x0) |
412 (reg.
quiet() ? 0x2000 : 0x0);
417 const unsigned cardNum = reg.
rctCard();
419 assert(regionIndex < 2);
422 offset = crateNum*22 + cardNum*2 + regionIndex;
426 assert(regionIndex < 8);
427 offset = crateNum*22 + 14 + regionIndex;
437 const uint32_t nSamples,
439 const uint32_t eventId)
const
451 return ((bxId & 0xfff) << 20) | ((nSamples & 0xf) << 16) | ((eventId & 0xf) << 12) | (blockId & 0xfff);
460 const unsigned int id = hdr.
blockId();
461 const unsigned int nSamples = hdr.
nSamples();
465 const uint16_t * p16 =
reinterpret_cast<const uint16_t *
>(d);
469 const unsigned int emCandCategoryOffset = nSamples * 4;
470 const unsigned int timeSampleOffset = nSamples * 2;
472 unsigned int samplesToUnpack = 1;
473 if(!
hltMode()) { samplesToUnpack = nSamples; }
475 for (
unsigned int iso=0; iso<2; ++iso)
477 bool isoFlag = (iso==1);
484 for (
unsigned int bx=0; bx<samplesToUnpack; ++bx)
488 const unsigned int cand0Offset = iso*emCandCategoryOffset + bx*2;
490 em->push_back(
L1GctEmCand(p16[cand0Offset], isoFlag,
id, 0, bx));
491 em->push_back(
L1GctEmCand(p16[cand0Offset + timeSampleOffset], isoFlag,
id, 1, bx));
492 em->push_back(
L1GctEmCand(p16[cand0Offset + 1], isoFlag,
id, 2, bx));
493 em->push_back(
L1GctEmCand(p16[cand0Offset + timeSampleOffset + 1], isoFlag,
id, 3, bx));
497 p16 += emCandCategoryOffset * 2;
506 const uint32_t * p32 =
reinterpret_cast<const uint32_t *
>(p16);
513 const unsigned int id = hdr.
blockId();
514 const unsigned int nSamples = hdr.
nSamples();
518 const uint16_t * p16 =
reinterpret_cast<const uint16_t *
>(d);
522 const unsigned int jetCandCategoryOffset = nSamples * 4;
523 const unsigned int timeSampleOffset = nSamples * 2;
525 unsigned int samplesToUnpack = 1;
526 if(!
hltMode()) { samplesToUnpack = nSamples; }
532 assert(jets->empty());
538 for(
unsigned int bx = 0 ; bx < samplesToUnpack ; ++bx)
541 const unsigned int cand0Offset = iCat*jetCandCategoryOffset + bx*2;
544 jets->push_back(
L1GctJetCand(p16[cand0Offset], tauflag, forwardFlag,
id, 0, bx));
546 jets->push_back(
L1GctJetCand(p16[cand0Offset + timeSampleOffset], tauflag, forwardFlag,
id, 1, bx));
548 jets->push_back(
L1GctJetCand(p16[cand0Offset + 1], tauflag, forwardFlag,
id, 2, bx));
550 jets->push_back(
L1GctJetCand(p16[cand0Offset + timeSampleOffset + 1], tauflag, forwardFlag,
id, 3, bx));
554 p16 += NUM_JET_CATEGORIES * jetCandCategoryOffset;
560 const uint32_t * p32 =
reinterpret_cast<const uint32_t *
>(p16);
575 if(
hltMode()) {
LogDebug(
"GCT") <<
"HLT mode - skipping unpack of RCT EM Cands";
return; }
577 unsigned int id = hdr.
blockId();
578 unsigned int nSamples = hdr.
nSamples();
582 uint16_t *
p =
reinterpret_cast<uint16_t *
>(
const_cast<unsigned char *
>(d));
586 uint16_t eIsoRank[4];
587 uint16_t eIsoCard[4];
589 uint16_t eNonIsoRank[4];
590 uint16_t eNonIsoCard[4];
591 uint16_t eNonIsoRgn[4];
592 uint16_t MIPbits[7][2];
593 uint16_t QBits[7][2];
601 for (
unsigned short iSfp=0 ; iSfp<4 ; ++iSfp) {
602 for (
unsigned short cyc=0 ; cyc<2 ; ++cyc) {
603 if (iSfp==0) { sfp[cyc][iSfp] = 0; }
609 p = p + 2*(nSamples-1);
613 srcCardRouting().
SFPtoEMU(eIsoRank, eIsoCard, eIsoRgn, eNonIsoRank, eNonIsoCard, eNonIsoRgn, MIPbits, QBits, sfp);
616 for (
unsigned short int i=0;
i<4; ++
i) {
619 for (
unsigned short int i=0;
i<4; ++
i) {
620 colls()->
rctEm()->push_back(
L1CaloEmCand( eNonIsoRank[
i], eNonIsoRgn[i], eNonIsoCard[i], crate,
false, i, bx) );
629 if(
hltMode()) {
LogDebug(
"GCT") <<
"HLT mode - skipping unpack of GCT Fibres";
return; }
631 unsigned int id = hdr.
blockId();
632 unsigned int nSamples = hdr.
nSamples();
636 uint32_t *
p =
reinterpret_cast<uint32_t *
>(
const_cast<unsigned char *
>(d));
638 for (
unsigned int i=0;
i<length; ++
i) {
639 for (
unsigned int bx=0; bx<nSamples; ++bx) {
655 if(
hltMode()) {
LogDebug(
"GCT") <<
"HLT mode - skipping unpack of RCT Calo Regions";
return; }
660 const int nSamples = hdr.
nSamples();
663 const uint16_t * p16 =
reinterpret_cast<const uint16_t *
>(d);
665 for(
unsigned iCrate = 0 ; iCrate < 18 ; ++iCrate)
668 for(
unsigned iCard = 0 ; iCard < 7 ; ++iCard)
671 for(int16_t iSample = 0 ; iSample < nSamples ; ++iSample)
674 for(
unsigned iRegion = 0 ; iRegion < 2 ; ++iRegion)
683 for(
unsigned iRegionPairNum = 0 ; iRegionPairNum < 4 ; ++iRegionPairNum)
686 for(int16_t iSample = 0 ; iSample < nSamples ; ++iSample)
689 for(
unsigned iPair = 0 ; iPair < 2 ; ++iPair)
701 template <
typename Collection>
704 bool foundBx0 =
false;
705 unsigned size = coll->size();
706 for(bx0Offset = 0 ; bx0Offset <
size ; ++bx0Offset)
708 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.
unsigned int offset(bool)
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