CMS 3D CMS Logo

CaloTowerUnpacker.cc
Go to the documentation of this file.
3 
5 
6 #include "CaloCollections.h"
7 #include "CaloTowerUnpacker.h"
9 
10 namespace l1t {
11  namespace stage2 {
13  // check this is the correct MP
14  unsigned int tmt = block.amc().getBoardID() - l1t::stage2::layer2::mp::offsetBoardId + 1;
15  unsigned int bxid = block.amc().getBX();
16 
17  LogDebug("L1T") << "Unpacking TMT # " << tmt << " for BX " << bxid;
18 
19  // Link number is block_ID / 2
20  unsigned link = block.header().getID() / 2;
21 
22  // Also need link number rounded down to even number
23  unsigned link_phi = (link % 2 == 0) ? link : (link - 1);
24 
25  // number of frames used in a few different places
26  unsigned nframes = 40;
27 
28  int nBX = int(ceil(
29  block.header().getSize() /
30  nframes)); // Since there are two Rx links per block with 2*28 slices in barrel and endcap + 2*13 for upgraded HF
31 
32  // Find the first and last BXs
33  int firstBX = -(std::ceil((double)nBX / 2.) - 1);
34  int lastBX;
35  if (nBX % 2 == 0) {
36  lastBX = std::ceil((double)nBX / 2.);
37  } else {
38  lastBX = std::ceil((double)nBX / 2.) - 1;
39  }
40 
41  auto res_ = static_cast<CaloCollections*>(coll)->getTowers();
42  res_->setBXRange(std::min(firstBX, res_->getFirstBX()), std::max(lastBX, res_->getLastBX()));
43 
44  LogDebug("L1T") << "Block : id=" << block.header().getID() << ", size=" << block.header().getSize()
45  << ", link=" << link << ", link_phi=" << link_phi << ", nBX=" << nBX << ", firstBX=" << firstBX
46  << ", lastBX=" << lastBX;
47 
48  // Loop over multiple BX and fill towers collection
49  for (int bx = firstBX; bx <= lastBX; bx++) {
50  for (unsigned iframe = 0; iframe < nframes && iframe < block.header().getSize(); ++iframe) {
51  uint32_t raw_data = block.payload().at(iframe);
52 
53  if ((raw_data & 0xFFFF) != 0) {
54  l1t::CaloTower tower1 = l1t::CaloTower();
55 
56  // First calo tower is in the LSW with phi
57  tower1.setHwPt(raw_data & 0x1FF);
58  tower1.setHwQual((raw_data >> 12) & 0xF);
59  tower1.setHwEtRatio((raw_data >> 9) & 0x7);
60  tower1.setHwPhi(link_phi + 1); // iPhi starts at 1
61 
62  int ieta = iframe + 1;
63  if (link % 2 != 0)
64  ieta = ieta * -1;
65 
67 
68  LogDebug("L1T") << "Tower 1: Eta " << tower1.hwEta() << " phi " << tower1.hwPhi() << " pT " << tower1.hwPt()
69  << " frame " << iframe << " qual " << tower1.hwQual() << " EtRatio " << tower1.hwEtRatio();
70 
71  res_->push_back(bx, tower1);
72  }
73 
74  if (((raw_data >> 16) & 0xFFFF) != 0) {
75  // Second calo tower is in the MSW with phi+1
76  l1t::CaloTower tower2 = l1t::CaloTower();
77 
78  tower2.setHwPt((raw_data >> 16) & 0x1FF);
79  tower2.setHwQual((raw_data >> 28) & 0xF);
80  tower2.setHwEtRatio((raw_data >> 25) & 0x7);
81  tower2.setHwPhi(link_phi + 2);
82 
83  int ieta = iframe + 1;
84  if (link % 2 != 0)
85  ieta = ieta * -1;
87 
88  LogDebug("L1T") << "Tower 2: Eta " << tower2.hwEta() << " phi " << tower2.hwPhi() << " pT " << tower2.hwPt()
89  << " frame " << iframe << " qual " << tower2.hwQual() << " EtRatio " << tower2.hwEtRatio();
90 
91  res_->push_back(bx, tower2);
92  }
93  }
94  }
95 
96  return true;
97  }
98  } // namespace stage2
99 } // namespace l1t
100 
l1t::CaloTools::caloEta
static int caloEta(int ietaMP)
Definition: CaloTools.cc:234
CaloTools.h
l1t::L1Candidate::hwPhi
int hwPhi() const
Definition: L1Candidate.h:37
MessageLogger.h
MainPageGenerator.link
link
Definition: MainPageGenerator.py:271
L1TStage2Layer2Constants.h
min
T min(T a, T b)
Definition: MathUtil.h:58
l1GtPatternGenerator_cfi.bx
bx
Definition: l1GtPatternGenerator_cfi.py:18
l1t::L1Candidate::hwQual
int hwQual() const
Definition: L1Candidate.h:38
l1t::stage2::CaloTowerUnpacker
Definition: CaloTowerUnpacker.h:8
l1t::CaloTower::setHwEtRatio
void setHwEtRatio(int ratio)
Definition: CaloTower.cc:31
RPCBxOrConfig_cff.firstBX
firstBX
Definition: RPCBxOrConfig_cff.py:5
l1t::CaloTower
Definition: CaloTower.h:12
l1t::L1Candidate::hwEta
int hwEta() const
Definition: L1Candidate.h:36
reco::ceil
constexpr int32_t ceil(float num)
Definition: constexpr_cmath.h:7
l1t::L1Candidate::setHwQual
void setHwQual(int qual)
Definition: L1Candidate.h:31
UnpackerFactory.h
l1t::stage2::CaloTowerUnpacker::unpack
bool unpack(const Block &block, UnpackerCollections *coll) override
Definition: CaloTowerUnpacker.cc:12
LEDCalibrationChannels.ieta
ieta
Definition: LEDCalibrationChannels.py:63
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
l1t
delete x;
Definition: CaloConfig.h:22
l1t::CaloTower::hwEtRatio
int hwEtRatio() const
Definition: CaloTower.cc:41
createfilelist.int
int
Definition: createfilelist.py:10
l1t::L1Candidate::setHwPt
void setHwPt(int pt)
Definition: L1Candidate.h:28
groupFilesInBlocks.block
block
Definition: groupFilesInBlocks.py:150
l1t::L1Candidate::setHwEta
void setHwEta(int eta)
Definition: L1Candidate.h:29
SiStripSourceConfigTier0_cff.stage2
stage2
Definition: SiStripSourceConfigTier0_cff.py:71
l1t::UnpackerCollections
Definition: UnpackerCollections.h:9
l1t::L1Candidate::hwPt
int hwPt() const
Definition: L1Candidate.h:35
RPCBxOrConfig_cff.lastBX
lastBX
Definition: RPCBxOrConfig_cff.py:4
DEFINE_L1T_UNPACKER
#define DEFINE_L1T_UNPACKER(type)
Definition: UnpackerFactory.h:23
l1t::L1Candidate::setHwPhi
void setHwPhi(int phi)
Definition: L1Candidate.h:30
l1t::stage2::layer2::mp::offsetBoardId
const unsigned int offsetBoardId
Definition: L1TStage2Layer2Constants.cc:6
CaloCollections.h
CaloTowerUnpacker.h
l1t::Block
Definition: Block.h:70