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::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 L1TCaloLayer1 (const edm::ParameterSet &)
 
 ~L1TCaloLayer1 ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Member Functions

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

Private Attributes

std::vector< std::vector< std::vector< uint32_t > > > ecalLUT
 
edm::EDGetTokenT< EcalTrigPrimDigiCollectionecalTPSource
 
std::string ecalTPSourceLabel
 
std::vector< std::vector< std::vector< uint32_t > > > hcalLUT
 
edm::EDGetTokenT< HcalTrigPrimDigiCollectionhcalTPSource
 
std::string hcalTPSourceLabel
 
std::vector< std::vector< uint32_t > > hfLUT
 
UCTLayer1 * layer1
 
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::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

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 115 of file L1TCaloLayer1.cc.

References a, b, hgcalDigitizer_cfi::fwVersion, edm::ParameterSet::getParameter(), layer1, and twrList.

115  :
116  ecalTPSource(consumes<EcalTrigPrimDigiCollection>(iConfig.getParameter<edm::InputTag>("ecalToken"))),
117  ecalTPSourceLabel(iConfig.getParameter<edm::InputTag>("ecalToken").label()),
118  hcalTPSource(consumes<HcalTrigPrimDigiCollection>(iConfig.getParameter<edm::InputTag>("hcalToken"))),
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"))
131 {
132  produces<CaloTowerBxCollection>();
133  produces<L1CaloRegionCollection>();
134 
135  // See UCTLayer1.hh for firmware version definitions
136  int fwVersion = iConfig.getParameter<int>("firmwareVersion");
137  layer1 = new UCTLayer1(fwVersion);
138 
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]);
148  }
149  }
150  }
151  }
152 
153  // This sort corresponds to the sort condition on
154  // the output CaloTowerBxCollection
155  std::sort(twrList.begin(), twrList.end(), [](UCTTower* a, UCTTower* b) {
156  return CaloTools::caloTowerHash(a->caloEta(), a->caloPhi()) < CaloTools::caloTowerHash(b->caloEta(), b->caloPhi());
157  });
158 }
T getParameter(std::string const &) const
std::vector< std::vector< std::vector< uint32_t > > > hcalLUT
std::vector< std::vector< uint32_t > > hfLUT
edm::EDGetTokenT< HcalTrigPrimDigiCollection > hcalTPSource
std::vector< UCTTower * > twrList
std::vector< std::vector< std::vector< uint32_t > > > ecalLUT
std::string ecalTPSourceLabel
edm::EDGetTokenT< EcalTrigPrimDigiCollection > ecalTPSource
UCTLayer1 * layer1
double b
Definition: hdecay.h:120
std::string hcalTPSourceLabel
std::string const & label() const
Definition: InputTag.h:36
double a
Definition: hdecay.h:121
L1TCaloLayer1::~L1TCaloLayer1 ( )

Definition at line 160 of file L1TCaloLayer1.cc.

References layer1.

160  {
161  if(layer1 != 0) delete layer1;
162 }
UCTLayer1 * layer1

Member Function Documentation

void L1TCaloLayer1::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 295 of file L1TCaloLayer1.cc.

296 {
297 }
void L1TCaloLayer1::beginRun ( edm::Run const &  ,
edm::EventSetup const &   
)
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 306 of file L1TCaloLayer1.cc.

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

307 {
309  LOG_ERROR << "L1TCaloLayer1::beginRun: failed to fetch LUTS - using unity" << std::endl;
310  }
311  for(uint32_t twr = 0; twr < twrList.size(); twr++) {
312  twrList[twr]->setECALLUT(&ecalLUT);
313  twrList[twr]->setHCALLUT(&hcalLUT);
314  twrList[twr]->setHFLUT(&hfLUT);
315  }
316 }
std::vector< std::vector< std::vector< uint32_t > > > hcalLUT
std::vector< std::vector< uint32_t > > hfLUT
std::vector< UCTTower * > twrList
std::vector< std::vector< std::vector< uint32_t > > > ecalLUT
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)
#define LOG_ERROR
Definition: CSCDQM_Logger.h:41
void L1TCaloLayer1::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 301 of file L1TCaloLayer1.cc.

301  {
302 }
void L1TCaloLayer1::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 345 of file L1TCaloLayer1.cc.

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

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

Definition at line 170 of file L1TCaloLayer1.cc.

References funct::abs(), ecalTPSource, stringResolutionProvider_cfi::et, g, edm::Event::getByToken(), hcalTPSource, edm::HandleBase::isValid(), layer1, LOG_ERROR, eostools::move(), edm::Event::put(), l1t::L1Candidate::setHwEta(), l1t::CaloTower::setHwEtEm(), l1t::CaloTower::setHwEtHad(), l1t::CaloTower::setHwEtRatio(), l1t::L1Candidate::setHwPhi(), l1t::L1Candidate::setHwPt(), l1t::L1Candidate::setHwQual(), lumiQTWidget::t, twrList, unpackEcalMask, and unpackHcalMask.

171 {
172  using namespace edm;
173 
175  iEvent.getByToken(ecalTPSource, ecalTPs);
177  iEvent.getByToken(hcalTPSource, hcalTPs);
178 
179  std::unique_ptr<CaloTowerBxCollection> towersColl (new CaloTowerBxCollection);
180  std::unique_ptr<L1CaloRegionCollection> rgnCollection (new L1CaloRegionCollection);
181 
182  uint32_t expectedTotalET = 0;
183  if(!layer1->clearEvent()) {
184  LOG_ERROR << "UCT: Failed to clear event" << std::endl;
185  return;
186  }
187 
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;
197  return;
198  }
199  expectedTotalET += et;
200  }
201 
202 
203  if(hcalTPs.isValid()){
204  for ( const auto& hcalTp : *hcalTPs ) {
205  if ( unpackHcalMask && ((hcalTp.sample(0).raw()>>13) & 0x1) ) continue;
206  int caloEta = hcalTp.id().ieta();
207  uint32_t absCaloEta = abs(caloEta);
208  // Tower 29 is not used by Layer-1
209  if(absCaloEta == 29) {
210  continue;
211  }
212  // Prevent usage of HF TPs with Layer-1 emulator if HCAL TPs are old style
213  else if(hcalTp.id().version() == 0 && absCaloEta > 29) {
214  continue;
215  }
216  else if(absCaloEta <= 41) {
217  int caloPhi = hcalTp.id().iphi();
218  int et = hcalTp.SOI_compressedEt();
219  bool fg = hcalTp.t0().fineGrain(0);
220  bool fg2 = hcalTp.t0().fineGrain(1);
221  if(caloPhi <= 72) {
222  UCTTowerIndex t = UCTTowerIndex(caloEta, caloPhi);
223  uint32_t featureBits = 0;
224  if(fg) featureBits |= 0b01;
225  // fg2 should only be set for HF
226  if(absCaloEta > 29 && fg2) featureBits |= 0b10;
227  if(!layer1->setHCALData(t, featureBits, et)) {
228  LOG_ERROR << "caloEta = " << caloEta << "; caloPhi =" << caloPhi << std::endl;
229  LOG_ERROR << "UCT: Failed loading an HCAL tower" << std::endl;
230  return;
231  }
232  expectedTotalET += et;
233  }
234  else {
235  LOG_ERROR << "Illegal Tower: caloEta = " << caloEta << "; caloPhi =" << caloPhi << "; et = " << et << std::endl;
236  }
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.put(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 = 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
281  if(!negativeEta) rEta = 11 + region; // Positive eta portion is offset by 11
282  rgnCollection->push_back(L1CaloRegion((uint16_t) regionData, (unsigned) rEta, (unsigned) rPhi, (int16_t) 0));
283  }
284  }
285  }
286  }
287  iEvent.put(std::move(rgnCollection));
288 
289 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
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
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
UCTLayer1 * layer1
void setHwPhi(int phi)
Definition: L1Candidate.h:43
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:510
#define LOG_ERROR
Definition: CSCDQM_Logger.h:41

Member Data Documentation

std::vector< std::vector< std::vector < uint32_t > > > L1TCaloLayer1::ecalLUT
private

Definition at line 84 of file L1TCaloLayer1.cc.

Referenced by beginRun().

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

Definition at line 79 of file L1TCaloLayer1.cc.

Referenced by produce().

std::string L1TCaloLayer1::ecalTPSourceLabel
private

Definition at line 80 of file L1TCaloLayer1.cc.

std::vector< std::vector< std::vector < uint32_t > > > L1TCaloLayer1::hcalLUT
private

Definition at line 85 of file L1TCaloLayer1.cc.

Referenced by beginRun().

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

Definition at line 81 of file L1TCaloLayer1.cc.

Referenced by produce().

std::string L1TCaloLayer1::hcalTPSourceLabel
private

Definition at line 82 of file L1TCaloLayer1.cc.

std::vector< std::vector< uint32_t > > L1TCaloLayer1::hfLUT
private

Definition at line 86 of file L1TCaloLayer1.cc.

Referenced by beginRun().

UCTLayer1* L1TCaloLayer1::layer1
private

Definition at line 99 of file L1TCaloLayer1.cc.

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

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 produce().

bool L1TCaloLayer1::unpackHcalMask
private

Definition at line 96 of file L1TCaloLayer1.cc.

Referenced by produce().

bool L1TCaloLayer1::useCalib
private

Definition at line 91 of file L1TCaloLayer1.cc.

Referenced by beginRun().

bool L1TCaloLayer1::useECALLUT
private

Definition at line 92 of file L1TCaloLayer1.cc.

Referenced by beginRun().

bool L1TCaloLayer1::useHCALLUT
private

Definition at line 93 of file L1TCaloLayer1.cc.

Referenced by beginRun().

bool L1TCaloLayer1::useHFLUT
private

Definition at line 94 of file L1TCaloLayer1.cc.

Referenced by beginRun().

bool L1TCaloLayer1::useLSB
private

Definition at line 90 of file L1TCaloLayer1.cc.

Referenced by beginRun().

bool L1TCaloLayer1::verbose
private