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->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()) --ieta;
66  if(ieta == -theTopology->lastHERing()) ++ieta;
67 
68  if (use2017_) {
69  if (ieta == 26 and depth == 7)
70  ++ieta;
71  if (ieta == -26 and depth == 7)
72  --ieta;
73  }
74 
75  results.emplace_back( HcalTrigTowerDetId(ieta, iphi1) );
76  results.emplace_back( HcalTrigTowerDetId(ieta, iphi1+1) );
77  }
78  }
79 
80  return results;
81 }
82 
83 
84 std::vector<HcalDetId>
85 HcalTrigTowerGeometry::detIds(const HcalTrigTowerDetId & hcalTrigTowerDetId) const {
86  // Written, tested by E. Berry (Princeton)
87  std::vector<HcalDetId> results;
88 
89  int tower_ieta = hcalTrigTowerDetId.ieta();
90  int tower_iphi = hcalTrigTowerDetId.iphi();
91 
92  int cell_ieta = tower_ieta;
93  int cell_iphi = tower_iphi;
94 
95  int min_depth, n_depths;
96 
97  // HB
98 
99  if (abs(cell_ieta) <= theTopology->lastHBRing()){
100  theTopology->depthBinInformation(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()){
108  theTopology->depthBinInformation(HcalOuter , abs(tower_ieta), tower_iphi, hcalTrigTowerDetId.zside(), n_depths, min_depth);
109  for (int ho_depth = min_depth; ho_depth <= min_depth + n_depths - 1; ho_depth++)
110  results.emplace_back(HcalDetId(HcalOuter, cell_ieta,cell_iphi,ho_depth));
111  }
112 
113  // HE
114 
115  if (abs(cell_ieta) >= theTopology->firstHERing() &&
116  abs(cell_ieta) < theTopology->lastHERing()){
117 
118  theTopology->depthBinInformation(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) cell_iphi = tower_iphi - 1;
123 
124  if (use2017_) {
125  if (abs(tower_ieta) == 26)
126  --n_depths;
127  if (tower_ieta == 27)
128  results.emplace_back(HcalDetId(HcalEndcap, cell_ieta - 1, cell_iphi, 7));
129  if (tower_ieta == -27)
130  results.emplace_back(HcalDetId(HcalEndcap, cell_ieta + 1, cell_iphi, 7));
131  }
132 
133  for (int cell_depth = min_depth; cell_depth <= min_depth + n_depths - 1; cell_depth++)
134  results.emplace_back(HcalDetId(HcalEndcap, cell_ieta, cell_iphi, cell_depth));
135 
136  // Special for split-eta cells
137  if (abs(tower_ieta) == 28){
138  theTopology->depthBinInformation(HcalEndcap, abs(tower_ieta)+1, tower_iphi, hcalTrigTowerDetId.zside(), n_depths, min_depth);
139  for (int cell_depth = min_depth; cell_depth <= min_depth + n_depths - 1; cell_depth++){
140  if (tower_ieta < 0) results.emplace_back(HcalDetId(HcalEndcap, tower_ieta - 1, cell_iphi, cell_depth));
141  if (tower_ieta > 0) results.emplace_back(HcalDetId(HcalEndcap, tower_ieta + 1, cell_iphi, cell_depth));
142  }
143  }
144 
145  }
146 
147  // HF
148 
149  if (abs(cell_ieta) >= theTopology->firstHFRing()){
150 
151  if (hcalTrigTowerDetId.version()==0) {
152 
153  int HfTowerPhiSize = 72 / nPhiBins(tower_ieta,0);
154 
155  int HfTowerEtaSize = hfTowerEtaSize(tower_ieta);
156  int FirstHFRingInTower = firstHFRingInTower(abs(tower_ieta));
157 
158  for (int iHFTowerPhiSegment = 0; iHFTowerPhiSegment < HfTowerPhiSize; iHFTowerPhiSegment++){
159 
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) continue; // These cells don't exist.
168 
169  for (int iHFTowerEtaSegment = 0; iHFTowerEtaSegment < HfTowerEtaSize; iHFTowerEtaSegment++){
170 
171  cell_ieta = FirstHFRingInTower + iHFTowerEtaSegment;
172 
173  if (cell_ieta >= 40 && cell_iphi%4 == 1) continue; // These cells don't exist.
174 
175  theTopology->depthBinInformation(HcalForward, cell_ieta, tower_iphi, hcalTrigTowerDetId.zside(), n_depths, min_depth);
176 
177  // Negative tower_ieta -> negative cell_ieta
178  int zside = 1;
179  if (tower_ieta < 0) zside = -1;
180 
181  cell_ieta *= zside;
182 
183  for (int cell_depth = min_depth; cell_depth <= min_depth + n_depths - 1; cell_depth++)
184  results.emplace_back(HcalDetId(HcalForward, cell_ieta, cell_iphi, cell_depth));
185 
186  if ( zside * cell_ieta == 30 ) {
187  theTopology->depthBinInformation(HcalForward, 29 * zside, tower_iphi, hcalTrigTowerDetId.zside(), n_depths, min_depth);
188  for (int cell_depth = min_depth; cell_depth <= min_depth + n_depths - 1; cell_depth++)
189  results.emplace_back(HcalDetId(HcalForward, 29 * zside , cell_iphi, cell_depth));
190  }
191  }
192  }
193  } else if (hcalTrigTowerDetId.version()==1) {
194  theTopology->depthBinInformation(HcalForward, tower_ieta, tower_iphi, hcalTrigTowerDetId.zside(), n_depths, min_depth);
195  for (int cell_depth = min_depth; cell_depth <= min_depth + n_depths - 1; cell_depth++)
196  results.emplace_back(HcalDetId(HcalForward, tower_ieta, tower_iphi, cell_depth));
197  if (abs(tower_ieta)==30) {
198  int i29 = 29;
199  if (tower_ieta < 0) i29 = -29;
200  theTopology->depthBinInformation(HcalForward, i29, tower_iphi, hcalTrigTowerDetId.zside(), n_depths, min_depth);
201  for (int cell_depth = min_depth; cell_depth <= min_depth + n_depths - 1; cell_depth++)
202  results.emplace_back(HcalDetId(HcalForward, i29, tower_iphi, cell_depth));
203  }
204  }
205  }
206 
207  return results;
208 }
209 
210 
212 
213  int ietaAbs = abs(ieta);
214  assert(ietaAbs >= firstHFTower(0) && ietaAbs <= nTowers(0));
215  // the first three come from rings 29-31, 32-34, 35-37. The last has 4 rings: 38-41
216  return (ietaAbs == nTowers(0)) ? 4 : 3;
217 
218 }
219 
220 
222  // count up to the correct HF ring
223  int inputTower = abs(ietaTower);
224  int result = theTopology->firstHFRing();
225  for(int iTower = firstHFTower(0); iTower != inputTower; ++iTower) {
226  result += hfTowerEtaSize(iTower);
227  }
228 
229  // negative in, negative out.
230  if(ietaTower < 0) result *= -1;
231  return result;
232 }
233 
234 
235 void HcalTrigTowerGeometry::towerEtaBounds(int ieta, int version, double & eta1, double & eta2) const {
236  int ietaAbs = abs(ieta);
237  std::pair<double,double> etas =
238  (ietaAbs < firstHFTower(version)) ? theTopology->etaRange(HcalBarrel,ietaAbs) :
239  theTopology->etaRange(HcalForward,ietaAbs);
240  eta1 = etas.first;
241  eta2 = etas.second;
242 
243  // get the signs and order right
244  if(ieta < 0) {
245  double tmp = eta1;
246  eta1 = -eta2;
247  eta2 = -tmp;
248  }
249 }
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 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