34 #include "L1Trigger/L1TCaloLayer1/src/UCTLayer1.hh"
35 #include "L1Trigger/L1TCaloLayer1/src/UCTCrate.hh"
36 #include "L1Trigger/L1TCaloLayer1/src/UCTCard.hh"
37 #include "L1Trigger/L1TCaloLayer1/src/UCTRegion.hh"
38 #include "L1Trigger/L1TCaloLayer1/src/UCTTower.hh"
40 #include "L1Trigger/L1TCaloLayer1/src/UCTGeometry.hh"
41 #include "L1Trigger/L1TCaloLayer1/src/UCTLogging.hh"
49 #include "L1Trigger/L1TCaloLayer1/src/L1TCaloLayer1FetchLUTs.hh"
52 using namespace l1tcalo;
80 std::vector<std::array<std::array<std::array<uint32_t, nEtBins>, nCalSideBins>, nCalEtaBins> >
ecalLUT;
81 std::vector<std::array<std::array<std::array<uint32_t, nEtBins>, nCalSideBins>, nCalEtaBins> >
hcalLUT;
82 std::vector<std::array<std::array<uint32_t, nEtBins>, nHfEtaBins> >
hfLUT;
117 towerPutToken{produces<CaloTowerBxCollection>()},
118 regionPutToken{produces<L1CaloRegionCollection>()},
122 useLSB(iConfig.getParameter<
bool>(
"useLSB")),
123 useCalib(iConfig.getParameter<
bool>(
"useCalib")),
124 useECALLUT(iConfig.getParameter<
bool>(
"useECALLUT")),
125 useHCALLUT(iConfig.getParameter<
bool>(
"useHCALLUT")),
126 useHFLUT(iConfig.getParameter<
bool>(
"useHFLUT")),
127 verbose(iConfig.getParameter<
bool>(
"verbose")),
130 fwVersion(iConfig.getParameter<
int>(
"firmwareVersion")) {
132 layer1 = std::make_unique<UCTLayer1>(
fwVersion);
134 vector<UCTCrate*> crates = layer1->getCrates();
135 for (uint32_t crt = 0; crt < crates.size(); crt++) {
136 vector<UCTCard*> cards = crates[crt]->getCards();
137 for (uint32_t crd = 0; crd < cards.size(); crd++) {
138 vector<UCTRegion*>
regions = cards[crd]->getRegions();
139 for (uint32_t rgn = 0; rgn <
regions.size(); rgn++) {
141 for (uint32_t twr = 0; twr <
towers.size(); twr++) {
142 twrList.push_back(
towers[twr]);
150 std::sort(twrList.begin(), twrList.end(), [](UCTTower*
a, UCTTower*
b) {
151 return CaloTools::caloTowerHash(
a->caloEta(),
a->caloPhi()) < CaloTools::caloTowerHash(
b->caloEta(),
b->caloPhi());
171 uint32_t expectedTotalET = 0;
172 if (!
layer1->clearEvent()) {
173 LOG_ERROR <<
"UCT: Failed to clear event" << std::endl;
177 for (
const auto& ecalTp : *ecalTPs) {
180 int caloEta = ecalTp.id().ieta();
181 int caloPhi = ecalTp.id().iphi();
182 int et = ecalTp.compressedEt();
183 bool fgVeto = ecalTp.fineGrain();
184 UCTTowerIndex
t = UCTTowerIndex(caloEta, caloPhi);
185 if (!
layer1->setECALData(
t, fgVeto,
et)) {
186 LOG_ERROR <<
"UCT: Failed loading an ECAL tower" << std::endl;
189 expectedTotalET +=
et;
193 for (
const auto& hcalTp : *hcalTPs) {
196 int caloEta = hcalTp.id().ieta();
197 uint32_t absCaloEta =
std::abs(caloEta);
199 if (absCaloEta == 29) {
203 else if (hcalTp.id().version() == 0 && absCaloEta > 29) {
205 }
else if (absCaloEta <= 41) {
206 int caloPhi = hcalTp.id().iphi();
207 int et = hcalTp.SOI_compressedEt();
208 bool fg = hcalTp.t0().fineGrain(0);
209 bool fg2 = hcalTp.t0().fineGrain(1);
211 UCTTowerIndex
t = UCTTowerIndex(caloEta, caloPhi);
212 uint32_t featureBits = 0;
216 if (absCaloEta > 29 && fg2)
218 if (!
layer1->setHCALData(
t, featureBits,
et)) {
219 LOG_ERROR <<
"caloEta = " << caloEta <<
"; caloPhi =" << caloPhi << std::endl;
220 LOG_ERROR <<
"UCT: Failed loading an HCAL tower" << std::endl;
223 expectedTotalET +=
et;
225 LOG_ERROR <<
"Illegal Tower: caloEta = " << caloEta <<
"; caloPhi =" << caloPhi <<
"; et = " <<
et
229 LOG_ERROR <<
"Illegal Tower: caloEta = " << caloEta << std::endl;
236 LOG_ERROR <<
"UCT: Failed to process layer 1" << std::endl;
241 for (uint32_t twr = 0; twr <
twrList.size(); twr++) {
256 vector<UCTCrate*> crates =
layer1->getCrates();
257 for (uint32_t crt = 0; crt < crates.size(); crt++) {
258 vector<UCTCard*> cards = crates[crt]->getCards();
259 for (uint32_t crd = 0; crd < cards.size(); crd++) {
260 vector<UCTRegion*>
regions = cards[crd]->getRegions();
261 for (uint32_t rgn = 0; rgn <
regions.size(); rgn++) {
263 uint32_t regionData =
rawData & 0x0000FFFF;
264 uint32_t crate =
regions[rgn]->getCrate();
265 uint32_t card =
regions[rgn]->getCard();
267 bool negativeEta =
regions[rgn]->isNegativeEta();
268 uint32_t rPhi =
g.getUCTRegionPhiIndex(crate, card);
269 if (
region < NRegionsInCard) {
275 rgnCollection.push_back(
L1CaloRegion((uint16_t)regionData, (
unsigned)rEta, (
unsigned)rPhi, (int16_t)0));
298 LOG_ERROR <<
"L1TCaloLayer1::beginRun: failed to fetch LUTS - using unity" << std::endl;
299 std::array<std::array<std::array<uint32_t, nEtBins>, nCalSideBins>, nCalEtaBins> eCalLayer1EtaSideEtArray;
300 std::array<std::array<std::array<uint32_t, nEtBins>, nCalSideBins>, nCalEtaBins> hCalLayer1EtaSideEtArray;
301 std::array<std::array<uint32_t, nEtBins>, nHfEtaBins> hfLayer1EtaEtArray;
302 ecalLUT.push_back(eCalLayer1EtaSideEtArray);
303 hcalLUT.push_back(hCalLayer1EtaSideEtArray);
304 hfLUT.push_back(hfLayer1EtaEtArray);
306 for (uint32_t twr = 0; twr <
twrList.size(); twr++) {