File indexing completed on 2024-04-06 11:58:22
0001 #include "CSCIndexerOldStartup.h"
0002 #include <iostream>
0003
0004 void CSCIndexerOldStartup::fillChamberLabel() const {
0005
0006
0007
0008
0009 chamberLabel.resize(271);
0010 IndexType count = 0;
0011 chamberLabel[count] = 0;
0012
0013 for (IndexType is = 1; is != 5; ++is) {
0014 IndexType irmax = ringsInStation(is);
0015 for (IndexType ir = 1; ir != irmax + 1; ++ir) {
0016 IndexType icmax = chambersInRingOfStation(is, ir);
0017 for (IndexType ic = 1; ic != icmax + 1; ++ic) {
0018 chamberLabel[++count] = is * 1000 + ir * 100 + ic;
0019 }
0020 }
0021 }
0022 }
0023
0024 CSCDetId CSCIndexerOldStartup::detIdFromChamberIndex_OLD(IndexType ici) const {
0025
0026
0027
0028 IndexType ie = 1;
0029 if (ici > 234) {
0030 ie = 2;
0031 ici -= 234;
0032 }
0033
0034
0035
0036 const IndexType station[] = {0, 1, 1, 1, 2, 2, 3, 3, 4};
0037 const IndexType ring[] = {0, 1, 2, 3, 1, 2, 1, 2, 1};
0038
0039
0040 const IndexType prevs[] = {0, 0, 1, 1, 1, 2, 2, 3, 3};
0041 const IndexType prevr[] = {0, 0, 1, 2, 3, 1, 2, 1, 2};
0042
0043 IndexType is = 4;
0044 IndexType ir = 1;
0045 for (IndexType i = 2; i <= 8; ++i) {
0046 IndexType js = station[i];
0047 IndexType jr = ring[i];
0048
0049 if (ici < startChamberIndexInEndcap(ie, js, jr)) {
0050 is = prevs[i];
0051 ir = prevr[i];
0052 break;
0053 }
0054
0055 }
0056 IndexType ic = ici - startChamberIndexInEndcap(ie, is, ir) + 1;
0057
0058 return CSCDetId(ie, is, ir, ic);
0059 }
0060
0061 CSCDetId CSCIndexerOldStartup::detIdFromChamberIndex(IndexType ici) const {
0062
0063
0064
0065 IndexType ie = 1;
0066 if (ici > 468) {
0067
0068 ici -= 234;
0069 if (ici > 270) {
0070 ie = 2;
0071 ici -= 36;
0072 }
0073 } else {
0074 if (ici > 234) {
0075 ie = 2;
0076 ici -= 234;
0077 }
0078 }
0079 if (chamberLabel.empty())
0080 fillChamberLabel();
0081 IndexType label = chamberLabel[ici];
0082 return detIdFromChamberLabel(ie, label);
0083 }
0084
0085 CSCIndexerOldStartup::IndexType CSCIndexerOldStartup::chamberLabelFromChamberIndex(IndexType ici) const {
0086
0087
0088
0089
0090
0091 if (ici > 468) {
0092
0093 ici -= 234;
0094 if (ici > 270) {
0095 ici -= 36;
0096 }
0097 } else {
0098 if (ici > 234) {
0099 ici -= 234;
0100 }
0101 }
0102 if (chamberLabel.empty())
0103 fillChamberLabel();
0104 return chamberLabel[ici];
0105 }
0106
0107 CSCDetId CSCIndexerOldStartup::detIdFromChamberLabel(IndexType ie, IndexType label) const {
0108 IndexType is = label / 1000;
0109 label -= is * 1000;
0110 IndexType ir = label / 100;
0111 label -= ir * 100;
0112 IndexType ic = label;
0113
0114 return CSCDetId(ie, is, ir, ic);
0115 }
0116
0117 CSCDetId CSCIndexerOldStartup::detIdFromLayerIndex(IndexType ili) const {
0118 IndexType il = (ili - 1) % 6 + 1;
0119 IndexType ici = (ili - 1) / 6 + 1;
0120 CSCDetId id = detIdFromChamberIndex(ici);
0121
0122 return CSCDetId(id.endcap(), id.station(), id.ring(), id.chamber(), il);
0123 }
0124
0125 std::pair<CSCDetId, CSCIndexerOldStartup::IndexType> CSCIndexerOldStartup::detIdFromStripChannelIndex(
0126 LongIndexType isi) const {
0127 const LongIndexType lastnonme42 = 217728;
0128 const LongIndexType lastplusznonme42 = 108864;
0129 const LongIndexType firstme13 = 34561;
0130 const LongIndexType lastme13 = 48384;
0131
0132 const IndexType lastnonme42layer = 2808;
0133 const IndexType lastplusznonme42layer = 1404;
0134 const IndexType firstme13layer = 433;
0135 const IndexType lastme13layer = 648;
0136
0137
0138 IndexType nchan = 80;
0139
0140
0141
0142 IndexType ie = 1;
0143
0144 LongIndexType istart = 0;
0145 IndexType layerOffset = 0;
0146
0147 if (isi <= lastnonme42) {
0148
0149
0150 if (isi > lastplusznonme42) {
0151 ie = 2;
0152 isi -= lastplusznonme42;
0153 }
0154
0155 if (isi > lastme13) {
0156 istart = lastme13;
0157 layerOffset = lastme13layer;
0158 } else if (isi >= firstme13) {
0159 istart = firstme13 - 1;
0160 layerOffset = firstme13layer - 1;
0161 nchan = 64;
0162 }
0163 } else {
0164
0165
0166 istart = lastnonme42;
0167 layerOffset = lastnonme42layer;
0168 }
0169
0170 isi -= istart;
0171 IndexType ichan = (isi - 1) % nchan + 1;
0172 IndexType ili = (isi - 1) / nchan + 1;
0173 ili += layerOffset;
0174 if (ie != 1)
0175 ili += lastplusznonme42layer;
0176
0177
0178 return std::pair<CSCDetId, IndexType>(detIdFromLayerIndex(ili), ichan);
0179 }
0180
0181 std::pair<CSCDetId, CSCIndexerOldStartup::IndexType> CSCIndexerOldStartup::detIdFromChipIndex(IndexType ici) const {
0182 const LongIndexType lastnonme42 = 13608;
0183 const LongIndexType lastplusznonme42 = 6804;
0184 const LongIndexType firstme13 = 2161;
0185 const LongIndexType lastme13 = 3024;
0186
0187 const IndexType lastnonme42layer = 2808;
0188 const IndexType lastplusznonme42layer = 1404;
0189 const IndexType firstme13layer = 433;
0190 const IndexType lastme13layer = 648;
0191
0192
0193 IndexType nchipPerLayer = 5;
0194
0195
0196
0197 IndexType ie = 1;
0198
0199 LongIndexType istart = 0;
0200 IndexType layerOffset = 0;
0201
0202 if (ici <= lastnonme42) {
0203
0204
0205 if (ici > lastplusznonme42) {
0206 ie = 2;
0207 ici -= lastplusznonme42;
0208 }
0209
0210 if (ici > lastme13) {
0211 istart = lastme13;
0212 layerOffset = lastme13layer;
0213 } else if (ici >= firstme13) {
0214 istart = firstme13 - 1;
0215 layerOffset = firstme13layer - 1;
0216 nchipPerLayer = 4;
0217 }
0218 } else {
0219
0220
0221 istart = lastnonme42;
0222 layerOffset = lastnonme42layer;
0223 }
0224
0225 ici -= istart;
0226 IndexType ichip = (ici - 1) % nchipPerLayer + 1;
0227 IndexType ili = (ici - 1) / nchipPerLayer + 1;
0228 ili += layerOffset;
0229 if (ie != 1)
0230 ili += lastplusznonme42layer;
0231
0232
0233 return std::pair<CSCDetId, IndexType>(detIdFromLayerIndex(ili), ichip);
0234 }
0235
0236 int CSCIndexerOldStartup::dbIndex(const CSCDetId &id, int &channel) {
0237 int ec = id.endcap();
0238 int st = id.station();
0239 int rg = id.ring();
0240 int ch = id.chamber();
0241 int la = id.layer();
0242
0243
0244 if (st == 1 && rg == 4) {
0245 rg = 1;
0246 if (channel <= 16)
0247 channel += 64;
0248 }
0249 return ec * 100000 + st * 10000 + rg * 1000 + ch * 10 + la;
0250 }