58 virtual void endJob()
override ;
85 m_caloTowerToken = consumes <CaloTowerBxCollection> (m_caloLabel);
87 produces<MuonCaloSumBxCollection>(
"TriggerTowerSums");
88 produces<MuonCaloSumBxCollection>(
"TriggerTower2x2s");
109 std::unique_ptr<MuonCaloSumBxCollection> towerSums (std::make_unique<MuonCaloSumBxCollection>());
110 std::unique_ptr<MuonCaloSumBxCollection> tower2x2s (std::make_unique<MuonCaloSumBxCollection>());
114 if (iEvent.
getByToken(m_caloTowerToken, caloTowers)) {
118 const int iFirstBx = caloTowers->
getFirstBX();
119 const int iLastBx = caloTowers->
getLastBX();
122 towerSums->setBXRange(iFirstBx, iLastBx);
123 tower2x2s->setBXRange(iFirstBx, iLastBx);
125 for (
int bx = iFirstBx; bx <= iLastBx; ++bx) {
126 std::map<int, MuonCaloSum> sums;
127 std::map<int, MuonCaloSum> regs;
129 for (
auto it = caloTowers->
begin(bx); it != caloTowers->
end(bx); ++it) {
131 int hwEta = twr.
hwEta();
135 int hwPt = twr.
hwPt();
139 int hwPhi = twr.
hwPhi();
142 int ieta2x2 = (hwEta + 27) / 2;
143 int iphi2x2 = hwPhi / 2;
144 int muon_idx = iphi2x2 * 28 + ieta2x2;
145 if (regs.count(muon_idx) == 0) {
146 regs[muon_idx] =
MuonCaloSum(hwPt, iphi2x2, ieta2x2, muon_idx);
148 regs.at(muon_idx).setEtBits(regs.at(muon_idx).etBits() + hwPt);
154 int ietamax = hwEta + detamax + 1;
155 for (
int ieta = hwEta-detamax; ieta < ietamax; ++ieta) {
159 int ietamu = (ieta + 27) / 2;
160 int iphimax = hwPhi + dphimax + 1;
161 for (
int iphi = hwPhi-dphimax; iphi < iphimax; ++iphi) {
162 int iphiwrapped = iphi;
163 if (iphiwrapped < 0) {
165 }
else if (iphiwrapped > 71) {
168 int iphimu = iphiwrapped / 2;
169 int idxmu = iphimu * 28 + ietamu;
170 if (sums.count(idxmu) == 0) {
171 sums[idxmu] =
MuonCaloSum(hwPt, iphimu, ietamu, idxmu);
173 sums.at(idxmu).setEtBits(sums.at(idxmu).etBits() + hwPt);
180 for (
auto it = sums.begin(); it != sums.end(); ++it) {
181 if (it->second.etBits() > 0) {
187 towerSums->push_back(bx, sum);
191 for (
auto it = regs.begin(); it != regs.end(); ++it) {
192 if (it->second.etBits() > 0) {
193 tower2x2s->push_back(bx, it->second);
198 LogWarning(
"GlobalMuon") <<
"CaloTowers not found. Producing empty collections." << std::endl;
const_iterator end(int bx) const
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
virtual void endRun(const edm::Run &, edm::EventSetup const &) override
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
edm::EDGetTokenT< CaloTowerBxCollection > m_caloTowerToken
L1TMuonCaloSumProducer(const edm::ParameterSet &)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
virtual void endJob() override
void addDefault(ParameterSetDescription const &psetDescription)
Abs< T >::type abs(const T &t)
virtual void beginLuminosityBlock(const edm::LuminosityBlock &, edm::EventSetup const &) override
virtual void produce(edm::Event &, const edm::EventSetup &) override
virtual void beginRun(const edm::Run &, edm::EventSetup const &) override
virtual void endLuminosityBlock(const edm::LuminosityBlock &, edm::EventSetup const &) override
virtual void beginJob() override
~L1TMuonCaloSumProducer()
const_iterator begin(int bx) const
edm::InputTag m_caloLabel