Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-08-26 03:15:45

0001 #include "DataFormats/MuonDetId/interface/CSCDetId.h"
0002 
0003 int CSCDetId::triggerSector() const {
0004   // UPDATED TO OCT 2005 - LGRAY Feb 2006
0005 
0006   int result;
0007   int ring = this->ring();
0008   int station = this->station();
0009   int chamber = this->chamber();
0010 
0011   if (station > 1 && ring > 1) {
0012     result = ((static_cast<unsigned>(chamber - 3) & 0x7f) / 6) + 1;  // ch 3-8->1, 9-14->2, ... 1,2 -> 6
0013   } else {
0014     result = (station != 1) ? ((static_cast<unsigned>(chamber - 2) & 0x1f) / 3) + 1 :  // ch 2-4-> 1, 5-7->2, ...
0015                  ((static_cast<unsigned>(chamber - 3) & 0x7f) / 6) + 1;
0016   }
0017 
0018   // max sector is 6, some calculations give a value greater than six but this is expected.
0019   return (result <= 6) ? result : 6;
0020 }
0021 
0022 int CSCDetId::triggerCscId() const {
0023   // UPDATED TO OCT 2005 - LGRAY Feb 2006
0024 
0025   int result;
0026   int ring = this->ring();
0027   int station = this->station();
0028   int chamber = this->chamber();
0029 
0030   if (station == 1) {
0031     result = (chamber) % 3 + 1;  // 1,2,3
0032     switch (ring) {
0033       case 1:
0034         break;
0035       case 2:
0036         result += 3;  // 4,5,6
0037         break;
0038       case 3:
0039         result += 6;  // 7,8,9
0040         break;
0041     }
0042   } else {
0043     if (ring == 1) {
0044       result = (chamber + 1) % 3 + 1;  // 1,2,3
0045     } else {
0046       result = (chamber + 3) % 6 + 4;  // 4,5,6,7,8,9
0047     }
0048   }
0049   return result;
0050 }
0051 
0052 unsigned short CSCDetId::iChamberType(unsigned short istation, unsigned short iring) {
0053   int i = 2 * istation + iring;  // i=2S+R ok for S=2, 3, 4
0054   if (istation == 1) {
0055     --i;  // ring 1R -> i=1+R (2S+R-1=1+R for S=1)
0056     if (i > 4)
0057       i = 1;  // But ring 1A (R=4) -> i=1
0058   }
0059   return i;
0060 }
0061 
0062 bool CSCDetId::isME1a() const { return iChamberType(station(), ring()) == 1; }
0063 bool CSCDetId::isME1b() const { return iChamberType(station(), ring()) == 2; }
0064 bool CSCDetId::isME11() const { return isME1a() or isME1b(); }
0065 bool CSCDetId::isME12() const { return iChamberType(station(), ring()) == 3; }
0066 bool CSCDetId::isME13() const { return iChamberType(station(), ring()) == 4; }
0067 bool CSCDetId::isME21() const { return iChamberType(station(), ring()) == 5; }
0068 bool CSCDetId::isME22() const { return iChamberType(station(), ring()) == 6; }
0069 bool CSCDetId::isME31() const { return iChamberType(station(), ring()) == 7; }
0070 bool CSCDetId::isME32() const { return iChamberType(station(), ring()) == 8; }
0071 bool CSCDetId::isME41() const { return iChamberType(station(), ring()) == 9; }
0072 bool CSCDetId::isME42() const { return iChamberType(station(), ring()) == 10; }
0073 
0074 std::string CSCDetId::chamberName(int endcap, int station, int ring, int chamber) {
0075   const std::string eSign = endcap == 1 ? "+" : "-";
0076   return "ME" + eSign + std::to_string(station) + "/" + std::to_string(ring) + "/" + std::to_string(chamber);
0077 }
0078 
0079 std::string CSCDetId::layerName(int endcap, int station, int ring, int chamber, int layer) {
0080   const std::string eSign = endcap == 1 ? "+" : "-";
0081   return "ME" + eSign + std::to_string(station) + "/" + std::to_string(ring) + "/" + std::to_string(chamber) + "/" +
0082          std::to_string(layer);
0083 }
0084 
0085 std::string CSCDetId::chamberName(int chamberType) {
0086   // ME1a, ME1b, ME12, ME13, ME21, ME22, ME31, ME32, ME41, ME42
0087   const unsigned stations[10] = {1, 1, 1, 1, 2, 2, 3, 3, 4, 4};
0088   const std::string rings[10] = {"A", "B", "2", "3", "1", "2", "1", "2", "1", "2"};
0089   return "ME" + std::to_string(stations[chamberType - 1]) + rings[chamberType - 1];
0090 }
0091 
0092 std::string CSCDetId::chamberName() const { return chamberName(endcap(), station(), ring(), chamber()); }
0093 
0094 std::string CSCDetId::layerName() const { return layerName(endcap(), station(), ring(), chamber(), layer()); }
0095 
0096 std::ostream& operator<<(std::ostream& os, const CSCDetId& id) {
0097   // Note that there is no endl to end the output
0098 
0099   os << " E:" << id.endcap() << " S:" << id.station() << " R:" << id.ring() << " C:" << id.chamber()
0100      << " L:" << id.layer();
0101   return os;
0102 }