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 ()
 
virtual void beginLuminosityBlock (edm::LuminosityBlock &, edm::EventSetup const &)
 
virtual void beginRun (edm::Run &, edm::EventSetup const &)
 
virtual void endJob ()
 
virtual void endLuminosityBlock (edm::LuminosityBlock &, edm::EventSetup const &)
 
virtual void endRun (edm::Run &, edm::EventSetup const &)
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 

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  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 186 of file L1TMuonCaloSumProducer.cc.

187 {
188 }
void L1TMuonCaloSumProducer::beginLuminosityBlock ( edm::LuminosityBlock ,
edm::EventSetup const &   
)
privatevirtual

Definition at line 209 of file L1TMuonCaloSumProducer.cc.

210 {
211 }
void L1TMuonCaloSumProducer::beginRun ( edm::Run ,
edm::EventSetup const &   
)
privatevirtual

Definition at line 197 of file L1TMuonCaloSumProducer.cc.

198 {
199 }
void L1TMuonCaloSumProducer::endJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 192 of file L1TMuonCaloSumProducer.cc.

192  {
193 }
void L1TMuonCaloSumProducer::endLuminosityBlock ( edm::LuminosityBlock ,
edm::EventSetup const &   
)
privatevirtual

Definition at line 215 of file L1TMuonCaloSumProducer.cc.

216 {
217 }
void L1TMuonCaloSumProducer::endRun ( edm::Run ,
edm::EventSetup const &   
)
privatevirtual

Definition at line 203 of file L1TMuonCaloSumProducer.cc.

204 {
205 }
void L1TMuonCaloSumProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 221 of file L1TMuonCaloSumProducer.cc.

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

221  {
222  //The following says we do not know what parameters are allowed so do no validation
223  // Please change this to state exactly what you do use, even if it is no parameters
225  desc.setUnknown();
226  descriptions.addDefault(desc);
227 }
void addDefault(ParameterSetDescription const &psetDescription)
void L1TMuonCaloSumProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual

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  // Make sure that you can get genParticles
114  std::map<int, MuonCaloSum> sums;
115  std::map<int, MuonCaloSum> regs;
116 
117  if (iEvent.getByToken(m_caloTowerToken, caloTowers)) {
118  for (auto it = caloTowers->begin(0); it != caloTowers->end(0); ++it) {
119  const CaloTower& twr = *it;
120  if (std::abs(twr.hwEta()) > 27) {
121  continue;
122  }
123  int ieta2x2 = (twr.hwEta() + 27) / 2;
124  int iphi2x2 = twr.hwPhi() / 2;
125  int muon_idx = iphi2x2 * 28 + ieta2x2;
126  if (regs.count(muon_idx) == 0) {
127  regs[muon_idx] = MuonCaloSum(twr.hwPt(), iphi2x2, ieta2x2, muon_idx);
128  } else {
129  regs.at(muon_idx).setEtBits(regs.at(muon_idx).etBits() + twr.hwPt());
130  }
131 
132  // std::cout << "iphi; phi " << twr.hwPhi() << "; " << twr.phi() << " .. ieta; eta" << twr.hwEta() << "; " << twr.eta() << std::endl;
133 
134  for (int ieta = -27; ieta < 28; ++ieta) {
135  for (int iphi = 0; iphi < 72; ++iphi) {
136  int deta = std::abs(ieta - twr.hwEta());
137  int dphi = iphi - twr.hwPhi();
138  if (dphi > 36) {
139  dphi -= 72;
140  }
141  if (dphi < -36) {
142  dphi += 72;
143  }
144  dphi = std::abs(dphi);
145  if (deta <= 4 && dphi <= 4) {
146  int ietamu = (ieta + 27) / 2;
147  int iphimu = iphi / 2;
148  int idxmu = iphimu * 28 + ietamu;
149  if (sums.count(idxmu) == 0) {
150  sums[idxmu] = MuonCaloSum(twr.hwPt(), iphimu, ietamu, idxmu);
151  } else {
152  sums.at(idxmu).setEtBits(sums.at(idxmu).etBits() + twr.hwPt());
153  }
154  }
155 
156  }
157  }
158  }
159  } else {
160  LogError("GlobalMuon") << "CaloTowers not found." << std::endl;
161  }
162 
163  for (auto it = sums.begin(); it != sums.end(); ++it) {
164  if (it->second.etBits() > 0) {
165  MuonCaloSum sum = MuonCaloSum(it->second);
166  // convert Et to correct scale:
167  if (sum.etBits() > 31) {
168  sum.setEtBits(31);
169  }
170  towerSums->push_back(0, sum);
171  }
172  }
173  for (auto it = regs.begin(); it != regs.end(); ++it) {
174  if (it->second.etBits() > 0) {
175  tower2x2s->push_back(0, it->second);
176  }
177  }
178 
179  iEvent.put(towerSums, "TriggerTowerSums");
180  iEvent.put(tower2x2s, "TriggerTower2x2s");
181 
182 }
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.cc:79
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.cc:74
void setEtBits(int bits)
Definition: MuonCaloSum.h:17
int hwPt() const
Definition: L1Candidate.cc:69
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.