File indexing completed on 2024-04-06 12:04:46
0001 #ifndef MuonDetId_CSCDetId_h
0002 #define MuonDetId_CSCDetId_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019 #include "DataFormats/DetId/interface/DetId.h"
0020 #include "DataFormats/MuonDetId/interface/MuonSubdetId.h"
0021
0022 class CSCDetId;
0023
0024 std::ostream& operator<<(std::ostream& os, const CSCDetId& id);
0025
0026 class CSCDetId : public DetId {
0027 public:
0028
0029
0030 CSCDetId() : DetId(DetId::Muon, MuonSubdetId::CSC) {}
0031
0032
0033
0034 CSCDetId(uint32_t id) : DetId(id) {}
0035 CSCDetId(DetId id) : DetId(id) {}
0036
0037
0038
0039
0040
0041 CSCDetId(int iendcap, int istation, int iring, int ichamber, int ilayer = 0) : DetId(DetId::Muon, MuonSubdetId::CSC) {
0042 id_ |= init(iendcap, istation, iring, ichamber, ilayer);
0043 }
0044
0045
0046
0047 CSCDetId chamberId() const {
0048
0049 return CSCDetId(id_ - layer());
0050 }
0051
0052
0053
0054
0055
0056 int layer() const { return (id_ & MASK_LAYER); }
0057
0058
0059
0060
0061
0062 int chamber() const { return ((id_ >> START_CHAMBER) & MASK_CHAMBER); }
0063
0064
0065
0066
0067
0068 int ring() const {
0069 if (((id_ >> START_STATION) & MASK_STATION) == 1)
0070 return (detIdToInt((id_ >> START_RING) & MASK_RING));
0071 else
0072 return (((id_ >> START_RING) & MASK_RING));
0073 }
0074
0075
0076
0077
0078
0079 int station() const { return ((id_ >> START_STATION) & MASK_STATION); }
0080
0081
0082
0083
0084
0085 int endcap() const { return ((id_ >> START_ENDCAP) & MASK_ENDCAP); }
0086
0087
0088
0089
0090
0091 short int zendcap() const { return (endcap() != 1 ? -1 : +1); }
0092
0093
0094
0095
0096 unsigned short iChamberType() const { return iChamberType(station(), ring()); }
0097
0098
0099
0100
0101
0102
0103
0104
0105 int channel(int istrip) {
0106 if (ring() == 4)
0107
0108
0109 return 1 + (istrip - 1) % 16;
0110 else
0111 return istrip;
0112 }
0113
0114
0115
0116
0117 bool isME1a() const;
0118 bool isME1b() const;
0119 bool isME11() const;
0120 bool isME12() const;
0121 bool isME13() const;
0122 bool isME21() const;
0123 bool isME22() const;
0124 bool isME31() const;
0125 bool isME32() const;
0126 bool isME41() const;
0127 bool isME42() const;
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142
0143
0144
0145
0146 static int rawIdMaker(int iendcap, int istation, int iring, int ichamber, int ilayer) {
0147 return ((DetId::Muon & 0xF) << (DetId::kDetOffset)) |
0148 ((MuonSubdetId::CSC & 0x7) << (DetId::kSubdetOffset)) |
0149 init(iendcap, istation, iring, ichamber, ilayer);
0150 }
0151
0152
0153
0154
0155
0156 static int layer(int index) { return (index & MASK_LAYER); }
0157
0158
0159
0160
0161
0162 static int chamber(int index) { return ((index >> START_CHAMBER) & MASK_CHAMBER); }
0163
0164
0165
0166
0167
0168 static int ring(int index) {
0169 if (((index >> START_STATION) & MASK_STATION) == 1)
0170 return (detIdToInt((index >> START_RING) & MASK_RING));
0171 else
0172 return ((index >> START_RING) & MASK_RING);
0173 }
0174
0175
0176
0177
0178
0179 static int station(int index) { return ((index >> START_STATION) & MASK_STATION); }
0180
0181
0182
0183
0184
0185 static int endcap(int index) { return ((index >> START_ENDCAP) & MASK_ENDCAP); }
0186
0187
0188
0189
0190
0191
0192
0193 static unsigned short iChamberType(unsigned short istation, unsigned short iring);
0194
0195
0196
0197
0198
0199
0200
0201
0202
0203
0204
0205
0206
0207
0208
0209
0210
0211
0212
0213
0214 int triggerSector() const;
0215
0216
0217
0218
0219
0220
0221
0222
0223
0224
0225
0226
0227
0228
0229 int triggerCscId() const;
0230
0231
0232
0233
0234 static int minEndcapId() { return MIN_ENDCAP; }
0235 static int maxEndcapId() { return MAX_ENDCAP; }
0236 static int minStationId() { return MIN_STATION; }
0237 static int maxStationId() { return MAX_STATION; }
0238 static int minRingId() { return MIN_RING; }
0239 static int maxRingId() { return MAX_RING; }
0240 static int minChamberId() { return MIN_CHAMBER; }
0241 static int maxChamberId() { return MAX_CHAMBER; }
0242 static int minLayerId() { return MIN_LAYER; }
0243 static int maxLayerId() { return MAX_LAYER; }
0244
0245
0246
0247
0248
0249 static std::string chamberName(int endcap, int station, int ring, int chamber);
0250 static std::string chamberName(int iChamberType);
0251 std::string chamberName() const;
0252
0253
0254
0255
0256 static std::string layerName(int endcap, int station, int ring, int chamber, int layer);
0257 std::string layerName() const;
0258
0259 private:
0260
0261
0262
0263
0264 static uint32_t init(int iendcap, int istation, int iring, int ichamber, int ilayer) {
0265 if (istation == 1)
0266 iring = intToDetId(iring);
0267
0268 return (ilayer & MASK_LAYER) | ((ichamber & MASK_CHAMBER) << START_CHAMBER) | ((iring & MASK_RING) << START_RING) |
0269 ((istation & MASK_STATION) << START_STATION) | ((iendcap & MASK_ENDCAP) << START_ENDCAP);
0270 }
0271
0272
0273
0274
0275
0276
0277
0278
0279
0280
0281
0282 static int intToDetId(int iring) {
0283
0284
0285 int i = (iring + 1) % 4;
0286 if (i == 0)
0287 i = 4;
0288 return i;
0289 }
0290
0291 static int detIdToInt(int iring) {
0292
0293
0294 int i = (iring - 1);
0295 if (i == 0)
0296 i = 4;
0297 return i;
0298 }
0299
0300
0301
0302
0303 enum eMaxNum { MAX_ENDCAP = 2, MAX_STATION = 4, MAX_RING = 4, MAX_CHAMBER = 36, MAX_LAYER = 6 };
0304
0305 enum eMinNum { MIN_ENDCAP = 1, MIN_STATION = 1, MIN_RING = 1, MIN_CHAMBER = 1, MIN_LAYER = 1 };
0306
0307
0308
0309 enum eNumBitDet { BITS_ENDCAP = 3, BITS_STATION = 3, BITS_RING = 3, BITS_CHAMBER = 6, BITS_LAYER = 3 };
0310
0311
0312 enum eMaskBitDet { MASK_ENDCAP = 07, MASK_STATION = 07, MASK_RING = 07, MASK_CHAMBER = 077, MASK_LAYER = 07 };
0313
0314
0315 enum eStartBitDet {
0316 START_CHAMBER = BITS_LAYER,
0317 START_RING = START_CHAMBER + BITS_CHAMBER,
0318 START_STATION = START_RING + BITS_RING,
0319 START_ENDCAP = START_STATION + BITS_STATION
0320 };
0321 };
0322
0323 #endif