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