File indexing completed on 2024-09-07 04:36:41
0001 #include "L1Trigger/CSCTrackFinder/interface/CSCSectorReceiverMiniLUT.h"
0002 #include "L1Trigger/CSCTriggerPrimitives/interface/CSCPatternBank.h"
0003 #include "DataFormats/L1CSCTrackFinder/interface/CSCBitWidths.h"
0004 #include "DataFormats/L1CSCTrackFinder/interface/CSCTFConstants.h"
0005 #include "DataFormats/CSCDigi/interface/CSCConstants.h"
0006
0007 #include "Geometry/CSCGeometry/interface/CSCLayerGeometry.h"
0008 #include "DataFormats/GeometryVector/interface/LocalPoint.h"
0009 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
0010
0011 #include "DataFormats/MuonDetId/interface/CSCTriggerNumbering.h"
0012
0013 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0014
0015 #include <fstream>
0016 #include <cmath>
0017
0018 lclphidat CSCSectorReceiverMiniLUT::calcLocalPhiMini(unsigned theadd, const bool gangedME1a) {
0019
0020
0021 lclphidat data;
0022
0023 constexpr int maxPhiL = 1 << CSCBitWidths::kLocalPhiDataBitWidth;
0024 unsigned short int pattern = ((theadd >> 8) & 0xf);
0025 unsigned short int strip = (theadd & 0xff);
0026
0027 if (strip < 2 * (CSCConstants::MAX_NUM_STRIPS_RUN1 * 7 / 5) &&
0028 pattern <
0029 CSCConstants::
0030 NUM_CLCT_PATTERNS) {
0031 data.phi_local = gangedME1a ? static_cast<unsigned>((lcl_phi_param0[pattern] + strip) * lcl_phi_param1)
0032 : static_cast<unsigned>((lcl_phi_param0[pattern] + strip) * 0.625 * lcl_phi_param1);
0033
0034 } else
0035 edm::LogWarning("CSCSectorReceiverMiniLUT") << "+++ Value of strip, " << strip << ", exceeds max allowed, "
0036 << 2 * CSCConstants::MAX_NUM_STRIPS_RUN1 - 1 << " +++\n";
0037
0038 if (data.phi_local >= maxPhiL)
0039 edm::LogWarning("CSCSectorReceiverMiniLUT")
0040 << "+++ Value of phi_local, " << data.phi_local << ", exceeds max allowed, "
0041 << CSCConstants::NUM_CLCT_PATTERNS - 1 << " +++\n";
0042
0043
0044
0045 data.phi_bend_local = pattern & 0x3F;
0046
0047 return data;
0048 }
0049
0050 global_eta_data CSCSectorReceiverMiniLUT::calcGlobalEtaMEMini(unsigned short endcap,
0051 unsigned short sector,
0052 unsigned short station,
0053 unsigned short subsector,
0054 unsigned theadd,
0055 const bool gangedME1a) {
0056 if (endcap < 1 || endcap > 2)
0057 edm::LogWarning("CSCSectorReceiverMiniLUT")
0058 << "+++ Value of endcap, " << endcap << ", is out of bounds, [1, 2] +++\n";
0059 if (sector < 1 || sector > 6)
0060 edm::LogWarning("CSCSectorReceiverMiniLUT")
0061 << "+++ Value of sector, " << sector << ", is out of bounds, [1, 6] +++\n";
0062 if (station < 1 || station > 4)
0063 edm::LogWarning("CSCSectorReceiverMiniLUT")
0064 << "+++ Value of station, " << station << ", is out of bounds, [1, 4] +++\n";
0065
0066 gbletadat data(0);
0067
0068 unsigned short int tcscid = ((theadd >> 15) & 0xf);
0069 unsigned short int lclPhi = ((theadd >> 6) & 0x3);
0070 unsigned short int WG = ((theadd >> 8) & 0x7f);
0071 unsigned short int bend = ((theadd) & 0x3f);
0072
0073 int eta_temp = 999, eta_min = 999, eta_max = 999;
0074
0075 if ((tcscid > 0) && (tcscid <= 12) && (WG < CSCConstants::MAX_NUM_WIREGROUPS)) {
0076 unsigned short int cscid = (tcscid > 9) ? tcscid - 9 : tcscid;
0077 if (station == 1) {
0078 unsigned short int lclPhip = 0;
0079 if (lclPhi == 1 || lclPhi == 3)
0080 lclPhip = 2;
0081
0082 if (gangedME1a) {
0083 eta_temp =
0084 (gbl_eta_params[endcap - 1][sector - 1][station - 1][subsector - 1][lclPhi][cscid - 1][0] +
0085 gbl_eta_params[endcap - 1][sector - 1][station - 1][subsector - 1][lclPhi][cscid - 1][1] *
0086 log(gbl_eta_params[endcap - 1][sector - 1][station - 1][subsector - 1][lclPhi][cscid - 1][2] + WG));
0087 eta_min = gbl_eta_bounds[endcap - 1][sector - 1][station - 1][subsector - 1][lclPhi][cscid - 1][0];
0088 eta_max = gbl_eta_bounds[endcap - 1][sector - 1][station - 1][subsector - 1][lclPhi][cscid - 1][1];
0089 } else {
0090 eta_temp =
0091 (gbl_eta_params[endcap - 1][sector - 1][station - 1][subsector - 1][lclPhip][cscid - 1][0] +
0092 gbl_eta_params[endcap - 1][sector - 1][station - 1][subsector - 1][lclPhip][cscid - 1][1] *
0093 log(gbl_eta_params[endcap - 1][sector - 1][station - 1][subsector - 1][lclPhip][cscid - 1][2] + WG));
0094 eta_min = gbl_eta_bounds[endcap - 1][sector - 1][station - 1][subsector - 1][lclPhip][cscid - 1][0];
0095 eta_max = gbl_eta_bounds[endcap - 1][sector - 1][station - 1][subsector - 1][lclPhip][cscid - 1][1];
0096 }
0097
0098
0099
0100 if (gangedME1a && (tcscid < 4) && (lclPhi == 3)) {
0101 if (endcap == 1)
0102 eta_temp += 3;
0103 else
0104 eta_temp -= 3;
0105 }
0106 } else {
0107 eta_temp = (gbl_eta_params[endcap - 1][sector - 1][station - 1][0][lclPhi][cscid - 1][0] +
0108 gbl_eta_params[endcap - 1][sector - 1][station - 1][0][lclPhi][cscid - 1][1] *
0109 log(gbl_eta_params[endcap - 1][sector - 1][station - 1][0][lclPhi][cscid - 1][2] + WG));
0110 eta_min = gbl_eta_bounds[endcap - 1][sector - 1][station - 1][0][lclPhi][cscid - 1][0];
0111 eta_max = gbl_eta_bounds[endcap - 1][sector - 1][station - 1][0][lclPhi][cscid - 1][1];
0112 }
0113 } else {
0114 edm::LogWarning("CSCSectorReceiverMiniLUT")
0115 << "+++ Value of cscid, " << tcscid << ", is out of bounds, [1, 9] -- or --"
0116 << " Value of wire group, " << WG << ", exceeds max allowed, " << CSCConstants::MAX_NUM_WIREGROUPS << " +++\n";
0117 }
0118
0119
0120 if ((eta_temp >= eta_min) && (eta_temp <= eta_max))
0121 data.global_eta = eta_temp;
0122 else if (eta_temp < eta_min)
0123 data.global_eta = eta_min;
0124 else
0125 data.global_eta = eta_max;
0126
0127
0128
0129 data.global_bend = bend & 0x1F;
0130
0131 return data;
0132 }
0133
0134 global_phi_data CSCSectorReceiverMiniLUT::calcGlobalPhiMEMini(unsigned short endcap,
0135 unsigned short sector,
0136 unsigned short station,
0137 unsigned short subsector,
0138 unsigned theadd,
0139 const bool gangedME1a) {
0140 if (endcap < 1 || endcap > 2)
0141 edm::LogWarning("CSCSectorReceiverMiniLUT")
0142 << "+++ Value of endcap, " << endcap << ", is out of bounds, [1, 2] +++\n";
0143 if (sector < 1 || sector > 6)
0144 edm::LogWarning("CSCSectorReceiverMiniLUT")
0145 << "+++ Value of sector, " << sector << ", is out of bounds, [1, 6] +++\n";
0146 if (station < 1 || station > 4)
0147 edm::LogWarning("CSCSectorReceiverMiniLUT")
0148 << "+++ Value of station, " << station << ", is out of bounds, [1, 4] +++\n";
0149
0150 gblphidat data(0);
0151
0152 unsigned short int maxPhiL = 1 << CSCBitWidths::kLocalPhiDataBitWidth;
0153 unsigned short int maxPhiG = 1 << CSCBitWidths::kGlobalPhiDataBitWidth;
0154 unsigned short int cscid = ((theadd >> 15) & 0xf);
0155 unsigned short int lclPhi = (theadd & 0x3ff);
0156 if (!gangedME1a)
0157 lclPhi = lclPhi / 0.625;
0158
0159
0160
0161 const double binPhiL = static_cast<double>(maxPhiL) / (2 * CSCConstants::MAX_NUM_STRIPS_RUN1);
0162
0163 int strip = static_cast<int>(lclPhi / binPhiL);
0164 if (station == 1 && (cscid <= 3) &&
0165 (strip >= 127 && strip < 224)) {
0166
0167
0168
0169
0170 gangedME1a
0171 ? lclPhi = (strip - 127 + 31) * (4 * binPhiL / 3)
0172 : lclPhi =
0173 (strip - 127) *
0174 (4 * binPhiL /
0175 3);
0176 }
0177
0178
0179 if (station == 1 && ((cscid <= 3) || (cscid >= 7))) {
0180
0181
0182
0183 maxPhiL =
0184 maxPhiL *
0185 (64. / 80);
0186 }
0187
0188
0189 if (station == 1 && (cscid >= 10)) {
0190 lclPhi = strip * (4 * binPhiL / 3);
0191 cscid = cscid - 9;
0192 }
0193
0194
0195 if ((cscid > 0) && (cscid <= 9)) {
0196 if ((station == 1) && (lclPhi < maxPhiL))
0197 data.global_phi = (gbl_phi_me_params[endcap - 1][sector - 1][station - 1][subsector - 1][cscid - 1][0] +
0198 gbl_phi_me_params[endcap - 1][sector - 1][station - 1][subsector - 1][cscid - 1][1] * lclPhi);
0199 else if ((station == 1) && (lclPhi >= maxPhiL))
0200 data.global_phi =
0201 (gbl_phi_me_params[endcap - 1][sector - 1][station - 1][subsector - 1][cscid - 1][0] +
0202 gbl_phi_me_params[endcap - 1][sector - 1][station - 1][subsector - 1][cscid - 1][1] * (maxPhiL - 1));
0203 else
0204 data.global_phi = (gbl_phi_me_params[endcap - 1][sector - 1][station - 1][0][cscid - 1][0] +
0205 gbl_phi_me_params[endcap - 1][sector - 1][station - 1][0][cscid - 1][1] * lclPhi);
0206 } else
0207 edm::LogWarning("CSCSectorReceiverMiniLUT")
0208 << "+++ Value of cscid, " << cscid << ", is out of bounds, [1, 9] +++\n";
0209
0210 if (data.global_phi >= maxPhiG)
0211 edm::LogWarning("CSCSectorReceiverMiniLUT")
0212 << "+++ Value of global_phi, " << data.global_phi << ", exceeds max allowed, " << maxPhiG - 1 << " +++\n";
0213
0214 return data;
0215 }
0216
0217 global_phi_data CSCSectorReceiverMiniLUT::calcGlobalPhiMBMini(
0218 unsigned short endcap, unsigned short sector, unsigned short subsector, unsigned theadd, const bool gangedME1a) {
0219 if (endcap < 1 || endcap > 2)
0220 edm::LogWarning("CSCSectorReceiverMiniLUT")
0221 << "+++ Value of endcap, " << endcap << ", is out of bounds, [1, 2] +++\n";
0222 if (sector < 1 || sector > 6)
0223 edm::LogWarning("CSCSectorReceiverMiniLUT")
0224 << "+++ Value of sector, " << sector << ", is out of bounds, [1, 6] +++\n";
0225
0226 gblphidat data(0);
0227
0228 unsigned short int maxPhiL = 1 << CSCBitWidths::kLocalPhiDataBitWidth;
0229 unsigned short int maxPhiG = 1 << CSCBitWidths::kGlobalPhiDataBitWidth;
0230 unsigned short int cscid = ((theadd >> 15) & 0xf);
0231 unsigned short int lclPhi = (theadd & 0x3ff);
0232 if (!gangedME1a)
0233 lclPhi = lclPhi / 0.625;
0234
0235 if ((cscid <= 3) || (cscid >= 7))
0236 maxPhiL =
0237 maxPhiL *
0238 (64. / 80);
0239
0240 if ((cscid > 0) && (cscid <= 9)) {
0241 if (lclPhi < maxPhiL)
0242 data.global_phi = (gbl_phi_mb_params[endcap - 1][sector - 1][subsector - 1][cscid - 1][0] +
0243 gbl_phi_mb_params[endcap - 1][sector - 1][subsector - 1][cscid - 1][1] * lclPhi);
0244 else
0245 data.global_phi = (gbl_phi_mb_params[endcap - 1][sector - 1][subsector - 1][cscid - 1][0] +
0246 gbl_phi_mb_params[endcap - 1][sector - 1][subsector - 1][cscid - 1][1] * (maxPhiL - 1));
0247 } else
0248 edm::LogWarning("CSCSectorReceiverMiniLUT")
0249 << "+++ Value of cscid, " << cscid << ", is out of bounds, [1, 9] +++\n";
0250
0251 if (data.global_phi >= maxPhiG)
0252 edm::LogWarning("CSCSectorReceiverMiniLUT")
0253 << "+++ Value of global_phi, " << data.global_phi << ", exceeds max allowed, " << maxPhiG - 1 << " +++\n";
0254
0255 if (data.global_phi >= maxPhiG)
0256 edm::LogWarning("CSCSectorReceiverMiniLUT")
0257 << "+++ Value of global_phi, " << data.global_phi << ", exceeds max allowed, " << maxPhiG - 1 << " +++\n";
0258
0259 return data;
0260 }