CMS 3D CMS Logo

CaloLayer1Packer.cc
Go to the documentation of this file.
3 
5 
6 #include "CaloLayer1Packer.h"
7 
8 namespace l1t {
9  namespace stage2 {
10 
11  // max_iEta_HcalTP = 41; // barrel <= 16, endcap <= 28, 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 
17  event.getByToken(static_cast<const CaloLayer1Tokens*>(toks)->getEcalDigiToken(), ecalDigis);
19  event.getByToken(static_cast<const CaloLayer1Tokens*>(toks)->getHcalDigiToken(), hcalDigis);
21  event.getByToken(static_cast<const CaloLayer1Tokens*>(toks)->getCaloRegionToken(), caloRegions);
22 
23  std::vector<uint32_t> load;
24  load.resize(192, 0u);
25 
26  auto ctp7_phi = board();
27  uint32_t* ptr = load.data();
28  UCTCTP7RawData ctp7Data(ptr);
29  makeECalTPGs(ctp7_phi, ctp7Data, ecalDigis.product());
30  makeHCalTPGs(ctp7_phi, ctp7Data, hcalDigis.product());
31  makeHFTPGs(ctp7_phi, ctp7Data, hcalDigis.product());
32  makeRegions(ctp7_phi, ctp7Data, caloRegions.product());
33 
34  unsigned bx_per_l1a = 1;
35  // CTP7 uses CMS scheme, starting at 0
36  // TODO: expected +2, but +1 apparently?
37  unsigned calo_bxid = (event.bunchCrossing() + 1) % 3564;
38 
39  // a la CTP7Payload::getHeader()
40  unsigned blockId = 0;
41  unsigned blockSize = 192;
42  unsigned capId = 0;
43  unsigned blockFlags = ((bx_per_l1a & 0xf) << 16) | (calo_bxid & 0xfff);
44  BlockHeader hdr(blockId, blockSize, capId, blockFlags, CTP7);
45  Block block(hdr, &*load.begin(), &*load.end());
46 
47  Blocks res;
48  res.push_back(block);
49  return res;
50  }
51 
52  void CaloLayer1Packer::makeECalTPGs(uint32_t lPhi,
53  UCTCTP7RawData& ctp7Data,
54  const EcalTrigPrimDigiCollection* ecalTPGs) {
56  for (uint32_t iPhi = 0; iPhi < 4; iPhi++) { // Loop over all four phi divisions on card
57  int cPhi = -1 + lPhi * 4 + iPhi; // Calorimeter phi index
58  if (cPhi == 0)
59  cPhi = 72;
60  else if (cPhi == -1)
61  cPhi = 71;
62  else if (cPhi < -1) {
63  edm::LogError("CaloLayer1Packer") << "Major error in makeECalTPGs" << std::endl;
64  return;
65  }
66  for (int cEta = -28; cEta <= 28; cEta++) { // Calorimeter Eta indices (HB/HE for now)
67  if (cEta != 0) { // Calorimeter eta = 0 is invalid
68  bool negativeEta = false;
69  if (cEta < 0)
70  negativeEta = true;
71  uint32_t iEta = abs(cEta);
72 
73  int zSide = cEta / ((int)iEta);
74  const EcalSubdetector ecalTriggerTower =
76  EcalTrigTowerDetId id(zSide, ecalTriggerTower, iEta, cPhi);
77  const auto& tp = ecalTPGs->find(id);
78  if (tp != ecalTPGs->end()) {
79  ctp7Data.setET(cType, negativeEta, iEta, iPhi, tp->compressedEt());
80  ctp7Data.setFB(cType, negativeEta, iEta, iPhi, tp->fineGrain());
81  }
82  }
83  }
84  }
85  }
86 
87  void CaloLayer1Packer::makeHCalTPGs(uint32_t lPhi,
88  UCTCTP7RawData& ctp7Data,
89  const HcalTrigPrimDigiCollection* hcalTPGs) {
91  for (uint32_t iPhi = 0; iPhi < 4; iPhi++) { // Loop over all four phi divisions on card
92  int cPhi = -1 + lPhi * 4 + iPhi; // Calorimeter phi index
93  if (cPhi == 0)
94  cPhi = 72;
95  else if (cPhi == -1)
96  cPhi = 71;
97  else if (cPhi < -1) {
98  edm::LogError("CaloLayer1Packer") << "Major error in makeHCalTPGs" << std::endl;
99  return;
100  }
101  for (int cEta = -28; cEta <= 28; cEta++) { // Calorimeter Eta indices (HB/HE for now)
102  if (cEta != 0) { // Calorimeter eta = 0 is invalid
103  bool negativeEta = false;
104  if (cEta < 0)
105  negativeEta = true;
106  uint32_t iEta = abs(cEta);
107 
108  HcalTrigTowerDetId id(cEta, cPhi);
109  const auto tp = hcalTPGs->find(id);
110  if (tp != hcalTPGs->end()) {
111  ctp7Data.setET(cType, negativeEta, iEta, iPhi, tp->SOI_compressedEt());
112  ctp7Data.setFB(cType, negativeEta, iEta, iPhi, tp->SOI_fineGrain());
113  }
114  }
115  }
116  }
117  }
118 
119  void CaloLayer1Packer::makeHFTPGs(uint32_t lPhi,
120  UCTCTP7RawData& ctp7Data,
121  const HcalTrigPrimDigiCollection* hcalTPGs) {
123  for (uint32_t side = 0; side <= 1; side++) {
124  bool negativeEta = false;
125  if (side == 0)
126  negativeEta = true;
127  for (uint32_t iEta = 30; iEta <= 40; iEta++) {
128  for (uint32_t iPhi = 0; iPhi < 2; iPhi++) {
129  if (iPhi == 1 && iEta == 40)
130  iEta = 41;
131  int cPhi = 1 + lPhi * 4 + iPhi * 2; // Calorimeter phi index: 1, 3, 5, ... 71
132  if (iEta == 41)
133  cPhi -= 2; // Last two HF are 3, 7, 11, ...
134  cPhi = (cPhi + 69) % 72 + 1; // cPhi -= 2 mod 72
135  int cEta = iEta;
136  if (negativeEta)
137  cEta = -iEta;
138 
139  HcalTrigTowerDetId id(cEta, cPhi);
140  id.setVersion(1); // To not process these 1x1 HF TPGs with RCT
141  const auto tp = hcalTPGs->find(id);
142  if (tp != hcalTPGs->end()) {
143  ctp7Data.setET(cType, negativeEta, iEta, iPhi, tp->SOI_compressedEt());
144  ctp7Data.setFB(cType, negativeEta, iEta, iPhi, ((tp->SOI_fineGrain(1) << 1) | tp->SOI_fineGrain(0)));
145  }
146  }
147  }
148  }
149  }
150 
152  for (uint32_t side = 0; side <= 1; side++) {
153  bool negativeEta = false;
154  if (side == 0)
155  negativeEta = true;
156  for (uint32_t region = 0; region <= 6; region++) {
157  uint32_t lEta = 10 - region; // GCT eta goes 0-21, 0-3 -HF, 4-10 -B/E, 11-17 +B/E, 18-21 +HF
158  if (!negativeEta)
159  lEta = region + 11;
160 
161  L1CaloRegionDetId id(lEta, lPhi);
162  // Can't use find since not an edm::SortedCollection
163  // const L1CaloRegion& rtp = *regions->find(id);
164  for (const auto& rtp : *regions) {
165  if (rtp.id() == id) {
166  ctp7Data.setRegionSummary(negativeEta, region, rtp.raw());
167  break;
168  }
169  }
170  }
171  }
172  }
173 
174  } // namespace stage2
175 } // namespace l1t
176 
l1t::Blocks
std::vector< Block > Blocks
Definition: Block.h:83
UCTCTP7RawData::HBHE
Definition: UCTCTP7RawData.h:9
PackerFactory.h
CaloTools.h
l1t::stage2::CaloLayer1Packer::makeECalTPGs
void makeECalTPGs(uint32_t lPhi, UCTCTP7RawData &ctp7Data, const EcalTrigPrimDigiCollection *ecalTPGs)
Definition: CaloLayer1Packer.cc:52
caloLayer1Raw_cfi.caloRegions
caloRegions
Definition: caloLayer1Raw_cfi.py:8
CaloLayer1Packer.h
UCTCTP7RawData::EBEE
Definition: UCTCTP7RawData.h:9
l1t::stage2::CaloLayer1Packer::pack
Blocks pack(const edm::Event &, const PackerTokens *) override
Definition: CaloLayer1Packer.cc:15
l1t::CTP7
Definition: Block.h:11
UCTCTP7RawData::setET
void setET(CaloType cType, bool negativeEta, uint32_t cEta, uint32_t iPhi, uint32_t et)
Definition: UCTCTP7RawData.h:145
UCTCTP7RawData
Definition: UCTCTP7RawData.h:7
UCTCTP7RawData::CaloType
CaloType
Definition: UCTCTP7RawData.h:9
edm::SortedCollection
Definition: SortedCollection.h:49
UCTCTP7RawData::setRegionSummary
void setRegionSummary(bool negativeEta, uint32_t region, uint32_t regionData)
Definition: UCTCTP7RawData.h:264
EcalSubdetector
EcalSubdetector
Definition: EcalSubdetector.h:10
EcalTrigTowerDetId
Definition: EcalTrigTowerDetId.h:14
edm::Handle
Definition: AssociativeIterator.h:50
EcalBarrel
Definition: EcalSubdetector.h:10
l1t::stage2::CaloLayer1Packer
Definition: CaloLayer1Packer.h:10
L1CaloRegionDetId
Definition: L1CaloRegionDetId.h:18
DigiToRawDM_cff.ecalDigis
ecalDigis
Definition: DigiToRawDM_cff.py:57
l1t::stage2::CaloLayer1Packer::makeHFTPGs
void makeHFTPGs(uint32_t lPhi, UCTCTP7RawData &ctp7Data, const HcalTrigPrimDigiCollection *hcalTPGs)
Definition: CaloLayer1Packer.cc:119
l1t::stage2::CaloLayer1Packer::makeHCalTPGs
void makeHCalTPGs(uint32_t lPhi, UCTCTP7RawData &ctp7Data, const HcalTrigPrimDigiCollection *hcalTPGs)
Definition: CaloLayer1Packer.cc:87
svgfig.load
def load(fileName)
Definition: svgfig.py:547
cmsswSequenceInfo.tp
tp
Definition: cmsswSequenceInfo.py:17
EcalEndcap
Definition: EcalSubdetector.h:10
DEFINE_L1T_PACKER
#define DEFINE_L1T_PACKER(type)
Definition: PackerFactory.h:23
edm::LogError
Definition: MessageLogger.h:183
Event.h
l1t
delete x;
Definition: CaloConfig.h:22
edm::SortedCollection::end
const_iterator end() const
Definition: SortedCollection.h:267
l1t::BlockHeader
Definition: Block.h:13
createfilelist.int
int
Definition: createfilelist.py:10
UCTCTP7RawData::setFB
void setFB(CaloType cType, bool negativeEta, uint32_t cEta, uint32_t iPhi, uint32_t fb)
Definition: UCTCTP7RawData.h:184
l1t::stage2::CaloLayer1Packer::makeRegions
void makeRegions(uint32_t lPhi, UCTCTP7RawData &ctp7Data, const L1CaloRegionCollection *regions)
Definition: CaloLayer1Packer.cc:151
groupFilesInBlocks.block
block
Definition: groupFilesInBlocks.py:150
l1t::PackerTokens
Definition: PackerTokens.h:10
res
Definition: Electron.h:6
SiStripSourceConfigTier0_cff.stage2
stage2
Definition: SiStripSourceConfigTier0_cff.py:71
edm::SortedCollection::find
iterator find(key_type k)
Definition: SortedCollection.h:240
L1CaloRegionCollection
std::vector< L1CaloRegion > L1CaloRegionCollection
Definition: L1CaloCollections.h:11
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
HLT_2018_cff.region
region
Definition: HLT_2018_cff.py:81479
L1TowerCalibrationProducer_cfi.iEta
iEta
Definition: L1TowerCalibrationProducer_cfi.py:60
DigiToRawDM_cff.hcalDigis
hcalDigis
Definition: DigiToRawDM_cff.py:58
AlignmentPI::regions
regions
Definition: AlignmentPayloadInspectorHelper.h:76
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
l1t::Block
Definition: Block.h:54
l1t::Packer::board
unsigned board()
Definition: Packer.h:18
UCTCTP7RawData::HF
Definition: UCTCTP7RawData.h:9
HcalTrigTowerDetId
Definition: HcalTrigTowerDetId.h:14