35 #include "L1Trigger/L1TCaloLayer1/src/UCTLayer1.hh"
36 #include "L1Trigger/L1TCaloLayer1/src/UCTCrate.hh"
37 #include "L1Trigger/L1TCaloLayer1/src/UCTCard.hh"
38 #include "L1Trigger/L1TCaloLayer1/src/UCTRegion.hh"
39 #include "L1Trigger/L1TCaloLayer1/src/UCTTower.hh"
41 #include "L1Trigger/L1TCaloLayer1/src/UCTGeometry.hh"
42 #include "L1Trigger/L1TCaloLayer1/src/UCTLogging.hh"
50 #include "L1Trigger/L1TCaloLayer1/src/L1TCaloLayer1FetchLUTs.hh"
53 using namespace l1tcalo;
69 virtual void endJob()
override;
84 std::vector< std::vector< std::vector < uint32_t > > >
ecalLUT;
85 std::vector< std::vector< std::vector < uint32_t > > >
hcalLUT;
86 std::vector< std::vector< uint32_t > >
hfLUT;
117 ecalTPSourceLabel(iConfig.getParameter<edm::
InputTag>(
"ecalToken").
label()),
119 hcalTPSourceLabel(iConfig.getParameter<edm::
InputTag>(
"hcalToken").
label()),
120 ecalLUT(28, std::vector< std::vector<uint32_t> >(2, std::vector<uint32_t>(256))),
121 hcalLUT(28, std::vector< std::vector<uint32_t> >(2, std::vector<uint32_t>(256))),
122 hfLUT(12, std::vector < uint32_t >(256)),
123 useLSB(iConfig.getParameter<bool>(
"useLSB")),
124 useCalib(iConfig.getParameter<bool>(
"useCalib")),
125 useECALLUT(iConfig.getParameter<bool>(
"useECALLUT")),
126 useHCALLUT(iConfig.getParameter<bool>(
"useHCALLUT")),
127 useHFLUT(iConfig.getParameter<bool>(
"useHFLUT")),
128 verbose(iConfig.getParameter<bool>(
"verbose")),
129 unpackHcalMask(iConfig.getParameter<bool>(
"unpackHcalMask")),
130 unpackEcalMask(iConfig.getParameter<bool>(
"unpackEcalMask"))
132 produces<CaloTowerBxCollection>();
133 produces<L1CaloRegionCollection>();
137 layer1 =
new UCTLayer1(fwVersion);
139 vector<UCTCrate*> crates = layer1->getCrates();
140 for(uint32_t crt = 0; crt < crates.size(); crt++) {
141 vector<UCTCard*> cards = crates[crt]->getCards();
142 for(uint32_t crd = 0; crd < cards.size(); crd++) {
143 vector<UCTRegion*> regions = cards[crd]->getRegions();
144 for(uint32_t rgn = 0; rgn < regions.size(); rgn++) {
145 vector<UCTTower*>
towers = regions[rgn]->getTowers();
146 for(uint32_t twr = 0; twr < towers.size(); twr++) {
147 twrList.push_back(towers[twr]);
156 return CaloTools::caloTowerHash(a->caloEta(), a->caloPhi()) < CaloTools::caloTowerHash(
b->caloEta(),
b->caloPhi());
182 uint32_t expectedTotalET = 0;
183 if(!
layer1->clearEvent()) {
184 LOG_ERROR <<
"UCT: Failed to clear event" << std::endl;
188 for (
const auto& ecalTp : *ecalTPs ) {
189 if (
unpackEcalMask && ((ecalTp.sample(0).raw()>>13) & 0x1) )
continue;
190 int caloEta = ecalTp.id().ieta();
191 int caloPhi = ecalTp.id().iphi();
192 int et = ecalTp.compressedEt();
193 bool fgVeto = ecalTp.fineGrain();
194 UCTTowerIndex
t = UCTTowerIndex(caloEta, caloPhi);
195 if(!
layer1->setECALData(t,fgVeto,et)) {
196 LOG_ERROR <<
"UCT: Failed loading an ECAL tower" << std::endl;
199 expectedTotalET += et;
202 for (
const auto& hcalTp : *hcalTPs ) {
203 if (
unpackHcalMask && ((hcalTp.sample(0).raw()>>13) & 0x1) )
continue;
204 int caloEta = hcalTp.id().ieta();
205 uint32_t absCaloEta =
abs(caloEta);
207 if(absCaloEta == 29) {
211 else if(hcalTp.id().version() == 0 && absCaloEta > 29) {
214 else if(absCaloEta <= 41) {
215 int caloPhi = hcalTp.id().iphi();
216 int et = hcalTp.SOI_compressedEt();
217 bool fg = hcalTp.t0().fineGrain(0);
218 bool fg2 = hcalTp.t0().fineGrain(1);
220 UCTTowerIndex
t = UCTTowerIndex(caloEta, caloPhi);
221 uint32_t featureBits = 0;
222 if(fg) featureBits |= 0b01;
224 if(absCaloEta > 29 && fg2) featureBits |= 0b10;
225 if(!
layer1->setHCALData(t, featureBits, et)) {
226 LOG_ERROR <<
"caloEta = " << caloEta <<
"; caloPhi =" << caloPhi << std::endl;
227 LOG_ERROR <<
"UCT: Failed loading an HCAL tower" << std::endl;
230 expectedTotalET += et;
233 LOG_ERROR <<
"Illegal Tower: caloEta = " << caloEta <<
"; caloPhi =" << caloPhi <<
"; et = " << et << std::endl;
237 LOG_ERROR <<
"Illegal Tower: caloEta = " << caloEta << std::endl;
243 LOG_ERROR <<
"UCT: Failed to process layer 1" << std::endl;
248 for(uint32_t twr = 0; twr <
twrList.size(); twr++) {
257 towersColl->push_back(theBX, caloTower);
263 vector<UCTCrate*> crates =
layer1->getCrates();
264 for(uint32_t crt = 0; crt < crates.size(); crt++) {
265 vector<UCTCard*> cards = crates[crt]->getCards();
266 for(uint32_t crd = 0; crd < cards.size(); crd++) {
267 vector<UCTRegion*> regions = cards[crd]->getRegions();
268 for(uint32_t rgn = 0; rgn < regions.size(); rgn++) {
269 uint32_t rawData = regions[rgn]->rawData();
270 uint32_t regionData = rawData & 0x0000FFFF;
271 uint32_t crate = regions[rgn]->getCrate();
272 uint32_t card = regions[rgn]->getCard();
273 uint32_t
region = regions[rgn]->getRegion();
274 bool negativeEta = regions[rgn]->isNegativeEta();
275 uint32_t rPhi =
g.getUCTRegionPhiIndex(crate, card);
276 if(region < NRegionsInCard) {
277 uint32_t rEta = 10 -
region;
278 if(!negativeEta) rEta = 11 +
region;
279 rgnCollection->push_back(
L1CaloRegion((uint16_t) regionData, (
unsigned) rEta, (
unsigned) rPhi, (int16_t) 0));
306 LOG_ERROR <<
"L1TCaloLayer1::beginRun: failed to fetch LUTS - using unity" << std::endl;
308 for(uint32_t twr = 0; twr <
twrList.size(); twr++) {
T getParameter(std::string const &) const
std::vector< std::vector< std::vector< uint32_t > > > hcalLUT
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
virtual void endJob() override
#define DEFINE_FWK_MODULE(type)
std::vector< std::vector< uint32_t > > hfLUT
edm::EDGetTokenT< HcalTrigPrimDigiCollection > hcalTPSource
std::vector< UCTTower * > twrList
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
virtual void produce(edm::Event &, const edm::EventSetup &) override
void addDefault(ParameterSetDescription const &psetDescription)
std::vector< std::vector< std::vector< uint32_t > > > ecalLUT
Abs< T >::type abs(const T &t)
std::string ecalTPSourceLabel
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void setHwEtRatio(int ratio)
edm::EDGetTokenT< EcalTrigPrimDigiCollection > ecalTPSource
virtual void beginJob() override
std::string hcalTPSourceLabel
L1TCaloLayer1(const edm::ParameterSet &)
bool L1TCaloLayer1FetchLUTs(const edm::EventSetup &iSetup, std::vector< std::vector< std::vector< uint32_t > > > &eLUT, std::vector< std::vector< std::vector< uint32_t > > > &hLUT, std::vector< std::vector< uint32_t > > &hfLUT, bool useLSB, bool useCalib, bool useECALLUT, bool useHCALLUT, bool useHFLUT)
virtual void beginRun(edm::Run const &, edm::EventSetup const &) override
A calorimeter trigger region (sum of 4x4 trigger towers)
std::vector< L1CaloRegion > L1CaloRegionCollection