CMS 3D CMS Logo

HcalTrigTowerGeometry.cc
Go to the documentation of this file.
5 
6 #include <iostream>
7 #include <cassert>
8 
10  auto tmode = theTopology->triggerMode();
14 }
15 
16 std::vector<HcalTrigTowerDetId> HcalTrigTowerGeometry::towerIds(const HcalDetId& cellId) const {
17  std::vector<HcalTrigTowerDetId> results;
18 
19  if (cellId.subdet() == HcalForward) {
20  if (useRCT_) {
21  // first do eta
22  int hfRing = cellId.ietaAbs();
23  int ieta = firstHFTower(0);
24  // find the tower that contains this ring
25  while (hfRing >= firstHFRingInTower(ieta + 1)) {
26  ++ieta;
27  }
28 
29  ieta *= cellId.zside();
30 
31  // now for phi
32  // HF towers are quad, 18 in phi.
33  // go two cells per trigger tower.
34 
35  int iphi = (((cellId.iphi() + 1) / 4) * 4 + 1) % 72; // 71+1 --> 1, 3+5 --> 5
36  results.emplace_back(HcalTrigTowerDetId(ieta, iphi));
37  }
38  if (use1x1_) {
39  int hfRing = cellId.ietaAbs();
40  if (hfRing == 29)
41  hfRing = 30; // sum 29 into 30.
42 
43  int ieta = hfRing * cellId.zside();
44  int iphi = cellId.iphi();
45 
47  id.setVersion(1); // version 1 for 1x1 HF granularity
48  results.emplace_back(id);
49  }
50 
51  } else {
52  // the first twenty rings are one-to-one
53  if (cellId.ietaAbs() <= theTopology->lastHBRing()) {
54  results.emplace_back(HcalTrigTowerDetId(cellId.ieta(), cellId.iphi()));
55  } else if (theTopology->maxDepthHE() == 0) {
56  // Ignore these
57  } else if (cellId.ietaAbs() < theTopology->firstHEDoublePhiRing()) {
58  results.emplace_back(HcalTrigTowerDetId(cellId.ieta(), cellId.iphi()));
59  } else {
60  // the remaining rings are two-to-one in phi
61  int iphi1 = cellId.iphi();
62  int ieta = cellId.ieta();
63  int depth = cellId.depth();
64  // the last eta ring in HE is split. Recombine.
65  if (ieta == theTopology->lastHERing())
66  --ieta;
67  if (ieta == -theTopology->lastHERing())
68  ++ieta;
69 
70  if (use2017_) {
71  if (ieta == 26 and depth == 7)
72  ++ieta;
73  if (ieta == -26 and depth == 7)
74  --ieta;
75  }
76 
77  results.emplace_back(HcalTrigTowerDetId(ieta, iphi1));
78  results.emplace_back(HcalTrigTowerDetId(ieta, iphi1 + 1));
79  }
80  }
81 
82  return results;
83 }
84 
85 std::vector<HcalTrigTowerDetId> HcalTrigTowerGeometry::towerIds_ZDC(const HcalZDCDetId& cellId) const {
86  std::vector<HcalTrigTowerDetId> results;
87 
88  int ieta = cellId.zside() > 0 ? 42 : -42;
89  int iphi = 99;
90  int channelId = cellId.channel();
91  if (cellId.depth() != 1)
92  channelId += 5;
93 
94  results.emplace_back(HcalTrigTowerDetId(ieta, channelId));
95  results.emplace_back(HcalTrigTowerDetId(ieta, iphi));
96 
97  return results;
98 }
99 
100 std::vector<HcalDetId> HcalTrigTowerGeometry::detIds(const HcalTrigTowerDetId& hcalTrigTowerDetId) const {
101  // Written, tested by E. Berry (Princeton)
102  std::vector<HcalDetId> results;
103 
104  int tower_ieta = hcalTrigTowerDetId.ieta();
105  int tower_iphi = hcalTrigTowerDetId.iphi();
106 
107  int cell_ieta = tower_ieta;
108  int cell_iphi = tower_iphi;
109 
110  int min_depth, n_depths;
111 
112  // HB
113 
114  if (abs(cell_ieta) <= theTopology->lastHBRing()) {
116  HcalBarrel, abs(tower_ieta), tower_iphi, hcalTrigTowerDetId.zside(), n_depths, min_depth);
117  for (int cell_depth = min_depth; cell_depth <= min_depth + n_depths - 1; cell_depth++)
118  results.emplace_back(HcalDetId(HcalBarrel, cell_ieta, cell_iphi, cell_depth));
119  }
120 
121  // HO
122 
123  if (abs(cell_ieta) <= theTopology->lastHORing()) {
125  HcalOuter, abs(tower_ieta), tower_iphi, hcalTrigTowerDetId.zside(), n_depths, min_depth);
126  for (int ho_depth = min_depth; ho_depth <= min_depth + n_depths - 1; ho_depth++)
127  results.emplace_back(HcalDetId(HcalOuter, cell_ieta, cell_iphi, ho_depth));
128  }
129 
130  // HE
131 
132  if (abs(cell_ieta) >= theTopology->firstHERing() && abs(cell_ieta) < theTopology->lastHERing()) {
134  HcalEndcap, abs(tower_ieta), tower_iphi, hcalTrigTowerDetId.zside(), n_depths, min_depth);
135 
136  // Special for double-phi cells
137  if (abs(cell_ieta) >= theTopology->firstHEDoublePhiRing())
138  if (tower_iphi % 2 == 0)
139  cell_iphi = tower_iphi - 1;
140 
141  if (use2017_) {
142  if (abs(tower_ieta) == 26)
143  --n_depths;
144  if (tower_ieta == 27)
145  results.emplace_back(HcalDetId(HcalEndcap, cell_ieta - 1, cell_iphi, 7));
146  if (tower_ieta == -27)
147  results.emplace_back(HcalDetId(HcalEndcap, cell_ieta + 1, cell_iphi, 7));
148  }
149 
150  for (int cell_depth = min_depth; cell_depth <= min_depth + n_depths - 1; cell_depth++)
151  results.emplace_back(HcalDetId(HcalEndcap, cell_ieta, cell_iphi, cell_depth));
152 
153  // Special for split-eta cells
154  if (abs(tower_ieta) == 28) {
156  HcalEndcap, abs(tower_ieta) + 1, tower_iphi, hcalTrigTowerDetId.zside(), n_depths, min_depth);
157  for (int cell_depth = min_depth; cell_depth <= min_depth + n_depths - 1; cell_depth++) {
158  if (tower_ieta < 0)
159  results.emplace_back(HcalDetId(HcalEndcap, tower_ieta - 1, cell_iphi, cell_depth));
160  if (tower_ieta > 0)
161  results.emplace_back(HcalDetId(HcalEndcap, tower_ieta + 1, cell_iphi, cell_depth));
162  }
163  }
164  }
165 
166  // HF
167 
168  if (abs(cell_ieta) >= theTopology->firstHFRing()) {
169  if (hcalTrigTowerDetId.version() == 0) {
170  int HfTowerPhiSize = 72 / nPhiBins(tower_ieta, 0);
171 
172  int HfTowerEtaSize = hfTowerEtaSize(tower_ieta);
173  int FirstHFRingInTower = firstHFRingInTower(abs(tower_ieta));
174 
175  for (int iHFTowerPhiSegment = 0; iHFTowerPhiSegment < HfTowerPhiSize; iHFTowerPhiSegment++) {
176  cell_iphi = (tower_iphi / HfTowerPhiSize) * HfTowerPhiSize; // Find the minimum phi segment
177  cell_iphi -= 2; // The first trigger tower starts at HCAL iphi = 71, not HCAL iphi = 1
178  cell_iphi += iHFTowerPhiSegment; // Get all of the HCAL iphi values in this trigger tower
179  cell_iphi += 72; // Don't want to take the mod of a negative number
180  cell_iphi = cell_iphi % 72; // There are, at most, 72 cells.
181  cell_iphi += 1; // There is no cell at iphi = 0
182 
183  if (cell_iphi % 2 == 0)
184  continue; // These cells don't exist.
185 
186  for (int iHFTowerEtaSegment = 0; iHFTowerEtaSegment < HfTowerEtaSize; iHFTowerEtaSegment++) {
187  cell_ieta = FirstHFRingInTower + iHFTowerEtaSegment;
188 
189  if (cell_ieta >= 40 && cell_iphi % 4 == 1)
190  continue; // These cells don't exist.
191 
193  HcalForward, cell_ieta, tower_iphi, hcalTrigTowerDetId.zside(), n_depths, min_depth);
194 
195  // Negative tower_ieta -> negative cell_ieta
196  int zside = 1;
197  if (tower_ieta < 0)
198  zside = -1;
199 
200  cell_ieta *= zside;
201 
202  for (int cell_depth = min_depth; cell_depth <= min_depth + n_depths - 1; cell_depth++)
203  results.emplace_back(HcalDetId(HcalForward, cell_ieta, cell_iphi, cell_depth));
204 
205  if (zside * cell_ieta == 30) {
207  HcalForward, 29 * zside, tower_iphi, hcalTrigTowerDetId.zside(), n_depths, min_depth);
208  for (int cell_depth = min_depth; cell_depth <= min_depth + n_depths - 1; cell_depth++)
209  results.emplace_back(HcalDetId(HcalForward, 29 * zside, cell_iphi, cell_depth));
210  }
211  }
212  }
213  } else if (hcalTrigTowerDetId.version() == 1) {
215  HcalForward, tower_ieta, tower_iphi, hcalTrigTowerDetId.zside(), n_depths, min_depth);
216  for (int cell_depth = min_depth; cell_depth <= min_depth + n_depths - 1; cell_depth++)
217  results.emplace_back(HcalDetId(HcalForward, tower_ieta, tower_iphi, cell_depth));
218  if (abs(tower_ieta) == 30) {
219  int i29 = 29;
220  if (tower_ieta < 0)
221  i29 = -29;
222  theTopology->depthBinInformation(HcalForward, i29, tower_iphi, hcalTrigTowerDetId.zside(), n_depths, min_depth);
223  for (int cell_depth = min_depth; cell_depth <= min_depth + n_depths - 1; cell_depth++)
224  results.emplace_back(HcalDetId(HcalForward, i29, tower_iphi, cell_depth));
225  }
226  }
227  }
228 
229  return results;
230 }
231 
233  int ietaAbs = abs(ieta);
234  assert(ietaAbs >= firstHFTower(0) && ietaAbs <= nTowers(0));
235  // the first three come from rings 29-31, 32-34, 35-37. The last has 4 rings: 38-41
236  return (ietaAbs == nTowers(0)) ? 4 : 3;
237 }
238 
240  // count up to the correct HF ring
241  int inputTower = abs(ietaTower);
242  int result = theTopology->firstHFRing();
243  for (int iTower = firstHFTower(0); iTower != inputTower; ++iTower) {
244  result += hfTowerEtaSize(iTower);
245  }
246 
247  // negative in, negative out.
248  if (ietaTower < 0)
249  result *= -1;
250  return result;
251 }
252 
253 void HcalTrigTowerGeometry::towerEtaBounds(int ieta, int version, double& eta1, double& eta2) const {
254  int ietaAbs = abs(ieta);
255  std::pair<double, double> etas = (ietaAbs < firstHFTower(version)) ? theTopology->etaRange(HcalBarrel, ietaAbs)
257  eta1 = etas.first;
258  eta2 = etas.second;
259 
260  // get the signs and order right
261  if (ieta < 0) {
262  double tmp = eta1;
263  eta1 = -eta2;
264  eta2 = -tmp;
265  }
266 }
constexpr int zside() const
get the z-side of the cell (1/-1)
Definition: HcalDetId.h:141
const HcalTopology * theTopology
constexpr int ietaAbs() const
get the absolute value of the cell ieta
Definition: HcalDetId.h:148
int maxDepthHE() const
Definition: HcalTopology.h:137
int lastHORing() const
Definition: HcalTopology.h:96
int nTowers(int version) const
number of towers (version dependent)
int zside(DetId const &)
assert(be >=bs)
constexpr int32_t depth() const
get the depth (1 for EM, channel + 1 for HAD, 2 for RPD, not sure yet for LUM, leave as default) ...
Definition: HcalZDCDetId.h:100
int iphi() const
get the tower iphi
int firstHFTower(int version) const
ALPAKA_FN_ACC ALPAKA_FN_INLINE uint32_t ietaAbs(uint32_t id)
constexpr HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:138
std::vector< HcalDetId > detIds(const HcalTrigTowerDetId &) const
HcalTopologyMode::TriggerMode triggerMode() const
Definition: HcalTopology.h:31
constexpr int ieta() const
get the cell ieta
Definition: HcalDetId.h:155
int lastHBRing() const
Definition: HcalTopology.h:89
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
std::pair< double, double > etaRange(HcalSubdetector subdet, int ieta) const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int firstHFRingInTower(int ietaTower) const
since the towers are irregular in eta in HF
int ieta() const
get the tower ieta
void depthBinInformation(HcalSubdetector subdet, int etaRing, int iphi, int zside, int &nDepthBins, int &startingBin) const
finds the number of depth bins and which is the number to start with
int firstHEDoublePhiRing() const
Definition: HcalTopology.h:98
void towerEtaBounds(int ieta, int version, double &eta1, double &eta2) const
where this tower begins and ends in eta
int lastHERing() const
Definition: HcalTopology.h:91
int zside() const
get the z-side of the tower (1/-1)
int nPhiBins(int ieta, int version) const
the number of phi bins in this eta ring
results
Definition: mysort.py:8
constexpr int32_t channel() const
get the channel
Definition: HcalZDCDetId.h:112
int hfTowerEtaSize(int ieta) const
constexpr int32_t zside() const
get the z-side of the cell (1/-1)
Definition: HcalZDCDetId.h:90
int version() const
get the version code for the trigger tower
tmp
align.sh
Definition: createJobs.py:716
HcalTrigTowerGeometry(const HcalTopology *topology)
std::vector< HcalTrigTowerDetId > towerIds(const HcalDetId &cellId) const
the mapping to and from DetIds
constexpr int iphi() const
get the cell iphi
Definition: HcalDetId.h:157
int firstHFRing() const
Definition: HcalTopology.h:93
int firstHERing() const
Definition: HcalTopology.h:90
std::vector< HcalTrigTowerDetId > towerIds_ZDC(const HcalZDCDetId &cellId) const
constexpr int depth() const
get the tower depth
Definition: HcalDetId.h:164