CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
L1TCaloLayer1 Class Reference

#include <L1Trigger/L1TCaloLayer1/plugins/L1TCaloLayer1.cc>

Inheritance diagram for L1TCaloLayer1:
edm::stream::EDProducer<>

Public Member Functions

 L1TCaloLayer1 (const edm::ParameterSet &)
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Member Functions

void beginRun (edm::Run const &, edm::EventSetup const &) override
 
void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

std::vector< std::array< std::array< std::array< uint32_t, nEtBins >, nCalSideBins >, nCalEtaBins > > ecalLUT
 
edm::EDGetTokenT< EcalTrigPrimDigiCollectionecalTPSource
 
std::vector< unsigned int > ePhiMap
 
int fwVersion
 
std::vector< std::array< std::array< std::array< uint32_t, nEtBins >, nCalSideBins >, nCalEtaBins > > hcalLUT
 
edm::EDGetTokenT< HcalTrigPrimDigiCollectionhcalTPSource
 
std::vector< std::array< std::array< uint32_t, nEtBins >, nHfEtaBins > > hfLUT
 
std::vector< unsigned int > hfPhiMap
 
std::vector< unsigned int > hPhiMap
 
std::unique_ptr< UCTLayer1 > layer1
 
const L1TCaloLayer1FetchLUTsTokens lutsTokens
 
edm::EDPutTokenT< L1CaloRegionCollectionregionPutToken
 
edm::EDPutTokenT< CaloTowerBxCollectiontowerPutToken
 
std::vector< UCTTower * > twrList
 
bool unpackEcalMask
 
bool unpackHcalMask
 
bool useCalib
 
bool useECALLUT
 
bool useHCALLUT
 
bool useHFLUT
 
bool useLSB
 
bool verbose
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Description: [one line class summary]

Implementation: [Notes on implementation]

Definition at line 58 of file L1TCaloLayer1.cc.

Constructor & Destructor Documentation

◆ L1TCaloLayer1()

L1TCaloLayer1::L1TCaloLayer1 ( const edm::ParameterSet iConfig)
explicit

Definition at line 115 of file L1TCaloLayer1.cc.

116  : ecalTPSource(consumes<EcalTrigPrimDigiCollection>(iConfig.getParameter<edm::InputTag>("ecalToken"))),
117  hcalTPSource(consumes<HcalTrigPrimDigiCollection>(iConfig.getParameter<edm::InputTag>("hcalToken"))),
118  towerPutToken{produces<CaloTowerBxCollection>()},
119  regionPutToken{produces<L1CaloRegionCollection>()},
120  lutsTokens{esConsumes<edm::Transition::BeginRun>(),
121  esConsumes<edm::Transition::BeginRun>(),
122  esConsumes<edm::Transition::BeginRun>()},
123  ePhiMap(72 * 2, 0),
124  hPhiMap(72 * 2, 0),
125  hfPhiMap(72 * 2, 0),
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")),
132  unpackHcalMask(iConfig.getParameter<bool>("unpackHcalMask")),
133  unpackEcalMask(iConfig.getParameter<bool>("unpackEcalMask")),
134  fwVersion(iConfig.getParameter<int>("firmwareVersion")) {
135  // See UCTLayer1.hh for firmware version definitions
136  layer1 = std::make_unique<UCTLayer1>(fwVersion);
137 
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++) {
144  vector<UCTTower*> towers = regions[rgn]->getTowers();
145  for (uint32_t twr = 0; twr < towers.size(); twr++) {
146  twrList.push_back(towers[twr]);
147  }
148  }
149  }
150  }
151 
152  // This sort corresponds to the sort condition on
153  // the output CaloTowerBxCollection
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());
156  });
157 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::vector< unsigned int > hfPhiMap
edm::EDGetTokenT< HcalTrigPrimDigiCollection > hcalTPSource
std::unique_ptr< UCTLayer1 > layer1
edm::EDPutTokenT< L1CaloRegionCollection > regionPutToken
std::vector< UCTTower * > twrList
edm::EDGetTokenT< EcalTrigPrimDigiCollection > ecalTPSource
const L1TCaloLayer1FetchLUTsTokens lutsTokens
double b
Definition: hdecay.h:118
edm::EDPutTokenT< CaloTowerBxCollection > towerPutToken
std::vector< unsigned int > hPhiMap
double a
Definition: hdecay.h:119
std::vector< unsigned int > ePhiMap

Member Function Documentation

◆ beginRun()

void L1TCaloLayer1::beginRun ( edm::Run const &  iRun,
edm::EventSetup const &  iSetup 
)
overrideprivate

Definition at line 294 of file L1TCaloLayer1.cc.

References ecalLUT, ePhiMap, fwVersion, hcalLUT, hfLUT, hfPhiMap, hPhiMap, LEDCalibrationChannels::ieta, LEDCalibrationChannels::iphi, L1TCaloLayer1FetchLUTs(), LOG_ERROR, lutsTokens, twrList, useCalib, useECALLUT, useHCALLUT, useHFLUT, and useLSB.

294  {
296  iSetup,
297  ecalLUT,
298  hcalLUT,
299  hfLUT,
300  ePhiMap,
301  hPhiMap,
302  hfPhiMap,
303  useLSB,
304  useCalib,
305  useECALLUT,
306  useHCALLUT,
307  useHFLUT,
308  fwVersion)) {
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);
316  }
317  for (uint32_t twr = 0; twr < twrList.size(); twr++) {
318  // Map goes minus 1 .. 72 plus 1 .. 72 -> 0 .. 143
319  int iphi = twrList[twr]->caloPhi();
320  int ieta = twrList[twr]->caloEta();
321  if (ieta < 0) {
322  iphi -= 1;
323  } else {
324  iphi += 71;
325  }
326  twrList[twr]->setECALLUT(&ecalLUT[ePhiMap[iphi]]);
327  twrList[twr]->setHCALLUT(&hcalLUT[hPhiMap[iphi]]);
328  twrList[twr]->setHFLUT(&hfLUT[hfPhiMap[iphi]]);
329  }
330 }
std::vector< std::array< std::array< uint32_t, nEtBins >, nHfEtaBins > > hfLUT
std::vector< unsigned int > hfPhiMap
std::vector< std::array< std::array< std::array< uint32_t, nEtBins >, nCalSideBins >, nCalEtaBins > > ecalLUT
std::vector< std::array< std::array< std::array< uint32_t, nEtBins >, nCalSideBins >, nCalEtaBins > > hcalLUT
std::vector< UCTTower * > twrList
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)
const L1TCaloLayer1FetchLUTsTokens lutsTokens
std::vector< unsigned int > hPhiMap
std::vector< unsigned int > ePhiMap
#define LOG_ERROR
Definition: CSCDQM_Logger.h:40

◆ fillDescriptions()

void L1TCaloLayer1::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 357 of file L1TCaloLayer1.cc.

References edm::ConfigurationDescriptions::addDefault(), and submitPVResolutionJobs::desc.

357  {
358  //The following says we do not know what parameters are allowed so do no validation
359  // Please change this to state exactly what you do use, even if it is no parameters
361  desc.setUnknown();
362  descriptions.addDefault(desc);
363 }
void addDefault(ParameterSetDescription const &psetDescription)

◆ produce()

void L1TCaloLayer1::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 164 of file L1TCaloLayer1.cc.

References funct::abs(), ecalTPSource, EgHLTOffHistBins_cfi::et, g, hcalTPSource, iEvent, edm::HandleBase::isValid(), layer1, LOG_ERROR, eostools::move(), BXVector< T >::push_back(), l1tstage2_dqm_sourceclient-live_cfg::rawData, HLT_2022v11_cff::region, regionPutToken, l1t::L1Candidate::setHwEta(), l1t::CaloTower::setHwEtEm(), l1t::CaloTower::setHwEtHad(), l1t::CaloTower::setHwEtRatio(), l1t::L1Candidate::setHwPhi(), l1t::L1Candidate::setHwPt(), l1t::L1Candidate::setHwQual(), submitPVValidationJobs::t, towerPutToken, twrList, unpackEcalMask, unpackHcalMask, and testProducerWithPsetDescEmpty_cfi::x1.

164  {
165  using namespace edm;
166 
168  iEvent.getByToken(ecalTPSource, ecalTPs);
170  iEvent.getByToken(hcalTPSource, hcalTPs);
171 
172  CaloTowerBxCollection towersColl;
173  L1CaloRegionCollection rgnCollection;
174 
175  uint32_t expectedTotalET = 0;
176  if (!layer1->clearEvent()) {
177  LOG_ERROR << "UCT: Failed to clear event" << std::endl;
178  return;
179  }
180 
181  for (const auto& ecalTp : *ecalTPs) {
182  if (unpackEcalMask && ((ecalTp.sample(0).raw() >> 13) & 0x1))
183  continue;
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;
191  return;
192  }
193  expectedTotalET += et;
194  }
195 
196  if (hcalTPs.isValid()) {
197  for (const auto& hcalTp : *hcalTPs) {
198  if (unpackHcalMask && ((hcalTp.sample(0).raw() >> 13) & 0x1))
199  continue;
200  int caloEta = hcalTp.id().ieta();
201  uint32_t absCaloEta = std::abs(caloEta);
202  // Tower 29 is not used by Layer-1
203  if (absCaloEta == 29) {
204  continue;
205  }
206  // Prevent usage of HF TPs with Layer-1 emulator if HCAL TPs are old style
207  else if (hcalTp.id().version() == 0 && absCaloEta > 29) {
208  continue;
209  } else if (absCaloEta <= 41) {
210  int caloPhi = hcalTp.id().iphi();
211  int et = hcalTp.SOI_compressedEt();
212  bool fg = hcalTp.t0().fineGrain(0); // depth
213  bool fg2 = hcalTp.t0().fineGrain(1); // prompt
214  bool fg3 = hcalTp.t0().fineGrain(2); // delay 1
215  bool fg4 = hcalTp.t0().fineGrain(3); // delay 2
216  // note that hcalTp.t0().fineGrain(4) and hcalTp.t0().fineGrain(5) are the reserved MIP bits (not used for LLP logic)
217  if (caloPhi <= 72) {
218  UCTTowerIndex t = UCTTowerIndex(caloEta, caloPhi);
219  uint32_t featureBits = 0;
220  if (absCaloEta > 29) {
221  if (fg)
222  featureBits |= 0b01;
223  // fg2 should only be set for HF
224  if (fg2)
225  featureBits |= 0b10;
226  } else
227  featureBits |= (fg | ((!fg2) & (fg3 | fg4))); // depth | (!prompt & (delay1 | delay2))
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;
231  return;
232  }
233  expectedTotalET += et;
234  } else {
235  LOG_ERROR << "Illegal Tower: caloEta = " << caloEta << "; caloPhi =" << caloPhi << "; et = " << et
236  << std::endl;
237  }
238  } else {
239  LOG_ERROR << "Illegal Tower: caloEta = " << caloEta << std::endl;
240  }
241  }
242  }
243 
244  //Process
245  if (!layer1->process()) {
246  LOG_ERROR << "UCT: Failed to process layer 1" << std::endl;
247  }
248 
249  int theBX = 0; // Currently we only read and process the "hit" BX only
250 
251  for (uint32_t twr = 0; twr < twrList.size(); twr++) {
252  CaloTower caloTower;
253  caloTower.setHwPt(twrList[twr]->et()); // Bits 0-8 of the 16-bit word per the interface protocol document
254  caloTower.setHwEtRatio(twrList[twr]->er()); // Bits 9-11 of the 16-bit word per the interface protocol document
255  caloTower.setHwQual(twrList[twr]->miscBits()); // Bits 12-15 of the 16-bit word per the interface protocol document
256  caloTower.setHwEta(twrList[twr]->caloEta()); // caloEta = 1-28 and 30-41
257  caloTower.setHwPhi(twrList[twr]->caloPhi()); // caloPhi = 1-72
258  caloTower.setHwEtEm(twrList[twr]->getEcalET()); // This is provided as a courtesy - not available to hardware
259  caloTower.setHwEtHad(twrList[twr]->getHcalET()); // This is provided as a courtesy - not available to hardware
260  towersColl.push_back(theBX, caloTower);
261  }
262 
263  iEvent.emplace(towerPutToken, std::move(towersColl));
264 
265  UCTGeometry g;
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++) {
272  uint32_t rawData = regions[rgn]->rawData();
273  uint32_t regionData = rawData & 0x0000FFFF;
274  uint32_t crate = regions[rgn]->getCrate();
275  uint32_t card = regions[rgn]->getCard();
276  uint32_t region = regions[rgn]->getRegion();
277  bool negativeEta = regions[rgn]->isNegativeEta();
278  uint32_t rPhi = g.getUCTRegionPhiIndex(crate, card);
279  if (region < NRegionsInCard) { // We only store the Barrel and Endcap - HF has changed in the upgrade
280  uint32_t rEta =
281  10 -
282  region; // UCT region is 0-6 for B/E but GCT eta goes 0-21, 0-3 -HF, 4-10 -B/E, 11-17 +B/E, 18-21 +HF
283  if (!negativeEta)
284  rEta = 11 + region; // Positive eta portion is offset by 11
285  rgnCollection.push_back(L1CaloRegion((uint16_t)regionData, (unsigned)rEta, (unsigned)rPhi, (int16_t)0));
286  }
287  }
288  }
289  }
290  iEvent.emplace(regionPutToken, std::move(rgnCollection));
291 }
edm::EDGetTokenT< HcalTrigPrimDigiCollection > hcalTPSource
void setHwQual(int qual)
Definition: L1Candidate.h:31
void setHwEtHad(int et)
Definition: CaloTower.cc:29
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
Definition: Activities.doc:4
std::unique_ptr< UCTLayer1 > layer1
edm::EDPutTokenT< L1CaloRegionCollection > regionPutToken
int iEvent
Definition: GenABIO.cc:224
std::vector< UCTTower * > twrList
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
void setHwEtRatio(int ratio)
Definition: CaloTower.cc:31
edm::EDGetTokenT< EcalTrigPrimDigiCollection > ecalTPSource
void setHwPhi(int phi)
Definition: L1Candidate.h:30
edm::EDPutTokenT< CaloTowerBxCollection > towerPutToken
bool isValid() const
Definition: HandleBase.h:70
HLT enums.
void setHwPt(int pt)
Definition: L1Candidate.h:28
A calorimeter trigger region (sum of 4x4 trigger towers)
Definition: L1CaloRegion.h:21
void setHwEta(int eta)
Definition: L1Candidate.h:29
std::vector< L1CaloRegion > L1CaloRegionCollection
void setHwEtEm(int et)
Definition: CaloTower.cc:27
def move(src, dest)
Definition: eostools.py:511
#define LOG_ERROR
Definition: CSCDQM_Logger.h:40
void push_back(int bx, T object)

Member Data Documentation

◆ ecalLUT

std::vector<std::array<std::array<std::array<uint32_t, nEtBins>, nCalSideBins>, nCalEtaBins> > L1TCaloLayer1::ecalLUT
private

Definition at line 81 of file L1TCaloLayer1.cc.

Referenced by beginRun().

◆ ecalTPSource

edm::EDGetTokenT<EcalTrigPrimDigiCollection> L1TCaloLayer1::ecalTPSource
private

Definition at line 75 of file L1TCaloLayer1.cc.

Referenced by produce().

◆ ePhiMap

std::vector<unsigned int> L1TCaloLayer1::ePhiMap
private

Definition at line 85 of file L1TCaloLayer1.cc.

Referenced by beginRun().

◆ fwVersion

int L1TCaloLayer1::fwVersion
private

Definition at line 99 of file L1TCaloLayer1.cc.

Referenced by beginRun().

◆ hcalLUT

std::vector<std::array<std::array<std::array<uint32_t, nEtBins>, nCalSideBins>, nCalEtaBins> > L1TCaloLayer1::hcalLUT
private

Definition at line 82 of file L1TCaloLayer1.cc.

Referenced by beginRun().

◆ hcalTPSource

edm::EDGetTokenT<HcalTrigPrimDigiCollection> L1TCaloLayer1::hcalTPSource
private

Definition at line 76 of file L1TCaloLayer1.cc.

Referenced by produce().

◆ hfLUT

std::vector<std::array<std::array<uint32_t, nEtBins>, nHfEtaBins> > L1TCaloLayer1::hfLUT
private

Definition at line 83 of file L1TCaloLayer1.cc.

Referenced by beginRun().

◆ hfPhiMap

std::vector<unsigned int> L1TCaloLayer1::hfPhiMap
private

Definition at line 87 of file L1TCaloLayer1.cc.

Referenced by beginRun().

◆ hPhiMap

std::vector<unsigned int> L1TCaloLayer1::hPhiMap
private

Definition at line 86 of file L1TCaloLayer1.cc.

Referenced by beginRun().

◆ layer1

std::unique_ptr<UCTLayer1> L1TCaloLayer1::layer1
private

Definition at line 101 of file L1TCaloLayer1.cc.

Referenced by produce().

◆ lutsTokens

const L1TCaloLayer1FetchLUTsTokens L1TCaloLayer1::lutsTokens
private

Definition at line 79 of file L1TCaloLayer1.cc.

Referenced by beginRun().

◆ regionPutToken

edm::EDPutTokenT<L1CaloRegionCollection> L1TCaloLayer1::regionPutToken
private

Definition at line 78 of file L1TCaloLayer1.cc.

Referenced by produce().

◆ towerPutToken

edm::EDPutTokenT<CaloTowerBxCollection> L1TCaloLayer1::towerPutToken
private

Definition at line 77 of file L1TCaloLayer1.cc.

Referenced by produce().

◆ twrList

std::vector<UCTTower*> L1TCaloLayer1::twrList
private

Definition at line 89 of file L1TCaloLayer1.cc.

Referenced by beginRun(), and produce().

◆ unpackEcalMask

bool L1TCaloLayer1::unpackEcalMask
private

Definition at line 98 of file L1TCaloLayer1.cc.

Referenced by produce().

◆ unpackHcalMask

bool L1TCaloLayer1::unpackHcalMask
private

Definition at line 97 of file L1TCaloLayer1.cc.

Referenced by produce().

◆ useCalib

bool L1TCaloLayer1::useCalib
private

Definition at line 92 of file L1TCaloLayer1.cc.

Referenced by beginRun().

◆ useECALLUT

bool L1TCaloLayer1::useECALLUT
private

Definition at line 93 of file L1TCaloLayer1.cc.

Referenced by beginRun().

◆ useHCALLUT

bool L1TCaloLayer1::useHCALLUT
private

Definition at line 94 of file L1TCaloLayer1.cc.

Referenced by beginRun().

◆ useHFLUT

bool L1TCaloLayer1::useHFLUT
private

Definition at line 95 of file L1TCaloLayer1.cc.

Referenced by beginRun().

◆ useLSB

bool L1TCaloLayer1::useLSB
private

Definition at line 91 of file L1TCaloLayer1.cc.

Referenced by beginRun().

◆ verbose

bool L1TCaloLayer1::verbose
private