CMS 3D CMS Logo

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