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
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

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<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Description: takes generated muons and fills them in the expected collections for the MicroGMT

Implementation: [Notes on implementation]

Definition at line 47 of file L1TMuonCaloSumProducer.cc.

Constructor & Destructor Documentation

◆ L1TMuonCaloSumProducer()

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

Definition at line 77 of file L1TMuonCaloSumProducer.cc.

References edm::ParameterSet::getParameter().

77  {
78  //register your inputs:
79  m_caloLabel = iConfig.getParameter<edm::InputTag>("caloStage2Layer2Label");
80  m_caloTowerToken = consumes<CaloTowerBxCollection>(m_caloLabel);
81  //register your products
82  produces<MuonCaloSumBxCollection>("TriggerTowerSums");
83  produces<MuonCaloSumBxCollection>("TriggerTower2x2s");
84 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::EDGetTokenT< CaloTowerBxCollection > m_caloTowerToken

◆ ~L1TMuonCaloSumProducer()

L1TMuonCaloSumProducer::~L1TMuonCaloSumProducer ( )
override

Definition at line 86 of file L1TMuonCaloSumProducer.cc.

86  {
87  // do anything here that needs to be done at desctruction time
88  // (e.g. close files, deallocate resources etc.)
89 }

Member Function Documentation

◆ beginLuminosityBlock()

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

Definition at line 201 of file L1TMuonCaloSumProducer.cc.

201 {}

◆ beginRun()

void L1TMuonCaloSumProducer::beginRun ( const edm::Run ,
edm::EventSetup const &   
)
overrideprivate

Definition at line 195 of file L1TMuonCaloSumProducer.cc.

195 {}

◆ endLuminosityBlock()

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

Definition at line 204 of file L1TMuonCaloSumProducer.cc.

204 {}

◆ endRun()

void L1TMuonCaloSumProducer::endRun ( const edm::Run ,
edm::EventSetup const &   
)
overrideprivate

Definition at line 198 of file L1TMuonCaloSumProducer.cc.

198 {}

◆ fillDescriptions()

void L1TMuonCaloSumProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 207 of file L1TMuonCaloSumProducer.cc.

References edm::ConfigurationDescriptions::addDefault(), and submitPVResolutionJobs::desc.

207  {
208  //The following says we do not know what parameters are allowed so do no validation
209  // Please change this to state exactly what you do use, even if it is no parameters
211  desc.setUnknown();
212  descriptions.addDefault(desc);
213 }
void addDefault(ParameterSetDescription const &psetDescription)

◆ produce()

void L1TMuonCaloSumProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 96 of file L1TMuonCaloSumProducer.cc.

References funct::abs(), l1GtPatternGenerator_cfi::bx, eleHcalExtractorBlocks_cff::caloTowers, l1t::MuonCaloSum::etBits(), l1t::L1Candidate::hwEta(), l1t::L1Candidate::hwPhi(), l1t::L1Candidate::hwPt(), LEDCalibrationChannels::ieta, iEvent, LEDCalibrationChannels::iphi, eostools::move(), and l1t::MuonCaloSum::setEtBits().

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

Member Data Documentation

◆ m_caloLabel

edm::InputTag L1TMuonCaloSumProducer::m_caloLabel
private

Definition at line 63 of file L1TMuonCaloSumProducer.cc.

◆ m_caloTowerToken

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

Definition at line 62 of file L1TMuonCaloSumProducer.cc.