CMS 3D CMS Logo

CaloLayer1Unpacker.cc
Go to the documentation of this file.
3 
4 #include "CaloLayer1Unpacker.h"
5 
6 using namespace edm;
7 
8 namespace l1t {
9  namespace stage2 {
10 
11  // max_iEta_HcalTP = 41; // barrel <= 16, endcap <= 29, hf <= 41
12  // there are two TT29’s: one in HE readout in TT28 and another in HF readout in TT30
13  // max_iPhi_HcalTP = 72;
14 
16  LogDebug("L1T") << "Block size = " << block.header().getSize();
17  LogDebug("L1T") << "Board ID = " << block.amc().getBoardID();
18 
19  auto res = static_cast<CaloLayer1Collections*>(coll);
20 
21  auto ctp7_phi = block.amc().getBoardID();
22  const uint32_t* ptr = block.payload().data();
23 
24  int N_BX = (block.header().getFlags() >> 16) & 0xf;
25  // std::cout << " N_BX calculated " << N_BX << std::endl;
26 
27  if (N_BX == 1) {
28  UCTCTP7RawData ctp7Data(ptr);
29  makeECalTPGs(ctp7_phi, ctp7Data, res->getEcalDigis());
30  makeHCalTPGs(ctp7_phi, ctp7Data, res->getHcalDigis());
31  makeHFTPGs(ctp7_phi, ctp7Data, res->getHcalDigis());
32  makeRegions(ctp7_phi, ctp7Data, res->getRegions());
33  } else if (N_BX == 5) {
34  const uint32_t* ptr5 = ptr;
35  UCTCTP7RawData ctp7Data(ptr);
36  makeECalTPGs(ctp7_phi, ctp7Data, res->getEcalDigis());
37  makeHCalTPGs(ctp7_phi, ctp7Data, res->getHcalDigis());
38  makeHFTPGs(ctp7_phi, ctp7Data, res->getHcalDigis());
39  makeRegions(ctp7_phi, ctp7Data, res->getRegions());
40  for (int i = 0; i < 5; i++) {
41  UCTCTP7RawData ctp7Data(ptr5);
42  makeECalTPGs(ctp7_phi, ctp7Data, res->getEcalDigisBx(i));
43  ptr5 += 192;
44  }
45  } else {
46  LogError("CaloLayer1Unpacker") << "Number of BXs to unpack is not 1 or 5, stop here !!! " << N_BX << std::endl;
47  return false;
48  }
49 
50  return true;
51  }
52 
53  void CaloLayer1Unpacker::makeECalTPGs(uint32_t lPhi,
54  UCTCTP7RawData& ctp7Data,
55  EcalTrigPrimDigiCollection* ecalTPGs) {
57  for (uint32_t iPhi = 0; iPhi < 4; iPhi++) { // Loop over all four phi divisions on card
58  int cPhi = -1 + lPhi * 4 + iPhi; // Calorimeter phi index
59  if (cPhi == 0)
60  cPhi = 72;
61  else if (cPhi == -1)
62  cPhi = 71;
63  else if (cPhi < -1) {
64  LogError("CaloLayer1Unpacker") << "Major error in makeECalTPGs" << std::endl;
65  return;
66  }
67  for (int cEta = -28; cEta <= 28; cEta++) { // Calorimeter Eta indices (HB/HE for now)
68  if (cEta != 0) { // Calorimeter eta = 0 is invalid
69  bool negativeEta = false;
70  if (cEta < 0)
71  negativeEta = true;
72  uint32_t iEta = abs(cEta);
73  // This code is fragile! Note that towerDatum is packed as is done in EcalTriggerPrimitiveSample
74  // Bottom 8-bits are ET
75  // Then finegrain feature bit
76  // Then three bits have ttBits, which I have no clue about (not available on ECAL links so not set)
77  // Then there is a spare FG Veto bit, which is used for L1 spike detection (not available on ECAL links so not set)
78  // Top three bits seem to be unused. So, we steal those to set the tower masking, link masking and link status information
79  // To decode these custom three bits use ((EcalTriggerPrimitiveSample::raw() >> 13) & 0x7)
80  uint32_t towerDatum = ctp7Data.getET(cType, negativeEta, iEta, iPhi);
81  if (ctp7Data.getFB(cType, negativeEta, iEta, iPhi) != 0)
82  towerDatum |= 0x0100;
83  if (ctp7Data.isTowerMasked(cType, negativeEta, iEta, iPhi))
84  towerDatum |= 0x2000;
85  if (ctp7Data.isLinkMasked(cType, negativeEta, iEta, iPhi))
86  towerDatum |= 0x4000;
87  if (ctp7Data.isLinkMisaligned(cType, negativeEta, iEta, iPhi) ||
88  ctp7Data.isLinkInError(cType, negativeEta, iEta, iPhi) ||
89  ctp7Data.isLinkDown(cType, negativeEta, iEta, iPhi))
90  towerDatum |= 0x8000;
92  int zSide = cEta / ((int)iEta);
93  // As far as I can tell, the ECal unpacker only uses barrel and endcap IDs, never EcalTriggerTower
94  const EcalSubdetector ecalTriggerTower =
96  EcalTrigTowerDetId id(zSide, ecalTriggerTower, iEta, cPhi);
98  tpg.setSize(1);
99  tpg.setSample(0, sample);
100  ecalTPGs->push_back(tpg);
101  }
102  }
103  }
104  }
105 
106  void CaloLayer1Unpacker::makeHCalTPGs(uint32_t lPhi,
107  UCTCTP7RawData& ctp7Data,
108  HcalTrigPrimDigiCollection* hcalTPGs) {
110  for (uint32_t iPhi = 0; iPhi < 4; iPhi++) { // Loop over all four phi divisions on card
111  int cPhi = -1 + lPhi * 4 + iPhi; // Calorimeter phi index
112  if (cPhi == 0)
113  cPhi = 72;
114  else if (cPhi == -1)
115  cPhi = 71;
116  else if (cPhi < -1) {
117  LogError("CaloLayer1Unpacker") << "Major error in makeHCalTPGs" << std::endl;
118  return;
119  }
120  for (int cEta = -28; cEta <= 28; cEta++) { // Calorimeter Eta indices (HB/HE for now)
121  if (cEta != 0) { // Calorimeter eta = 0 is invalid
122  bool negativeEta = false;
123  if (cEta < 0)
124  negativeEta = true;
125  uint32_t iEta = abs(cEta);
126  // This code is fragile! Note that towerDatum is packed as is done in HcalTriggerPrimitiveSample
127  // Bottom 8-bits are ET
128  // Then feature bit
129  // The remaining bits are undefined presently
130  // We use next three bits for link details, which we did not have room in EcalTriggerPrimitiveSample case
131  // We use next three bits to set the tower masking, link masking and link status information as done for Ecal
132  // To decode these custom six bits use ((EcalTriggerPrimitiveSample::raw() >> 9) & 0x77)
133  uint32_t towerDatum = ctp7Data.getET(cType, negativeEta, iEta, iPhi);
134  if (ctp7Data.getFB(cType, negativeEta, iEta, iPhi) != 0)
135  towerDatum |= 0x0100;
136  if (ctp7Data.isLinkMisaligned(cType, negativeEta, iEta, iPhi))
137  towerDatum |= 0x0200;
138  if (ctp7Data.isLinkInError(cType, negativeEta, iEta, iPhi))
139  towerDatum |= 0x0400;
140  if (ctp7Data.isLinkDown(cType, negativeEta, iEta, iPhi))
141  towerDatum |= 0x0800;
142  if (ctp7Data.isTowerMasked(cType, negativeEta, iEta, iPhi))
143  towerDatum |= 0x2000;
144  if (ctp7Data.isLinkMasked(cType, negativeEta, iEta, iPhi))
145  towerDatum |= 0x4000;
146  if (ctp7Data.isLinkMisaligned(cType, negativeEta, iEta, iPhi) ||
147  ctp7Data.isLinkInError(cType, negativeEta, iEta, iPhi) ||
148  ctp7Data.isLinkDown(cType, negativeEta, iEta, iPhi))
149  towerDatum |= 0x8000;
151  HcalTrigTowerDetId id(cEta, cPhi);
152  HcalTriggerPrimitiveDigi tpg(id);
153  tpg.setSize(1);
154  tpg.setSample(0, sample);
155  hcalTPGs->push_back(tpg);
156  }
157  }
158  }
159  }
160 
161  void CaloLayer1Unpacker::makeHFTPGs(uint32_t lPhi, UCTCTP7RawData& ctp7Data, HcalTrigPrimDigiCollection* hcalTPGs) {
163  for (uint32_t side = 0; side <= 1; side++) {
164  bool negativeEta = false;
165  if (side == 0)
166  negativeEta = true;
167  for (uint32_t iEta = 30; iEta <= 40; iEta++) {
168  for (uint32_t iPhi = 0; iPhi < 2; iPhi++) {
169  if (iPhi == 1 && iEta == 40)
170  iEta = 41;
171  int cPhi = 1 + lPhi * 4 + iPhi * 2; // Calorimeter phi index: 1, 3, 5, ... 71
172  if (iEta == 41)
173  cPhi -= 2; // Last two HF are 3, 7, 11, ...
174  cPhi = (cPhi + 69) % 72 + 1; // cPhi -= 2 mod 72
175  int cEta = iEta;
176  if (negativeEta)
177  cEta = -iEta;
178  // This code is fragile! Note that towerDatum is packed as is done in HcalTriggerPrimitiveSample
179  // Bottom 8-bits are ET
180  // Then feature bit
181  // Then minBias ADC count bit
182  // The remaining bits are undefined presently
183  // We use next three bits for link details, which we did not have room in EcalTriggerPrimitiveSample case
184  // We use next three bits to set the tower masking, link masking and link status information as done for Ecal
185  // To decode these custom six bits use ((EcalTriggerPrimitiveSample::raw() >> 9) & 0x77)
186  uint32_t towerDatum = ctp7Data.getET(cType, negativeEta, iEta, iPhi);
187  towerDatum |= ctp7Data.getFB(cType, negativeEta, iEta, iPhi) << 8;
188  if (ctp7Data.isLinkMisaligned(cType, negativeEta, iEta, iPhi))
189  towerDatum |= 0x0400;
190  if (ctp7Data.isLinkInError(cType, negativeEta, iEta, iPhi))
191  towerDatum |= 0x0800;
192  if (ctp7Data.isLinkDown(cType, negativeEta, iEta, iPhi))
193  towerDatum |= 0x1000;
194  if (ctp7Data.isTowerMasked(cType, negativeEta, iEta, iPhi))
195  towerDatum |= 0x2000;
196  if (ctp7Data.isLinkMasked(cType, negativeEta, iEta, iPhi))
197  towerDatum |= 0x4000;
198  if (ctp7Data.isLinkMisaligned(cType, negativeEta, iEta, iPhi) ||
199  ctp7Data.isLinkInError(cType, negativeEta, iEta, iPhi) ||
200  ctp7Data.isLinkDown(cType, negativeEta, iEta, iPhi))
201  towerDatum |= 0x8000;
203  HcalTrigTowerDetId id(cEta, cPhi);
204  id.setVersion(1); // To not process these 1x1 HF TPGs with RCT
205  HcalTriggerPrimitiveDigi tpg(id);
206  tpg.setSize(1);
207  tpg.setSample(0, sample);
208  hcalTPGs->push_back(tpg);
209  }
210  }
211  }
212  }
213 
214  void CaloLayer1Unpacker::makeRegions(uint32_t lPhi, UCTCTP7RawData& ctp7Data, L1CaloRegionCollection* regions) {
215  for (uint32_t side = 0; side <= 1; side++) {
216  bool negativeEta = false;
217  if (side == 0)
218  negativeEta = true;
219  for (uint32_t region = 0; region <= 6; region++) {
220  uint32_t regionData = ctp7Data.getRegionSummary(negativeEta, region);
221  uint32_t lEta = 10 - region; // GCT eta goes 0-21, 0-3 -HF, 4-10 -B/E, 11-17 +B/E, 18-21 +HF
222  if (!negativeEta)
223  lEta = region + 11;
224  regions->push_back(L1CaloRegion((uint16_t)regionData, (unsigned)lEta, (unsigned)lPhi, (int16_t)0));
225  }
226  }
227  }
228 
229  } // namespace stage2
230 } // namespace l1t
231 
UCTCTP7RawData::HBHE
Definition: UCTCTP7RawData.h:9
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
UCTCTP7RawData::getRegionSummary
uint32_t getRegionSummary(bool negativeEta, uint32_t region)
Definition: UCTCTP7RawData.h:274
L1CaloRegion
A calorimeter trigger region (sum of 4x4 trigger towers)
Definition: L1CaloRegion.h:21
simplePhotonAnalyzer_cfi.sample
sample
Definition: simplePhotonAnalyzer_cfi.py:12
UCTCTP7RawData::EBEE
Definition: UCTCTP7RawData.h:9
l1t::stage2::CaloLayer1Unpacker
Definition: CaloLayer1Unpacker.h:10
HcalTriggerPrimitiveSample
Definition: HcalTriggerPrimitiveSample.h:11
edm
HLT enums.
Definition: AlignableModifier.h:19
UCTCTP7RawData
Definition: UCTCTP7RawData.h:7
UCTCTP7RawData::CaloType
CaloType
Definition: UCTCTP7RawData.h:9
edm::SortedCollection
Definition: SortedCollection.h:49
EcalSubdetector
EcalSubdetector
Definition: EcalSubdetector.h:10
EcalTrigTowerDetId
Definition: EcalTrigTowerDetId.h:14
HcalTriggerPrimitiveDigi::setSample
void setSample(int i, const HcalTriggerPrimitiveSample &sam)
Definition: HcalTriggerPrimitiveDigi.h:43
edm::SortedCollection::push_back
void push_back(T const &t)
Definition: SortedCollection.h:188
EcalBarrel
Definition: EcalSubdetector.h:10
UCTCTP7RawData::isLinkMasked
bool isLinkMasked(CaloType cType, bool negativeEta, uint32_t cEta, uint32_t iPhi)
Definition: UCTCTP7RawData.h:327
UCTCTP7RawData::isLinkDown
bool isLinkDown(CaloType cType, bool negativeEta, uint32_t cEta, uint32_t iPhi)
Definition: UCTCTP7RawData.h:319
CaloLayer1Unpacker.h
UCTCTP7RawData::isTowerMasked
bool isTowerMasked(CaloType cType, bool negativeEta, uint32_t cEta, uint32_t iPhi)
Definition: UCTCTP7RawData.h:290
UnpackerFactory.h
UCTCTP7RawData::isLinkInError
bool isLinkInError(CaloType cType, bool negativeEta, uint32_t cEta, uint32_t iPhi)
Definition: UCTCTP7RawData.h:311
EcalEndcap
Definition: EcalSubdetector.h:10
EcalTriggerPrimitiveDigi::setSize
void setSize(int size)
Definition: EcalTriggerPrimitiveDigi.cc:60
HcalTriggerPrimitiveDigi
Definition: HcalTriggerPrimitiveDigi.h:13
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:223
l1t
delete x;
Definition: CaloConfig.h:22
EcalTriggerPrimitiveDigi::setSample
void setSample(int i, const EcalTriggerPrimitiveSample &sam)
Definition: EcalTriggerPrimitiveDigi.h:36
HLT_FULL_cff.region
region
Definition: HLT_FULL_cff.py:88272
createfilelist.int
int
Definition: createfilelist.py:10
UCTCTP7RawData::isLinkMisaligned
bool isLinkMisaligned(CaloType cType, bool negativeEta, uint32_t cEta, uint32_t iPhi)
Definition: UCTCTP7RawData.h:303
groupFilesInBlocks.block
block
Definition: groupFilesInBlocks.py:150
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
res
Definition: Electron.h:6
SiStripSourceConfigTier0_cff.stage2
stage2
Definition: SiStripSourceConfigTier0_cff.py:71
UCTCTP7RawData::getET
uint32_t getET(CaloType cType, bool negativeEta, uint32_t cEta, uint32_t iPhi)
Definition: UCTCTP7RawData.h:166
L1CaloRegionCollection
std::vector< L1CaloRegion > L1CaloRegionCollection
Definition: L1CaloCollections.h:11
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
EcalTriggerPrimitiveDigi
Definition: EcalTriggerPrimitiveDigi.h:16
UCTCTP7RawData::getFB
uint32_t getFB(CaloType cType, bool negativeEta, uint32_t cEta, uint32_t iPhi)
Definition: UCTCTP7RawData.h:203
l1t::UnpackerCollections
Definition: UnpackerCollections.h:9
BeamSpotPI::unpack
std::pair< unsigned int, unsigned int > unpack(cond::Time_t since)
Definition: BeamSpotPayloadInspectorHelper.h:22
DEFINE_L1T_UNPACKER
#define DEFINE_L1T_UNPACKER(type)
Definition: UnpackerFactory.h:23
L1TowerCalibrationProducer_cfi.iEta
iEta
Definition: L1TowerCalibrationProducer_cfi.py:60
EcalTriggerPrimitiveSample
Definition: EcalTriggerPrimitiveSample.h:12
AlignmentPI::regions
regions
Definition: AlignmentPayloadInspectorHelper.h:76
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
l1t::Block
Definition: Block.h:70
HcalTriggerPrimitiveDigi::setSize
void setSize(int size)
Definition: HcalTriggerPrimitiveDigi.cc:7
UCTCTP7RawData::HF
Definition: UCTCTP7RawData.h:9
lumi::N_BX
const unsigned int N_BX
Definition: ConstantDef.h:5
HcalTrigTowerDetId
Definition: HcalTrigTowerDetId.h:14