CMS 3D CMS Logo

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