83 m_caloTowerToken = consumes <CaloTowerBxCollection> (m_caloLabel);
85 produces<MuonCaloSumBxCollection>(
"TriggerTowerSums");
86 produces<MuonCaloSumBxCollection>(
"TriggerTower2x2s");
107 std::unique_ptr<MuonCaloSumBxCollection> towerSums (std::make_unique<MuonCaloSumBxCollection>());
108 std::unique_ptr<MuonCaloSumBxCollection> tower2x2s (std::make_unique<MuonCaloSumBxCollection>());
112 if (iEvent.
getByToken(m_caloTowerToken, caloTowers)) {
116 const int iFirstBx = caloTowers->
getFirstBX();
117 const int iLastBx = caloTowers->
getLastBX();
120 towerSums->setBXRange(iFirstBx, iLastBx);
121 tower2x2s->setBXRange(iFirstBx, iLastBx);
123 for (
int bx = iFirstBx; bx <= iLastBx; ++bx) {
124 std::map<int, MuonCaloSum> sums;
125 std::map<int, MuonCaloSum> regs;
127 for (
auto it = caloTowers->
begin(bx); it != caloTowers->
end(bx); ++it) {
129 int hwEta = twr.
hwEta();
133 int hwPt = twr.
hwPt();
137 int hwPhi = twr.
hwPhi();
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);
146 regs.at(muon_idx).setEtBits(regs.at(muon_idx).etBits() + hwPt);
152 int ietamax = hwEta + detamax + 1;
153 for (
int ieta = hwEta-detamax; ieta < ietamax; ++ieta) {
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) {
163 }
else if (iphiwrapped > 71) {
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);
171 sums.at(idxmu).setEtBits(sums.at(idxmu).etBits() + hwPt);
178 for (
auto it = sums.begin(); it != sums.end(); ++it) {
179 if (it->second.etBits() > 0) {
185 towerSums->push_back(bx, sum);
189 for (
auto it = regs.begin(); it != regs.end(); ++it) {
190 if (it->second.etBits() > 0) {
191 tower2x2s->push_back(bx, it->second);
196 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.
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)
void addDefault(ParameterSetDescription const &psetDescription)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Abs< T >::type abs(const T &t)
void beginLuminosityBlock(const edm::LuminosityBlock &, edm::EventSetup const &) override
void produce(edm::Event &, const edm::EventSetup &) override
void beginRun(const edm::Run &, edm::EventSetup const &) override
void endLuminosityBlock(const edm::LuminosityBlock &, edm::EventSetup const &) override
~L1TMuonCaloSumProducer() override
const_iterator begin(int bx) const
edm::InputTag m_caloLabel