File indexing completed on 2024-04-06 12:15:19
0001 #include "Geometry/RPCGeometry/interface/RPCGeomServ.h"
0002 #include "DataFormats/MuonDetId/interface/RPCDetId.h"
0003 #include <sstream>
0004 #include <iomanip>
0005
0006 RPCGeomServ::RPCGeomServ::RPCGeomServ(const RPCDetId& id)
0007 : _id(&id), _n(""), _sn(""), _cn(""), _t(-99), _z(true), _a(true) {}
0008
0009 RPCGeomServ::~RPCGeomServ(void) {}
0010
0011 std::string RPCGeomServ::name(void) {
0012 if (_n.empty()) {
0013 int station = _id->station();
0014 int region = _id->region();
0015 int roll = _id->roll();
0016 int ring = _id->ring();
0017 int layer = _id->layer();
0018 int sector = _id->sector();
0019 int subsector = _id->subsector();
0020
0021 std::stringstream os;
0022
0023 if (region == 0) {
0024 os << "W";
0025 os << std::setw(2) << std::setfill('+') << ring << std::setfill(' ') << "_";
0026
0027 os << "RB" << station;
0028 if (station <= 2) {
0029 (layer == 1) ? os << "in" : os << "out";
0030
0031 } else if (station > 2) {
0032 if (sector == 4 && station == 4) {
0033 if (subsector == 1) {
0034 os << "--";
0035 } else if (subsector == 2) {
0036 os << "-";
0037 } else if (subsector == 3) {
0038 os << "+";
0039 } else if (subsector == 4) {
0040 os << "++";
0041 }
0042 }
0043
0044 if (station == 3) {
0045 if (subsector == 1)
0046 os << "-";
0047 else
0048 os << "+";
0049 } else if (station == 4 && sector != 9 && sector != 11 && sector != 4) {
0050 if (subsector == 1)
0051 os << "-";
0052 else
0053 os << "+";
0054 }
0055 }
0056
0057 os << "_";
0058 os << "S" << std::setw(2) << std::setfill('0') << sector << std::setfill(' ');
0059 if (roll == 1)
0060 os << "_Backward";
0061 else if (roll == 3)
0062 os << "_Forward";
0063 else if (roll == 2)
0064 os << "_Middle";
0065 } else {
0066 os << "RE";
0067
0068 os << std::setw(2) << std::setfill('+') << station * region << std::setfill(' ') << "_";
0069
0070 os << "R" << ring;
0071 os << "_CH" << std::setw(2) << std::setfill('0') << this->segment();
0072
0073 if (roll == 1)
0074 os << "_A";
0075 else if (roll == 2)
0076 os << "_B";
0077 else if (roll == 3)
0078 os << "_C";
0079 else if (roll == 4)
0080 os << "_D";
0081 else if (roll == 5)
0082 os << "_E";
0083 }
0084 _n = os.str();
0085 }
0086 return _n;
0087 }
0088
0089 std::string RPCGeomServ::chambername() {
0090 if (_cn.empty()) {
0091 int station = _id->station();
0092 int region = _id->region();
0093 int ring = _id->ring();
0094 int layer = _id->layer();
0095 int sector = _id->sector();
0096 int subsector = _id->subsector();
0097
0098 std::stringstream os;
0099
0100 if (region == 0) {
0101 os << "W";
0102
0103 os << std::setw(2) << std::setfill('+') << ring << std::setfill(' ') << "_";
0104
0105 os << "RB" << station;
0106 if (station <= 2) {
0107 (layer == 1) ? os << "in" : os << "out";
0108
0109 } else if (station > 2) {
0110 if (sector == 4 && station == 4) {
0111 if (subsector == 1) {
0112 os << "--";
0113 } else if (subsector == 2) {
0114 os << "-";
0115 } else if (subsector == 3) {
0116 os << "+";
0117 } else if (subsector == 4) {
0118 os << "++";
0119 }
0120 }
0121
0122 if (station == 3) {
0123 if (subsector == 1)
0124 os << "-";
0125 else
0126 os << "+";
0127 } else if (station == 4 && sector != 9 && sector != 11 && sector != 4) {
0128 if (subsector == 1)
0129 os << "-";
0130 else
0131 os << "+";
0132 }
0133 }
0134
0135 os << "_";
0136 os << "S" << std::setw(2) << std::setfill('0') << sector << std::setfill(' ');
0137 } else {
0138 os << "RE";
0139
0140 os << std::setw(2) << std::setfill('+') << station * region << std::setfill(' ') << "_";
0141
0142 os << "R" << ring;
0143 os << "_CH" << std::setw(2) << std::setfill('0') << this->segment();
0144 }
0145 _cn = os.str();
0146 }
0147 return _cn;
0148 }
0149
0150 std::string RPCGeomServ::shortname(void) {
0151 if (_sn.empty()) {
0152 int station = _id->station();
0153 int region = _id->region();
0154 int roll = _id->roll();
0155 int ring = _id->ring();
0156 int layer = _id->layer();
0157 int sector = _id->sector();
0158 int subsector = _id->subsector();
0159
0160 std::stringstream os;
0161
0162 if (region == 0) {
0163 os << "RB" << station;
0164 if (station <= 2) {
0165 (layer == 1) ? os << "in" : os << "out";
0166
0167 } else {
0168 if (sector == 4 && station == 4) {
0169 if (subsector == 1) {
0170 os << "--";
0171 } else if (subsector == 2) {
0172 os << ",-";
0173 } else if (subsector == 3) {
0174 os << "+";
0175 } else if (subsector == 4) {
0176 os << "++";
0177 }
0178 } else {
0179 if (subsector == 1)
0180 os << ",-";
0181 else
0182 os << "+";
0183 }
0184 }
0185 if (roll == 1)
0186 os << " B";
0187 else if (roll == 3)
0188 os << " F";
0189 else if (roll == 2)
0190 os << " M";
0191 } else {
0192 os << "Ri" << ring << " Su" << subsector;
0193 }
0194 _sn = os.str();
0195 }
0196 return _sn;
0197 }
0198
0199
0200 std::vector<int> RPCGeomServ::channelInChip(void) {
0201 std::vector<int> chipCh(4, 8);
0202
0203 if (_id->region() == 0) {
0204 chipCh.clear();
0205
0206 int station = _id->station();
0207
0208 if (station < 3 && _id->layer() == 1) {
0209 chipCh.emplace_back(7);
0210 chipCh.emplace_back(8);
0211 } else if (station == 1 || station == 3) {
0212 chipCh.emplace_back(7);
0213 chipCh.emplace_back(7);
0214 } else if (station == 2) {
0215 chipCh.emplace_back(6);
0216 chipCh.emplace_back(8);
0217 } else if (_id->sector() == 4 || _id->sector() == 10 || (_id->sector() == 8 && _id->subsector() != 1) ||
0218 (_id->sector() == 12 && _id->subsector() == 1)) {
0219 chipCh.emplace_back(6);
0220 chipCh.emplace_back(6);
0221 } else {
0222 chipCh.emplace_back(8);
0223 chipCh.emplace_back(8);
0224 }
0225 }
0226
0227 return chipCh;
0228 }
0229
0230 int RPCGeomServ::eta_partition() {
0231 if (_t < -90) {
0232 if (_id->region() == 0) {
0233 if (this->inverted()) {
0234 _t = 3 * (_id->ring()) + (3 - _id->roll()) - 1;
0235 } else {
0236 _t = 3 * (_id->ring()) + _id->roll() - 2;
0237 }
0238 } else {
0239 _t = _id->region() * (3 * (3 - _id->ring()) + _id->roll() + 7);
0240 }
0241 }
0242 return _t;
0243 }
0244
0245 int RPCGeomServ::chambernr() {
0246
0247 if (_id->station() == 1) {
0248
0249 if (_id->layer() == 1) {
0250 if (_id->roll() == 1)
0251 _cnr = 1;
0252 else
0253 _cnr = 2;
0254 }
0255
0256 else {
0257 if (_id->roll() == 1)
0258 _cnr = 3;
0259 else
0260 _cnr = 4;
0261 }
0262 }
0263
0264
0265 if (_id->station() == 2) {
0266
0267 if (_id->layer() == 1) {
0268 if (_id->roll() == 1)
0269 _cnr = 5;
0270 if (_id->roll() == 3)
0271 _cnr = 6;
0272 if (_id->roll() == 2)
0273 _cnr = 7;
0274 }
0275
0276 else {
0277 if (_id->roll() == 2)
0278
0279 _cnr = 7;
0280
0281 if (_id->roll() == 1)
0282 _cnr = 8;
0283 if (_id->roll() == 3)
0284 _cnr = 9;
0285 }
0286 }
0287
0288
0289 if (_id->station() == 3) {
0290 if (_id->subsector() == 1) {
0291 if (_id->roll() == 1)
0292 _cnr = 10;
0293 else
0294 _cnr = 11;
0295 } else {
0296 if (_id->roll() == 1)
0297 _cnr = 12;
0298 else
0299 _cnr = 13;
0300 }
0301 }
0302
0303
0304 if (_id->station() == 4) {
0305 if (_id->sector() == 4) {
0306 if (_id->subsector() == 2) {
0307
0308 if (_id->roll() == 1)
0309 _cnr = 14;
0310 else
0311 _cnr = 15;
0312 }
0313
0314 if (_id->subsector() == 3) {
0315
0316 if (_id->roll() == 1)
0317 _cnr = 16;
0318 else
0319 _cnr = 17;
0320 }
0321
0322 if (_id->subsector() == 1) {
0323
0324 if (_id->roll() == 1)
0325 _cnr = 18;
0326 else
0327 _cnr = 19;
0328 }
0329
0330 if (_id->subsector() == 4) {
0331
0332 if (_id->roll() == 1)
0333 _cnr = 20;
0334 else
0335 _cnr = 21;
0336 }
0337
0338 }
0339
0340 else
0341
0342 {
0343 if (_id->subsector() == 1) {
0344 if (_id->roll() == 1)
0345 _cnr = 14;
0346 else
0347 _cnr = 15;
0348 } else {
0349 if (_id->roll() == 1)
0350 _cnr = 16;
0351 else
0352 _cnr = 17;
0353 }
0354 }
0355 }
0356
0357
0358 return _cnr;
0359 }
0360
0361 int RPCGeomServ::segment(void) {
0362 int nsub = 6;
0363 int station = _id->station();
0364 int ring = _id->ring();
0365 (ring == 1 && station > 1) ? nsub = 3 : nsub = 6;
0366
0367 return (_id->subsector() + nsub * (_id->sector() - 1));
0368 }
0369
0370 bool RPCGeomServ::inverted() {
0371
0372 return !(this->zpositive());
0373 }
0374
0375 bool RPCGeomServ::zpositive() {
0376 if (_id->region() == 0 && _t < -90) {
0377 if (_id->ring() < 0) {
0378 _z = false;
0379 }
0380 if (_id->ring() == 0) {
0381 if (_id->sector() == 1 || _id->sector() == 4 || _id->sector() == 5 || _id->sector() == 8 || _id->sector() == 9 ||
0382 _id->sector() == 12) {
0383 _z = false;
0384 }
0385 }
0386 }
0387
0388 return _z;
0389 }
0390
0391 bool RPCGeomServ::aclockwise() {
0392 if (_id->region() == 0 && _t < -90) {
0393 if (_id->ring() > 0) {
0394 if (_id->layer() == 2) {
0395 _a = false;
0396 }
0397 } else if (_id->ring() < 0) {
0398 if (_id->layer() == 1) {
0399 _a = false;
0400 }
0401 } else if (_id->ring() == 0) {
0402 if ((_id->sector() == 1 || _id->sector() == 4 || _id->sector() == 5 || _id->sector() == 8 || _id->sector() == 9 ||
0403 _id->sector() == 12) &&
0404 _id->layer() == 1)
0405 _a = false;
0406 else if ((_id->sector() == 2 || _id->sector() == 3 || _id->sector() == 6 || _id->sector() == 7 ||
0407 _id->sector() == 10 || _id->sector() == 11) &&
0408 _id->layer() == 2)
0409 _a = false;
0410 }
0411 }
0412 return _a;
0413 }
0414
0415 RPCGeomServ::RPCGeomServ() : _id(nullptr), _n(""), _sn(""), _cn(""), _t(-99), _z(false), _a(false) {}