CMS 3D CMS Logo

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