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" 69 virtual void endJob()
override;
84 std::vector< std::array< std::array< std::array<uint32_t, nEtBins>, nCalSideBins >, nCalEtaBins> >
ecalLUT;
85 std::vector< std::array< std::array< std::array<uint32_t, nEtBins>, nCalSideBins >, nCalEtaBins> >
hcalLUT;
86 std::vector< std::array< std::array<uint32_t, nEtBins>, nHfEtaBins > >
hfLUT;
121 ecalTPSourceLabel(iConfig.getParameter<
edm::InputTag>(
"ecalToken").
label()),
123 hcalTPSourceLabel(iConfig.getParameter<
edm::InputTag>(
"hcalToken").
label()),
127 useLSB(iConfig.getParameter<bool>(
"useLSB")),
128 useCalib(iConfig.getParameter<bool>(
"useCalib")),
129 useECALLUT(iConfig.getParameter<bool>(
"useECALLUT")),
130 useHCALLUT(iConfig.getParameter<bool>(
"useHCALLUT")),
131 useHFLUT(iConfig.getParameter<bool>(
"useHFLUT")),
132 verbose(iConfig.getParameter<bool>(
"verbose")),
133 unpackHcalMask(iConfig.getParameter<bool>(
"unpackHcalMask")),
134 unpackEcalMask(iConfig.getParameter<bool>(
"unpackEcalMask"))
136 produces<CaloTowerBxCollection>();
137 produces<L1CaloRegionCollection>();
141 layer1 =
new UCTLayer1(fwVersion);
143 vector<UCTCrate*> crates = layer1->getCrates();
144 for(uint32_t crt = 0; crt < crates.size(); crt++) {
145 vector<UCTCard*> cards = crates[crt]->getCards();
146 for(uint32_t crd = 0; crd < cards.size(); crd++) {
147 vector<UCTRegion*> regions = cards[crd]->getRegions();
148 for(uint32_t rgn = 0; rgn < regions.size(); rgn++) {
149 vector<UCTTower*> towers = regions[rgn]->getTowers();
150 for(uint32_t twr = 0; twr < towers.size(); twr++) {
151 twrList.push_back(towers[twr]);
160 return CaloTools::caloTowerHash(a->caloEta(), a->caloPhi()) < CaloTools::caloTowerHash(
b->caloEta(),
b->caloPhi());
186 uint32_t expectedTotalET = 0;
187 if(!
layer1->clearEvent()) {
188 LOG_ERROR <<
"UCT: Failed to clear event" << std::endl;
192 for (
const auto& ecalTp : *ecalTPs ) {
193 if (
unpackEcalMask && ((ecalTp.sample(0).raw()>>13) & 0x1) )
continue;
194 int caloEta = ecalTp.id().ieta();
195 int caloPhi = ecalTp.id().iphi();
196 int et = ecalTp.compressedEt();
197 bool fgVeto = ecalTp.fineGrain();
198 UCTTowerIndex
t = UCTTowerIndex(caloEta, caloPhi);
199 if(!
layer1->setECALData(t,fgVeto,et)) {
200 LOG_ERROR <<
"UCT: Failed loading an ECAL tower" << std::endl;
203 expectedTotalET +=
et;
208 for (
const auto& hcalTp : *hcalTPs ) {
209 if (
unpackHcalMask && ((hcalTp.sample(0).raw()>>13) & 0x1) )
continue;
210 int caloEta = hcalTp.id().ieta();
211 uint32_t absCaloEta =
std::abs(caloEta);
213 if(absCaloEta == 29) {
217 else if(hcalTp.id().version() == 0 && absCaloEta > 29) {
220 else if(absCaloEta <= 41) {
221 int caloPhi = hcalTp.id().iphi();
222 int et = hcalTp.SOI_compressedEt();
223 bool fg = hcalTp.t0().fineGrain(0);
224 bool fg2 = hcalTp.t0().fineGrain(1);
226 UCTTowerIndex
t = UCTTowerIndex(caloEta, caloPhi);
227 uint32_t featureBits = 0;
228 if(fg) featureBits |= 0b01;
230 if(absCaloEta > 29 && fg2) featureBits |= 0b10;
231 if(!
layer1->setHCALData(t, featureBits, et)) {
232 LOG_ERROR <<
"caloEta = " << caloEta <<
"; caloPhi =" << caloPhi << std::endl;
233 LOG_ERROR <<
"UCT: Failed loading an HCAL tower" << std::endl;
236 expectedTotalET +=
et;
239 LOG_ERROR <<
"Illegal Tower: caloEta = " << caloEta <<
"; caloPhi =" << caloPhi <<
"; et = " << et << std::endl;
243 LOG_ERROR <<
"Illegal Tower: caloEta = " << caloEta << std::endl;
250 LOG_ERROR <<
"UCT: Failed to process layer 1" << std::endl;
255 for(uint32_t twr = 0; twr <
twrList.size(); twr++) {
264 towersColl->push_back(theBX, caloTower);
270 vector<UCTCrate*> crates =
layer1->getCrates();
271 for(uint32_t crt = 0; crt < crates.size(); crt++) {
272 vector<UCTCard*> cards = crates[crt]->getCards();
273 for(uint32_t crd = 0; crd < cards.size(); crd++) {
274 vector<UCTRegion*> regions = cards[crd]->getRegions();
275 for(uint32_t rgn = 0; rgn < regions.size(); rgn++) {
276 uint32_t rawData = regions[rgn]->rawData();
277 uint32_t regionData = rawData & 0x0000FFFF;
278 uint32_t crate = regions[rgn]->getCrate();
279 uint32_t card = regions[rgn]->getCard();
280 uint32_t region = regions[rgn]->getRegion();
281 bool negativeEta = regions[rgn]->isNegativeEta();
282 uint32_t rPhi = g.getUCTRegionPhiIndex(crate, card);
283 if(region < NRegionsInCard) {
284 uint32_t rEta = 10 - region;
285 if(!negativeEta) rEta = 11 + region;
286 rgnCollection->push_back(
L1CaloRegion((uint16_t) regionData, (
unsigned) rEta, (
unsigned) rPhi, (int16_t) 0));
312 if(!
L1TCaloLayer1FetchLUTs(iSetup,
ecalLUT,
hcalLUT,
hfLUT,
ePhiMap,
hPhiMap,
hfPhiMap,
useLSB,
useCalib,
useECALLUT,
useHCALLUT,
useHFLUT)) {
313 LOG_ERROR <<
"L1TCaloLayer1::beginRun: failed to fetch LUTS - using unity" << std::endl;
314 std::array< std::array< std::array<uint32_t, nEtBins>, nCalSideBins >, nCalEtaBins> eCalLayer1EtaSideEtArray;
315 std::array< std::array< std::array<uint32_t, nEtBins>, nCalSideBins >, nCalEtaBins> hCalLayer1EtaSideEtArray;
316 std::array< std::array<uint32_t, nEtBins>, nHfEtaBins > hfLayer1EtaEtArray;
317 ecalLUT.push_back(eCalLayer1EtaSideEtArray);
318 hcalLUT.push_back(hCalLayer1EtaSideEtArray);
319 hfLUT.push_back(hfLayer1EtaEtArray);
321 for(uint32_t twr = 0; twr <
twrList.size(); twr++) {
323 int iphi =
twrList[twr]->caloPhi();
324 int ieta =
twrList[twr]->caloEta();
bool L1TCaloLayer1FetchLUTs(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)
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
std::vector< unsigned int > hfPhiMap
bool getByToken(EDGetToken token, Handle< PROD > &result) const
virtual void endJob() override
#define DEFINE_FWK_MODULE(type)
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
std::vector< unsigned int > hPhiMap
void addDefault(ParameterSetDescription const &psetDescription)
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
et
define resolution functions of each parameter
std::vector< std::array< std::array< std::array< uint32_t, nEtBins >, nCalSideBins >, nCalEtaBins > > ecalLUT
std::string hcalTPSourceLabel
L1TCaloLayer1(const edm::ParameterSet &)
std::vector< std::array< std::array< std::array< uint32_t, nEtBins >, nCalSideBins >, nCalEtaBins > > hcalLUT
std::vector< std::array< std::array< uint32_t, nEtBins >, nHfEtaBins > > hfLUT
std::vector< unsigned int > ePhiMap
virtual void beginRun(edm::Run const &, edm::EventSetup const &) override
A calorimeter trigger region (sum of 4x4 trigger towers)
std::vector< L1CaloRegion > L1CaloRegionCollection