CMS 3D CMS Logo

RCTEmRegionUnpacker.cc
Go to the documentation of this file.
2 #include "rctDataBase.h"
3 
10 
12 
14 
15 #include <iostream>
16 #include <fstream>
17 
19 
20 #include "CaloCollections.h"
21 #include "RCTEmRegionUnpacker.h"
22 
23 namespace l1t {
24  namespace stage1 {
25  void unpack_em(const Block& block, UnpackerCollections* coll) {
26  int nBX, firstBX, lastBX;
27  nBX = int(ceil(block.header().getSize() / 6.));
28  getBXRange(nBX, firstBX, lastBX);
29 
30  auto resRCTEMCands_ = static_cast<CaloCollections*>(coll)->getCaloEmCands();
31 
32  // Initialise index
33  int unsigned i = 0;
34 
35  for (int bx = firstBX; bx <= lastBX; bx++) {
36  unsigned int crate;
37  bool even = false;
38 
39  std::vector<uint32_t> uint;
40  uint.reserve(6);
41 
43  rctDataBase database;
44  int mp7link = (int)(block.header().getID() / 2);
45  database.GetLinkRCT(mp7link, crate, even);
46 
47  uint.push_back(block.payload()[i++]);
48  uint.push_back(block.payload()[i++]);
49  uint.push_back(block.payload()[i++]);
50  uint.push_back(block.payload()[i++]);
51  uint.push_back(block.payload()[i++]);
52  uint.push_back(block.payload()[i++]);
53 
54  LogDebug("L1T") << "--------------- mp7 link =" << mp7link << "RCT crate id=" << crate
55  << ", RCT crate even=" << even << std::endl;
56 
57  if (!even) {
58  for (int i = 0; i < 6; i++)
59  converter.Set32bitWordLinkOdd(i, uint[i]);
60  converter.Convert();
61 
62  for (int j = 0; j < 4; j++) {
63  unsigned int rank = (unsigned int)converter.GetNEEt(j);
64  unsigned int reg = (unsigned int)converter.GetNEReg(j);
65  unsigned int card = (unsigned int)converter.GetNECard(j);
66 
67  LogDebug("L1T") << "UNPACKER, CRATE" << crate << "NON ISO em rank=" << rank << ", region=" << reg
68  << ", card=" << card << std::endl;
69 
70  L1CaloEmCand em = L1CaloEmCand(rank, reg, card, crate, false, j, bx);
71  resRCTEMCands_->push_back(em);
72  }
73 
74  for (int j = 0; j < 4; j++) {
75  unsigned int rank = converter.GetIEEt(j);
76  unsigned int reg = converter.GetIEReg(j);
77  unsigned int card = converter.GetIECard(j);
78 
79  LogDebug("L1T") << "UNPACKER, CRATE" << crate << "ISO em rank=" << rank << ", region=" << reg
80  << ", card=" << card << std::endl;
81  L1CaloEmCand em = L1CaloEmCand(rank, reg, card, crate, true, j, bx);
82  resRCTEMCands_->push_back(em);
83  }
84  } // end if odd
85  } // end of loop over BX
86  }
87 
89  int nBX, firstBX, lastBX;
90  nBX = int(ceil(block.header().getSize() / 6.));
91  getBXRange(nBX, firstBX, lastBX);
92 
93  auto resRCTRegions_ = static_cast<CaloCollections*>(coll)->getCaloRegions();
94 
95  // Initialise index
96  int unsigned i = 0;
97  std::vector<uint32_t> uint;
98  uint.reserve(6);
99 
100  for (int bx = firstBX; bx <= lastBX; bx++) {
101  unsigned int crate;
102  bool even = false;
103 
105  rctDataBase database;
106  int mp7link = (int)(block.header().getID() / 2);
107  database.GetLinkRCT(mp7link, crate, even);
108 
109  uint.push_back(block.payload()[i++]);
110  uint.push_back(block.payload()[i++]);
111  uint.push_back(block.payload()[i++]);
112  uint.push_back(block.payload()[i++]);
113  uint.push_back(block.payload()[i++]);
114  uint.push_back(block.payload()[i++]);
115 
116  LogDebug("L1T") << "--------------- mp7 link =" << mp7link << "RCT crate id=" << crate
117  << ", RCT crate even=" << even << std::endl;
118 
119  if (!even) {
120  for (int i = 0; i < 6; i++)
121  converter.Set32bitWordLinkOdd(i, uint[i]);
122  converter.Convert();
123 
124  for (int j = 0; j < 8; j++) {
125  unsigned int hfet = (unsigned int)converter.GetHFEt(j);
126  bool hfgrain = (bool)converter.GetHFFg(j);
127 
128  LogDebug("L1T") << "UNPACKER, CRATE" << crate << "region=" << j << ", rgnEt=" << hfet << std::endl;
129  L1CaloRegion rgn = L1CaloRegion(hfet, hfgrain, crate, j);
130  rgn.setBx(bx);
131  resRCTRegions_->push_back(rgn);
132  }
133  } // end if odd
134 
135  else {
136  for (int i = 0; i < 6; i++)
137  converter.Set32bitWordLinkEven(i, uint[i]);
138  converter.Convert();
139 
140  for (int j = 0; j < 7; j++) {
141  for (int k = 0; k < 2; k++) {
142  unsigned int RCet = (unsigned int)converter.GetRCEt(j, k);
143  bool overflow = (bool)converter.GetRCOf(j, k);
144  bool tauveto = (bool)converter.GetRCTau(j, k);
145  bool hadveto = (bool)converter.GetRCHad(j, k);
146  bool quiet = false; //to be fixed
147 
148  LogDebug("L1T") << "UNPACKER, CRATE=" << crate << ",region=" << k << ", card=" << j << ", rgnEt=" << RCet
149  << ", overflow=" << overflow << ", tauveto=" << tauveto << ", hadveto=" << hadveto
150  << std::endl;
151  L1CaloRegion rgn = L1CaloRegion(RCet, overflow, tauveto, hadveto, quiet, crate, j, k);
152  rgn.setBx(bx);
153  resRCTRegions_->push_back(rgn);
154  }
155  }
156  } // end if even
157  } // end of loop over BX
158  }
159 
161  if (block.header().getCapID() == 0) {
162  unpack_region(block, coll);
163  } else if (block.header().getCapID() == 1) {
164  unpack_em(block, coll);
165  } else {
166  return false;
167  }
168  return true;
169  }
170  } // namespace stage1
171 } // namespace l1t
172 
Block.h
L1CaloEmCand.h
electrons_cff.bool
bool
Definition: electrons_cff.py:366
mps_fire.i
i
Definition: mps_fire.py:428
L1CaloRegion::setBx
void setBx(int16_t bx)
set bx
Definition: L1CaloRegion.cc:103
MessageLogger.h
l1t::stage1::unpack_em
void unpack_em(const Block &block, UnpackerCollections *coll)
Definition: RCTEmRegionUnpacker.cc:25
L1CaloRegion
A calorimeter trigger region (sum of 4x4 trigger towers)
Definition: L1CaloRegion.h:21
converter
Definition: CandidateProducer.h:25
l1GtPatternGenerator_cfi.bx
bx
Definition: l1GtPatternGenerator_cfi.py:18
l1t::stage1::unpack_region
void unpack_region(const Block &block, UnpackerCollections *coll)
Definition: RCTEmRegionUnpacker.cc:88
RPCBxOrConfig_cff.firstBX
firstBX
Definition: RPCBxOrConfig_cff.py:5
rctDataBase.h
parallelization.uint
uint
Definition: parallelization.py:124
l1t::PhysicsToBitConverter
Definition: PhysicsToBitConverter.h:21
CaloRegion.h
PhysicsToBitConverter.h
reco::ceil
constexpr int32_t ceil(float num)
Definition: constexpr_cmath.h:7
l1t::rctDataBase::GetLinkRCT
void GetLinkRCT(int linkMP7, unsigned int &RCTcrate, bool &RCTeven)
Definition: rctDataBase.h:42
UnpackerFactory.h
dqmdumpme.k
k
Definition: dqmdumpme.py:60
l1t::stage1::RCTEmRegionUnpacker
Definition: RCTEmRegionUnpacker.h:8
L1CaloRegionDetId.h
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
l1t
delete x;
Definition: CaloConfig.h:22
l1t::rctDataBase
Definition: rctDataBase.h:10
createfilelist.int
int
Definition: createfilelist.py:10
L1CaloCollections.h
groupFilesInBlocks.block
block
Definition: groupFilesInBlocks.py:150
CaloEmCand.h
l1t::UnpackerCollections
Definition: UnpackerCollections.h:9
RPCBxOrConfig_cff.lastBX
lastBX
Definition: RPCBxOrConfig_cff.py:4
DEFINE_L1T_UNPACKER
#define DEFINE_L1T_UNPACKER(type)
Definition: UnpackerFactory.h:23
l1t::getBXRange
void getBXRange(int nbx, int &first, int &last)
Definition: UnpackerFactory.cc:12
l1t::stage1::RCTEmRegionUnpacker::unpack
bool unpack(const Block &block, UnpackerCollections *coll) override
Definition: RCTEmRegionUnpacker.cc:160
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
CaloCollections.h
L1CaloEmCand
Level-1 Region Calorimeter Trigger EM candidate.
Definition: L1CaloEmCand.h:17
l1t::Block
Definition: Block.h:70
RCTEmRegionUnpacker.h
L1CaloRegion.h