CMS 3D CMS Logo

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