CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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)
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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
< CaloTowerBxCollection
m_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 201 of file L1TMuonCaloSumProducer.cc.

202 {
203 }
void L1TMuonCaloSumProducer::beginLuminosityBlock ( const edm::LuminosityBlock ,
edm::EventSetup const &   
)
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 224 of file L1TMuonCaloSumProducer.cc.

225 {
226 }
void L1TMuonCaloSumProducer::beginRun ( const edm::Run ,
edm::EventSetup const &   
)
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 212 of file L1TMuonCaloSumProducer.cc.

213 {
214 }
void L1TMuonCaloSumProducer::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 207 of file L1TMuonCaloSumProducer.cc.

207  {
208 }
void L1TMuonCaloSumProducer::endLuminosityBlock ( const edm::LuminosityBlock ,
edm::EventSetup const &   
)
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 230 of file L1TMuonCaloSumProducer.cc.

231 {
232 }
void L1TMuonCaloSumProducer::endRun ( const edm::Run ,
edm::EventSetup const &   
)
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 218 of file L1TMuonCaloSumProducer.cc.

219 {
220 }
void L1TMuonCaloSumProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 236 of file L1TMuonCaloSumProducer.cc.

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

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

Implements edm::EDProducer.

Definition at line 106 of file L1TMuonCaloSumProducer.cc.

References funct::abs(), HLT_25ns10e33_v2_cff::caloTowers, l1t::MuonCaloSum::etBits(), edm::Event::getByToken(), l1t::L1Candidate::hwEta(), l1t::L1Candidate::hwPhi(), l1t::L1Candidate::hwPt(), edm::Event::put(), and l1t::MuonCaloSum::setEtBits().

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