80 m_caloTowerToken = consumes<CaloTowerBxCollection>(m_caloLabel);
82 produces<MuonCaloSumBxCollection>(
"TriggerTowerSums");
83 produces<MuonCaloSumBxCollection>(
"TriggerTower2x2s");
98 std::unique_ptr<MuonCaloSumBxCollection> towerSums(std::make_unique<MuonCaloSumBxCollection>());
99 std::unique_ptr<MuonCaloSumBxCollection> tower2x2s(std::make_unique<MuonCaloSumBxCollection>());
107 const int iFirstBx =
caloTowers->getFirstBX();
111 towerSums->setBXRange(iFirstBx, iLastBx);
112 tower2x2s->setBXRange(iFirstBx, iLastBx);
114 for (
int bx = iFirstBx;
bx <= iLastBx; ++
bx) {
115 std::map<int, MuonCaloSum> sums;
116 std::map<int, MuonCaloSum> regs;
120 int hwEta = twr.
hwEta();
124 int hwPt = twr.
hwPt();
128 int hwPhi = twr.
hwPhi();
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);
137 regs.at(muon_idx).setEtBits(regs.at(muon_idx).etBits() + hwPt);
143 int ietamax = hwEta + detamax + 1;
144 for (
int ieta = hwEta - detamax;
ieta < ietamax; ++
ieta) {
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) {
154 }
else if (iphiwrapped > 71) {
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);
162 sums.at(idxmu).setEtBits(sums.at(idxmu).etBits() + hwPt);
169 for (
auto it = sums.begin(); it != sums.end(); ++it) {
170 if (it->second.etBits() > 0) {
176 towerSums->push_back(
bx, sum);
180 for (
auto it = regs.begin(); it != regs.end(); ++it) {
181 if (it->second.etBits() > 0) {
182 tower2x2s->push_back(
bx, it->second);
187 LogWarning(
"GlobalMuon") <<
"CaloTowers not found. Producing empty collections." << std::endl;