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";
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();
const CSCLayer * layer(CSCDetId id) const
Return the layer corresponding to the given id.
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
const CSCChamber * chamber(CSCDetId id) const
Return the chamber corresponding to given DetId.
std::string fullPath() const
static int maxTriggerCscId()
Geom::Phi< T > phi() const
static const double minEta
gblphidat globalPhiMB(int phi_local, int wire_group, int cscid, const bool gangedME1a=false) const
Log< level::Error, false > LogError
class global_phi_address gblphiadd
edm::FileInPath mb_gbl_phi_file
gbletadat calcGlobalEtaME(const gbletaadd &address) const
Global Eta LUT.
CSCSectorReceiverLUT & operator=(const CSCSectorReceiverLUT &)
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...
const CSCLayerGeometry * geometry() const
std::string encodeFileIndex() const
Helpers.
lclphidat calcLocalPhi(const lclphiadd &address) const
Local Phi LUT.
double getGlobalPhiValue(const CSCLayer *thelayer, const unsigned &strip, const unsigned &wire_group) const
static const double SECTOR1_CENT_RAD
int numberOfStrips() const
gblphidat * mb_global_phi
int numberOfWireGroups() const
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)
gbletadat * me_global_eta
static const double maxEta
static lclphidat calcLocalPhiMini(unsigned theadd, const bool gangedME1a)
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Log< level::Info, false > LogInfo
const Plane & surface() const
The nominal surface of the GeomDet.
gblphidat calcGlobalPhiME(const gblphiadd &address) const
Global Phi LUT.
edm::FileInPath me_gbl_eta_file
static const double SECTOR_DEG
static lclphidat * me_lcl_phi
double getGlobalEtaValue(const unsigned &cscid, const unsigned &wire_group, const unsigned &phi_local) const
class global_phi_data gblphidat
class local_phi_address lclphiadd
class local_phi_data lclphidat
Data Types.
gblphidat globalPhiME(int phi_local, int wire_group, int cscid, const bool gangedME1a=false) const
static bool me_lcl_phi_loaded
static double getLegacyPosition(int pattern)
gblphidat calcGlobalPhiMB(const gblphidat &me_gphi_data) const
lclphidat localPhi(int strip, int pattern, int quality, int lr, const bool gangedME1a=false) const
Geometry Lookup Tables.
char data[epos_bytes_allocation]
LocalPoint stripWireGroupIntersection(int strip, int wireGroup) const
class global_eta_address gbletaadd
static const double SECTOR_RAD
gbletadat globalEtaME(int phi_bend, int phi_local, int wire_group, int cscid, const bool gangedME1a=false) const
static int minTriggerCscId()
GlobalPoint centerOfStrip(int strip) const
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)
static int chamberFromTriggerLabels(int TriggerSector, int TriggerSubSector, int station, int TriggerCSCID)
GlobalPoint centerOfWireGroup(int wireGroup) const