CMS 3D CMS Logo

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