26 : _endcap(endcap), _sector(sector), _subsector(subsector), _station(station),
isTMB07(TMB07) {
144 double patternOffset;
153 if (theadd.pattern_type == 1 ||
isTMB07)
154 data.phi_local =
static_cast<unsigned>((0.5 + theadd.strip + patternOffset) * binPhiL);
156 data.phi_local =
static_cast<unsigned>((2 + theadd.strip + 4. * patternOffset) * binPhiL);
158 throw cms::Exception(
"CSCSectorReceiverLUT") <<
"+++ Value of strip, " << theadd.strip <<
", exceeds max allowed, " 162 if (data.phi_local >= maxPhiL) {
164 <<
"+++ Value of phi_local, " << data.phi_local <<
", exceeds max allowed, " << maxPhiL - 1 <<
" +++\n";
167 LogDebug(
"CSCSectorReceiver") <<
"endcap = " <<
_endcap <<
" station = " <<
_station <<
" maxPhiL = " << maxPhiL
168 <<
" binPhiL = " << binPhiL;
169 LogDebug(
"CSCSectorReceiver") <<
"strip # " << theadd.strip <<
" hs/ds = " << theadd.pattern_type
170 <<
" pattern = " << theadd.clct_pattern <<
" offset = " << patternOffset
171 <<
" phi_local = " << data.phi_local;
174 data.phi_bend_local = 0;
187 theadd.strip =
strip;
188 theadd.clct_pattern = pattern & 0x7;
189 theadd.pattern_type = (pattern & 0x8) >> 3;
194 return localPhi(theadd, gangedME1a);
225 const unsigned&
strip,
226 const unsigned& wire_group)
const {
241 LogDebug(
"CSCSectorReceiverLUT|getGlobalPhiValue") << e.
what();
252 int cscid = address.cscid;
253 unsigned wire_group = address.wire_group;
254 unsigned local_phi = address.phi_local;
255 const double sectorOffset =
284 if (wire_group >= 1 << 5) {
286 <<
"warning: wire_group" << wire_group <<
" is out of bounds (1-" << ((1 << 5) - 1) <<
"]\n";
288 <<
"+++ Value of wire_group, " << wire_group <<
", is out of bounds (1-" << ((1 << 5) - 1) <<
"] +++\n";
291 if (local_phi >= maxPhiL) {
293 <<
"warning: local_phi" << local_phi <<
" is out of bounds [0-" << maxPhiL <<
")\n";
295 <<
"+++ Value of local_phi, " << local_phi <<
", is out of bounds [0-, " << maxPhiL <<
") +++\n";
320 int strip = 0, halfstrip = 0;
322 halfstrip =
static_cast<int>(local_phi / binPhiL);
323 strip = halfstrip / 2;
333 const double hsWidth_f = fabs(
getGlobalPhiValue(thelayer, 2, wire_group) - phi_f) / 2.;
334 const double hsWidth_l = fabs(phi_l -
getGlobalPhiValue(thelayer, nStrips - 1, wire_group)) / 2.;
349 double leftEdge, rightEdge;
350 if (fabs(phi_f - phi_l) <
M_PI) {
352 clockwiseOrder =
true;
354 clockwiseOrder =
false;
357 clockwiseOrder =
false;
359 clockwiseOrder =
true;
361 if (clockwiseOrder) {
362 leftEdge = phi_f - hsWidth_f;
363 rightEdge = phi_l + hsWidth_l;
365 leftEdge = phi_l - hsWidth_l;
366 rightEdge = phi_f + hsWidth_f;
368 if (fabs(phi_f - phi_l) >=
M_PI) {
369 rightEdge += 2. *
M_PI;
377 double temp_phi = 0.0, strip_phi = 0.0,
delta_phi = 0.0;
378 double distFromHalfStripCenter = 0.0, halfstripWidth = 0.0;
380 if (strip < nStrips) {
383 distFromHalfStripCenter = (local_phi + 0.5) / binPhiL - halfstrip - 0.5;
388 if ((halfstrip % 2 == 0 && halfstrip != 0) || halfstrip == 2 * nStrips - 1) {
398 if (halfstripWidth >
M_PI / 2.)
399 halfstripWidth =
M_PI - halfstripWidth;
403 delta_phi = halfstripWidth * (((halfstrip % 2) - 0.5) + distFromHalfStripCenter);
414 temp_phi = rightEdge;
422 temp_phi -= sectorOffset;
425 temp_phi += 2. *
M_PI;
430 result.global_phi = 0;
431 }
else if (temp_phi >= maxPhiG) {
432 result.global_phi = maxPhiG - 1;
434 result.global_phi =
static_cast<unsigned short>(temp_phi);
437 LogDebug(
"CSCSectorReceiverLUT") <<
"local_phi = " << local_phi <<
" halfstrip = " << halfstrip
438 <<
" strip = " << strip
439 <<
" distFromHalfStripCenter = " << distFromHalfStripCenter
440 <<
" halfstripWidth = " << halfstripWidth
441 <<
" strip phi = " << strip_phi / (
M_PI / 180.)
443 <<
" global_phi = " << result.global_phi <<
" " 456 theadd.phi_local = phi_local;
457 theadd.wire_group = ((1 << 5) - 1) & (wire_group >> 2);
458 theadd.cscid = cscid;
503 int GlobalPhiMin = (
_subsector == 1) ? 0x42 : 0x800;
504 int GlobalPhiMax = (
_subsector == 1) ? 0x7ff : 0xfbd;
505 double GlobalPhiShift = (1.0 * GlobalPhiMin + (GlobalPhiMax - GlobalPhiMin) / 2.0);
507 double dt_out =
static_cast<double>(csclut.global_phi) - GlobalPhiShift;
510 dt_out = (dt_out / 1982) * 2145;
514 dtlut.global_phi = 0x7ff &
static_cast<unsigned>(dt_out);
516 dtlut.global_phi =
static_cast<unsigned>(-dt_out);
517 dtlut.global_phi = ~dtlut.global_phi;
518 dtlut.global_phi |= 0x800;
528 address.cscid = cscid;
529 address.wire_group = ((1 << 5) - 1) & (wire_group >> 2);
530 address.phi_local = phi_local;
571 const unsigned& thewire_group,
572 const unsigned& thephi_local)
const {
574 unsigned wire_group = thewire_group;
575 int cscid = thecscid;
576 unsigned phi_local = thephi_local;
580 bool me1ir_only =
false;
589 const unsigned numBins = 1 << 2;
591 if (phi_local > numBins - 1) {
593 <<
"warning: phiL " << phi_local <<
" is out of bounds [0-" << numBins - 1 <<
"]\n";
594 phi_local = numBins - 1;
607 if (wire_group >= nWireGroups) {
609 <<
"warning: wireGroup " << wire_group <<
" is out of bounds [0-" << nWireGroups <<
")\n";
610 wire_group = nWireGroups - 1;
629 <<
") is not divisible by numBins " << numBins <<
" Station " <<
_station <<
" sector " <<
_sector 630 <<
" subsector " <<
_subsector <<
" cscid " << cscid <<
"\n";
632 unsigned maxStripPrevBin = 0, maxStripThisBin = 0;
633 unsigned correctionStrip;
637 maxStripThisBin = nStripsPerBin * (phi_local + 1);
638 if (maxStripThisBin <= nStrips) {
639 correctionStrip = nStripsPerBin / 2 * (2 * phi_local + 1);
645 maxStripPrevBin = nStripsPerBin * phi_local;
646 correctionStrip = (nStrips + maxStripPrevBin) / 2;
653 result = gPoint.
eta();
657 LogDebug(
"CSCSectorReceiver|OutofBoundInput") << e.
what();
660 return std::fabs(result);
665 double float_eta =
getGlobalEtaValue(address.cscid, address.wire_group, address.phi_local);
666 unsigned int_eta = 0;
667 unsigned bend_global = 0;
669 const unsigned me12EtaCut = 56;
675 << address.cscid <<
" wire group " << address.wire_group;
687 float_eta = float_eta / etaPerBin;
688 int_eta =
static_cast<unsigned>(float_eta);
701 if (ring == 1 && int_eta < me12EtaCut) {
702 int_eta = me12EtaCut;
703 }
else if (ring == 2 && int_eta >= me12EtaCut) {
704 int_eta = me12EtaCut - 1;
707 result.global_eta = int_eta;
709 result.global_bend = bend_global;
715 int tphi_bend,
int tphi_local,
int twire_group,
int tcscid,
const bool gangedME1a)
const {
719 theadd.phi_bend = tphi_bend;
721 theadd.wire_group = twire_group;
722 theadd.cscid = tcscid;
799 std::ifstream LocalPhiLUT;
804 LocalPhiLUT.open(
fName.c_str(), std::ios::binary);
806 int length = LocalPhiLUT.tellg();
808 LocalPhiLUT.seekg(0, std::ios::beg);
809 LocalPhiLUT.read(reinterpret_cast<char*>(
me_lcl_phi), length);
815 LocalPhiLUT.open(
fName.c_str());
817 unsigned short temp = 0;
828 std::ifstream GlobalPhiLUT;
833 GlobalPhiLUT.open(fName.c_str(), std::ios::binary);
835 int length = GlobalPhiLUT.tellg();
837 GlobalPhiLUT.seekg(0, std::ios::beg);
838 GlobalPhiLUT.read(reinterpret_cast<char*>(
me_global_phi), length);
840 edm::LogError(
"CSCSectorReceiverLUT") <<
"File " << fName <<
" is incorrect size!";
841 GlobalPhiLUT.close();
843 GlobalPhiLUT.open(fName.c_str());
844 unsigned short temp = 0;
847 GlobalPhiLUT >>
temp;
850 GlobalPhiLUT.close();
857 std::ifstream GlobalPhiLUT;
862 GlobalPhiLUT.open(fName.c_str(), std::ios::binary);
864 int length = GlobalPhiLUT.tellg();
866 GlobalPhiLUT.seekg(0, std::ios::beg);
867 GlobalPhiLUT.read(reinterpret_cast<char*>(
mb_global_phi), length);
869 edm::LogError(
"CSCSectorReceiverLUT") <<
"File " << fName <<
" is incorrect size!";
870 GlobalPhiLUT.close();
872 GlobalPhiLUT.open(fName.c_str());
873 unsigned short temp = 0;
876 GlobalPhiLUT >>
temp;
879 GlobalPhiLUT.close();
885 std::ifstream GlobalEtaLUT;
890 GlobalEtaLUT.open(fName.c_str(), std::ios::binary);
892 int length = GlobalEtaLUT.tellg();
894 GlobalEtaLUT.seekg(0, std::ios::beg);
895 GlobalEtaLUT.read(reinterpret_cast<char*>(
me_global_eta), length);
897 edm::LogError(
"CSCSectorReceiverLUT") <<
"File " << fName <<
" is incorrect size!";
898 GlobalEtaLUT.close();
900 GlobalEtaLUT.open(fName.c_str());
901 unsigned short temp = 0;
904 GlobalEtaLUT >>
temp;
907 GlobalEtaLUT.close();
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
LocalPoint stripWireGroupIntersection(int strip, int wireGroup) const
T getUntrackedParameter(std::string const &, T const &) const
lclphidat localPhi(int strip, int pattern, int quality, int lr, const bool gangedME1a=false) const
Geometry Lookup Tables.
static global_phi_data calcGlobalPhiMEMini(unsigned short endcap, unsigned short sector, unsigned short station, unsigned short subsector, unsigned theadd, const bool gangedME1a)
gblphidat * me_global_phi
static int maxTriggerCscId()
static double getPosition(int pattern)
Geom::Phi< T > phi() const
static const double minEta
int numberOfStrips() const
char const * what() const override
gbletadat calcGlobalEtaME(const gbletaadd &address) const
Global Eta LUT.
std::string encodeFileIndex() const
Helpers.
class global_phi_address gblphiadd
edm::FileInPath mb_gbl_phi_file
const Plane & surface() const
The nominal surface of the GeomDet.
CSCSectorReceiverLUT & operator=(const CSCSectorReceiverLUT &)
int numberOfWireGroups() const
static int ringFromTriggerLabels(int station, int triggerCSCID)
nStrips
1.2 is to make the matching window safely the two nearest strips 0.35 is the size of an ME0 chamber i...
double getGlobalPhiValue(const CSCLayer *thelayer, const unsigned &strip, const unsigned &wire_group) const
static const double SECTOR1_CENT_RAD
gblphidat globalPhiME(int phi_local, int wire_group, int cscid, const bool gangedME1a=false) const
double getGlobalEtaValue(const unsigned &cscid, const unsigned &wire_group, const unsigned &phi_local) const
gblphidat * mb_global_phi
edm::FileInPath me_gbl_phi_file
edm::FileInPath me_lcl_phi_file
CSCSectorReceiverLUT(int endcap, int sector, int subsector, int station, const edm::ParameterSet &pset, bool TMB07)
const CSCLayer * layer(CSCDetId id) const
Return the layer corresponding to the given id.
gbletadat * me_global_eta
static const double maxEta
static lclphidat calcLocalPhiMini(unsigned theadd, const bool gangedME1a)
GlobalPoint centerOfWireGroup(int wireGroup) const
gblphidat globalPhiMB(int phi_local, int wire_group, int cscid, const bool gangedME1a=false) const
GlobalPoint centerOfStrip(int strip) const
static double get2007Position(int pattern)
edm::FileInPath me_gbl_eta_file
static const double SECTOR_DEG
static lclphidat * me_lcl_phi
class global_phi_data gblphidat
const CSCChamber * chamber(CSCDetId id) const
Return the chamber corresponding to given DetId.
class local_phi_address lclphiadd
class local_phi_data lclphidat
Data Types.
static bool me_lcl_phi_loaded
char data[epos_bytes_allocation]
gbletadat globalEtaME(int phi_bend, int phi_local, int wire_group, int cscid, const bool gangedME1a=false) const
gblphidat calcGlobalPhiME(const gblphiadd &address) const
Global Phi LUT.
class global_eta_address gbletaadd
static const double SECTOR_RAD
std::string fullPath() const
lclphidat calcLocalPhi(const lclphiadd &address) const
Local Phi LUT.
static int minTriggerCscId()
class global_eta_data gbletadat
const CSCGeometry * csc_g
static global_eta_data calcGlobalEtaMEMini(unsigned short endcap, unsigned short sector, unsigned short station, unsigned short subsector, unsigned theadd, const bool gangedME1a)
const CSCLayerGeometry * geometry() const
static int chamberFromTriggerLabels(int TriggerSector, int TriggerSubSector, int station, int TriggerCSCID)
gblphidat calcGlobalPhiMB(const gblphidat &me_gphi_data) const