CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CSCTriggerNumbering.cc
Go to the documentation of this file.
4 
6 {
7  if(station < CSCDetId::minStationId() || station > CSCDetId::maxStationId() ||
8  triggerCSCID < MIN_CSCID || triggerCSCID > MAX_CSCID)
9  throw cms::Exception("CSCTriggerNumbering::InvalidInput") << "CSCTriggerNumbering::ringFromTriggerLabels():"
10  << " Station: " << station
11  << " TriggerCSCID: " << triggerCSCID
12  << " is not a valid set of labels."
13  << " Cannot Convert!!";
14 
15  int ring = 0;
16 
17  if(station == 1)
18  if(triggerCSCID <= 3)
19  ring = 1;
20  else if(triggerCSCID <= 6)
21  ring = 2;
22  else
23  ring = 3;
24  else
25  if(triggerCSCID <= 3)
26  ring = 1;
27  else
28  ring = 2;
29 
30  return ring;
31 }
32 
33 int CSCTriggerNumbering::chamberFromTriggerLabels(int TriggerSector, int TriggerSubSector, int station, int TriggerCSCID)
34 {
35  if(TriggerSector < MIN_TRIGSECTOR || TriggerSector > MAX_TRIGSECTOR ||
36  TriggerSubSector < MIN_TRIGSUBSECTOR || TriggerSubSector > MAX_TRIGSUBSECTOR ||
37  station < CSCDetId::minStationId() || station > CSCDetId::maxStationId() ||
38  TriggerCSCID < MIN_CSCID || TriggerCSCID > MAX_CSCID)
39  throw cms::Exception("CSCTriggerNumbering::InvalidInput") << "CSCTriggerNumbering::chamberFromTriggerLabels():"
40  << " Trigger Sector: " << TriggerSector
41  << " Trigger SubSector: " << TriggerSubSector
42  << " Station: " << station
43  << " TriggerCSCID: " << TriggerCSCID
44  << " is not a valid set of labels."
45  << " Cannot Convert!!";
46 
47 
48  int chamber = 0;
49  int realsubsector = (TriggerSubSector + 2*(TriggerSector - 1))%12 + 1; // station 1 only
50 
51  if(station != 1)
52  if(TriggerCSCID <= 3)
53  chamber = (TriggerCSCID + 3*(TriggerSector - 1))%18 + 1; // Derived from CMS Note: CMS IN 2000/04 ver 2.1 Oct/2005
54  // As far as I know this is reality.
55  else
56  chamber = (TriggerCSCID + 6*(TriggerSector - 1) - 2)%36 + 1;
57  else
58  if(TriggerCSCID <= 3)
59  chamber = (TriggerCSCID + 3*(realsubsector - 1)+34)%36 + 1;
60  else if(TriggerCSCID <= 6)
61  chamber = (TriggerCSCID + 3*(realsubsector - 1)+31)%36 + 1;
62  else
63  chamber = (TriggerCSCID + 3*(realsubsector - 1)+28)%36 + 1;
64 
65  return chamber;
66 }
67 
68 int CSCTriggerNumbering::sectorFromTriggerLabels(int TriggerSector, int TriggerSubSector, int station)
69 {
70  if(TriggerSector < MIN_TRIGSECTOR || TriggerSector > MAX_TRIGSECTOR ||
71  TriggerSubSector < MIN_TRIGSUBSECTOR || TriggerSubSector > MAX_TRIGSUBSECTOR ||
72  station < CSCDetId::minStationId() || station > CSCDetId::maxStationId())
73  throw cms::Exception("CSCTriggerNumbering::InvalidInput") << "CSCTriggerNumbering::sectorFromTriggerLabels():"
74  << " Trigger Sector: " << TriggerSector
75  << " Trigger SubSector: " << TriggerSubSector
76  << " Station: " << station
77  << " is not a valid set of labels."
78  << " Cannot Convert!!";
79 
80  return ((station == 1) ? ((TriggerSubSector + 2*(TriggerSector - 1))%12 + 1) : TriggerSector);
81 }
82 
84 {
85  if(station < CSCDetId::minStationId() || station > CSCDetId::maxStationId() ||
86  ring < CSCDetId::minRingId() || ring > CSCDetId::maxRingId() ||
87  chamber < CSCDetId::minChamberId() || chamber > CSCDetId::maxChamberId())
88  throw cms::Exception("CSCTriggerNumbering::InvalidInput") << "CSCTriggerNumbering::triggerSectorFromLabels():"
89  << " Station: " << station
90  << " Ring: " << ring
91  << " Chamber: " << chamber
92  << " is not a valid set of labels."
93  << " Cannot Convert!!";
94 
95 
96  int result;
97  // This version 16-Nov-99 ptc to match simplified chamber labelling for cms116
98  //@@ REQUIRES UPDATE TO 2005 REALITY, ONCE I UNDERSTAND WHAT THAT IS
99  // UPDATED - LGRAY Feb 2006
100 
101  if(station > 1 && ring > 1 ) {
102  result = ((static_cast<unsigned>(chamber-3) & 0x7f) / 6) + 1; // ch 3-8->1, 9-14->2, ... 1,2 -> 6
103  }
104  else {
105  result = (station != 1) ? ((static_cast<unsigned>(chamber-2) & 0x1f) / 3) + 1 : // ch 2-4-> 1, 5-7->2, ...
106  ((static_cast<unsigned>(chamber-3) & 0x7f) / 6) + 1;
107  }
108 
109  return (result <= 6) ? result : 6; // Max sector is 6, some calculations give a value greater than six but this is expected
110  // and delt with.
111 }
112 
114 {
115  return triggerSectorFromLabels(id.station(),id.ring(),id.chamber());
116 }
117 
119 {
120  if(station < CSCDetId::minStationId() || station > CSCDetId::maxStationId() ||
121  chamber < CSCDetId::minChamberId() || chamber > CSCDetId::maxChamberId())
122  throw cms::Exception("CSCTriggerNumbering::InvalidInput") << "CSCTriggerNumbering::triggerSectorFromLabels():"
123  << " Station: " << station
124  << " Chamber: " << chamber
125  << " is not a valid set of labels."
126  << " Cannot Convert!!";
127 
128  if(station != 1) return 0; // only station one has subsectors
129 
130  switch(chamber) // first make things easier to deal with
131  {
132  case 1:
133  chamber = 36;
134  break;
135  case 2:
136  chamber = 35;
137  break;
138  default:
139  chamber -= 2;
140  }
141 
142  chamber = ((chamber-1)%6) + 1; // renumber all chambers to 1-6
143 
144  return ((chamber-1) / 3) + 1; // [1,3] -> 1 , [4,6]->2
145 }
146 
148 {
149  return triggerSubSectorFromLabels(id.station(),id.chamber());
150 }
151 
152 int CSCTriggerNumbering::triggerCscIdFromLabels(int station, int ring, int chamber) // updated to 2005
153 {
154  if(station < CSCDetId::minStationId() || station > CSCDetId::maxStationId() ||
155  ring < CSCDetId::minRingId() || ring > CSCDetId::maxRingId() ||
156  chamber < CSCDetId::minChamberId() || chamber > CSCDetId::maxChamberId())
157  throw cms::Exception("CSCTriggerNumbering::InvalidInput") << "CSCTriggerNumbering::triggerSectorFromLabels():"
158  << " Station: " << station
159  << " Ring: " << ring
160  << " Chamber: " << chamber
161  << " is not a valid set of labels."
162  << " Cannot Convert!!";
163 
164  int result;
165 
166  if( station == 1 ) {
167  result = (chamber) % 3 + 1; // 1,2,3
168  switch (ring) {
169  case 1:
170  break;
171  case 2:
172  result += 3; // 4,5,6
173  break;
174  case 3:
175  result += 6; // 7,8,9
176  break;
177  }
178  }
179  else {
180  if( ring == 1 ) {
181  result = (chamber+1) % 3 + 1; // 1,2,3
182  }
183  else {
184  result = (chamber+3) % 6 + 4; // 4,5,6,7,8,9
185  }
186  }
187  return result;
188 }
189 
191 {
192  return triggerCscIdFromLabels(id.station(),id.ring(),id.chamber());
193 }
static int minRingId()
Definition: CSCDetId.h:240
static int maxStationId()
Definition: CSCDetId.h:239
static int maxRingId()
Definition: CSCDetId.h:241
static int ringFromTriggerLabels(int station, int triggerCSCID)
static int minChamberId()
Definition: CSCDetId.h:242
tuple result
Definition: mps_fire.py:84
static int sectorFromTriggerLabels(int TriggerSector, int TriggerSubSector, int station)
static int minStationId()
Definition: CSCDetId.h:238
static int triggerCscIdFromLabels(int station, int ring, int chamber)
static int maxChamberId()
Definition: CSCDetId.h:243
static int triggerSectorFromLabels(int station, int ring, int chamber)
static int triggerSubSectorFromLabels(int station, int chamber)
static int chamberFromTriggerLabels(int TriggerSector, int TriggerSubSector, int station, int TriggerCSCID)