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 hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () 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 47 of file L1TMuonCaloSumProducer.cc.

Constructor & Destructor Documentation

◆ L1TMuonCaloSumProducer()

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

Definition at line 77 of file L1TMuonCaloSumProducer.cc.

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 }

References edm::ParameterSet::getParameter().

◆ ~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.

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 }

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

◆ produce()

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

Definition at line 96 of file L1TMuonCaloSumProducer.cc.

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 }

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().

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.

l1t::MuonCaloSum::etBits
const int etBits() const
Definition: MuonCaloSum.h:20
l1t::L1Candidate::hwPhi
int hwPhi() const
Definition: L1Candidate.h:37
edm
HLT enums.
Definition: AlignableModifier.h:19
l1GtPatternGenerator_cfi.bx
bx
Definition: l1GtPatternGenerator_cfi.py:18
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
L1TMuonCaloSumProducer::m_caloLabel
edm::InputTag m_caloLabel
Definition: L1TMuonCaloSumProducer.cc:63
edm::Handle
Definition: AssociativeIterator.h:50
l1t::CaloTower
Definition: CaloTower.h:12
LEDCalibrationChannels.iphi
iphi
Definition: LEDCalibrationChannels.py:64
l1t::L1Candidate::hwEta
int hwEta() const
Definition: L1Candidate.h:36
l1t::MuonCaloSum::setEtBits
void setEtBits(int bits)
Definition: MuonCaloSum.h:15
edm::LogWarning
Definition: MessageLogger.h:141
LEDCalibrationChannels.ieta
ieta
Definition: LEDCalibrationChannels.py:63
L1TMuonCaloSumProducer::m_caloTowerToken
edm::EDGetTokenT< CaloTowerBxCollection > m_caloTowerToken
Definition: L1TMuonCaloSumProducer.cc:62
eleHcalExtractorBlocks_cff.caloTowers
caloTowers
Definition: eleHcalExtractorBlocks_cff.py:15
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::ParameterSetDescription::setUnknown
void setUnknown()
Definition: ParameterSetDescription.cc:39
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
eostools.move
def move(src, dest)
Definition: eostools.py:511
l1t::MuonCaloSum
Definition: MuonCaloSum.h:7
l1t::L1Candidate::hwPt
int hwPt() const
Definition: L1Candidate.h:35
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
edm::ConfigurationDescriptions::addDefault
void addDefault(ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:99
edm::InputTag
Definition: InputTag.h:15