109 std::unique_ptr<MuonCaloSumBxCollection> towerSums (std::make_unique<MuonCaloSumBxCollection>());
110 std::unique_ptr<MuonCaloSumBxCollection> tower2x2s (std::make_unique<MuonCaloSumBxCollection>());
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
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
edm::EDGetTokenT< CaloTowerBxCollection > m_caloTowerToken
Abs< T >::type abs(const T &t)
const_iterator begin(int bx) const