CMS 3D CMS Logo

CastorTopology.cc
Go to the documentation of this file.
2 #include <cmath>
3 #include <iostream>
4 #include <algorithm>
5 
6 static const int MODULE_EM_MAX = 2;
7 static const int MODULE_HAD_MAX = 12;
8 
10  : excludeEM_(false),
11  excludeHAD_(false),
12  excludeZP_(false),
13  excludeZN_(false),
14  firstEMModule_(1),
15  lastEMModule_(2),
16  firstHADModule_(3),
17  lastHADModule_(14) {}
18 
19 bool CastorTopology::valid(const HcalCastorDetId& id) const { return (validRaw(id) && !isExcluded(id)); }
20 
22  bool exed = false;
23 
24  // check for section exclutions
25  switch (id.section()) {
26  case (HcalCastorDetId::EM):
27  exed = excludeEM_;
28  break;
29  case (HcalCastorDetId::HAD):
30  exed = excludeHAD_;
31  break;
32  default:
33  exed = false;
34  }
35 
36  // check the entire list
37  if (!exed && !exclusionList_.empty()) {
38  std::vector<HcalCastorDetId>::const_iterator i = std::lower_bound(exclusionList_.begin(), exclusionList_.end(), id);
39  if (i != exclusionList_.end() && *i == id)
40  exed = true;
41  }
42  return exed;
43 }
44 
46  std::vector<HcalCastorDetId>::iterator i = std::lower_bound(exclusionList_.begin(), exclusionList_.end(), id);
47  if (i == exclusionList_.end() || *i != id) {
48  exclusionList_.insert(i, id);
49  }
50 }
51 
53  switch (zside) {
54  case (1):
55  excludeZP_ = true;
56  break;
57  case (-1):
58  excludeZN_ = true;
59  break;
60  default:
61  break;
62  }
63 }
64 
66  switch (zside) {
67  case (1):
68  excludeZP_ = true;
69  break;
70  case (-1):
71  excludeZN_ = true;
72  break;
73  default:
74  break;
75  }
76  switch (section) {
77  case (HcalCastorDetId::EM):
78  excludeEM_ = true;
79  break;
80  case (HcalCastorDetId::HAD):
81  excludeHAD_ = true;
82  break;
83  default:
84  break;
85  }
86 }
87 
89  HcalCastorDetId::Section section1,
90  int isec1,
91  int imod1,
92  HcalCastorDetId::Section section2,
93  int isec2,
94  int imod2) {
95  bool exed = false;
96  switch (zside) {
97  case (1):
98  exed = excludeZP_;
99  break;
100  case (-1):
101  exed = excludeZN_;
102  break;
103  default:
104  exed = false;
105  }
106  if (exed)
107  return 0;
108 
109  /* NOTE not so sure about the exclusion */
110  if (section1 == HcalCastorDetId::EM && section2 == HcalCastorDetId::EM) {
111  exed = excludeEM_;
112  } else if (section1 == HcalCastorDetId::HAD && section2 == HcalCastorDetId::HAD) {
113  exed = excludeHAD_;
114  } else {
115  exed = false;
116  };
117 
118  if (exed)
119  return 0;
120 
121  bool isPositive = false;
122  if (zside == 1)
123  isPositive = true;
124 
125  int n = 0;
126  for (int isec = isec1; isec < isec2; isec++) {
127  for (int imod = imod1; imod < imod2; imod++) {
128  HcalCastorDetId id(section1, isPositive, isec, imod);
129  if (validRaw(id))
130  exclude(id);
131  n++;
132  }
133  }
134  return n;
135 }
136 
138  return HcalCastorDetId::validDetId(id.section(), id.zside() > 0, id.sector(), id.module());
139 }
140 
141 std::vector<DetId> CastorTopology::incSector(const DetId& id) const {
142  std::vector<DetId> vNeighborsDetId;
143  HcalCastorDetId castorId = HcalCastorDetId(id);
144  HcalCastorDetId castorDetId;
145  if (validRaw(castorId)) {
146  bool isPositive = false;
147  if (castorId.zside() == 1)
148  isPositive = true;
149  if (castorId.sector() == 1) {
150  castorDetId = HcalCastorDetId(castorId.section(), isPositive, castorId.sector() + 1, castorId.module());
151  vNeighborsDetId.emplace_back(castorDetId.rawId());
152  return vNeighborsDetId;
153  }
154  if (castorId.sector() == 16) {
155  castorDetId = HcalCastorDetId(castorId.section(), isPositive, castorId.sector() - 1, castorId.module());
156  vNeighborsDetId.emplace_back(castorDetId.rawId());
157  return vNeighborsDetId;
158  }
159  castorDetId = HcalCastorDetId(castorId.section(), isPositive, castorId.sector() - 1, castorId.module());
160  vNeighborsDetId.emplace_back(castorDetId.rawId());
161  castorDetId = HcalCastorDetId(castorId.section(), isPositive, castorId.sector() + 1, castorId.module());
162  vNeighborsDetId.emplace_back(castorDetId.rawId());
163  }
164  return vNeighborsDetId;
165 }
166 
167 std::vector<DetId> CastorTopology::incModule(const DetId& id) const {
168  std::vector<DetId> vNeighborsDetId;
169  HcalCastorDetId castorId = HcalCastorDetId(id);
170  HcalCastorDetId castorDetId;
171  if (validRaw(castorId) && castorId.section() == HcalCastorDetId::EM) {
172  bool isPositive = false;
173  if (castorId.zside() == 1)
174  isPositive = true;
175  if (castorId.module() == 1) {
176  castorDetId = HcalCastorDetId(castorId.section(), isPositive, castorId.sector(), castorId.module() + 1);
177  vNeighborsDetId.emplace_back(castorDetId.rawId());
178  return vNeighborsDetId;
179  }
180  if (castorId.module() == MODULE_EM_MAX) {
181  castorDetId = HcalCastorDetId(castorId.section(), isPositive, castorId.sector(), castorId.module() - 1);
182  vNeighborsDetId.emplace_back(castorDetId.rawId());
183  return vNeighborsDetId;
184  }
185  castorDetId = HcalCastorDetId(castorId.section(), isPositive, castorId.sector(), castorId.module() - 1);
186  vNeighborsDetId.emplace_back(castorDetId.rawId());
187  castorDetId = HcalCastorDetId(castorId.section(), isPositive, castorId.sector(), castorId.module() + 1);
188  vNeighborsDetId.emplace_back(castorDetId.rawId());
189  }
190  if (validRaw(castorId) && castorId.section() == HcalCastorDetId::HAD) {
191  bool isPositive = false;
192  if (castorId.zside() == 1)
193  isPositive = true;
194  if (castorId.module() == 1) {
195  castorDetId = HcalCastorDetId(castorId.section(), isPositive, castorId.sector(), castorId.module() + 1);
196  vNeighborsDetId.emplace_back(castorDetId.rawId());
197  return vNeighborsDetId;
198  }
199  if (castorId.module() == MODULE_HAD_MAX) {
200  castorDetId = HcalCastorDetId(castorId.section(), isPositive, castorId.sector(), castorId.module() - 1);
201  vNeighborsDetId.emplace_back(castorDetId.rawId());
202  return vNeighborsDetId;
203  }
204  }
205  return vNeighborsDetId;
206 }
207 
208 std::vector<DetId> CastorTopology::east(const DetId& /*id*/) const {
209  std::cout << "CastorTopology::east() not yet implemented" << std::endl;
210  std::vector<DetId> vNeighborsDetId;
211  return vNeighborsDetId;
212 }
213 
214 std::vector<DetId> CastorTopology::west(const DetId& /*id*/) const {
215  std::cout << "CastorTopology::west() not yet implemented" << std::endl;
216  std::vector<DetId> vNeighborsDetId;
217  return vNeighborsDetId;
218 }
219 
220 std::vector<DetId> CastorTopology::north(const DetId& /*id*/) const {
221  std::cout << "CastorTopology::north() not yet implemented" << std::endl;
222  std::vector<DetId> vNeighborsDetId;
223  return vNeighborsDetId;
224 }
225 std::vector<DetId> CastorTopology::south(const DetId& /*id*/) const {
226  std::cout << "CastorTopology::south() not yet implemented" << std::endl;
227  std::vector<DetId> vNeighborsDetId;
228  return vNeighborsDetId;
229 }
230 std::vector<DetId> CastorTopology::up(const DetId& /*id*/) const {
231  std::cout << "CastorTopology::up() not yet implemented" << std::endl;
232  std::vector<DetId> vNeighborsDetId;
233  return vNeighborsDetId;
234 }
235 std::vector<DetId> CastorTopology::down(const DetId& /*id*/) const {
236  std::cout << "CastorTopology::down() not yet implemented" << std::endl;
237  std::vector<DetId> vNeighborsDetId;
238  return vNeighborsDetId;
239 }
240 
242  int ncells = 0;
243  switch (section) {
244  case (HcalCastorDetId::EM):
245  ncells = MODULE_EM_MAX * 16;
246  break;
247  case (HcalCastorDetId::HAD):
248  ncells = MODULE_HAD_MAX * 16;
249  break;
251  ncells = 0;
252  break;
253  }
254  return ncells;
255 }
256 
258  int firstCell = 0;
259  switch (section) {
260  case (HcalCastorDetId::EM):
262  break;
263  case (HcalCastorDetId::HAD):
265  break;
267  firstCell = 0;
268  break;
269  }
270  return firstCell;
271 }
272 
274  int lastCell = 0;
275  switch (section) {
276  case (HcalCastorDetId::EM):
278  break;
279  case (HcalCastorDetId::HAD):
281  break;
283  lastCell = 0;
284  break;
285  }
286  return lastCell;
287 }
CastorTopology::south
std::vector< DetId > south(const DetId &id) const override
Definition: CastorTopology.cc:225
CastorTopology::incModule
virtual std::vector< DetId > incModule(const DetId &id) const
Definition: CastorTopology.cc:167
CastorTopology::exclude
void exclude(const HcalCastorDetId &id)
Definition: CastorTopology.cc:45
mps_fire.i
i
Definition: mps_fire.py:428
funct::false
false
Definition: Factorize.h:29
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
HcalCastorDetId::validDetId
static bool validDetId(Section iSection, bool posEta, int iSector, int iMod)
Definition: HcalCastorDetId.cc:69
CastorTopology::lastCell
int lastCell(HcalCastorDetId::Section section) const
Definition: CastorTopology.cc:273
ecaldqm::zside
int zside(DetId const &)
Definition: EcalDQMCommonUtils.cc:189
gather_cfg.cout
cout
Definition: gather_cfg.py:144
CastorTopology::isExcluded
bool isExcluded(const HcalCastorDetId &id) const
Definition: CastorTopology.cc:21
HcalCastorDetId::Section
Section
Definition: HcalCastorDetId.h:25
CastorTopology::excludeZP_
bool excludeZP_
Definition: CastorTopology.h:63
HcalCastorDetId::Unknown
Definition: HcalCastorDetId.h:25
DetId
Definition: DetId.h:17
CastorTopology::CastorTopology
CastorTopology()
Definition: CastorTopology.cc:9
CastorTopology::down
std::vector< DetId > down(const DetId &id) const override
Definition: CastorTopology.cc:235
CastorTopology::excludeHAD_
bool excludeHAD_
Definition: CastorTopology.h:63
CastorTopology::lastHADModule_
int lastHADModule_
Definition: CastorTopology.h:65
HcalCastorDetId::section
Section section() const
get the section
Definition: HcalCastorDetId.cc:49
CastorTopology::firstHADModule_
int firstHADModule_
Definition: CastorTopology.h:65
HcalCastorDetId
Definition: HcalCastorDetId.h:23
pfDeepBoostedJetPreprocessParams_cfi.lower_bound
lower_bound
Definition: pfDeepBoostedJetPreprocessParams_cfi.py:15
CastorTopology::lastEMModule_
int lastEMModule_
Definition: CastorTopology.h:65
HcalCastorDetId::module
int module() const
get the module (1-2 for EM, 1-12 for HAD)
Definition: HcalCastorDetId.h:58
CastorTopology::valid
virtual bool valid(const HcalCastorDetId &id) const
Definition: CastorTopology.cc:19
CastorTopology::west
std::vector< DetId > west(const DetId &id) const override
Definition: CastorTopology.cc:214
CaloSubdetectorTopology::ncells
virtual unsigned int ncells() const
return a count of valid cells (for dense indexing use)
Definition: CaloSubdetectorTopology.h:30
CastorTopology::up
std::vector< DetId > up(const DetId &id) const override
Definition: CastorTopology.cc:230
HcalCastorDetId::zside
int zside() const
get the z-side of the cell (1/-1)
Definition: HcalCastorDetId.h:50
MODULE_EM_MAX
static const int MODULE_EM_MAX
Definition: CastorTopology.cc:6
HcalCastorDetId::sector
int sector() const
get the sector (1-16)
Definition: HcalCastorDetId.h:62
CastorTopology::north
std::vector< DetId > north(const DetId &id) const override
Definition: CastorTopology.cc:220
CastorTopology::excludeZN_
bool excludeZN_
Definition: CastorTopology.h:63
callgraph.module
module
Definition: callgraph.py:61
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
CastorTopology::validRaw
virtual bool validRaw(const HcalCastorDetId &id) const
Definition: CastorTopology.cc:137
CastorTopology::excludeEM_
bool excludeEM_
Definition: CastorTopology.h:63
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:29
CastorTopology.h
CastorTopology::firstEMModule_
int firstEMModule_
Definition: CastorTopology.h:65
CastorTopology::exclusionList_
std::vector< HcalCastorDetId > exclusionList_
Definition: CastorTopology.h:61
hgcalPlots.section
section
Definition: hgcalPlots.py:2679
MODULE_HAD_MAX
static const int MODULE_HAD_MAX
Definition: CastorTopology.cc:7
HcalCastorDetId::HAD
Definition: HcalCastorDetId.h:25
CastorTopology::east
std::vector< DetId > east(const DetId &id) const override
Definition: CastorTopology.cc:208
CastorTopology::incSector
virtual std::vector< DetId > incSector(const DetId &id) const
Definition: CastorTopology.cc:141
CastorTopology::firstCell
int firstCell(HcalCastorDetId::Section section) const
Definition: CastorTopology.cc:257
HcalCastorDetId::EM
Definition: HcalCastorDetId.h:25