File indexing completed on 2023-03-17 10:47:12
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #include <cmath>
0016
0017
0018 #include "CondFormats/L1TObjects/interface/L1CaloGeometry.h"
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055 L1CaloGeometry::L1CaloGeometry()
0056 : m_version(kOrig),
0057 m_numberGctEmJetPhiBins(0),
0058 m_numberGctEtSumPhiBins(0),
0059 m_numberGctHtSumPhiBins(0),
0060 m_numberGctCentralEtaBinsPerHalf(0),
0061 m_numberGctForwardEtaBinsPerHalf(0),
0062 m_etaSignBitOffset(0),
0063 m_gctEtaBinBoundaries(),
0064 m_etaBinsPerHalf(0),
0065 m_gctEmJetPhiBinWidth(0.),
0066 m_gctEtSumPhiBinWidth(0.),
0067 m_gctHtSumPhiBinWidth(0.),
0068 m_gctEmJetPhiOffset(0.),
0069 m_gctEtSumPhiOffset(0.),
0070 m_gctHtSumPhiOffset(0.) {}
0071
0072 L1CaloGeometry::L1CaloGeometry(unsigned int numberGctEmJetPhiBins,
0073 double gctEmJetPhiBinOffset,
0074 unsigned int numberGctEtSumPhiBins,
0075 double gctEtSumPhiBinOffset,
0076 unsigned int numberGctHtSumPhiBins,
0077 double gctHtSumPhiBinOffset,
0078 unsigned int numberGctCentralEtaBinsPerHalf,
0079 unsigned int numberGctForwardEtaBinsPerHalf,
0080 unsigned int etaSignBitOffset,
0081 const std::vector<double>& gctEtaBinBoundaries)
0082 : m_version(kAddedMHTPhi),
0083 m_numberGctEmJetPhiBins(numberGctEmJetPhiBins),
0084 m_numberGctEtSumPhiBins(numberGctEtSumPhiBins),
0085 m_numberGctHtSumPhiBins(numberGctHtSumPhiBins),
0086 m_numberGctCentralEtaBinsPerHalf(numberGctCentralEtaBinsPerHalf),
0087 m_numberGctForwardEtaBinsPerHalf(numberGctForwardEtaBinsPerHalf),
0088 m_etaSignBitOffset(etaSignBitOffset),
0089 m_gctEtaBinBoundaries(gctEtaBinBoundaries) {
0090 m_etaBinsPerHalf = m_numberGctCentralEtaBinsPerHalf + m_numberGctForwardEtaBinsPerHalf;
0091
0092 m_gctEmJetPhiBinWidth = 2. * M_PI / m_numberGctEmJetPhiBins;
0093 m_gctEtSumPhiBinWidth = 2. * M_PI / m_numberGctEtSumPhiBins;
0094 m_gctHtSumPhiBinWidth = 2. * M_PI / m_numberGctHtSumPhiBins;
0095
0096 m_gctEmJetPhiOffset = gctEmJetPhiBinOffset * m_gctEmJetPhiBinWidth;
0097 m_gctEtSumPhiOffset = gctEtSumPhiBinOffset * m_gctEtSumPhiBinWidth;
0098 m_gctHtSumPhiOffset = gctHtSumPhiBinOffset * m_gctHtSumPhiBinWidth;
0099 }
0100
0101
0102
0103
0104
0105
0106 L1CaloGeometry::~L1CaloGeometry() {}
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128 double L1CaloGeometry::globalEtaBinCenter(unsigned int globalEtaIndex) const {
0129 int etaIndex;
0130 double etaSign = 1.;
0131 if (globalEtaIndex < m_etaBinsPerHalf) {
0132 etaIndex = m_etaBinsPerHalf - globalEtaIndex - 1;
0133 etaSign = -1.;
0134 } else {
0135 etaIndex = globalEtaIndex - m_etaBinsPerHalf;
0136 }
0137
0138 return 0.5 * etaSign * (m_gctEtaBinBoundaries[etaIndex] + m_gctEtaBinBoundaries[etaIndex + 1]);
0139 }
0140
0141 double L1CaloGeometry::globalEtaBinLowEdge(unsigned int globalEtaIndex) const {
0142 int etaIndex;
0143 double etaSign = 1.;
0144 if (globalEtaIndex < m_etaBinsPerHalf) {
0145 etaIndex = m_etaBinsPerHalf - globalEtaIndex - 1;
0146 etaSign = -1.;
0147 } else {
0148 etaIndex = globalEtaIndex - m_etaBinsPerHalf;
0149 }
0150
0151 return (etaSign > 0. ? m_gctEtaBinBoundaries[etaIndex] : -m_gctEtaBinBoundaries[etaIndex + 1]);
0152 }
0153
0154 double L1CaloGeometry::globalEtaBinHighEdge(unsigned int globalEtaIndex) const {
0155 int etaIndex;
0156 double etaSign = 1.;
0157 if (globalEtaIndex < m_etaBinsPerHalf) {
0158 etaIndex = m_etaBinsPerHalf - globalEtaIndex - 1;
0159 etaSign = -1.;
0160 } else {
0161 etaIndex = globalEtaIndex - m_etaBinsPerHalf;
0162 }
0163
0164 return (etaSign > 0. ? m_gctEtaBinBoundaries[etaIndex + 1] : -m_gctEtaBinBoundaries[etaIndex]);
0165 }
0166
0167 double L1CaloGeometry::etaBinCenter(unsigned int etaIndex, bool central) const {
0168
0169
0170 double etaSign = 1.;
0171
0172
0173 if (etaIndex >= m_etaSignBitOffset) {
0174 etaSign = -1.;
0175 etaIndex -= m_etaSignBitOffset;
0176 }
0177
0178
0179 if (!central) {
0180 etaIndex += m_numberGctCentralEtaBinsPerHalf;
0181 }
0182
0183 return 0.5 * etaSign * (m_gctEtaBinBoundaries[etaIndex] + m_gctEtaBinBoundaries[etaIndex + 1]);
0184 }
0185
0186 double L1CaloGeometry::etaBinLowEdge(unsigned int etaIndex, bool central) const {
0187
0188
0189 double etaSign = 1.;
0190
0191
0192 if (etaIndex >= m_etaSignBitOffset) {
0193 etaSign = -1.;
0194 etaIndex -= m_etaSignBitOffset;
0195 }
0196
0197
0198 if (!central) {
0199 etaIndex += m_numberGctCentralEtaBinsPerHalf;
0200 }
0201
0202 return (etaSign > 0. ? m_gctEtaBinBoundaries[etaIndex] : -m_gctEtaBinBoundaries[etaIndex + 1]);
0203 }
0204
0205 double L1CaloGeometry::etaBinHighEdge(unsigned int etaIndex, bool central) const {
0206
0207
0208 double etaSign = 1.;
0209
0210
0211 if (etaIndex >= m_etaSignBitOffset) {
0212 etaSign = -1.;
0213 etaIndex -= m_etaSignBitOffset;
0214 }
0215
0216
0217 if (!central) {
0218 etaIndex += m_numberGctCentralEtaBinsPerHalf;
0219 }
0220
0221 return (etaSign > 0. ? m_gctEtaBinBoundaries[etaIndex + 1] : -m_gctEtaBinBoundaries[etaIndex]);
0222 }
0223
0224 double L1CaloGeometry::emJetPhiBinCenter(unsigned int phiIndex) const {
0225 return ((double)phiIndex + 0.5) * m_gctEmJetPhiBinWidth + m_gctEmJetPhiOffset;
0226 }
0227
0228 double L1CaloGeometry::emJetPhiBinLowEdge(unsigned int phiIndex) const {
0229 return ((double)phiIndex) * m_gctEmJetPhiBinWidth + m_gctEmJetPhiOffset;
0230 }
0231
0232 double L1CaloGeometry::emJetPhiBinHighEdge(unsigned int phiIndex) const {
0233 return ((double)phiIndex + 1.) * m_gctEmJetPhiBinWidth + m_gctEmJetPhiOffset;
0234 }
0235
0236 double L1CaloGeometry::etSumPhiBinCenter(unsigned int phiIndex) const {
0237 return ((double)phiIndex + 0.5) * m_gctEtSumPhiBinWidth + m_gctEtSumPhiOffset;
0238 }
0239
0240 double L1CaloGeometry::etSumPhiBinLowEdge(unsigned int phiIndex) const {
0241 return ((double)phiIndex) * m_gctEtSumPhiBinWidth + m_gctEtSumPhiOffset;
0242 }
0243
0244 double L1CaloGeometry::etSumPhiBinHighEdge(unsigned int phiIndex) const {
0245 return ((double)phiIndex + 1.) * m_gctEtSumPhiBinWidth + m_gctEtSumPhiOffset;
0246 }
0247
0248 double L1CaloGeometry::htSumPhiBinCenter(unsigned int phiIndex) const {
0249 if (m_version == kOrig) {
0250 return ((double)phiIndex + 0.5) * m_gctEtSumPhiBinWidth * 4. + m_gctEtSumPhiOffset;
0251 } else {
0252 return ((double)phiIndex + 0.5) * m_gctHtSumPhiBinWidth + m_gctHtSumPhiOffset;
0253 }
0254 }
0255
0256 double L1CaloGeometry::htSumPhiBinLowEdge(unsigned int phiIndex) const {
0257 if (m_version == kOrig) {
0258 return ((double)phiIndex) * m_gctEtSumPhiBinWidth * 4. + m_gctEtSumPhiOffset;
0259 } else {
0260 return ((double)phiIndex) * m_gctHtSumPhiBinWidth + m_gctHtSumPhiOffset;
0261 }
0262 }
0263
0264 double L1CaloGeometry::htSumPhiBinHighEdge(unsigned int phiIndex) const {
0265 if (m_version == kOrig) {
0266 return ((double)phiIndex + 1.) * m_gctEtSumPhiBinWidth * 4. + m_gctEtSumPhiOffset;
0267 } else {
0268 return ((double)phiIndex + 1.) * m_gctHtSumPhiBinWidth + m_gctHtSumPhiOffset;
0269 }
0270 }
0271
0272 unsigned int L1CaloGeometry::etaIndex(const double& etaValue) const {
0273 unsigned int etaIndex = 0;
0274
0275 for (unsigned int i = 0; i < m_numberGctCentralEtaBinsPerHalf; ++i) {
0276 if (fabs(etaValue) >= m_gctEtaBinBoundaries[i]) {
0277 etaIndex = i;
0278 }
0279 }
0280
0281 for (unsigned int i = 0; i < m_numberGctForwardEtaBinsPerHalf; ++i) {
0282 if (fabs(etaValue) >= m_gctEtaBinBoundaries[i + m_numberGctCentralEtaBinsPerHalf]) {
0283 etaIndex = i;
0284 }
0285 }
0286
0287 if (etaValue < 0.) {
0288 etaIndex += m_etaSignBitOffset;
0289 }
0290
0291 return etaIndex;
0292 }
0293
0294 unsigned int L1CaloGeometry::globalEtaIndex(const double& etaValue) const {
0295 unsigned int etaIndex = 0;
0296
0297 if (etaValue < 0.) {
0298 for (unsigned int i = m_etaBinsPerHalf; i > 0; --i) {
0299 if (fabs(etaValue) < m_gctEtaBinBoundaries[i]) {
0300 etaIndex = m_etaBinsPerHalf - i;
0301 }
0302 }
0303 } else {
0304 for (unsigned int i = 0; i < m_etaBinsPerHalf; ++i) {
0305 if (etaValue >= m_gctEtaBinBoundaries[i]) {
0306 etaIndex = i + m_etaBinsPerHalf;
0307 }
0308 }
0309 }
0310
0311 return etaIndex;
0312 }
0313
0314 unsigned int L1CaloGeometry::emJetPhiIndex(const double& phiValue) const {
0315 double phiAdjusted = phiValue - m_gctEmJetPhiOffset;
0316
0317
0318 if (phiAdjusted < 0.) {
0319 do {
0320 phiAdjusted += 2. * M_PI;
0321 } while (phiAdjusted < 0.);
0322 } else if (phiAdjusted > 2. * M_PI) {
0323 do {
0324 phiAdjusted -= 2. * M_PI;
0325 } while (phiAdjusted > 2. * M_PI);
0326 }
0327
0328 return ((int)(phiAdjusted / m_gctEmJetPhiBinWidth));
0329 }
0330
0331 unsigned int L1CaloGeometry::etSumPhiIndex(const double& phiValue) const {
0332 double phiAdjusted = phiValue - m_gctEtSumPhiOffset;
0333
0334
0335 if (phiAdjusted < 0.) {
0336 do {
0337 phiAdjusted += 2. * M_PI;
0338 } while (phiAdjusted < 0.);
0339 } else if (phiAdjusted > 2. * M_PI) {
0340 do {
0341 phiAdjusted -= 2. * M_PI;
0342 } while (phiAdjusted > 2. * M_PI);
0343 }
0344
0345 return ((int)(phiAdjusted / m_gctEtSumPhiBinWidth));
0346 }
0347
0348 unsigned int L1CaloGeometry::htSumPhiIndex(const double& phiValue) const {
0349 double phiAdjusted = phiValue - m_gctEtSumPhiOffset;
0350
0351
0352 if (phiAdjusted < 0.) {
0353 do {
0354 phiAdjusted += 2. * M_PI;
0355 } while (phiAdjusted < 0.);
0356 } else if (phiAdjusted > 2. * M_PI) {
0357 do {
0358 phiAdjusted -= 2. * M_PI;
0359 } while (phiAdjusted > 2. * M_PI);
0360 }
0361
0362 if (m_version == kOrig) {
0363 return ((int)(phiAdjusted / (m_gctEtSumPhiBinWidth * 4.)));
0364 } else {
0365 return ((int)(phiAdjusted / m_gctHtSumPhiBinWidth));
0366 }
0367 }
0368
0369 unsigned int L1CaloGeometry::numberGctHtSumPhiBins() const {
0370 if (m_version == kOrig) {
0371 return m_numberGctEtSumPhiBins / 4;
0372 } else {
0373 return m_numberGctHtSumPhiBins;
0374 }
0375 }
0376
0377 std::ostream& operator<<(std::ostream& os, const L1CaloGeometry& obj) {
0378 os << "L1CaloGeometry:" << std::endl;
0379
0380 os << "Central/tau eta bins: low / center / high" << std::endl;
0381 for (unsigned int i = 0; i < obj.numberGctCentralEtaBinsPerHalf(); ++i) {
0382 os << " bin " << i << ": " << obj.etaBinLowEdge(i) << " / " << obj.etaBinCenter(i) << " / "
0383 << obj.etaBinHighEdge(i) << std::endl;
0384 }
0385
0386 os << "Forward eta bins: low / center / high" << std::endl;
0387 for (unsigned int i = 0; i < obj.numberGctForwardEtaBinsPerHalf(); ++i) {
0388 os << " bin " << i << ": " << obj.etaBinLowEdge(i, false) << " / " << obj.etaBinCenter(i, false) << " / "
0389 << obj.etaBinHighEdge(i, false) << std::endl;
0390 }
0391
0392 os << "Global eta bins: low / center / high" << std::endl;
0393 for (unsigned int i = 0; i < obj.numberGctCentralEtaBinsPerHalf() + obj.numberGctForwardEtaBinsPerHalf(); ++i) {
0394 os << " bin " << i << ": " << obj.globalEtaBinLowEdge(i) << " / " << obj.globalEtaBinCenter(i) << " / "
0395 << obj.globalEtaBinHighEdge(i) << std::endl;
0396 }
0397
0398 os << "EM/jet phi bins: low / center / high" << std::endl;
0399 for (unsigned int i = 0; i < obj.numberGctEmJetPhiBins(); ++i) {
0400 os << " bin " << i << ": " << obj.emJetPhiBinLowEdge(i) << " / " << obj.emJetPhiBinCenter(i) << " / "
0401 << obj.emJetPhiBinHighEdge(i) << std::endl;
0402 }
0403
0404 os << "Et sum phi bins: low / center / high" << std::endl;
0405 for (unsigned int i = 0; i < obj.numberGctEtSumPhiBins(); ++i) {
0406 os << " bin " << i << ": " << obj.etSumPhiBinLowEdge(i) << " / " << obj.etSumPhiBinCenter(i) << " / "
0407 << obj.etSumPhiBinHighEdge(i) << std::endl;
0408 }
0409
0410 os << "Ht sum phi bins: low / center / high" << std::endl;
0411 for (unsigned int i = 0; i < obj.numberGctHtSumPhiBins(); ++i) {
0412 os << " bin " << i << ": " << obj.htSumPhiBinLowEdge(i) << " / " << obj.htSumPhiBinCenter(i) << " / "
0413 << obj.htSumPhiBinHighEdge(i) << std::endl;
0414 }
0415
0416 return os;
0417 }
0418
0419
0420
0421