CMS 3D CMS Logo

CSCUtils.cc
Go to the documentation of this file.
2 
4 
5 namespace emtf::phase2::csc {
6 
7  // Chambers
8  int getNext10DegChamber(int chamber) { return (chamber == 36) ? 1 : (chamber + 1); }
9 
10  int getPrev10DegChamber(int chamber) { return (chamber == 1) ? 36 : (chamber - 1); }
11 
12  int getNext20DegChamber(int chamber) { return (chamber == 18) ? 1 : (chamber + 1); }
13 
14  int getPrev20DegChamber(int chamber) { return (chamber == 1) ? 18 : (chamber - 1); }
15 
16  // Sectors
17  bool isTPInSector(int sp_endcap, int sp_sector, int tp_endcap, int tp_sector) {
18  return sp_endcap == tp_endcap && sp_sector == tp_sector;
19  }
20 
22  int sp_endcap, int sp_sector, int tp_endcap, int tp_sector, int tp_subsector, int tp_station, int tp_id) {
23  // Match endcap and neighbor sector
24  int neighbor_sector = ((sp_sector == 1) ? 6 : sp_sector - 1);
25 
26  if ((sp_endcap != tp_endcap) || (neighbor_sector != tp_sector))
27  return false;
28 
29  // Match CSCID in station 1
30  if (tp_station == 1)
31  return (tp_subsector == 2) && (tp_id == 3 || tp_id == 6 || tp_id == 9);
32 
33  // Match CSCID in other stations
34  return tp_id == 3 || tp_id == 9;
35  }
36 
37  // Use CSC trigger "CSC ID" definitions
38  // Copied from DataFormats/MuonDetId/src/CSCDetId.cc
39  int getId(int station, int ring, int chamber) {
40  int result = 0;
41 
42  if (station == 1) {
43  result = (chamber) % 3 + 1; // 1,2,3
44 
45  switch (ring) {
46  case 1:
47  break;
48  case 2:
49  result += 3; // 4,5,6
50  break;
51  case 3:
52  result += 6; // 7,8,9
53  break;
54  case 4:
55  break;
56  }
57  } else {
58  if (ring == 1) {
59  result = (chamber + 1) % 3 + 1; // 1,2,3
60  } else {
61  result = (chamber + 3) % 6 + 4; // 4,5,6,7,8,9
62  }
63  }
64 
65  return result;
66  }
67 
68  // Use CSC trigger sector definitions
69  // Copied from DataFormats/MuonDetId/src/CSCDetId.cc
70  int getTriggerSector(int station, int ring, int chamber) {
71  int result = 0;
72 
73  if (station > 1 && ring > 1) {
74  result = ((static_cast<unsigned>(chamber - 3) & 0x7f) / 6) + 1; // ch 3-8->1, 9-14->2, ... 1,2 -> 6
75  } else if (station == 1) {
76  result = ((static_cast<unsigned>(chamber - 3) & 0x7f) / 6) + 1; // ch 3-8->1, 9-14->2, ... 1,2 -> 6
77  } else {
78  result = ((static_cast<unsigned>(chamber - 2) & 0x1f) / 3) + 1; // ch 2-4-> 1, 5-7->2, ...
79  }
80 
81  return (result <= 6) ? result
82  : 6; // max sector is 6, some calculations give a value greater than six but this is expected.
83  }
84 
86  // station 2,3,4 --> subsector 0
87  if (station != 1) {
88  return 0;
89  }
90 
91  // station 1 --> subsector 1 or 2
92  if ((chamber % 6) > 2) {
93  return 1;
94  }
95 
96  return 2;
97  }
98 
99  // Copied from RecoMuon/DetLayers/src/MuonCSCDetLayerGeometryBuilder.cc
101  bool is_not_overlapping = (station == 1 && ring == 3);
102 
103  // Not overlapping means it's facing backwards
104  if (is_not_overlapping)
105  return Facing::kRear;
106 
107  // odd chambers are bolted to the iron, which faces
108  // forward in stations 1 and 2, backward in stations 3 and 4
109  bool is_even = (chamber % 2 == 0);
110 
111  if (station < 3)
112  return (is_even ? Facing::kRear : Facing::kFront);
113 
114  return (is_even ? Facing::kFront : Facing::kRear);
115  }
116 
117  // Number of halfstrips and wiregroups
118  // +----------------------------+------------+------------+
119  // | Chamber type | Num of | Num of |
120  // | | halfstrips | wiregroups |
121  // +----------------------------+------------+------------+
122  // | ME1/1a | 96 | 48 |
123  // | ME1/1b | 128 | 48 |
124  // | ME1/2 | 160 | 64 |
125  // | ME1/3 | 128 | 32 |
126  // | ME2/1 | 160 | 112 |
127  // | ME3/1, ME4/1 | 160 | 96 |
128  // | ME2/2, ME3/2, ME4/2 | 160 | 64 |
129  // +----------------------------+------------+------------+
130 
131  std::pair<int, int> getMaxStripAndWire(int station, int ring) {
132  int max_strip = 0; // halfstrip
133  int max_wire = 0; // wiregroup
134 
135  if (station == 1 && ring == 4) { // ME1/1a
136  max_strip = 96;
137  max_wire = 48;
138  } else if (station == 1 && ring == 1) { // ME1/1b
139  max_strip = 128;
140  max_wire = 48;
141  } else if (station == 1 && ring == 2) { // ME1/2
142  max_strip = 160;
143  max_wire = 64;
144  } else if (station == 1 && ring == 3) { // ME1/3
145  max_strip = 128;
146  max_wire = 32;
147  } else if (station == 2 && ring == 1) { // ME2/1
148  max_strip = 160;
149  max_wire = 112;
150  } else if (station >= 3 && ring == 1) { // ME3/1, ME4/1
151  max_strip = 160;
152  max_wire = 96;
153  } else if (station >= 2 && ring == 2) { // ME2/2, ME3/2, ME4/2
154  max_strip = 160;
155  max_wire = 64;
156  }
157 
158  return std::make_pair(max_strip, max_wire);
159  }
160 
161  std::pair<int, int> getMaxPatternAndQuality(int station, int ring) {
162  int max_pattern = 11;
163  int max_quality = 16;
164 
165  return std::make_pair(max_pattern, max_quality);
166  }
167 
168 } // namespace emtf::phase2::csc
bool isTPInSector(int match_endcap, int match_sector, int tp_endcap, int tp_sector)
Definition: CSCUtils.cc:17
std::pair< int, int > getMaxPatternAndQuality(int station, int ring)
Definition: CSCUtils.cc:161
int getId(int ring, int station, int chamber)
Definition: CSCUtils.cc:39
int getNext20DegChamber(int chamber)
Definition: CSCUtils.cc:12
int getTriggerSubsector(int station, int chamber)
Definition: CSCUtils.cc:85
std::pair< int, int > getMaxStripAndWire(int station, int ring)
Definition: CSCUtils.cc:131
int getNext10DegChamber(int chamber)
Definition: CSCUtils.cc:8
int getTriggerSector(int ring, int station, int chamber)
Definition: CSCUtils.cc:70
Facing getFaceDirection(int station, int ring, int chamber)
Definition: CSCUtils.cc:100
bool isTPInNeighborSector(int match_endcap, int match_sector, int tp_endcap, int tp_sector, int tp_subsector, int tp_station, int tp_id)
Definition: CSCUtils.cc:21
int getPrev10DegChamber(int chamber)
Definition: CSCUtils.cc:10
int getPrev20DegChamber(int chamber)
Definition: CSCUtils.cc:14