test
CMS 3D CMS Logo

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