00001 #include <L1Trigger/CSCCommonTrigger/interface/CSCTriggerGeometry.h>
00002 #include <L1Trigger/CSCCommonTrigger/interface/CSCTriggerGeomManager.h>
00003 #include <L1Trigger/CSCCommonTrigger/interface/CSCPatternLUT.h>
00004 #include <L1Trigger/CSCCommonTrigger/interface/CSCFrontRearLUT.h>
00005 #include <DataFormats/L1CSCTrackFinder/interface/CSCBitWidths.h>
00006 #include <DataFormats/L1CSCTrackFinder/interface/CSCTFConstants.h>
00007 #include <L1Trigger/CSCCommonTrigger/interface/CSCConstants.h>
00008
00009 #include <Geometry/CSCGeometry/interface/CSCLayerGeometry.h>
00010 #include "DataFormats/GeometryVector/interface/LocalPoint.h"
00011 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
00012
00013 #include <DataFormats/MuonDetId/interface/CSCTriggerNumbering.h>
00014
00015 #include <FWCore/MessageLogger/interface/MessageLogger.h>
00016
00017 #include <fstream>
00018 #include <math.h>
00019 #include <L1Trigger/CSCTrackFinder/interface/CSCSectorReceiverMiniLUT.h>
00020
00021 lclphidat CSCSectorReceiverMiniLUT::calcLocalPhiMini(unsigned theadd)
00022 {
00023
00024
00025 lclphidat data;
00026
00027 static int maxPhiL = 1<<CSCBitWidths::kLocalPhiDataBitWidth;
00028 unsigned short int pattern = ((theadd >> 8) & 0xf);
00029 unsigned short int strip = (theadd & 0xff);
00030
00031 if(strip < 2*CSCConstants::MAX_NUM_STRIPS && pattern < CSCConstants::NUM_CLCT_PATTERNS)
00032 data.phi_local = static_cast<unsigned>((lcl_phi_param0[pattern] + strip)*lcl_phi_param1);
00033 else
00034 edm::LogWarning("CSCSectorReceiverMiniLUT")
00035 << "+++ Value of strip, " << strip
00036 << ", exceeds max allowed, " << 2*CSCConstants::MAX_NUM_STRIPS-1
00037 << " +++\n";
00038
00039 if(data.phi_local >= maxPhiL)
00040 edm::LogWarning("CSCSectorReceiverMiniLUT")
00041 << "+++ Value of phi_local, " << data.phi_local
00042 << ", exceeds max allowed, " << CSCConstants::NUM_CLCT_PATTERNS-1 << " +++\n";
00043
00044 data.phi_bend_local = 0;
00045
00046 return data;
00047 }
00048
00049 global_eta_data CSCSectorReceiverMiniLUT::calcGlobalEtaMEMini(unsigned short endcap,
00050 unsigned short sector,
00051 unsigned short station,
00052 unsigned short subsector,
00053 unsigned theadd)
00054 {
00055 if(endcap < 1 || endcap > 2)
00056 edm::LogWarning("CSCSectorReceiverMiniLUT")
00057 << "+++ Value of endcap, " << endcap
00058 << ", is out of bounds, [1, 2] +++\n";
00059 if(sector < 1 || sector > 6)
00060 edm::LogWarning("CSCSectorReceiverMiniLUT")
00061 << "+++ Value of sector, " << sector
00062 << ", is out of bounds, [1, 6] +++\n";
00063 if(station < 1 || station > 4)
00064 edm::LogWarning("CSCSectorReceiverMiniLUT")
00065 << "+++ Value of station, " << station
00066 << ", is out of bounds, [1, 4] +++\n";
00067
00068 gbletadat data(0);
00069
00070 unsigned short int cscid = ((theadd >> 15) & 0xf);
00071 unsigned short int lclPhi = ((theadd >> 6) & 0x3);
00072 unsigned short int WG = ((theadd >> 8) & 0x7f);
00073
00074 int eta_temp=999, eta_min=999, eta_max=999;
00075
00076 if((cscid > 0) && (cscid <= 9) && (WG < CSCConstants::MAX_NUM_WIRES))
00077 {
00078 if(station == 1)
00079 {
00080 eta_temp = (gbl_eta_params[endcap-1][sector-1][station-1][subsector-1][lclPhi][cscid-1][0] +
00081 gbl_eta_params[endcap-1][sector-1][station-1][subsector-1][lclPhi][cscid-1][1] *
00082 log(gbl_eta_params[endcap-1][sector-1][station-1][subsector-1][lclPhi][cscid-1][2] + WG));
00083 eta_min = gbl_eta_bounds[endcap-1][sector-1][station-1][subsector-1][lclPhi][cscid-1][0];
00084 eta_max = gbl_eta_bounds[endcap-1][sector-1][station-1][subsector-1][lclPhi][cscid-1][1];
00085 }
00086 else
00087 {
00088 eta_temp = (gbl_eta_params[endcap-1][sector-1][station-1][0][lclPhi][cscid-1][0] +
00089 gbl_eta_params[endcap-1][sector-1][station-1][0][lclPhi][cscid-1][1] *
00090 log(gbl_eta_params[endcap-1][sector-1][station-1][0][lclPhi][cscid-1][2] + WG));
00091 eta_min = gbl_eta_bounds[endcap-1][sector-1][station-1][0][lclPhi][cscid-1][0];
00092 eta_max = gbl_eta_bounds[endcap-1][sector-1][station-1][0][lclPhi][cscid-1][1];
00093 }
00094 }
00095 else
00096 {
00097 edm::LogWarning("CSCSectorReceiverMiniLUT")
00098 << "+++ Value of cscid, " << cscid
00099 << ", is out of bounds, [1, 9] -- or --"
00100 << " Value of wire group, " << WG
00101 << ", exceeds max allowed, " << CSCConstants::MAX_NUM_WIRES << " +++\n";
00102 }
00103
00104
00105 if((eta_temp >= eta_min) &&
00106 (eta_temp <= eta_max))
00107 data.global_eta = eta_temp;
00108 else if(eta_temp < eta_min)
00109 data.global_eta = eta_min;
00110 else
00111 data.global_eta = eta_max;
00112
00113 data.global_bend = 0;
00114
00115 return data;
00116 }
00117
00118 global_phi_data CSCSectorReceiverMiniLUT::calcGlobalPhiMEMini(unsigned short endcap,
00119 unsigned short sector,
00120 unsigned short station,
00121 unsigned short subsector,
00122 unsigned theadd)
00123 {
00124 if(endcap < 1 || endcap > 2)
00125 edm::LogWarning("CSCSectorReceiverMiniLUT")
00126 << "+++ Value of endcap, " << endcap
00127 << ", is out of bounds, [1, 2] +++\n";
00128 if(sector < 1 || sector > 6)
00129 edm::LogWarning("CSCSectorReceiverMiniLUT")
00130 << "+++ Value of sector, " << sector
00131 << ", is out of bounds, [1, 6] +++\n";
00132 if(station < 1 || station > 4)
00133 edm::LogWarning("CSCSectorReceiverMiniLUT")
00134 << "+++ Value of station, " << station
00135 << ", is out of bounds, [1, 4] +++\n";
00136
00137 gblphidat data(0);
00138
00139 unsigned short int maxPhiL = 1<<CSCBitWidths::kLocalPhiDataBitWidth;
00140 unsigned short int maxPhiG = 1<<CSCBitWidths::kGlobalPhiDataBitWidth;
00141 unsigned short int cscid = ((theadd >> 15)&0xf);
00142 unsigned short int lclPhi = (theadd & 0x3ff);
00143
00144
00145
00146 const double binPhiL = static_cast<double>(maxPhiL)/(2*CSCConstants::MAX_NUM_STRIPS);
00147
00148 int strip = static_cast<int>(lclPhi/binPhiL);
00149
00150 if (station == 1 && (cscid <= 3) && (strip >= 127 && strip < 160)){
00151
00152
00153
00154
00155
00156 lclPhi = (strip-127+31)*(4*binPhiL/3);
00157 }
00158
00159
00160 if(station == 1 && ((cscid <= 3) || (cscid >= 7))) {
00161
00162
00163
00164 maxPhiL = maxPhiL*(64./80);
00165 }
00166
00167
00168 if (station == 1 && (cscid >= 10)) {
00169 lclPhi = strip*(4*binPhiL/3);
00170 cscid = cscid - 9;
00171 }
00172
00173
00174 if((cscid > 0) && (cscid <= 9))
00175 {
00176 if((station == 1) && (lclPhi < maxPhiL))
00177 data.global_phi = (gbl_phi_me_params[endcap-1][sector-1][station-1][subsector-1][cscid-1][0] +
00178 gbl_phi_me_params[endcap-1][sector-1][station-1][subsector-1][cscid-1][1]*lclPhi);
00179 else if((station == 1) && (lclPhi >= maxPhiL))
00180 data.global_phi = (gbl_phi_me_params[endcap-1][sector-1][station-1][subsector-1][cscid-1][0] +
00181 gbl_phi_me_params[endcap-1][sector-1][station-1][subsector-1][cscid-1][1]*(maxPhiL-1));
00182 else
00183 data.global_phi = (gbl_phi_me_params[endcap-1][sector-1][station-1][0][cscid-1][0] +
00184 gbl_phi_me_params[endcap-1][sector-1][station-1][0][cscid-1][1]*lclPhi);
00185 }
00186 else
00187 edm::LogWarning("CSCSectorReceiverMiniLUT")
00188 << "+++ Value of cscid, " << cscid
00189 << ", is out of bounds, [1, 9] +++\n";
00190
00191 if(data.global_phi >= maxPhiG)
00192 edm::LogWarning("CSCSectorReceiverMiniLUT")
00193 << "+++ Value of global_phi, " << data.global_phi
00194 << ", exceeds max allowed, " << maxPhiG-1 << " +++\n";
00195
00196 return data;
00197 }
00198
00199 global_phi_data CSCSectorReceiverMiniLUT::calcGlobalPhiMBMini(unsigned short endcap,
00200 unsigned short sector,
00201 unsigned short subsector,
00202 unsigned theadd)
00203 {
00204 if(endcap < 1 || endcap > 2)
00205 edm::LogWarning("CSCSectorReceiverMiniLUT")
00206 << "+++ Value of endcap, " << endcap
00207 << ", is out of bounds, [1, 2] +++\n";
00208 if(sector < 1 || sector > 6)
00209 edm::LogWarning("CSCSectorReceiverMiniLUT")
00210 << "+++ Value of sector, " << sector
00211 << ", is out of bounds, [1, 6] +++\n";
00212
00213 gblphidat data(0);
00214
00215 unsigned short int maxPhiL = 1<<CSCBitWidths::kLocalPhiDataBitWidth;
00216 unsigned short int maxPhiG = 1<<CSCBitWidths::kGlobalPhiDataBitWidth;
00217 unsigned short int cscid = ((theadd >> 15)&0xf);
00218 unsigned short int lclPhi = (theadd & 0x3ff);
00219
00220 if((cscid <= 3) || (cscid >= 7))
00221 maxPhiL = maxPhiL*(64./80);
00222
00223 if((cscid > 0) && (cscid <= 9))
00224 {
00225 if(lclPhi < maxPhiL)
00226 data.global_phi = (gbl_phi_mb_params[endcap-1][sector-1][subsector-1][cscid-1][0] +
00227 gbl_phi_mb_params[endcap-1][sector-1][subsector-1][cscid-1][1]*lclPhi);
00228 else
00229 data.global_phi = (gbl_phi_mb_params[endcap-1][sector-1][subsector-1][cscid-1][0] +
00230 gbl_phi_mb_params[endcap-1][sector-1][subsector-1][cscid-1][1]*(maxPhiL-1));
00231 }
00232 else
00233 edm::LogWarning("CSCSectorReceiverMiniLUT")
00234 << "+++ Value of cscid, " << cscid
00235 << ", is out of bounds, [1, 9] +++\n";
00236
00237 if(data.global_phi >= maxPhiG)
00238 edm::LogWarning("CSCSectorReceiverMiniLUT")
00239 << "+++ Value of global_phi, " << data.global_phi
00240 << ", exceeds max allowed, " << maxPhiG-1 << " +++\n";
00241
00242 if(data.global_phi >= maxPhiG)
00243 edm::LogWarning("CSCSectorReceiverMiniLUT")
00244 << "+++ Value of global_phi, " << data.global_phi
00245 << ", exceeds max allowed, " << maxPhiG-1 << " +++\n";
00246
00247 return data;
00248 }