28 isBinary =
pset.getUntrackedParameter<
bool>(
"Binary",
false);
56 : _endcap(lut._endcap),
58 _subsector(lut._subsector),
59 _station(lut._station),
60 me_lcl_phi_file(lut.me_lcl_phi_file),
61 me_gbl_phi_file(lut.me_gbl_phi_file),
62 mb_gbl_phi_file(lut.mb_gbl_phi_file),
63 me_gbl_eta_file(lut.me_gbl_eta_file),
64 LUTsFromFile(lut.LUTsFromFile),
143 double patternOffset;
149 if (theadd.pattern_type == 1 ||
isTMB07)
150 data.phi_local = static_cast<unsigned>((0.5 + theadd.strip + patternOffset) * binPhiL);
152 data.phi_local = static_cast<unsigned>((2 + theadd.strip + 4. * patternOffset) * binPhiL);
154 throw cms::Exception(
"CSCSectorReceiverLUT") <<
"+++ Value of strip, " << theadd.strip <<
", exceeds max allowed, "
158 if (
data.phi_local >= maxPhiL) {
160 <<
"+++ Value of phi_local, " <<
data.phi_local <<
", exceeds max allowed, " << maxPhiL - 1 <<
" +++\n";
163 LogDebug(
"CSCSectorReceiver") <<
"endcap = " <<
_endcap <<
" station = " <<
_station <<
" maxPhiL = " << maxPhiL
164 <<
" binPhiL = " << binPhiL;
165 LogDebug(
"CSCSectorReceiver") <<
"strip # " << theadd.strip <<
" hs/ds = " << theadd.pattern_type
166 <<
" pattern = " << theadd.clct_pattern <<
" offset = " << patternOffset
167 <<
" phi_local = " <<
data.phi_local;
170 data.phi_bend_local = 0;
183 theadd.strip =
strip;
184 theadd.clct_pattern =
pattern & 0x7;
185 theadd.pattern_type = (
pattern & 0x8) >> 3;
221 const unsigned&
strip,
222 const unsigned& wire_group)
const {
237 LogDebug(
"CSCSectorReceiverLUT|getGlobalPhiValue") <<
e.what();
248 int cscid = address.cscid;
249 unsigned wire_group = address.wire_group;
250 unsigned local_phi = address.phi_local;
251 const double sectorOffset =
280 if (wire_group >= 1 << 5) {
282 <<
"warning: wire_group" << wire_group <<
" is out of bounds (1-" << ((1 << 5) - 1) <<
"]\n";
284 <<
"+++ Value of wire_group, " << wire_group <<
", is out of bounds (1-" << ((1 << 5) - 1) <<
"] +++\n";
287 if (local_phi >= maxPhiL) {
289 <<
"warning: local_phi" << local_phi <<
" is out of bounds [0-" << maxPhiL <<
")\n";
291 <<
"+++ Value of local_phi, " << local_phi <<
", is out of bounds [0-, " << maxPhiL <<
") +++\n";
298 thechamber = const_cast<const CSCChamber*>(
csc_g->
chamber(detid));
311 int strip = 0, halfstrip = 0;
313 halfstrip = static_cast<int>(local_phi / binPhiL);
314 strip = halfstrip / 2;
324 const double hsWidth_f = fabs(
getGlobalPhiValue(thelayer, 2, wire_group) - phi_f) / 2.;
340 double leftEdge, rightEdge;
341 if (fabs(phi_f - phi_l) <
M_PI) {
343 clockwiseOrder =
true;
345 clockwiseOrder =
false;
348 clockwiseOrder =
false;
350 clockwiseOrder =
true;
352 if (clockwiseOrder) {
353 leftEdge = phi_f - hsWidth_f;
354 rightEdge = phi_l + hsWidth_l;
356 leftEdge = phi_l - hsWidth_l;
357 rightEdge = phi_f + hsWidth_f;
359 if (fabs(phi_f - phi_l) >=
M_PI) {
360 rightEdge += 2. *
M_PI;
368 double temp_phi = 0.0, strip_phi = 0.0,
delta_phi = 0.0;
369 double distFromHalfStripCenter = 0.0, halfstripWidth = 0.0;
374 distFromHalfStripCenter = (local_phi + 0.5) / binPhiL - halfstrip - 0.5;
379 if ((halfstrip % 2 == 0 && halfstrip != 0) || halfstrip == 2 *
nStrips - 1) {
389 if (halfstripWidth >
M_PI / 2.)
390 halfstripWidth =
M_PI - halfstripWidth;
394 delta_phi = halfstripWidth * (((halfstrip % 2) - 0.5) + distFromHalfStripCenter);
405 temp_phi = rightEdge;
413 temp_phi -= sectorOffset;
416 temp_phi += 2. *
M_PI;
422 }
else if (temp_phi >= maxPhiG) {
423 result.global_phi = maxPhiG - 1;
425 result.global_phi = static_cast<unsigned short>(temp_phi);
428 LogDebug(
"CSCSectorReceiverLUT") <<
"local_phi = " << local_phi <<
" halfstrip = " << halfstrip
429 <<
" strip = " <<
strip
430 <<
" distFromHalfStripCenter = " << distFromHalfStripCenter
431 <<
" halfstripWidth = " << halfstripWidth
432 <<
" strip phi = " << strip_phi / (
M_PI / 180.)
434 <<
" global_phi = " <<
result.global_phi <<
" "
438 edm::LogError(
"CSCSectorReceiverLUT|getGlobalPhiValue") <<
e.what();
447 theadd.phi_local = phi_local;
448 theadd.wire_group = ((1 << 5) - 1) & (wire_group >> 2);
449 theadd.cscid = cscid;
494 int GlobalPhiMin = (
_subsector == 1) ? 0x42 : 0x800;
495 int GlobalPhiMax = (
_subsector == 1) ? 0x7ff : 0xfbd;
496 double GlobalPhiShift = (1.0 * GlobalPhiMin + (GlobalPhiMax - GlobalPhiMin) / 2.0);
498 double dt_out = static_cast<double>(csclut.global_phi) - GlobalPhiShift;
501 dt_out = (dt_out / 1982) * 2145;
505 dtlut.global_phi = 0x7ff & static_cast<unsigned>(dt_out);
507 dtlut.global_phi = static_cast<unsigned>(-dt_out);
508 dtlut.global_phi = ~dtlut.global_phi;
509 dtlut.global_phi |= 0x800;
519 address.cscid = cscid;
520 address.wire_group = ((1 << 5) - 1) & (wire_group >> 2);
521 address.phi_local = phi_local;
562 const unsigned& thewire_group,
563 const unsigned& thephi_local)
const {
565 unsigned wire_group = thewire_group;
566 int cscid = thecscid;
567 unsigned phi_local = thephi_local;
571 bool me1ir_only =
false;
580 const unsigned numBins = 1 << 2;
582 if (phi_local > numBins - 1) {
584 <<
"warning: phiL " << phi_local <<
" is out of bounds [0-" << numBins - 1 <<
"]\n";
585 phi_local = numBins - 1;
598 if (wire_group >= nWireGroups) {
600 <<
"warning: wireGroup " << wire_group <<
" is out of bounds [0-" << nWireGroups <<
")\n";
601 wire_group = nWireGroups - 1;
620 <<
") is not divisible by numBins " << numBins <<
" Station " <<
_station <<
" sector " <<
_sector
621 <<
" subsector " <<
_subsector <<
" cscid " << cscid <<
"\n";
623 unsigned maxStripPrevBin = 0, maxStripThisBin = 0;
624 unsigned correctionStrip;
628 maxStripThisBin = nStripsPerBin * (phi_local + 1);
629 if (maxStripThisBin <=
nStrips) {
630 correctionStrip = nStripsPerBin / 2 * (2 * phi_local + 1);
636 maxStripPrevBin = nStripsPerBin * phi_local;
637 correctionStrip = (
nStrips + maxStripPrevBin) / 2;
648 LogDebug(
"CSCSectorReceiver|OutofBoundInput") <<
e.what();
656 double float_eta =
getGlobalEtaValue(address.cscid, address.wire_group, address.phi_local);
657 unsigned int_eta = 0;
658 unsigned bend_global = 0;
660 const unsigned me12EtaCut = 56;
666 << address.cscid <<
" wire group " << address.wire_group;
678 float_eta = float_eta / etaPerBin;
679 int_eta = static_cast<unsigned>(float_eta);
692 if (
ring == 1 && int_eta < me12EtaCut) {
693 int_eta = me12EtaCut;
694 }
else if (
ring == 2 && int_eta >= me12EtaCut) {
695 int_eta = me12EtaCut - 1;
698 result.global_eta = int_eta;
700 result.global_bend = bend_global;
706 int tphi_bend,
int tphi_local,
int twire_group,
int tcscid,
const bool gangedME1a)
const {
710 theadd.phi_bend = tphi_bend;
712 theadd.wire_group = twire_group;
713 theadd.cscid = tcscid;
790 std::ifstream LocalPhiLUT;
795 LocalPhiLUT.open(
fName.c_str(), std::ios::binary);
797 int length = LocalPhiLUT.tellg();
799 LocalPhiLUT.seekg(0, std::ios::beg);
800 LocalPhiLUT.read(reinterpret_cast<char*>(
me_lcl_phi), length);
806 LocalPhiLUT.open(
fName.c_str());
808 unsigned short temp = 0;
819 std::ifstream GlobalPhiLUT;
824 GlobalPhiLUT.open(
fName.c_str(), std::ios::binary);
826 int length = GlobalPhiLUT.tellg();
828 GlobalPhiLUT.seekg(0, std::ios::beg);
829 GlobalPhiLUT.read(reinterpret_cast<char*>(
me_global_phi), length);
832 GlobalPhiLUT.close();
834 GlobalPhiLUT.open(
fName.c_str());
835 unsigned short temp = 0;
838 GlobalPhiLUT >>
temp;
841 GlobalPhiLUT.close();
848 std::ifstream GlobalPhiLUT;
853 GlobalPhiLUT.open(
fName.c_str(), std::ios::binary);
855 int length = GlobalPhiLUT.tellg();
857 GlobalPhiLUT.seekg(0, std::ios::beg);
858 GlobalPhiLUT.read(reinterpret_cast<char*>(
mb_global_phi), length);
861 GlobalPhiLUT.close();
863 GlobalPhiLUT.open(
fName.c_str());
864 unsigned short temp = 0;
867 GlobalPhiLUT >>
temp;
870 GlobalPhiLUT.close();
876 std::ifstream GlobalEtaLUT;
881 GlobalEtaLUT.open(
fName.c_str(), std::ios::binary);
883 int length = GlobalEtaLUT.tellg();
885 GlobalEtaLUT.seekg(0, std::ios::beg);
886 GlobalEtaLUT.read(reinterpret_cast<char*>(
me_global_eta), length);
889 GlobalEtaLUT.close();
891 GlobalEtaLUT.open(
fName.c_str());
892 unsigned short temp = 0;
895 GlobalEtaLUT >>
temp;
898 GlobalEtaLUT.close();