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 hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () 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 59 of file L1TCaloLayer1.cc.

Constructor & Destructor Documentation

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

Definition at line 118 of file L1TCaloLayer1.cc.

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

118  :
119  ecalTPSource(consumes<EcalTrigPrimDigiCollection>(iConfig.getParameter<edm::InputTag>("ecalToken"))),
120  hcalTPSource(consumes<HcalTrigPrimDigiCollection>(iConfig.getParameter<edm::InputTag>("hcalToken"))),
121  towerPutToken{produces<CaloTowerBxCollection>()},
122  regionPutToken{produces<L1CaloRegionCollection>()},
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 {
136 
137  // See UCTLayer1.hh for firmware version definitions
138  layer1 = std::make_unique<UCTLayer1>(fwVersion);
139 
140  vector<UCTCrate*> crates = layer1->getCrates();
141  for(uint32_t crt = 0; crt < crates.size(); crt++) {
142  vector<UCTCard*> cards = crates[crt]->getCards();
143  for(uint32_t crd = 0; crd < cards.size(); crd++) {
144  vector<UCTRegion*> regions = cards[crd]->getRegions();
145  for(uint32_t rgn = 0; rgn < regions.size(); rgn++) {
146  vector<UCTTower*> towers = regions[rgn]->getTowers();
147  for(uint32_t twr = 0; twr < towers.size(); twr++) {
148  twrList.push_back(towers[twr]);
149  }
150  }
151  }
152  }
153 
154  // This sort corresponds to the sort condition on
155  // the output CaloTowerBxCollection
156  std::sort(twrList.begin(), twrList.end(), [](UCTTower* a, UCTTower* b) {
157  return CaloTools::caloTowerHash(a->caloEta(), a->caloPhi()) < CaloTools::caloTowerHash(b->caloEta(), b->caloPhi());
158  });
159 }
T getParameter(std::string const &) const
std::vector< unsigned int > hfPhiMap
edm::EDGetTokenT< HcalTrigPrimDigiCollection > hcalTPSource
std::vector< UCTTower * > twrList
std::unique_ptr< UCTLayer1 > layer1
edm::EDPutTokenT< L1CaloRegionCollection > regionPutToken
std::vector< unsigned int > hPhiMap
edm::EDGetTokenT< EcalTrigPrimDigiCollection > ecalTPSource
double b
Definition: hdecay.h:120
edm::EDPutTokenT< CaloTowerBxCollection > towerPutToken
double a
Definition: hdecay.h:121
std::vector< unsigned int > ePhiMap

Member Function Documentation

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

Definition at line 292 of file L1TCaloLayer1.cc.

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

293 {
295  LOG_ERROR << "L1TCaloLayer1::beginRun: failed to fetch LUTS - using unity" << std::endl;
296  std::array< std::array< std::array<uint32_t, nEtBins>, nCalSideBins >, nCalEtaBins> eCalLayer1EtaSideEtArray;
297  std::array< std::array< std::array<uint32_t, nEtBins>, nCalSideBins >, nCalEtaBins> hCalLayer1EtaSideEtArray;
298  std::array< std::array<uint32_t, nEtBins>, nHfEtaBins > hfLayer1EtaEtArray;
299  ecalLUT.push_back(eCalLayer1EtaSideEtArray);
300  hcalLUT.push_back(hCalLayer1EtaSideEtArray);
301  hfLUT.push_back(hfLayer1EtaEtArray);
302  }
303  for(uint32_t twr = 0; twr < twrList.size(); twr++) {
304  // Map goes minus 1 .. 72 plus 1 .. 72 -> 0 .. 143
305  int iphi = twrList[twr]->caloPhi();
306  int ieta = twrList[twr]->caloEta();
307  if (ieta<0) {
308  iphi -= 1;
309  }
310  else {
311  iphi += 71;
312  }
313  twrList[twr]->setECALLUT(&ecalLUT[ePhiMap[iphi]]);
314  twrList[twr]->setHCALLUT(&hcalLUT[hPhiMap[iphi]]);
315  twrList[twr]->setHFLUT(&hfLUT[hfPhiMap[iphi]]);
316  }
317 }
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< UCTTower * > twrList
std::vector< unsigned int > hPhiMap
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< std::array< std::array< uint32_t, nEtBins >, nHfEtaBins > > hfLUT
std::vector< unsigned int > ePhiMap
#define LOG_ERROR
Definition: CSCDQM_Logger.h:41
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 167 of file L1TCaloLayer1.cc.

References funct::abs(), ecalTPSource, edm::Event::emplace(), stringResolutionProvider_cfi::et, g, edm::Event::getByToken(), hcalTPSource, edm::HandleBase::isValid(), layer1, LOG_ERROR, eostools::move(), BXVector< T >::push_back(), regionPutToken, l1t::L1Candidate::setHwEta(), l1t::CaloTower::setHwEtEm(), l1t::CaloTower::setHwEtHad(), l1t::CaloTower::setHwEtRatio(), l1t::L1Candidate::setHwPhi(), l1t::L1Candidate::setHwPt(), l1t::L1Candidate::setHwQual(), protons_cff::t, towerPutToken, twrList, unpackEcalMask, unpackHcalMask, and globals_cff::x1.

168 {
169  using namespace edm;
170 
172  iEvent.getByToken(ecalTPSource, ecalTPs);
174  iEvent.getByToken(hcalTPSource, hcalTPs);
175 
176  CaloTowerBxCollection towersColl;
177  L1CaloRegionCollection rgnCollection;
178 
179  uint32_t expectedTotalET = 0;
180  if(!layer1->clearEvent()) {
181  LOG_ERROR << "UCT: Failed to clear event" << std::endl;
182  return;
183  }
184 
185  for ( const auto& ecalTp : *ecalTPs ) {
186  if ( unpackEcalMask && ((ecalTp.sample(0).raw()>>13) & 0x1) ) continue;
187  int caloEta = ecalTp.id().ieta();
188  int caloPhi = ecalTp.id().iphi();
189  int et = ecalTp.compressedEt();
190  bool fgVeto = ecalTp.fineGrain();
191  UCTTowerIndex t = UCTTowerIndex(caloEta, caloPhi);
192  if(!layer1->setECALData(t,fgVeto,et)) {
193  LOG_ERROR << "UCT: Failed loading an ECAL tower" << std::endl;
194  return;
195  }
196  expectedTotalET += et;
197  }
198 
199 
200  if(hcalTPs.isValid()){
201  for ( const auto& hcalTp : *hcalTPs ) {
202  if ( unpackHcalMask && ((hcalTp.sample(0).raw()>>13) & 0x1) ) continue;
203  int caloEta = hcalTp.id().ieta();
204  uint32_t absCaloEta = std::abs(caloEta);
205  // Tower 29 is not used by Layer-1
206  if(absCaloEta == 29) {
207  continue;
208  }
209  // Prevent usage of HF TPs with Layer-1 emulator if HCAL TPs are old style
210  else if(hcalTp.id().version() == 0 && absCaloEta > 29) {
211  continue;
212  }
213  else if(absCaloEta <= 41) {
214  int caloPhi = hcalTp.id().iphi();
215  int et = hcalTp.SOI_compressedEt();
216  bool fg = hcalTp.t0().fineGrain(0);
217  bool fg2 = hcalTp.t0().fineGrain(1);
218  if(caloPhi <= 72) {
219  UCTTowerIndex t = UCTTowerIndex(caloEta, caloPhi);
220  uint32_t featureBits = 0;
221  if(fg) featureBits |= 0b01;
222  // fg2 should only be set for HF
223  if(absCaloEta > 29 && fg2) featureBits |= 0b10;
224  if(!layer1->setHCALData(t, featureBits, et)) {
225  LOG_ERROR << "caloEta = " << caloEta << "; caloPhi =" << caloPhi << std::endl;
226  LOG_ERROR << "UCT: Failed loading an HCAL tower" << std::endl;
227  return;
228  }
229  expectedTotalET += et;
230  }
231  else {
232  LOG_ERROR << "Illegal Tower: caloEta = " << caloEta << "; caloPhi =" << caloPhi << "; et = " << et << std::endl;
233  }
234  }
235  else {
236  LOG_ERROR << "Illegal Tower: caloEta = " << caloEta << std::endl;
237  }
238  }
239  }
240 
241  //Process
242  if(!layer1->process()) {
243  LOG_ERROR << "UCT: Failed to process layer 1" << std::endl;
244  }
245 
246  int theBX = 0; // Currently we only read and process the "hit" BX only
247 
248  for(uint32_t twr = 0; twr < twrList.size(); twr++) {
249  CaloTower caloTower;
250  caloTower.setHwPt(twrList[twr]->et()); // Bits 0-8 of the 16-bit word per the interface protocol document
251  caloTower.setHwEtRatio(twrList[twr]->er()); // Bits 9-11 of the 16-bit word per the interface protocol document
252  caloTower.setHwQual(twrList[twr]->miscBits()); // Bits 12-15 of the 16-bit word per the interface protocol document
253  caloTower.setHwEta(twrList[twr]->caloEta()); // caloEta = 1-28 and 30-41
254  caloTower.setHwPhi(twrList[twr]->caloPhi()); // caloPhi = 1-72
255  caloTower.setHwEtEm(twrList[twr]->getEcalET()); // This is provided as a courtesy - not available to hardware
256  caloTower.setHwEtHad(twrList[twr]->getHcalET()); // This is provided as a courtesy - not available to hardware
257  towersColl.push_back(theBX, caloTower);
258  }
259 
260  iEvent.emplace(towerPutToken,std::move(towersColl));
261 
262  UCTGeometry g;
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) { // We only store the Barrel and Endcap - HF has changed in the upgrade
277  uint32_t rEta = 10 - 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
278  if(!negativeEta) rEta = 11 + region; // Positive eta portion is offset by 11
279  rgnCollection.push_back(L1CaloRegion((uint16_t) regionData, (unsigned) rEta, (unsigned) rPhi, (int16_t) 0));
280  }
281  }
282  }
283  }
284  iEvent.emplace(regionPutToken,std::move(rgnCollection));
285 
286 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
edm::EDGetTokenT< HcalTrigPrimDigiCollection > hcalTPSource
void setHwQual(int qual)
Definition: L1Candidate.h:44
void setHwEtHad(int et)
Definition: CaloTower.cc:44
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
Definition: Activities.doc:4
std::unique_ptr< UCTLayer1 > layer1
edm::EDPutTokenT< L1CaloRegionCollection > regionPutToken
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
bool isValid() const
Definition: HandleBase.h:74
void setHwEtRatio(int ratio)
Definition: CaloTower.cc:49
edm::EDGetTokenT< EcalTrigPrimDigiCollection > ecalTPSource
void setHwPhi(int phi)
Definition: L1Candidate.h:43
OrphanHandle< PROD > emplace(EDPutTokenT< PROD > token, Args &&...args)
puts a new product
Definition: Event.h:413
edm::EDPutTokenT< CaloTowerBxCollection > towerPutToken
et
define resolution functions of each parameter
HLT enums.
void setHwPt(int pt)
Definition: L1Candidate.h:41
A calorimeter trigger region (sum of 4x4 trigger towers)
Definition: L1CaloRegion.h:22
void setHwEta(int eta)
Definition: L1Candidate.h:42
std::vector< L1CaloRegion > L1CaloRegionCollection
void setHwEtEm(int et)
Definition: CaloTower.cc:39
def move(src, dest)
Definition: eostools.py:511
#define LOG_ERROR
Definition: CSCDQM_Logger.h:41
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 82 of file L1TCaloLayer1.cc.

Referenced by beginRun().

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

Definition at line 76 of file L1TCaloLayer1.cc.

Referenced by produce().

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

Definition at line 86 of file L1TCaloLayer1.cc.

Referenced by beginRun(), and L1TCaloLayer1().

int L1TCaloLayer1::fwVersion
private

Definition at line 100 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 83 of file L1TCaloLayer1.cc.

Referenced by beginRun().

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

Definition at line 77 of file L1TCaloLayer1.cc.

Referenced by produce().

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

Definition at line 84 of file L1TCaloLayer1.cc.

Referenced by beginRun().

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

Definition at line 88 of file L1TCaloLayer1.cc.

Referenced by beginRun(), and L1TCaloLayer1().

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

Definition at line 87 of file L1TCaloLayer1.cc.

Referenced by beginRun(), and L1TCaloLayer1().

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

Definition at line 102 of file L1TCaloLayer1.cc.

Referenced by L1TCaloLayer1(), and produce().

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

Definition at line 79 of file L1TCaloLayer1.cc.

Referenced by L1TCaloLayer1(), and produce().

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

Definition at line 78 of file L1TCaloLayer1.cc.

Referenced by produce().

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

Definition at line 90 of file L1TCaloLayer1.cc.

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

bool L1TCaloLayer1::unpackEcalMask
private

Definition at line 99 of file L1TCaloLayer1.cc.

Referenced by L1TCaloLayer1(), and produce().

bool L1TCaloLayer1::unpackHcalMask
private

Definition at line 98 of file L1TCaloLayer1.cc.

Referenced by L1TCaloLayer1(), and produce().

bool L1TCaloLayer1::useCalib
private

Definition at line 93 of file L1TCaloLayer1.cc.

Referenced by beginRun(), and L1TCaloLayer1().

bool L1TCaloLayer1::useECALLUT
private

Definition at line 94 of file L1TCaloLayer1.cc.

Referenced by beginRun(), and L1TCaloLayer1().

bool L1TCaloLayer1::useHCALLUT
private

Definition at line 95 of file L1TCaloLayer1.cc.

Referenced by beginRun(), and L1TCaloLayer1().

bool L1TCaloLayer1::useHFLUT
private

Definition at line 96 of file L1TCaloLayer1.cc.

Referenced by beginRun(), and L1TCaloLayer1().

bool L1TCaloLayer1::useLSB
private

Definition at line 92 of file L1TCaloLayer1.cc.

Referenced by beginRun(), and L1TCaloLayer1().

bool L1TCaloLayer1::verbose
private