1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
|
#include "CSCIndexerOldStartup.h"
#include <iostream>
void CSCIndexerOldStartup::fillChamberLabel() const {
// Fill the member vector which permits decoding of the linear chamber index
// Logically const since initializes cache only,
// Beware that the ME42 indices 235-270 within this vector do NOT correspond
// to their 'real' linear indices (which are 469-504 for +z)
chamberLabel.resize(271); // one more than #chambers per endcap. Includes ME42.
IndexType count = 0;
chamberLabel[count] = 0;
for (IndexType is = 1; is != 5; ++is) {
IndexType irmax = ringsInStation(is);
for (IndexType ir = 1; ir != irmax + 1; ++ir) {
IndexType icmax = chambersInRingOfStation(is, ir);
for (IndexType ic = 1; ic != icmax + 1; ++ic) {
chamberLabel[++count] = is * 1000 + ir * 100 + ic;
}
}
}
}
CSCDetId CSCIndexerOldStartup::detIdFromChamberIndex_OLD(IndexType ici) const {
// Will not work as is for ME42
// ============================
IndexType ie = 1;
if (ici > 234) {
ie = 2;
ici -= 234;
}
// Now ici is in range 1-234 (assuming valid input in range 1-468)
// MEij pairs...
const IndexType station[] = {0, 1, 1, 1, 2, 2, 3, 3, 4};
const IndexType ring[] = {0, 1, 2, 3, 1, 2, 1, 2, 1};
// MEij preceding a given MEij matching linear index above
const IndexType prevs[] = {0, 0, 1, 1, 1, 2, 2, 3, 3};
const IndexType prevr[] = {0, 0, 1, 2, 3, 1, 2, 1, 2};
IndexType is = 4;
IndexType ir = 1;
for (IndexType i = 2; i <= 8; ++i) {
IndexType js = station[i];
IndexType jr = ring[i];
// if it's before start of MEjs/jr then it's in the previous MEis/ir
if (ici < startChamberIndexInEndcap(ie, js, jr)) {
is = prevs[i];
ir = prevr[i];
break;
}
// otherwise it's in ME41
}
IndexType ic = ici - startChamberIndexInEndcap(ie, is, ir) + 1;
return CSCDetId(ie, is, ir, ic);
}
CSCDetId CSCIndexerOldStartup::detIdFromChamberIndex(IndexType ici) const {
// Expected range of input range argument is 1-540.
// 1-468 for CSCs installed at 2008 start-up. 469-540 for ME42.
IndexType ie = 1;
if (ici > 468) {
// ME42
ici -= 234; // now in range 235-306
if (ici > 270) { // -z
ie = 2;
ici -= 36; // now in range 235-270
}
} else { // in range 1-468
if (ici > 234) { // -z
ie = 2;
ici -= 234; // now in range 1-234
}
}
if (chamberLabel.empty())
fillChamberLabel();
IndexType label = chamberLabel[ici];
return detIdFromChamberLabel(ie, label);
}
CSCIndexerOldStartup::IndexType CSCIndexerOldStartup::chamberLabelFromChamberIndex(IndexType ici) const {
// This is just for cross-checking
// Expected range of input range argument is 1-540.
// 1-468 for CSCs installed at 2008 start-up. 469-540 for ME42.
if (ici > 468) {
// ME42
ici -= 234; // now in range 235-306
if (ici > 270) { // -z
ici -= 36; // now in range 235-270
}
} else { // in range 1-468
if (ici > 234) { // -z
ici -= 234; // now in range 1-234
}
}
if (chamberLabel.empty())
fillChamberLabel();
return chamberLabel[ici];
}
CSCDetId CSCIndexerOldStartup::detIdFromChamberLabel(IndexType ie, IndexType label) const {
IndexType is = label / 1000;
label -= is * 1000;
IndexType ir = label / 100;
label -= ir * 100;
IndexType ic = label;
return CSCDetId(ie, is, ir, ic);
}
CSCDetId CSCIndexerOldStartup::detIdFromLayerIndex(IndexType ili) const {
IndexType il = (ili - 1) % 6 + 1;
IndexType ici = (ili - 1) / 6 + 1;
CSCDetId id = detIdFromChamberIndex(ici);
return CSCDetId(id.endcap(), id.station(), id.ring(), id.chamber(), il);
}
std::pair<CSCDetId, CSCIndexerOldStartup::IndexType> CSCIndexerOldStartup::detIdFromStripChannelIndex(
LongIndexType isi) const {
const LongIndexType lastnonme42 = 217728; // channels in 2008 installed chambers
const LongIndexType lastplusznonme42 = 108864; // = 217728/2
const LongIndexType firstme13 = 34561; // First channel of ME13
const LongIndexType lastme13 = 48384; // Last channel of ME13
const IndexType lastnonme42layer = 2808;
const IndexType lastplusznonme42layer = 1404; // = 2808/2
const IndexType firstme13layer = 433; // = 72*6 + 1 (ME13 chambers are 72-108 in range 1-234)
const IndexType lastme13layer = 648; // = 108*6
// All chambers but ME13 have 80 channels
IndexType nchan = 80;
// Set endcap to +z. This should work for ME42 channels too, since we don't
// need to calculate its endcap explicitly.
IndexType ie = 1;
LongIndexType istart = 0;
IndexType layerOffset = 0;
if (isi <= lastnonme42) {
// Chambers as of 2008 Installation
if (isi > lastplusznonme42) {
ie = 2;
isi -= lastplusznonme42;
}
if (isi > lastme13) { // after ME13
istart = lastme13;
layerOffset = lastme13layer;
} else if (isi >= firstme13) { // ME13
istart = firstme13 - 1;
layerOffset = firstme13layer - 1;
nchan = 64;
}
} else {
// ME42 chambers
istart = lastnonme42;
layerOffset = lastnonme42layer;
}
isi -= istart; // remove earlier group(s)
IndexType ichan = (isi - 1) % nchan + 1;
IndexType ili = (isi - 1) / nchan + 1;
ili += layerOffset; // add appropriate offset for earlier group(s)
if (ie != 1)
ili += lastplusznonme42layer; // add offset to -z endcap; ME42 doesn't need
// this.
return std::pair<CSCDetId, IndexType>(detIdFromLayerIndex(ili), ichan);
}
std::pair<CSCDetId, CSCIndexerOldStartup::IndexType> CSCIndexerOldStartup::detIdFromChipIndex(IndexType ici) const {
const LongIndexType lastnonme42 = 13608; // chips in 2008 installed chambers
const LongIndexType lastplusznonme42 = 6804; // = 13608/2
const LongIndexType firstme13 = 2161; // First channel of ME13
const LongIndexType lastme13 = 3024; // Last channel of ME13
const IndexType lastnonme42layer = 2808;
const IndexType lastplusznonme42layer = 1404; // = 2808/2
const IndexType firstme13layer = 433; // = 72*6 + 1 (ME13 chambers are 72-108 in range 1-234)
const IndexType lastme13layer = 648; // = 108*6
// All chambers but ME13 have 5 chips/layer
IndexType nchipPerLayer = 5;
// Set endcap to +z. This should work for ME42 channels too, since we don't
// need to calculate its endcap explicitly.
IndexType ie = 1;
LongIndexType istart = 0;
IndexType layerOffset = 0;
if (ici <= lastnonme42) {
// Chambers as of 2008 Installation
if (ici > lastplusznonme42) {
ie = 2;
ici -= lastplusznonme42;
}
if (ici > lastme13) { // after ME13
istart = lastme13;
layerOffset = lastme13layer;
} else if (ici >= firstme13) { // ME13
istart = firstme13 - 1;
layerOffset = firstme13layer - 1;
nchipPerLayer = 4;
}
} else {
// ME42 chambers
istart = lastnonme42;
layerOffset = lastnonme42layer;
}
ici -= istart; // remove earlier group(s)
IndexType ichip = (ici - 1) % nchipPerLayer + 1;
IndexType ili = (ici - 1) / nchipPerLayer + 1;
ili += layerOffset; // add appropriate offset for earlier group(s)
if (ie != 1)
ili += lastplusznonme42layer; // add offset to -z endcap; ME42 doesn't need
// this.
return std::pair<CSCDetId, IndexType>(detIdFromLayerIndex(ili), ichip);
}
int CSCIndexerOldStartup::dbIndex(const CSCDetId &id, int &channel) {
int ec = id.endcap();
int st = id.station();
int rg = id.ring();
int ch = id.chamber();
int la = id.layer();
// The channels of ME1A are channels 65-80 of ME11
if (st == 1 && rg == 4) {
rg = 1;
if (channel <= 16)
channel += 64; // no trapping for any bizarreness
}
return ec * 100000 + st * 10000 + rg * 1000 + ch * 10 + la;
}
|