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
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

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
 
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<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache 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 ( const edm::ParameterSet iConfig)
explicit

Definition at line 114 of file L1TCaloLayer1.cc.

References a, b, ePhiMap, fwVersion, hfPhiMap, hPhiMap, layer1, regionPutToken, HLT_2018_cff::towers, twrList, unpackEcalMask, unpackHcalMask, useCalib, useECALLUT, useHCALLUT, useHFLUT, useLSB, and verbose.

115  : ecalTPSource(consumes<EcalTrigPrimDigiCollection>(iConfig.getParameter<edm::InputTag>("ecalToken"))),
116  hcalTPSource(consumes<HcalTrigPrimDigiCollection>(iConfig.getParameter<edm::InputTag>("hcalToken"))),
117  towerPutToken{produces<CaloTowerBxCollection>()},
118  regionPutToken{produces<L1CaloRegionCollection>()},
119  ePhiMap(72 * 2, 0),
120  hPhiMap(72 * 2, 0),
121  hfPhiMap(72 * 2, 0),
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")),
128  unpackHcalMask(iConfig.getParameter<bool>("unpackHcalMask")),
129  unpackEcalMask(iConfig.getParameter<bool>("unpackEcalMask")),
130  fwVersion(iConfig.getParameter<int>("firmwareVersion")) {
131  // See UCTLayer1.hh for firmware version definitions
132  layer1 = std::make_unique<UCTLayer1>(fwVersion);
133 
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++) {
140  vector<UCTTower*> towers = regions[rgn]->getTowers();
141  for (uint32_t twr = 0; twr < towers.size(); twr++) {
142  twrList.push_back(towers[twr]);
143  }
144  }
145  }
146  }
147 
148  // This sort corresponds to the sort condition on
149  // the output CaloTowerBxCollection
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());
152  });
153 }
T getParameter(std::string const &) const
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
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

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

Definition at line 284 of file L1TCaloLayer1.cc.

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

284  {
285  if (!L1TCaloLayer1FetchLUTs(iSetup,
286  ecalLUT,
287  hcalLUT,
288  hfLUT,
289  ePhiMap,
290  hPhiMap,
291  hfPhiMap,
292  useLSB,
293  useCalib,
294  useECALLUT,
295  useHCALLUT,
296  useHFLUT,
297  fwVersion)) {
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);
305  }
306  for (uint32_t twr = 0; twr < twrList.size(); twr++) {
307  // Map goes minus 1 .. 72 plus 1 .. 72 -> 0 .. 143
308  int iphi = twrList[twr]->caloPhi();
309  int ieta = twrList[twr]->caloEta();
310  if (ieta < 0) {
311  iphi -= 1;
312  } else {
313  iphi += 71;
314  }
315  twrList[twr]->setECALLUT(&ecalLUT[ePhiMap[iphi]]);
316  twrList[twr]->setHCALLUT(&hcalLUT[hPhiMap[iphi]]);
317  twrList[twr]->setHFLUT(&hfLUT[hfPhiMap[iphi]]);
318  }
319 }
std::vector< std::array< std::array< uint32_t, nEtBins >, nHfEtaBins > > hfLUT
std::vector< unsigned int > hfPhiMap
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, int fwVersion)
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
std::vector< unsigned int > hPhiMap
std::vector< unsigned int > ePhiMap
#define LOG_ERROR
Definition: CSCDQM_Logger.h:40
void L1TCaloLayer1::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 346 of file L1TCaloLayer1.cc.

References edm::ConfigurationDescriptions::addDefault(), DEFINE_FWK_MODULE, and edm::ParameterSetDescription::setUnknown().

346  {
347  //The following says we do not know what parameters are allowed so do no validation
348  // Please change this to state exactly what you do use, even if it is no parameters
350  desc.setUnknown();
351  descriptions.addDefault(desc);
352 }
void addDefault(ParameterSetDescription const &psetDescription)
void L1TCaloLayer1::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 160 of file L1TCaloLayer1.cc.

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

160  {
161  using namespace edm;
162 
164  iEvent.getByToken(ecalTPSource, ecalTPs);
166  iEvent.getByToken(hcalTPSource, hcalTPs);
167 
168  CaloTowerBxCollection towersColl;
169  L1CaloRegionCollection rgnCollection;
170 
171  uint32_t expectedTotalET = 0;
172  if (!layer1->clearEvent()) {
173  LOG_ERROR << "UCT: Failed to clear event" << std::endl;
174  return;
175  }
176 
177  for (const auto& ecalTp : *ecalTPs) {
178  if (unpackEcalMask && ((ecalTp.sample(0).raw() >> 13) & 0x1))
179  continue;
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;
187  return;
188  }
189  expectedTotalET += et;
190  }
191 
192  if (hcalTPs.isValid()) {
193  for (const auto& hcalTp : *hcalTPs) {
194  if (unpackHcalMask && ((hcalTp.sample(0).raw() >> 13) & 0x1))
195  continue;
196  int caloEta = hcalTp.id().ieta();
197  uint32_t absCaloEta = std::abs(caloEta);
198  // Tower 29 is not used by Layer-1
199  if (absCaloEta == 29) {
200  continue;
201  }
202  // Prevent usage of HF TPs with Layer-1 emulator if HCAL TPs are old style
203  else if (hcalTp.id().version() == 0 && absCaloEta > 29) {
204  continue;
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);
210  if (caloPhi <= 72) {
211  UCTTowerIndex t = UCTTowerIndex(caloEta, caloPhi);
212  uint32_t featureBits = 0;
213  if (fg)
214  featureBits |= 0b01;
215  // fg2 should only be set for HF
216  if (absCaloEta > 29 && fg2)
217  featureBits |= 0b10;
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;
221  return;
222  }
223  expectedTotalET += et;
224  } else {
225  LOG_ERROR << "Illegal Tower: caloEta = " << caloEta << "; caloPhi =" << caloPhi << "; et = " << et
226  << std::endl;
227  }
228  } else {
229  LOG_ERROR << "Illegal Tower: caloEta = " << caloEta << std::endl;
230  }
231  }
232  }
233 
234  //Process
235  if (!layer1->process()) {
236  LOG_ERROR << "UCT: Failed to process layer 1" << std::endl;
237  }
238 
239  int theBX = 0; // Currently we only read and process the "hit" BX only
240 
241  for (uint32_t twr = 0; twr < twrList.size(); twr++) {
242  CaloTower caloTower;
243  caloTower.setHwPt(twrList[twr]->et()); // Bits 0-8 of the 16-bit word per the interface protocol document
244  caloTower.setHwEtRatio(twrList[twr]->er()); // Bits 9-11 of the 16-bit word per the interface protocol document
245  caloTower.setHwQual(twrList[twr]->miscBits()); // Bits 12-15 of the 16-bit word per the interface protocol document
246  caloTower.setHwEta(twrList[twr]->caloEta()); // caloEta = 1-28 and 30-41
247  caloTower.setHwPhi(twrList[twr]->caloPhi()); // caloPhi = 1-72
248  caloTower.setHwEtEm(twrList[twr]->getEcalET()); // This is provided as a courtesy - not available to hardware
249  caloTower.setHwEtHad(twrList[twr]->getHcalET()); // This is provided as a courtesy - not available to hardware
250  towersColl.push_back(theBX, caloTower);
251  }
252 
253  iEvent.emplace(towerPutToken, std::move(towersColl));
254 
255  UCTGeometry g;
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++) {
262  uint32_t rawData = regions[rgn]->rawData();
263  uint32_t regionData = rawData & 0x0000FFFF;
264  uint32_t crate = regions[rgn]->getCrate();
265  uint32_t card = regions[rgn]->getCard();
266  uint32_t region = regions[rgn]->getRegion();
267  bool negativeEta = regions[rgn]->isNegativeEta();
268  uint32_t rPhi = g.getUCTRegionPhiIndex(crate, card);
269  if (region < NRegionsInCard) { // We only store the Barrel and Endcap - HF has changed in the upgrade
270  uint32_t rEta =
271  10 -
272  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
273  if (!negativeEta)
274  rEta = 11 + region; // Positive eta portion is offset by 11
275  rgnCollection.push_back(L1CaloRegion((uint16_t)regionData, (unsigned)rEta, (unsigned)rPhi, (int16_t)0));
276  }
277  }
278  }
279  }
280  iEvent.emplace(regionPutToken, std::move(rgnCollection));
281 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
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
std::vector< UCTTower * > twrList
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
bool isValid() const
Definition: HandleBase.h:70
void setHwEtRatio(int ratio)
Definition: CaloTower.cc:31
edm::EDGetTokenT< EcalTrigPrimDigiCollection > ecalTPSource
void setHwPhi(int phi)
Definition: L1Candidate.h:30
OrphanHandle< PROD > emplace(EDPutTokenT< PROD > token, Args &&...args)
puts a new product
Definition: Event.h:421
edm::EDPutTokenT< CaloTowerBxCollection > towerPutToken
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

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

Definition at line 80 of file L1TCaloLayer1.cc.

Referenced by beginRun().

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

Definition at line 75 of file L1TCaloLayer1.cc.

Referenced by produce().

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

Definition at line 84 of file L1TCaloLayer1.cc.

Referenced by beginRun(), and L1TCaloLayer1().

int L1TCaloLayer1::fwVersion
private

Definition at line 98 of file L1TCaloLayer1.cc.

Referenced by beginRun(), and L1TCaloLayer1().

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

Definition at line 81 of file L1TCaloLayer1.cc.

Referenced by beginRun().

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

Definition at line 76 of file L1TCaloLayer1.cc.

Referenced by produce().

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

Definition at line 82 of file L1TCaloLayer1.cc.

Referenced by beginRun().

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

Definition at line 86 of file L1TCaloLayer1.cc.

Referenced by beginRun(), and L1TCaloLayer1().

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

Definition at line 85 of file L1TCaloLayer1.cc.

Referenced by beginRun(), and L1TCaloLayer1().

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

Definition at line 100 of file L1TCaloLayer1.cc.

Referenced by L1TCaloLayer1(), and produce().

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

Definition at line 78 of file L1TCaloLayer1.cc.

Referenced by L1TCaloLayer1(), and produce().

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

Definition at line 77 of file L1TCaloLayer1.cc.

Referenced by produce().

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

Definition at line 88 of file L1TCaloLayer1.cc.

Referenced by beginRun(), L1TCaloLayer1(), and produce().

bool L1TCaloLayer1::unpackEcalMask
private

Definition at line 97 of file L1TCaloLayer1.cc.

Referenced by L1TCaloLayer1(), and produce().

bool L1TCaloLayer1::unpackHcalMask
private

Definition at line 96 of file L1TCaloLayer1.cc.

Referenced by L1TCaloLayer1(), and produce().

bool L1TCaloLayer1::useCalib
private

Definition at line 91 of file L1TCaloLayer1.cc.

Referenced by beginRun(), and L1TCaloLayer1().

bool L1TCaloLayer1::useECALLUT
private

Definition at line 92 of file L1TCaloLayer1.cc.

Referenced by beginRun(), and L1TCaloLayer1().

bool L1TCaloLayer1::useHCALLUT
private

Definition at line 93 of file L1TCaloLayer1.cc.

Referenced by beginRun(), and L1TCaloLayer1().

bool L1TCaloLayer1::useHFLUT
private

Definition at line 94 of file L1TCaloLayer1.cc.

Referenced by beginRun(), and L1TCaloLayer1().

bool L1TCaloLayer1::useLSB
private

Definition at line 90 of file L1TCaloLayer1.cc.

Referenced by beginRun(), and L1TCaloLayer1().

bool L1TCaloLayer1::verbose
private