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