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" 81 std::vector<std::array<std::array<std::array<uint32_t, nEtBins>, nCalSideBins>, nCalEtaBins> >
ecalLUT;
82 std::vector<std::array<std::array<std::array<uint32_t, nEtBins>, nCalSideBins>, nCalEtaBins> >
hcalLUT;
83 std::vector<std::array<std::array<uint32_t, nEtBins>, nHfEtaBins> >
hfLUT;
118 towerPutToken{produces<CaloTowerBxCollection>()},
119 regionPutToken{produces<L1CaloRegionCollection>()},
120 lutsTokens{esConsumes<edm::Transition::BeginRun>(),
121 esConsumes<edm::Transition::BeginRun>(),
122 esConsumes<edm::Transition::BeginRun>()},
126 useLSB(iConfig.getParameter<
bool>(
"useLSB")),
127 useCalib(iConfig.getParameter<
bool>(
"useCalib")),
128 useECALLUT(iConfig.getParameter<
bool>(
"useECALLUT")),
129 useHCALLUT(iConfig.getParameter<
bool>(
"useHCALLUT")),
130 useHFLUT(iConfig.getParameter<
bool>(
"useHFLUT")),
131 verbose(iConfig.getParameter<
bool>(
"verbose")),
134 fwVersion(iConfig.getParameter<
int>(
"firmwareVersion")) {
136 layer1 = std::make_unique<UCTLayer1>(
fwVersion);
138 vector<UCTCrate*> crates = layer1->getCrates();
139 for (uint32_t crt = 0; crt < crates.size(); crt++) {
140 vector<UCTCard*> cards = crates[crt]->getCards();
141 for (uint32_t crd = 0; crd < cards.size(); crd++) {
142 vector<UCTRegion*>
regions = cards[crd]->getRegions();
143 for (uint32_t rgn = 0; rgn <
regions.size(); rgn++) {
145 for (uint32_t twr = 0; twr <
towers.size(); twr++) {
146 twrList.push_back(
towers[twr]);
154 std::sort(twrList.begin(), twrList.end(), [](UCTTower*
a, UCTTower*
b) {
155 return CaloTools::caloTowerHash(
a->caloEta(),
a->caloPhi()) < CaloTools::caloTowerHash(
b->caloEta(),
b->caloPhi());
175 uint32_t expectedTotalET = 0;
176 if (!
layer1->clearEvent()) {
177 LOG_ERROR <<
"UCT: Failed to clear event" << std::endl;
181 for (
const auto& ecalTp : *ecalTPs) {
184 int caloEta = ecalTp.id().ieta();
185 int caloPhi = ecalTp.id().iphi();
186 int et = ecalTp.compressedEt();
187 bool fgVeto = ecalTp.fineGrain();
188 UCTTowerIndex
t = UCTTowerIndex(caloEta, caloPhi);
189 if (!
layer1->setECALData(
t, fgVeto,
et)) {
190 LOG_ERROR <<
"UCT: Failed loading an ECAL tower" << std::endl;
193 expectedTotalET +=
et;
197 for (
const auto& hcalTp : *hcalTPs) {
200 int caloEta = hcalTp.id().ieta();
201 uint32_t absCaloEta =
std::abs(caloEta);
203 if (absCaloEta == 29) {
207 else if (hcalTp.id().version() == 0 && absCaloEta > 29) {
209 }
else if (absCaloEta <= 41) {
210 int caloPhi = hcalTp.id().iphi();
211 int et = hcalTp.SOI_compressedEt();
212 bool fg = hcalTp.t0().fineGrain(0);
213 bool fg2 = hcalTp.t0().fineGrain(1);
214 bool fg3 = hcalTp.t0().fineGrain(2);
215 bool fg4 = hcalTp.t0().fineGrain(3);
218 UCTTowerIndex
t = UCTTowerIndex(caloEta, caloPhi);
219 uint32_t featureBits = 0;
220 if (absCaloEta > 29) {
226 }
else if (absCaloEta < 16)
227 featureBits |= (fg | ((!fg2) & (fg3 | fg4)));
228 if (!
layer1->setHCALData(
t, featureBits,
et)) {
229 LOG_ERROR <<
"caloEta = " << caloEta <<
"; caloPhi =" << caloPhi << std::endl;
230 LOG_ERROR <<
"UCT: Failed loading an HCAL tower" << std::endl;
233 expectedTotalET +=
et;
235 LOG_ERROR <<
"Illegal Tower: caloEta = " << caloEta <<
"; caloPhi =" << caloPhi <<
"; et = " <<
et 239 LOG_ERROR <<
"Illegal Tower: caloEta = " << caloEta << std::endl;
246 LOG_ERROR <<
"UCT: Failed to process layer 1" << std::endl;
251 for (uint32_t twr = 0; twr <
twrList.size(); twr++) {
266 vector<UCTCrate*> crates =
layer1->getCrates();
267 for (uint32_t crt = 0; crt < crates.size(); crt++) {
268 vector<UCTCard*> cards = crates[crt]->getCards();
269 for (uint32_t crd = 0; crd < cards.size(); crd++) {
270 vector<UCTRegion*>
regions = cards[crd]->getRegions();
271 for (uint32_t rgn = 0; rgn <
regions.size(); rgn++) {
273 uint32_t regionData =
rawData & 0x0000FFFF;
274 uint32_t crate =
regions[rgn]->getCrate();
275 uint32_t card =
regions[rgn]->getCard();
277 bool negativeEta =
regions[rgn]->isNegativeEta();
278 uint32_t rPhi =
g.getUCTRegionPhiIndex(crate, card);
279 if (
region < NRegionsInCard) {
285 rgnCollection.push_back(
L1CaloRegion((uint16_t)regionData, (
unsigned)rEta, (
unsigned)rPhi, (int16_t)0));
309 LOG_ERROR <<
"L1TCaloLayer1::beginRun: failed to fetch LUTS - using unity" << std::endl;
310 std::array<std::array<std::array<uint32_t, nEtBins>, nCalSideBins>, nCalEtaBins> eCalLayer1EtaSideEtArray;
311 std::array<std::array<std::array<uint32_t, nEtBins>, nCalSideBins>, nCalEtaBins> hCalLayer1EtaSideEtArray;
312 std::array<std::array<uint32_t, nEtBins>, nHfEtaBins> hfLayer1EtaEtArray;
313 ecalLUT.push_back(eCalLayer1EtaSideEtArray);
314 hcalLUT.push_back(hCalLayer1EtaSideEtArray);
315 hfLUT.push_back(hfLayer1EtaEtArray);
317 for (uint32_t twr = 0; twr <
twrList.size(); twr++) {
std::vector< std::array< std::array< uint32_t, nEtBins >, nHfEtaBins > > hfLUT
std::vector< unsigned int > hfPhiMap
edm::EDGetTokenT< HcalTrigPrimDigiCollection > hcalTPSource
std::vector< std::array< std::array< std::array< uint32_t, nEtBins >, nCalSideBins >, nCalEtaBins > > ecalLUT
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
std::unique_ptr< UCTLayer1 > layer1
edm::EDPutTokenT< L1CaloRegionCollection > regionPutToken
void produce(edm::Event &, const edm::EventSetup &) override
void addDefault(ParameterSetDescription const &psetDescription)
std::vector< std::array< std::array< std::array< uint32_t, nEtBins >, nCalSideBins >, nCalEtaBins > > hcalLUT
std::vector< UCTTower * > twrList
Abs< T >::type abs(const T &t)
bool L1TCaloLayer1FetchLUTs(const L1TCaloLayer1FetchLUTsTokens &iTokens, const edm::EventSetup &iSetup, std::vector< std::array< std::array< std::array< uint32_t, nEtBins >, nCalSideBins >, nCalEtaBins > > &eLUT, std::vector< std::array< std::array< std::array< uint32_t, nEtBins >, nCalSideBins >, nCalEtaBins > > &hLUT, std::vector< std::array< std::array< uint32_t, nEtBins >, nHfEtaBins > > &hfLUT, std::vector< unsigned int > &ePhiMap, std::vector< unsigned int > &hPhiMap, std::vector< unsigned int > &hfPhiMap, bool useLSB, bool useCalib, bool useECALLUT, bool useHCALLUT, bool useHFLUT, int fwVersion)
#define DEFINE_FWK_MODULE(type)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void setHwEtRatio(int ratio)
edm::EDGetTokenT< EcalTrigPrimDigiCollection > ecalTPSource
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const L1TCaloLayer1FetchLUTsTokens lutsTokens
edm::EDPutTokenT< CaloTowerBxCollection > towerPutToken
std::vector< unsigned int > hPhiMap
L1TCaloLayer1(const edm::ParameterSet &)
void beginRun(edm::Run const &, edm::EventSetup const &) override
A calorimeter trigger region (sum of 4x4 trigger towers)
std::vector< L1CaloRegion > L1CaloRegionCollection
std::vector< unsigned int > ePhiMap
void push_back(int bx, T object)