File indexing completed on 2024-04-06 12:15:18
0001 #include "DataFormats/MuonDetId/interface/CSCDetId.h"
0002 #include "Geometry/MuonNumbering/interface/CSCNumberingScheme.h"
0003 #include "Geometry/MuonNumbering/interface/MuonBaseNumber.h"
0004 #include "Geometry/MuonNumbering/interface/MuonGeometryConstants.h"
0005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0006
0007
0008
0009 CSCNumberingScheme::CSCNumberingScheme(const MuonGeometryConstants& muonConstants) { initMe(muonConstants); }
0010
0011 void CSCNumberingScheme::initMe(const MuonGeometryConstants& muonConstants) {
0012 int theLevelPart = muonConstants.getValue("level");
0013 theRegionLevel = muonConstants.getValue("me_region") / theLevelPart;
0014 theStationLevel = muonConstants.getValue("me_station") / theLevelPart;
0015 theSubringLevel = muonConstants.getValue("me_subring") / theLevelPart;
0016 theSectorLevel = muonConstants.getValue("me_sector") / theLevelPart;
0017 theRingLevel = muonConstants.getValue("me_ring") / theLevelPart;
0018 theLayerLevel = muonConstants.getValue("me_layer") / theLevelPart;
0019 #ifdef EDM_ML_DEBUG
0020 edm::LogVerbatim("MuonGeom") << "Initialize CSCNumberingScheme"
0021 << "\ntheRegionLevel " << theRegionLevel << "\ntheStationLevel " << theStationLevel
0022 << "\ntheSubringLevel " << theSubringLevel << "\ntheSectorLevel " << theSectorLevel
0023 << "\ntheRingLevel " << theRingLevel << "\ntheLayerLevel " << theLayerLevel;
0024 #endif
0025 }
0026
0027 int CSCNumberingScheme::baseNumberToUnitNumber(const MuonBaseNumber& num) const {
0028 #ifdef EDM_ML_DEBUG
0029 edm::LogVerbatim("MuonGeom") << "CSCNumbering " << num.getLevels();
0030 for (int level = 1; level <= num.getLevels(); level++) {
0031 edm::LogVerbatim("MuonGeom") << level << " " << num.getSuperNo(level) << " " << num.getBaseNo(level);
0032 }
0033 #endif
0034 int fwbw_id = 0;
0035 int station_id = 0;
0036 int ring_id = 0;
0037 int subring_id = 0;
0038 int sector_id = 0;
0039 int layer_id = 0;
0040
0041
0042
0043
0044 for (int level = 1; level <= num.getLevels(); level++) {
0045 if (level == theRegionLevel) {
0046 const int copyno = num.getBaseNo(level);
0047 fwbw_id = copyno + 1;
0048 #ifdef EDM_ML_DEBUG
0049 edm::LogVerbatim("MuonGeom") << "endcap=" << fwbw_id;
0050 #endif
0051 } else if (level == theStationLevel) {
0052 const int station_tag = num.getSuperNo(level);
0053 station_id = station_tag;
0054 #ifdef EDM_ML_DEBUG
0055 edm::LogVerbatim("MuonGeom") << "station=" << station_id;
0056 #endif
0057 } else if (level == theSubringLevel) {
0058 const int copyno = num.getBaseNo(level);
0059 subring_id = copyno + 1;
0060 #ifdef EDM_ML_DEBUG
0061 edm::LogVerbatim("MuonGeom") << "subring=" << subring_id;
0062 #endif
0063 } else if (level == theSectorLevel) {
0064 const int copyno = num.getBaseNo(level);
0065 sector_id = copyno + 1;
0066 #ifdef EDM_ML_DEBUG
0067 edm::LogVerbatim("MuonGeom") << "sector=" << sector_id;
0068 #endif
0069 } else if (level == theLayerLevel) {
0070 const int copyno = num.getBaseNo(level);
0071 layer_id = copyno + 1;
0072 #ifdef EDM_ML_DEBUG
0073 edm::LogVerbatim("MuonGeom") << "layer=" << layer_id;
0074 #endif
0075 } else if (level == theRingLevel) {
0076 const int ring_tag = num.getSuperNo(level);
0077 ring_id = ring_tag;
0078 #ifdef EDM_ML_DEBUG
0079 edm::LogVerbatim("MuonGeom") << "ring=" << ring_id;
0080 #endif
0081 }
0082 }
0083
0084
0085
0086 if ((fwbw_id < 1) || (fwbw_id > 2)) {
0087 edm::LogError("MuonGeom") << "@SUB=CSCNumberingScheme::baseNumberToUnitNumber"
0088 << "forward/backward id out of range:" << fwbw_id;
0089 }
0090
0091 if ((station_id < 1) || (station_id > 4)) {
0092 edm::LogError("MuonGeom") << "@SUB=CSCNumberingScheme::baseNumberToUnitNumber"
0093 << "station id out of range:" << station_id;
0094 }
0095
0096 if ((ring_id < 1) || (ring_id > 4)) {
0097 edm::LogError("MuonGeom") << "@SUB=CSCNumberingScheme::baseNumberToUnitNumber"
0098 << "ring id out of range:" << ring_id;
0099 }
0100
0101 if ((subring_id < 1) || (subring_id > 2)) {
0102 edm::LogError("MuonGeom") << "@SUB=CSCNumberingScheme::baseNumberToUnitNumber"
0103 << "subring id out of range:" << subring_id;
0104 }
0105
0106 if ((sector_id < 1) || (sector_id > 36)) {
0107 edm::LogError("MuonGeom") << "@SUB=CSCNumberingScheme::baseNumberToUnitNumber"
0108 << "sector id out of range:" << sector_id;
0109 }
0110
0111
0112 if ((layer_id < 0) || (layer_id > 6)) {
0113 edm::LogError("MuonGeom") << "@SUB=CSCNumberingScheme::baseNumberToUnitNumber"
0114 << "layer id out of range" << layer_id;
0115 }
0116
0117
0118
0119 int chamber_id = chamberIndex(station_id, ring_id, subring_id, sector_id);
0120
0121
0122
0123 int intIndex = CSCDetId::rawIdMaker(fwbw_id, station_id, ring_id, chamber_id, layer_id);
0124
0125 #ifdef EDM_ML_DEBUG
0126 edm::LogVerbatim("MuonGeom") << "CSCNumberingScheme : fw/bw " << fwbw_id << " station " << station_id << " ring "
0127 << ring_id << " subring " << subring_id << " chamber " << chamber_id << " sector "
0128 << sector_id << " layer " << layer_id;
0129 #endif
0130
0131 return intIndex;
0132 }
0133
0134 int CSCNumberingScheme::chamberIndex(int station_id, int ring_id, int subring_id, int sector_id) const {
0135 int chamber_id = 0;
0136
0137
0138
0139
0140
0141 if (ring_id == 3) {
0142 chamber_id = sector_id;
0143 } else {
0144 if (subring_id == 1) {
0145 chamber_id = 2 * sector_id - 1;
0146 } else {
0147 chamber_id = 2 * sector_id;
0148 }
0149 }
0150
0151 return chamber_id;
0152 }