29 isBinary =
pset.getUntrackedParameter<
bool>(
"Binary",
false);
57 : _endcap(lut._endcap),
59 _subsector(lut._subsector),
60 _station(lut._station),
61 me_lcl_phi_file(lut.me_lcl_phi_file),
62 me_gbl_phi_file(lut.me_gbl_phi_file),
63 mb_gbl_phi_file(lut.mb_gbl_phi_file),
64 me_gbl_eta_file(lut.me_gbl_eta_file),
65 LUTsFromFile(lut.LUTsFromFile),
144 double patternOffset;
150 if (theadd.pattern_type == 1 ||
isTMB07)
151 data.phi_local = static_cast<unsigned>((0.5 + theadd.strip + patternOffset) * binPhiL);
153 data.phi_local = static_cast<unsigned>((2 + theadd.strip + 4. * patternOffset) * binPhiL);
155 throw cms::Exception(
"CSCSectorReceiverLUT") <<
"+++ Value of strip, " << theadd.strip <<
", exceeds max allowed, "
159 if (
data.phi_local >= maxPhiL) {
161 <<
"+++ Value of phi_local, " <<
data.phi_local <<
", exceeds max allowed, " << maxPhiL - 1 <<
" +++\n";
164 LogDebug(
"CSCSectorReceiver") <<
"endcap = " <<
_endcap <<
" station = " <<
_station <<
" maxPhiL = " << maxPhiL
165 <<
" binPhiL = " << binPhiL;
166 LogDebug(
"CSCSectorReceiver") <<
"strip # " << theadd.strip <<
" hs/ds = " << theadd.pattern_type
167 <<
" pattern = " << theadd.clct_pattern <<
" offset = " << patternOffset
168 <<
" phi_local = " <<
data.phi_local;
171 data.phi_bend_local = 0;
184 theadd.strip =
strip;
185 theadd.clct_pattern =
pattern & 0x7;
186 theadd.pattern_type = (
pattern & 0x8) >> 3;
222 const unsigned&
strip,
223 const unsigned& wire_group)
const {
238 LogDebug(
"CSCSectorReceiverLUT|getGlobalPhiValue") <<
e.what();
249 int cscid = address.cscid;
250 unsigned wire_group = address.wire_group;
251 unsigned local_phi = address.phi_local;
252 const double sectorOffset =
281 if (wire_group >= 1 << 5) {
283 <<
"warning: wire_group" << wire_group <<
" is out of bounds (1-" << ((1 << 5) - 1) <<
"]\n";
285 <<
"+++ Value of wire_group, " << wire_group <<
", is out of bounds (1-" << ((1 << 5) - 1) <<
"] +++\n";
288 if (local_phi >= maxPhiL) {
290 <<
"warning: local_phi" << local_phi <<
" is out of bounds [0-" << maxPhiL <<
")\n";
292 <<
"+++ Value of local_phi, " << local_phi <<
", is out of bounds [0-, " << maxPhiL <<
") +++\n";
299 thechamber = const_cast<const CSCChamber*>(
csc_g->
chamber(detid));
312 int strip = 0, halfstrip = 0;
314 halfstrip = static_cast<int>(local_phi / binPhiL);
315 strip = halfstrip / 2;
325 const double hsWidth_f = fabs(
getGlobalPhiValue(thelayer, 2, wire_group) - phi_f) / 2.;
341 double leftEdge, rightEdge;
342 if (fabs(phi_f - phi_l) <
M_PI) {
344 clockwiseOrder =
true;
346 clockwiseOrder =
false;
349 clockwiseOrder =
false;
351 clockwiseOrder =
true;
353 if (clockwiseOrder) {
354 leftEdge = phi_f - hsWidth_f;
355 rightEdge = phi_l + hsWidth_l;
357 leftEdge = phi_l - hsWidth_l;
358 rightEdge = phi_f + hsWidth_f;
360 if (fabs(phi_f - phi_l) >=
M_PI) {
361 rightEdge += 2. *
M_PI;
369 double temp_phi = 0.0, strip_phi = 0.0,
delta_phi = 0.0;
370 double distFromHalfStripCenter = 0.0, halfstripWidth = 0.0;
375 distFromHalfStripCenter = (local_phi + 0.5) / binPhiL - halfstrip - 0.5;
380 if ((halfstrip % 2 == 0 && halfstrip != 0) || halfstrip == 2 *
nStrips - 1) {
390 if (halfstripWidth >
M_PI / 2.)
391 halfstripWidth =
M_PI - halfstripWidth;
395 delta_phi = halfstripWidth * (((halfstrip % 2) - 0.5) + distFromHalfStripCenter);
406 temp_phi = rightEdge;
414 temp_phi -= sectorOffset;
417 temp_phi += 2. *
M_PI;
423 }
else if (temp_phi >= maxPhiG) {
424 result.global_phi = maxPhiG - 1;
426 result.global_phi = static_cast<unsigned short>(temp_phi);
429 LogDebug(
"CSCSectorReceiverLUT") <<
"local_phi = " << local_phi <<
" halfstrip = " << halfstrip
430 <<
" strip = " <<
strip
431 <<
" distFromHalfStripCenter = " << distFromHalfStripCenter
432 <<
" halfstripWidth = " << halfstripWidth
433 <<
" strip phi = " << strip_phi / (
M_PI / 180.)
435 <<
" global_phi = " <<
result.global_phi <<
" "
439 edm::LogError(
"CSCSectorReceiverLUT|getGlobalPhiValue") <<
e.what();
448 theadd.phi_local = phi_local;
449 theadd.wire_group = ((1 << 5) - 1) & (wire_group >> 2);
450 theadd.cscid = cscid;
495 int GlobalPhiMin = (
_subsector == 1) ? 0x42 : 0x800;
496 int GlobalPhiMax = (
_subsector == 1) ? 0x7ff : 0xfbd;
497 double GlobalPhiShift = (1.0 * GlobalPhiMin + (GlobalPhiMax - GlobalPhiMin) / 2.0);
499 double dt_out = static_cast<double>(csclut.global_phi) - GlobalPhiShift;
502 dt_out = (dt_out / 1982) * 2145;
506 dtlut.global_phi = 0x7ff & static_cast<unsigned>(dt_out);
508 dtlut.global_phi = static_cast<unsigned>(-dt_out);
509 dtlut.global_phi = ~dtlut.global_phi;
510 dtlut.global_phi |= 0x800;
520 address.cscid = cscid;
521 address.wire_group = ((1 << 5) - 1) & (wire_group >> 2);
522 address.phi_local = phi_local;
563 const unsigned& thewire_group,
564 const unsigned& thephi_local)
const {
566 unsigned wire_group = thewire_group;
567 int cscid = thecscid;
568 unsigned phi_local = thephi_local;
572 bool me1ir_only =
false;
581 const unsigned numBins = 1 << 2;
583 if (phi_local > numBins - 1) {
585 <<
"warning: phiL " << phi_local <<
" is out of bounds [0-" << numBins - 1 <<
"]\n";
586 phi_local = numBins - 1;
599 if (wire_group >= nWireGroups) {
601 <<
"warning: wireGroup " << wire_group <<
" is out of bounds [0-" << nWireGroups <<
")\n";
602 wire_group = nWireGroups - 1;
621 <<
") is not divisible by numBins " << numBins <<
" Station " <<
_station <<
" sector " <<
_sector
622 <<
" subsector " <<
_subsector <<
" cscid " << cscid <<
"\n";
624 unsigned maxStripPrevBin = 0, maxStripThisBin = 0;
625 unsigned correctionStrip;
629 maxStripThisBin = nStripsPerBin * (phi_local + 1);
630 if (maxStripThisBin <=
nStrips) {
631 correctionStrip = nStripsPerBin / 2 * (2 * phi_local + 1);
637 maxStripPrevBin = nStripsPerBin * phi_local;
638 correctionStrip = (
nStrips + maxStripPrevBin) / 2;
649 LogDebug(
"CSCSectorReceiver|OutofBoundInput") <<
e.what();
657 double float_eta =
getGlobalEtaValue(address.cscid, address.wire_group, address.phi_local);
658 unsigned int_eta = 0;
659 unsigned bend_global = 0;
661 const unsigned me12EtaCut = 56;
667 << address.cscid <<
" wire group " << address.wire_group;
679 float_eta = float_eta / etaPerBin;
680 int_eta = static_cast<unsigned>(float_eta);
693 if (
ring == 1 && int_eta < me12EtaCut) {
694 int_eta = me12EtaCut;
695 }
else if (
ring == 2 && int_eta >= me12EtaCut) {
696 int_eta = me12EtaCut - 1;
699 result.global_eta = int_eta;
701 result.global_bend = bend_global;
707 int tphi_bend,
int tphi_local,
int twire_group,
int tcscid,
const bool gangedME1a)
const {
711 theadd.phi_bend = tphi_bend;
713 theadd.wire_group = twire_group;
714 theadd.cscid = tcscid;
791 std::ifstream LocalPhiLUT;
796 LocalPhiLUT.open(
fName.c_str(), std::ios::binary);
798 int length = LocalPhiLUT.tellg();
800 LocalPhiLUT.seekg(0, std::ios::beg);
801 LocalPhiLUT.read(reinterpret_cast<char*>(
me_lcl_phi), length);
807 LocalPhiLUT.open(
fName.c_str());
809 unsigned short temp = 0;
820 std::ifstream GlobalPhiLUT;
825 GlobalPhiLUT.open(
fName.c_str(), std::ios::binary);
827 int length = GlobalPhiLUT.tellg();
829 GlobalPhiLUT.seekg(0, std::ios::beg);
830 GlobalPhiLUT.read(reinterpret_cast<char*>(
me_global_phi), length);
833 GlobalPhiLUT.close();
835 GlobalPhiLUT.open(
fName.c_str());
836 unsigned short temp = 0;
839 GlobalPhiLUT >>
temp;
842 GlobalPhiLUT.close();
849 std::ifstream GlobalPhiLUT;
854 GlobalPhiLUT.open(
fName.c_str(), std::ios::binary);
856 int length = GlobalPhiLUT.tellg();
858 GlobalPhiLUT.seekg(0, std::ios::beg);
859 GlobalPhiLUT.read(reinterpret_cast<char*>(
mb_global_phi), length);
862 GlobalPhiLUT.close();
864 GlobalPhiLUT.open(
fName.c_str());
865 unsigned short temp = 0;
868 GlobalPhiLUT >>
temp;
871 GlobalPhiLUT.close();
877 std::ifstream GlobalEtaLUT;
882 GlobalEtaLUT.open(
fName.c_str(), std::ios::binary);
884 int length = GlobalEtaLUT.tellg();
886 GlobalEtaLUT.seekg(0, std::ios::beg);
887 GlobalEtaLUT.read(reinterpret_cast<char*>(
me_global_eta), length);
890 GlobalEtaLUT.close();
892 GlobalEtaLUT.open(
fName.c_str());
893 unsigned short temp = 0;
896 GlobalEtaLUT >>
temp;
899 GlobalEtaLUT.close();