CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
CSCNumberingScheme.cc
Go to the documentation of this file.
6 
7 //#define EDM_ML_DEBUG
8 
9 CSCNumberingScheme::CSCNumberingScheme(const MuonGeometryConstants& muonConstants) { initMe(muonConstants); }
10 
12  int theLevelPart = muonConstants.getValue("level");
13  theRegionLevel = muonConstants.getValue("me_region") / theLevelPart;
14  theStationLevel = muonConstants.getValue("me_station") / theLevelPart;
15  theSubringLevel = muonConstants.getValue("me_subring") / theLevelPart;
16  theSectorLevel = muonConstants.getValue("me_sector") / theLevelPart;
17  theRingLevel = muonConstants.getValue("me_ring") / theLevelPart;
18  theLayerLevel = muonConstants.getValue("me_layer") / theLevelPart;
19 #ifdef EDM_ML_DEBUG
20  edm::LogVerbatim("MuonGeom") << "Initialize CSCNumberingScheme"
21  << "\ntheRegionLevel " << theRegionLevel << "\ntheStationLevel " << theStationLevel
22  << "\ntheSubringLevel " << theSubringLevel << "\ntheSectorLevel " << theSectorLevel
23  << "\ntheRingLevel " << theRingLevel << "\ntheLayerLevel " << theLayerLevel;
24 #endif
25 }
26 
28 #ifdef EDM_ML_DEBUG
29  edm::LogVerbatim("MuonGeom") << "CSCNumbering " << num.getLevels();
30  for (int level = 1; level <= num.getLevels(); level++) {
31  edm::LogVerbatim("MuonGeom") << level << " " << num.getSuperNo(level) << " " << num.getBaseNo(level);
32  }
33 #endif
34  int fwbw_id = 0;
35  int station_id = 0;
36  int ring_id = 0;
37  int subring_id = 0;
38  int sector_id = 0;
39  int layer_id = 0;
40 
41  // Decode endcap levels
42  // We should be able to work with 6 (layer-level) or 5 (chamber-level)
43 
44  for (int level = 1; level <= num.getLevels(); level++) {
45  if (level == theRegionLevel) {
46  const int copyno = num.getBaseNo(level);
47  fwbw_id = copyno + 1;
48 #ifdef EDM_ML_DEBUG
49  edm::LogVerbatim("MuonGeom") << "endcap=" << fwbw_id;
50 #endif
51  } else if (level == theStationLevel) {
52  const int station_tag = num.getSuperNo(level);
53  station_id = station_tag;
54 #ifdef EDM_ML_DEBUG
55  edm::LogVerbatim("MuonGeom") << "station=" << station_id;
56 #endif
57  } else if (level == theSubringLevel) {
58  const int copyno = num.getBaseNo(level);
59  subring_id = copyno + 1;
60 #ifdef EDM_ML_DEBUG
61  edm::LogVerbatim("MuonGeom") << "subring=" << subring_id;
62 #endif
63  } else if (level == theSectorLevel) {
64  const int copyno = num.getBaseNo(level);
65  sector_id = copyno + 1;
66 #ifdef EDM_ML_DEBUG
67  edm::LogVerbatim("MuonGeom") << "sector=" << sector_id;
68 #endif
69  } else if (level == theLayerLevel) {
70  const int copyno = num.getBaseNo(level);
71  layer_id = copyno + 1;
72 #ifdef EDM_ML_DEBUG
73  edm::LogVerbatim("MuonGeom") << "layer=" << layer_id;
74 #endif
75  } else if (level == theRingLevel) {
76  const int ring_tag = num.getSuperNo(level);
77  ring_id = ring_tag;
78 #ifdef EDM_ML_DEBUG
79  edm::LogVerbatim("MuonGeom") << "ring=" << ring_id;
80 #endif
81  }
82  }
83 
84  // check validity
85 
86  if ((fwbw_id < 1) || (fwbw_id > 2)) {
87  edm::LogError("MuonGeom") << "@SUB=CSCNumberingScheme::baseNumberToUnitNumber"
88  << "forward/backward id out of range:" << fwbw_id;
89  }
90 
91  if ((station_id < 1) || (station_id > 4)) {
92  edm::LogError("MuonGeom") << "@SUB=CSCNumberingScheme::baseNumberToUnitNumber"
93  << "station id out of range:" << station_id;
94  }
95 
96  if ((ring_id < 1) || (ring_id > 4)) {
97  edm::LogError("MuonGeom") << "@SUB=CSCNumberingScheme::baseNumberToUnitNumber"
98  << "ring id out of range:" << ring_id;
99  }
100 
101  if ((subring_id < 1) || (subring_id > 2)) {
102  edm::LogError("MuonGeom") << "@SUB=CSCNumberingScheme::baseNumberToUnitNumber"
103  << "subring id out of range:" << subring_id;
104  }
105 
106  if ((sector_id < 1) || (sector_id > 36)) {
107  edm::LogError("MuonGeom") << "@SUB=CSCNumberingScheme::baseNumberToUnitNumber"
108  << "sector id out of range:" << sector_id;
109  }
110 
111  // Allow id=0 since that means a chamber
112  if ((layer_id < 0) || (layer_id > 6)) {
113  edm::LogError("MuonGeom") << "@SUB=CSCNumberingScheme::baseNumberToUnitNumber"
114  << "layer id out of range" << layer_id;
115  }
116 
117  // find appropriate chamber label
118 
119  int chamber_id = chamberIndex(station_id, ring_id, subring_id, sector_id);
120 
121  // convert into raw id of appropriate DetId
122 
123  int intIndex = CSCDetId::rawIdMaker(fwbw_id, station_id, ring_id, chamber_id, layer_id);
124 
125 #ifdef EDM_ML_DEBUG
126  edm::LogVerbatim("MuonGeom") << "CSCNumberingScheme : fw/bw " << fwbw_id << " station " << station_id << " ring "
127  << ring_id << " subring " << subring_id << " chamber " << chamber_id << " sector "
128  << sector_id << " layer " << layer_id;
129 #endif
130 
131  return intIndex;
132 }
133 
134 int CSCNumberingScheme::chamberIndex(int station_id, int ring_id, int subring_id, int sector_id) const {
135  int chamber_id = 0;
136 
137  // chamber label is related to sector_id but we need to
138  // adjust to real hardware labelling
139  // Tim confirms this works properly according to CMS IN 2000/004 Version 2.5 March 2007.
140 
141  if (ring_id == 3) {
142  chamber_id = sector_id;
143  } else {
144  if (subring_id == 1) {
145  chamber_id = 2 * sector_id - 1;
146  } else {
147  chamber_id = 2 * sector_id;
148  }
149  }
150 
151  return chamber_id;
152 }
Log< level::Info, true > LogVerbatim
int getValue(const std::string &name) const
int getBaseNo(int level) const
static int rawIdMaker(int iendcap, int istation, int iring, int ichamber, int ilayer)
Definition: CSCDetId.h:146
Log< level::Error, false > LogError
void initMe(const MuonGeometryConstants &muonConstants)
int chamberIndex(int, int, int, int) const
int baseNumberToUnitNumber(const MuonBaseNumber &) const override
CSCNumberingScheme(const MuonGeometryConstants &muonConstants)
int getLevels() const
int getSuperNo(int level) const
tuple level
Definition: testEve_cfg.py:47