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::stream::EDProducer<>

Public Member Functions

 L1TMuonCaloSumProducer (const edm::ParameterSet &)
 
 ~L1TMuonCaloSumProducer () override
 
- 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 beginLuminosityBlock (const edm::LuminosityBlock &, edm::EventSetup const &) override
 
void beginRun (const edm::Run &, edm::EventSetup const &) override
 
void endLuminosityBlock (const edm::LuminosityBlock &, edm::EventSetup const &) override
 
void endRun (const edm::Run &, edm::EventSetup const &) override
 
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::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: 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 80 of file L1TMuonCaloSumProducer.cc.

References edm::ParameterSet::getParameter().

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

Definition at line 90 of file L1TMuonCaloSumProducer.cc.

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

Member Function Documentation

void L1TMuonCaloSumProducer::beginLuminosityBlock ( const edm::LuminosityBlock ,
edm::EventSetup const &   
)
overrideprivate

Definition at line 218 of file L1TMuonCaloSumProducer.cc.

219 {
220 }
void L1TMuonCaloSumProducer::beginRun ( const edm::Run ,
edm::EventSetup const &   
)
overrideprivate

Definition at line 206 of file L1TMuonCaloSumProducer.cc.

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

Definition at line 224 of file L1TMuonCaloSumProducer.cc.

225 {
226 }
void L1TMuonCaloSumProducer::endRun ( const edm::Run ,
edm::EventSetup const &   
)
overrideprivate

Definition at line 212 of file L1TMuonCaloSumProducer.cc.

213 {
214 }
void L1TMuonCaloSumProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 230 of file L1TMuonCaloSumProducer.cc.

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

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

Definition at line 104 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().

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

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

Definition at line 63 of file L1TMuonCaloSumProducer.cc.