CMS 3D CMS Logo

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