CMS 3D CMS Logo

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

#include <L1Trigger/L1TGlobalMuon/plugins/L1TMuonCaloSumProducer.cc>

Inheritance diagram for L1TMuonCaloSumProducer:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 L1TMuonCaloSumProducer (const edm::ParameterSet &)
 
 ~L1TMuonCaloSumProducer ()
 
- 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 & itemsToGetFrom (BranchType iType) 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 beginLuminosityBlock (const edm::LuminosityBlock &, edm::EventSetup const &) override
 
virtual void beginRun (const edm::Run &, edm::EventSetup const &) override
 
virtual void endJob () override
 
virtual void endLuminosityBlock (const edm::LuminosityBlock &, edm::EventSetup const &) override
 
virtual void endRun (const edm::Run &, edm::EventSetup const &) override
 
virtual void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

edm::InputTag m_caloLabel
 
edm::EDGetTokenT< CaloTowerBxCollectionm_caloTowerToken
 

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: takes generated muons and fills them in the expected collections for the MicroGMT

Implementation: [Notes on implementation]

Definition at line 48 of file L1TMuonCaloSumProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 82 of file L1TMuonCaloSumProducer.cc.

References edm::ParameterSet::getParameter().

82  {
83  //register your inputs:
84  m_caloLabel = iConfig.getParameter<edm::InputTag> ("caloStage2Layer2Label");
85  m_caloTowerToken = consumes <CaloTowerBxCollection> (m_caloLabel);
86  //register your products
87  produces<MuonCaloSumBxCollection>("TriggerTowerSums");
88  produces<MuonCaloSumBxCollection>("TriggerTower2x2s");
89 }
T getParameter(std::string const &) const
edm::EDGetTokenT< CaloTowerBxCollection > m_caloTowerToken
L1TMuonCaloSumProducer::~L1TMuonCaloSumProducer ( )

Definition at line 92 of file L1TMuonCaloSumProducer.cc.

93 {
94  // do anything here that needs to be done at desctruction time
95  // (e.g. close files, deallocate resources etc.)
96 }

Member Function Documentation

void L1TMuonCaloSumProducer::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 208 of file L1TMuonCaloSumProducer.cc.

209 {
210 }
void L1TMuonCaloSumProducer::beginLuminosityBlock ( const edm::LuminosityBlock ,
edm::EventSetup const &   
)
overrideprivatevirtual

Definition at line 231 of file L1TMuonCaloSumProducer.cc.

232 {
233 }
void L1TMuonCaloSumProducer::beginRun ( const edm::Run ,
edm::EventSetup const &   
)
overrideprivatevirtual

Definition at line 219 of file L1TMuonCaloSumProducer.cc.

220 {
221 }
void L1TMuonCaloSumProducer::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 214 of file L1TMuonCaloSumProducer.cc.

214  {
215 }
void L1TMuonCaloSumProducer::endLuminosityBlock ( const edm::LuminosityBlock ,
edm::EventSetup const &   
)
overrideprivatevirtual

Definition at line 237 of file L1TMuonCaloSumProducer.cc.

238 {
239 }
void L1TMuonCaloSumProducer::endRun ( const edm::Run ,
edm::EventSetup const &   
)
overrideprivatevirtual

Definition at line 225 of file L1TMuonCaloSumProducer.cc.

226 {
227 }
void L1TMuonCaloSumProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 243 of file L1TMuonCaloSumProducer.cc.

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

243  {
244  //The following says we do not know what parameters are allowed so do no validation
245  // Please change this to state exactly what you do use, even if it is no parameters
247  desc.setUnknown();
248  descriptions.addDefault(desc);
249 }
void addDefault(ParameterSetDescription const &psetDescription)
void L1TMuonCaloSumProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Definition at line 106 of file L1TMuonCaloSumProducer.cc.

References funct::abs(), BXVector< T >::begin(), eleHcalExtractorBlocks_cff::caloTowers, BXVector< T >::end(), l1t::MuonCaloSum::etBits(), edm::Event::getByToken(), BXVector< T >::getFirstBX(), BXVector< T >::getLastBX(), l1t::L1Candidate::hwEta(), l1t::L1Candidate::hwPhi(), l1t::L1Candidate::hwPt(), eostools::move(), edm::Event::put(), and l1t::MuonCaloSum::setEtBits().

107 {
108  using namespace edm;
109  std::unique_ptr<MuonCaloSumBxCollection> towerSums (std::make_unique<MuonCaloSumBxCollection>());
110  std::unique_ptr<MuonCaloSumBxCollection> tower2x2s (std::make_unique<MuonCaloSumBxCollection>());
111 
113 
114  if (iEvent.getByToken(m_caloTowerToken, caloTowers)) {
115  int detamax = 4;
116  int dphimax = 4;
117 
118  const int iFirstBx = caloTowers->getFirstBX();
119  const int iLastBx = caloTowers->getLastBX();
120 
121  // set BX range for sums
122  towerSums->setBXRange(iFirstBx, iLastBx);
123  tower2x2s->setBXRange(iFirstBx, iLastBx);
124 
125  for (int bx = iFirstBx; bx <= iLastBx; ++bx) {
126  std::map<int, MuonCaloSum> sums;
127  std::map<int, MuonCaloSum> regs;
128 
129  for (auto it = caloTowers->begin(bx); it != caloTowers->end(bx); ++it) {
130  const CaloTower& twr = *it;
131  int hwEta = twr.hwEta();
132  if (std::abs(hwEta) > 27) {
133  continue;
134  }
135  int hwPt = twr.hwPt();
136  if (hwPt < 1) {
137  continue;
138  }
139  int hwPhi = twr.hwPhi();
140 
141  // calculating tower2x2s
142  int ieta2x2 = (hwEta + 27) / 2;
143  int iphi2x2 = hwPhi / 2;
144  int muon_idx = iphi2x2 * 28 + ieta2x2;
145  if (regs.count(muon_idx) == 0) {
146  regs[muon_idx] = MuonCaloSum(hwPt, iphi2x2, ieta2x2, muon_idx);
147  } else {
148  regs.at(muon_idx).setEtBits(regs.at(muon_idx).etBits() + hwPt);
149  }
150 
151  // std::cout << "iphi; phi " << hwPhi << "; " << phi << " .. ieta; eta" << hwEta << "; " << twr.eta() << std::endl;
152 
153  // calculating towerSums
154  int ietamax = hwEta + detamax + 1;
155  for (int ieta = hwEta-detamax; ieta < ietamax; ++ieta) {
156  if (std::abs(ieta) > 27) {
157  continue;
158  }
159  int ietamu = (ieta + 27) / 2;
160  int iphimax = hwPhi + dphimax + 1;
161  for (int iphi = hwPhi-dphimax; iphi < iphimax; ++iphi) {
162  int iphiwrapped = iphi;
163  if (iphiwrapped < 0) {
164  iphiwrapped += 72;
165  } else if (iphiwrapped > 71) {
166  iphiwrapped -= 72;
167  }
168  int iphimu = iphiwrapped / 2;
169  int idxmu = iphimu * 28 + ietamu;
170  if (sums.count(idxmu) == 0) {
171  sums[idxmu] = MuonCaloSum(hwPt, iphimu, ietamu, idxmu);
172  } else {
173  sums.at(idxmu).setEtBits(sums.at(idxmu).etBits() + hwPt);
174  }
175  }
176  }
177  }
178 
179  // fill towerSums output collection for this BX
180  for (auto it = sums.begin(); it != sums.end(); ++it) {
181  if (it->second.etBits() > 0) {
182  MuonCaloSum sum = MuonCaloSum(it->second);
183  // convert Et to correct scale:
184  if (sum.etBits() > 31) {
185  sum.setEtBits(31);
186  }
187  towerSums->push_back(bx, sum);
188  }
189  }
190  // fill tower2x2s output collection for this BX
191  for (auto it = regs.begin(); it != regs.end(); ++it) {
192  if (it->second.etBits() > 0) {
193  tower2x2s->push_back(bx, it->second);
194  }
195  }
196  }
197  } else {
198  LogWarning("GlobalMuon") << "CaloTowers not found. Producing empty collections." << std::endl;
199  }
200 
201  iEvent.put(std::move(towerSums), "TriggerTowerSums");
202  iEvent.put(std::move(tower2x2s), "TriggerTower2x2s");
203 
204 }
const_iterator end(int bx) const
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:460
edm::EDGetTokenT< CaloTowerBxCollection > m_caloTowerToken
int hwPhi() const
Definition: L1Candidate.h:50
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int hwEta() const
Definition: L1Candidate.h:49
void setEtBits(int bits)
Definition: MuonCaloSum.h:17
int getFirstBX() const
int hwPt() const
Definition: L1Candidate.h:48
HLT enums.
int getLastBX() const
const_iterator begin(int bx) const
def move(src, dest)
Definition: eostools.py:510
const int etBits() const
Definition: MuonCaloSum.h:22

Member Data Documentation

edm::InputTag L1TMuonCaloSumProducer::m_caloLabel
private

Definition at line 66 of file L1TMuonCaloSumProducer.cc.

edm::EDGetTokenT<CaloTowerBxCollection> L1TMuonCaloSumProducer::m_caloTowerToken
private

Definition at line 65 of file L1TMuonCaloSumProducer.cc.