CMS 3D CMS Logo

CSCIndexerPostls1.cc
Go to the documentation of this file.
2 #include <algorithm>
3 
5 
6 std::pair<CSCDetId, CSCIndexerBase::IndexType> CSCIndexerPostls1::detIdFromStripChannelIndex(LongIndexType isi) const {
7  const LongIndexType lastnonme1a = 252288; // channels with ME42 installed
8  const LongIndexType lastpluszme1a = 262656; // last unganged ME1a +z channel = 252288 + 10368
9  const LongIndexType lastnonme42 = 217728; // channels in 2008 installed chambers
10  const LongIndexType lastplusznonme42 = 108864; // = 217728/2
11  const LongIndexType firstme13 = 34561; // First channel of ME13
12  const LongIndexType lastme13 = 48384; // Last channel of ME13
13 
14  const IndexType lastnonme42layer = 2808;
15  const IndexType lastplusznonme42layer = 1404; // = 2808/2
16  const IndexType firstme13layer = 433; // = 72*6 + 1 (ME13 chambers are 72-108 in range 1-234)
17  const IndexType lastme13layer = 648; // = 108*6
18 
19  bool me1a = false;
20 
21  // Most chambers (except ME13 & ME1a) have 80 channels index width allocated
22  // unganged ME1a have 48 channels
23  // ME13 have 64 channels
24  IndexType nchan = 80;
25 
26  // Set endcap to +z initially
27  IndexType ie = 1;
28 
29  LongIndexType istart = 0;
30  IndexType layerOffset = 0;
31 
32  if (isi <= lastnonme42) {
33  // Chambers as of 2008 Installation (ME11 keeps the same #of channels 80
34  // allocated for it in the index)
35  if (isi > lastplusznonme42) {
36  ie = 2;
37  isi -= lastplusznonme42;
38  }
39  if (isi > lastme13) // after ME13
40  {
41  istart = lastme13;
42  layerOffset = lastme13layer;
43  } else if (isi >= firstme13) // ME13
44  {
45  istart = firstme13 - 1;
46  layerOffset = firstme13layer - 1;
47  nchan = 64;
48  }
49  } else if (isi <= lastnonme1a) // ME42 chambers
50  {
51  istart = lastnonme42;
52  layerOffset = lastnonme42layer;
53  // don't care about ie, as ME42 stretch of indices is uniform
54  } else // Unganged ME1a channels
55  {
56  me1a = true;
57  if (isi > lastpluszme1a)
58  ie = 2;
59  istart = lastnonme1a;
60  nchan = 48;
61  // layerOffset stays 0, as we want to map them onto ME1b's layer indices
62  }
63 
64  isi -= istart; // remove earlier group(s)
65  IndexType ichan = (isi - 1) % nchan + 1;
66  IndexType ili = (isi - 1) / nchan + 1;
67  ili += layerOffset; // add appropriate offset for earlier group(s)
68  if (ie != 1)
69  ili += lastplusznonme42layer; // add offset to -z endcap; ME42 doesn't need
70  // this.
71 
72  CSCDetId id = detIdFromLayerIndex(ili);
73 
74  // For unganged ME1a we need to turn this ME11 detid into an ME1a one
75  if (me1a)
76  id = CSCDetId(id.endcap(), 1, 4, id.chamber(), id.layer());
77 
78  return std::make_pair(id, ichan);
79 }
80 
81 std::pair<CSCDetId, CSCIndexerBase::IndexType> CSCIndexerPostls1::detIdFromChipIndex(IndexType ici) const {
82  const LongIndexType lastnonme1a = 15768; // chips in chambers with ME42 installed
83  const LongIndexType lastpluszme1a = 16416; // last unganged ME1a +z chip = 15768 + 648 = 16416
84  const LongIndexType lastnonme42 = 13608; // chips in 2008 installed chambers
85  const LongIndexType lastplusznonme42 = 6804; // = 13608/2
86  const LongIndexType firstme13 = 2161; // First channel of ME13
87  const LongIndexType lastme13 = 3024; // Last channel of ME13
88 
89  const IndexType lastnonme42layer = 2808;
90  const IndexType lastplusznonme42layer = 1404; // = 2808/2
91  const IndexType firstme13layer = 433; // = 72*6 + 1 (ME13 chambers are 72-108 in range 1-234)
92  const IndexType lastme13layer = 648; // = 108*6
93 
94  bool me1a = false;
95 
96  // Most chambers (except ME13, ME1a) have 5 chips/layer
97  IndexType nchipPerLayer = 5;
98 
99  // Set endcap to +z. This should work for ME42 channels too, since we don't
100  // need to calculate its endcap explicitly.
101  IndexType ie = 1;
102 
103  LongIndexType istart = 0;
104  IndexType layerOffset = 0;
105 
106  if (ici <= lastnonme42) {
107  // Chambers as of 2008 Installation (ME11 keeps the same #of chips 5
108  // allocated for it in the index)
109  if (ici > lastplusznonme42) {
110  ie = 2;
111  ici -= lastplusznonme42;
112  }
113  if (ici > lastme13) // after ME13
114  {
115  istart = lastme13;
116  layerOffset = lastme13layer;
117  } else if (ici >= firstme13) // ME13
118  {
119  istart = firstme13 - 1;
120  layerOffset = firstme13layer - 1;
121  nchipPerLayer = 4;
122  }
123  } else if (ici <= lastnonme1a) // ME42 chambers
124  {
125  istart = lastnonme42;
126  layerOffset = lastnonme42layer;
127  // don't care about ie, as ME42 stratch of indices is uniform
128  } else // Unganged ME1a channels
129  {
130  me1a = true;
131  if (ici > lastpluszme1a)
132  ie = 2;
133  istart = lastnonme1a;
134  nchipPerLayer = 3;
135  // layerOffset stays 0, as we want to map them onto ME1b's layer indices
136  }
137 
138  ici -= istart; // remove earlier group(s)
139  IndexType ichip = (ici - 1) % nchipPerLayer + 1;
140  IndexType ili = (ici - 1) / nchipPerLayer + 1;
141  ili += layerOffset; // add appropriate offset for earlier group(s)
142  if (ie != 1)
143  ili += lastplusznonme42layer; // add offset to -z endcap; ME42 doesn't need
144  // this.
145 
146  CSCDetId id = detIdFromLayerIndex(ili);
147 
148  // For unganged ME1a we need to turn this ME11 detid into an ME1a one
149  if (me1a)
150  id = CSCDetId(id.endcap(), 1, 4, id.chamber(), id.layer());
151 
152  return std::make_pair(id, ichip);
153 }
154 
155 int CSCIndexerPostls1::dbIndex(const CSCDetId &id, int &channel) const {
156  int ec = id.endcap();
157  int st = id.station();
158  int rg = id.ring();
159  int ch = id.chamber();
160  int la = id.layer();
161 
162  return ec * 100000 + st * 10000 + rg * 1000 + ch * 10 + la;
163 }
164 
166  const int n_types = 20;
167  const IndexType type_starts[n_types] = {1, 1081, 4321, 6913, 8533, 13933, 15553, 20953, 22573, 23653,
168  26893, 29485, 31105, 36505, 38125, 43525, 45145, 50545, 55945, 56593};
169  //+1/1 +1/2 +1/3 +2/1 +2/2 +3/1 +3/2 +4/1 -1/1 -1/2 -1/3 -2/1
170  //-2/2 -3/1 -3/2 -4/1 +4/2 -4/2 +1/4 -1/4
171 
172  const int endcaps[n_types] = {1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 1, 2};
173  const int stations[n_types] = {1, 1, 1, 2, 2, 3, 3, 4, 1, 1, 1, 2, 2, 3, 3, 4, 4, 4, 1, 1};
174  const int rings[n_types] = {1, 2, 3, 1, 2, 1, 2, 1, 1, 2, 3, 1, 2, 1, 2, 1, 2, 2, 4, 4};
175 
176  // determine chamber type
177  std::vector<IndexType> v_type_starts(type_starts, type_starts + n_types);
178  int type = int(std::upper_bound(v_type_starts.begin(), v_type_starts.end(), igg) - v_type_starts.begin()) - 1;
179 
180  // determine factors for #HVsectors and #chips
181  int sectors_per_layer = sectorsPerLayer(stations[type], rings[type]);
182  int chips_per_layer = chipsPerLayer(stations[type], rings[type]);
183 
184  IndexType igg_chamber_etc = igg - type_starts[type] + 1;
185 
186  IndexType igg_chamber_and_layer = (igg_chamber_etc - 1) / sectors_per_layer + 1;
187 
188  // extract chamber & layer
189  int chamber = (igg_chamber_and_layer - 1) / 6 + 1;
190  int layer = (igg_chamber_and_layer - 1) % 6 + 1;
191 
192  IndexType igg_hvseg_etc = (igg_chamber_etc - 1) % sectors_per_layer + 1;
193 
194  // extract HVsegment and chip numbers
195  IndexType hvsegment = (igg_hvseg_etc - 1) / chips_per_layer + 1;
196  IndexType chip = (igg_hvseg_etc - 1) % chips_per_layer + 1;
197 
198  CSCDetId id(endcaps[type], stations[type], rings[type], chamber, layer);
199  return std::make_tuple(id, hvsegment, chip);
200 }
int dbIndex(const CSCDetId &id, int &channel) const override
uint32_t LongIndexType
~CSCIndexerPostls1() override
CSCIndexerBase::GasGainIndexType detIdFromGasGainIndex(IndexType igg) const override
CSCDetId detIdFromLayerIndex(IndexType ili) const
uint16_t IndexType
std::pair< CSCDetId, IndexType > detIdFromChipIndex(IndexType ichi) const override
std::pair< CSCDetId, IndexType > detIdFromStripChannelIndex(LongIndexType ichi) const override
IndexType sectorsPerLayer(IndexType is, IndexType ir) const
std::tuple< CSCDetId, IndexType, IndexType > GasGainIndexType
IndexType chipsPerLayer(IndexType is, IndexType ir) const override