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.
5 
6 #include <iostream>
7 #include <cassert>
8 
10  : theTopology( topology )
11 {
12  useShortFibers_=true;
13  useHFQuadPhiRings_=true;
15 }
16 
17 void HcalTrigTowerGeometry::setupHF(bool useShortFibers, bool useQuadRings) {
18  useShortFibers_=useShortFibers;
19  useHFQuadPhiRings_=useQuadRings;
20 }
21 
22 std::vector<HcalTrigTowerDetId>
24 
25  std::vector<HcalTrigTowerDetId> results;
26 
27  int HfTowerPhiSize, shift;
29  HfTowerPhiSize = 1;
30  shift = 0;
31  } else {
32  HfTowerPhiSize = 4;
33  shift = 1;
34  }
35 
36  if(cellId.subdet() == HcalForward) {
37  // short fibers don't count
38  if(cellId.depth() == 1 || useShortFibers_) {
39  // first do eta
40  int hfRing = cellId.ietaAbs();
41  int ieta = firstHFTower();
42  // find the tower that contains this ring
43  while(hfRing >= firstHFRingInTower(ieta+1)) {
44  ++ieta;
45  }
46 
47  if ( useUpgradeConfigurationHFTowers_ && ieta == 29) {
48  ieta = 30;
49  }
50 
51  ieta *= cellId.zside();
52 
53  // now for phi
54  // HF towers are quad, 18 in phi.
55  // go two cells per trigger tower.
56 
57  int iphi = (((cellId.iphi()+shift)/HfTowerPhiSize) * HfTowerPhiSize + shift)%72; // 71+1 --> 1, 3+5 --> 5
59  results.push_back( HcalTrigTowerDetId(ieta, iphi) );
60  }
61 
62  } else {
63  // the first twenty rings are one-to-one
64  if(cellId.ietaAbs() < theTopology->firstHEDoublePhiRing()) {
65  results.push_back( HcalTrigTowerDetId(cellId.ieta(), cellId.iphi()) );
66  } else {
67  // the remaining rings are two-to-one in phi
68  int iphi1 = cellId.iphi();
69  int ieta = cellId.ieta();
70  // the last eta ring in HE is split. Recombine.
71  if(ieta == theTopology->lastHERing()) --ieta;
72  if(ieta == -theTopology->lastHERing()) ++ieta;
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  for (int cell_depth = min_depth; cell_depth <= min_depth + n_depths - 1; cell_depth++)
124  results.push_back(HcalDetId(HcalEndcap, cell_ieta, cell_iphi, cell_depth));
125 
126  // Special for split-eta cells
127  if (abs(tower_ieta) == 28){
128  theTopology->depthBinInformation(HcalEndcap, abs(tower_ieta)+1, n_depths, min_depth);
129  for (int cell_depth = min_depth; cell_depth <= min_depth + n_depths - 1; cell_depth++){
130  if (tower_ieta < 0) results.push_back(HcalDetId(HcalEndcap, tower_ieta - 1, cell_iphi, cell_depth));
131  if (tower_ieta > 0) results.push_back(HcalDetId(HcalEndcap, tower_ieta + 1, cell_iphi, cell_depth));
132  }
133  }
134 
135  }
136 
137  // HF
138 
139  if (abs(cell_ieta) >= theTopology->firstHFRing()){
140 
141  int HfTowerPhiSize;
142  if ( useUpgradeConfigurationHFTowers_ ) HfTowerPhiSize = 1;
143  else HfTowerPhiSize = 72 / nPhiBins(tower_ieta);
144 
145  int HfTowerEtaSize = hfTowerEtaSize(tower_ieta);
146  int FirstHFRingInTower = firstHFRingInTower(abs(tower_ieta));
147 
148  for (int iHFTowerPhiSegment = 0; iHFTowerPhiSegment < HfTowerPhiSize; iHFTowerPhiSegment++){
149 
150  cell_iphi = (tower_iphi / HfTowerPhiSize) * HfTowerPhiSize; // Find the minimum phi segment
151  if ( !useUpgradeConfigurationHFTowers_ ) cell_iphi -= 2; // The first trigger tower starts at HCAL iphi = 71, not HCAL iphi = 1
152  cell_iphi += iHFTowerPhiSegment; // Get all of the HCAL iphi values in this trigger tower
153  cell_iphi += 72; // Don't want to take the mod of a negative number
154  cell_iphi = cell_iphi % 72; // There are, at most, 72 cells.
155  if ( !useUpgradeConfigurationHFTowers_) cell_iphi += 1;// There is no cell at iphi = 0
156 
157  if (cell_iphi%2 == 0) continue; // These cells don't exist.
158 
159  for (int iHFTowerEtaSegment = 0; iHFTowerEtaSegment < HfTowerEtaSize; iHFTowerEtaSegment++){
160 
161  cell_ieta = FirstHFRingInTower + iHFTowerEtaSegment;
162 
163  if (cell_ieta >= 40 && cell_iphi%4 == 1) continue; // These cells don't exist.
164 
165  theTopology->depthBinInformation(HcalForward, cell_ieta, n_depths, min_depth);
166 
167  // Negative tower_ieta -> negative cell_ieta
168  int zside = 1;
169  if (tower_ieta < 0) zside = -1;
170 
171  cell_ieta *= zside;
172 
173  for (int cell_depth = min_depth; cell_depth <= min_depth + n_depths - 1; cell_depth++)
174  results.push_back(HcalDetId(HcalForward, cell_ieta, cell_iphi, cell_depth));
175 
176  if ( zside * cell_ieta == 30 ) {
177  theTopology->depthBinInformation(HcalForward, 29 * zside, n_depths, min_depth);
178  for (int cell_depth = min_depth; cell_depth <= min_depth + n_depths - 1; cell_depth++)
179  results.push_back(HcalDetId(HcalForward, 29 * zside , cell_iphi, cell_depth));
180  }
181 
182  }
183  }
184  }
185 
186  return results;
187 }
188 
189 
191 
192  if ( useUpgradeConfigurationHFTowers_ ) return 1;
193 
194  int ietaAbs = abs(ieta);
195  assert(ietaAbs >= firstHFTower() && ietaAbs <= nTowers());
196  // the first three come from rings 29-31, 32-34, 35-37. The last has 4 rings: 38-41
197  return (ietaAbs == nTowers()) ? 4 : 3;
198 
199 }
200 
201 
203  // count up to the correct HF ring
204  int inputTower = abs(ietaTower);
205  int result = theTopology->firstHFRing();
206  for(int iTower = firstHFTower(); iTower != inputTower; ++iTower) {
207  result += hfTowerEtaSize(iTower);
208  }
209 
210  // negative in, negative out.
211  if(ietaTower < 0) result *= -1;
212  return result;
213 }
214 
215 
216 void HcalTrigTowerGeometry::towerEtaBounds(int ieta, double & eta1, double & eta2) const {
217  int ietaAbs = abs(ieta);
218  if(ietaAbs < firstHFTower()) {
219  eta1 = theHBHEEtaBounds[ietaAbs-1];
220  eta2 = theHBHEEtaBounds[ietaAbs];
221  // the last tower is split, so get tower 29, too
222  if(ietaAbs == theTopology->lastHERing()-1) {
223  eta2 = theHBHEEtaBounds[ietaAbs+1];
224  }
225  } else {
226  // count from 0
227  int hfIndex = firstHFRingInTower(ietaAbs) - theTopology->firstHFRing();
228  eta1 = theHFEtaBounds[hfIndex];
229  eta2 = theHFEtaBounds[hfIndex + hfTowerEtaSize(ieta)];
230  }
231 
232  // get the signs and order right
233  if(ieta < 0) {
234  double tmp = eta1;
235  eta1 = -eta2;
236  eta2 = -tmp;
237  }
238 }
int firstHFRing() const
Definition: HcalTopology.h:83
HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:45
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:47
assert(m_qm.get())
int lastHBRing() const
Definition: HcalTopology.h:80
int zside(DetId const &)
int ieta() const
get the tower ieta
int hfTowerEtaSize(int ieta) const
int nPhiBins(int ieta) const
an interface for CaloSubdetectorGeometry
int depth() const
get the tower depth
Definition: HcalDetId.h:55
tuple result
Definition: query.py:137
int ieta() const
get the cell ieta
Definition: HcalDetId.h:51
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:88
int ietaAbs() const
get the absolute value of the cell ieta
Definition: HcalDetId.h:49
int iphi() const
get the cell iphi
Definition: HcalDetId.h:53
void towerEtaBounds(int ieta, double &eta1, double &eta2) const
where this tower begins and ends in eta
int firstHFRingInTower(int ietaTower) const
since the towers are irregular in eta in HF
static const double theHFEtaBounds[]
int firstHERing() const
Definition: HcalTopology.h:81
int firstHFQuadPhiRing() const
Definition: HcalTopology.h:89
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
static unsigned int const shift
static const double theHBHEEtaBounds[]
HcalTrigTowerGeometry(const HcalTopology *topology)
int lastHORing() const
Definition: HcalTopology.h:86
int iphi() const
get the tower iphi
int lastHERing() const
Definition: HcalTopology.h:82
void setupHF(bool useShortFibers, bool useQuadRings)
std::vector< HcalDetId > detIds(const HcalTrigTowerDetId &) const