25 : _endcap(endcap), _sector(sector), _subsector(subsector), _station(station), isTMB07(TMB07) {
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;
180 const int strip,
const int pattern,
const int quality,
const int lr,
const bool gangedME1a)
const {
183 theadd.strip =
strip;
184 theadd.clct_pattern = pattern & 0x7;
185 theadd.pattern_type = (pattern & 0x8) >> 3;
190 return localPhi(theadd, gangedME1a);
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";
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.;
325 const double hsWidth_l = fabs(phi_l -
getGlobalPhiValue(thelayer, nStrips - 1, wire_group)) / 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;
371 if (strip < nStrips) {
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;
421 result.global_phi = 0;
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 <<
" "
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;
644 result = gPoint.
eta();
648 LogDebug(
"CSCSectorReceiver|OutofBoundInput") << e.
what();
651 return std::fabs(result);
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);
831 edm::LogError(
"CSCSectorReceiverLUT") <<
"File " << fName <<
" is incorrect size!";
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);
860 edm::LogError(
"CSCSectorReceiverLUT") <<
"File " << fName <<
" is incorrect size!";
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);
888 edm::LogError(
"CSCSectorReceiverLUT") <<
"File " << fName <<
" is incorrect size!";
889 GlobalEtaLUT.close();
891 GlobalEtaLUT.open(fName.c_str());
892 unsigned short temp = 0;
895 GlobalEtaLUT >>
temp;
898 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
uint32_t const *__restrict__ Quality * quality
static int maxTriggerCscId()
Geom::Phi< T > phi() const
static const double minEta
int numberOfStrips() const
gbletadat calcGlobalEtaME(const gbletaadd &address) const
Global Eta LUT.
std::string encodeFileIndex() const
Helpers.
Log< level::Error, false > LogError
class global_phi_address gblphiadd
edm::FileInPath mb_gbl_phi_file
tuple nStrips
1.2 is to make the matching window safely the two nearest strips 0.35 is the size of an ME0 chamber i...
const Plane & surface() const
The nominal surface of the GeomDet.
CSCSectorReceiverLUT & operator=(const CSCSectorReceiverLUT &)
int numberOfWireGroups() const
static int ringFromTriggerLabels(int station, int triggerCSCID)
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)
char const * what() const noexceptoverride
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
double delta_phi(double ph11, double phi2)
Log< level::Info, false > LogInfo
GlobalPoint centerOfStrip(int strip) const
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
static double getLegacyPosition(int pattern)
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()
Log< level::Warning, false > LogWarning
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