File indexing completed on 2024-04-06 12:08:12
0001 #include "DQM/RPCMonitorClient/interface/RPCNameHelper.h"
0002 #include <fmt/format.h>
0003
0004 const std::array<std::string, 3> RPCNameHelper::regionNames = {{"Endcap-", "Barrel", "Endcap+"}};
0005
0006 std::string RPCNameHelper::name(const RPCDetId& detId, const bool useRoll) {
0007 return useRoll ? rollName(detId) : chamberName(detId);
0008 }
0009
0010 std::string RPCNameHelper::rollName(const RPCDetId& detId) {
0011 std::string chName = chamberName(detId);
0012 const int region = detId.region();
0013 const int roll = detId.roll();
0014
0015 if (region == 0) {
0016 if (roll == 1)
0017 chName += "_Backward";
0018 else if (roll == 3)
0019 chName += "_Forward";
0020 else
0021 chName += "_Middle";
0022 } else {
0023 if (roll == 1)
0024 chName += "_A";
0025 else if (roll == 2)
0026 chName += "_B";
0027 else if (roll == 3)
0028 chName += "_C";
0029 else if (roll == 4)
0030 chName += "_D";
0031 else if (roll == 5)
0032 chName += "_E";
0033 }
0034
0035 return chName;
0036 }
0037
0038 std::string RPCNameHelper::chamberName(const RPCDetId& detId) {
0039 const int region = detId.region();
0040 const int sector = detId.sector();
0041 if (region != 0) {
0042
0043 const int disk = detId.region() * detId.station();
0044 const int ring = detId.ring();
0045 const int nsub = (ring == 1 and detId.station() > 1) ? 3 : 6;
0046 const int segment = detId.subsector() + (detId.sector() - 1) * nsub;
0047
0048 return fmt::format("RE{:+2d}_R{}_CH{:02d}", disk, ring, segment);
0049 } else {
0050
0051 const int wheel = detId.ring();
0052 const int station = detId.station();
0053 const int layer = detId.layer();
0054 const int subsector = detId.subsector();
0055
0056 std::string roll;
0057 if (station <= 2) {
0058 roll = (layer == 1) ? "in" : "out";
0059 } else if (station == 3) {
0060 roll = (subsector == 1) ? "-" : "+";
0061 } else {
0062 if (sector == 4) {
0063 const static std::array<std::string, 4> ssarr = {{"--", "-", "+", "++"}};
0064 roll = ssarr[subsector - 1];
0065 } else if (sector != 9 && sector != 11) {
0066 roll = (subsector == 1) ? "-" : "+";
0067 }
0068 }
0069
0070 return fmt::format("W{:+2d}_RB{:d}{}_S{:02d}", wheel, station, roll, sector);
0071 }
0072
0073 return "";
0074 }
0075
0076 std::string RPCNameHelper::regionName(const int region) {
0077 if (region < -1 or region > 1)
0078 return "";
0079 return regionNames[region + 1];
0080 }