CMS 3D CMS Logo

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