CMS 3D CMS Logo

ZdcTopology.cc
Go to the documentation of this file.
2 #include <cmath>
3 #include <iostream>
4 #include <algorithm>
5 
6 static const int ICH_EM_MAX = 5;
7 static const int ICH_HAD_MAX = 4;
8 static const int ICH_LUM_MAX = 2;
9 static const int ICH_RPD_MAX = 16;
10 
12  : excludeEM_(false),
13  excludeHAD_(false),
14  excludeLUM_(false),
15  excludeRPD_(false),
16  excludeZP_(false),
17  excludeZN_(false),
18  firstEMModule_(1),
19  lastEMModule_(5),
20  firstHADModule_(1),
21  lastHADModule_(4),
22  firstLUMModule_(1),
23  lastLUMModule_(2),
24  firstRPDModule_(1),
25  lastRPDModule_(16) {}
26 
27 bool ZdcTopology::valid(const HcalZDCDetId& id) const {
28  // check the raw rules
29  bool ok = validRaw(id);
30  ok = ok && !isExcluded(id);
31  return ok;
32 }
33 
34 bool ZdcTopology::isExcluded(const HcalZDCDetId& id) const {
35  bool exed = false;
36 
37  // check for section exclutions
38  switch (id.section()) {
39  case (HcalZDCDetId::EM):
40  exed = excludeEM_;
41  break;
42  case (HcalZDCDetId::HAD):
43  exed = excludeHAD_;
44  break;
45  case (HcalZDCDetId::LUM):
46  exed = excludeLUM_;
47  break;
48  case (HcalZDCDetId::RPD):
49  exed = excludeRPD_;
50  break;
51  default:
52  exed = false;
53  }
54 
55  // check the entire list
56  if (!exed && !exclusionList_.empty()) {
57  std::vector<HcalZDCDetId>::const_iterator i = std::lower_bound(exclusionList_.begin(), exclusionList_.end(), id);
58  if (i != exclusionList_.end() && *i == id)
59  exed = true;
60  }
61  return exed;
62 }
63 
65  std::vector<HcalZDCDetId>::iterator i = std::lower_bound(exclusionList_.begin(), exclusionList_.end(), id);
66  if (i == exclusionList_.end() || *i != id) {
67  exclusionList_.insert(i, id);
68  }
69 }
70 
72  switch (zside) {
73  case (1):
74  excludeZP_ = true;
75  break;
76  case (-1):
77  excludeZN_ = true;
78  break;
79  default:
80  break;
81  }
82 }
83 
85  switch (zside) {
86  case (1):
87  excludeZP_ = true;
88  break;
89  case (-1):
90  excludeZN_ = true;
91  break;
92  default:
93  break;
94  }
95  switch (section) {
96  case (HcalZDCDetId::EM):
97  excludeEM_ = true;
98  break;
99  case (HcalZDCDetId::HAD):
100  excludeHAD_ = true;
101  break;
102  case (HcalZDCDetId::LUM):
103  excludeLUM_ = true;
104  break;
105  case (HcalZDCDetId::RPD):
106  excludeRPD_ = true;
107  break;
108  default:
109  break;
110  }
111 }
112 
114  bool exed = false;
115  switch (zside) {
116  case (1):
117  exed = excludeZP_;
118  break;
119  case (-1):
120  exed = excludeZN_;
121  break;
122  default:
123  exed = false;
124  }
125  if (exed)
126  return 0;
127 
128  switch (section) {
129  case (HcalZDCDetId::EM):
130  exed = excludeEM_;
131  break;
132  case (HcalZDCDetId::HAD):
133  exed = excludeHAD_;
134  break;
135  case (HcalZDCDetId::LUM):
136  exed = excludeLUM_;
137  break;
138  case (HcalZDCDetId::RPD):
139  exed = excludeRPD_;
140  break;
141  default:
142  exed = false;
143  }
144  if (exed)
145  return 0;
146 
147  bool isPositive = false;
148  if (zside == 1)
149  isPositive = true;
150 
151  int n = 0;
152  for (int ich = ich1; ich < ich2; ich++) {
153  HcalZDCDetId id(section, isPositive, ich);
154  if (validRaw(id))
155  exclude(id);
156  n++;
157  }
158  return n;
159 }
160 
161 bool ZdcTopology::validRaw(const HcalZDCDetId& id) const {
162  bool ok = true;
163  if (abs(id.zside()) != 1)
164  ok = false;
165  else if (id.channel() <= 0)
166  ok = false;
167  else if (!(id.section() == HcalZDCDetId::EM || id.section() == HcalZDCDetId::HAD ||
168  id.section() == HcalZDCDetId::LUM))
169  // id.section()== HcalZDCDetId::LUM ||
170  // id.section()== HcalZDCDetId::RPD))
171  ok = false;
172  else if (id.section() == HcalZDCDetId::EM && id.channel() > ICH_EM_MAX)
173  ok = false;
174  else if (id.section() == HcalZDCDetId::HAD && id.channel() > ICH_HAD_MAX)
175  ok = false;
176  else if (id.section() == HcalZDCDetId::LUM && id.channel() > ICH_LUM_MAX)
177  ok = false;
178  else if (id.section() == HcalZDCDetId::RPD && id.channel() > ICH_RPD_MAX)
179  ok = false;
180  return ok;
181 }
182 
183 std::vector<DetId> ZdcTopology::transverse(const DetId& id) const {
184  std::vector<DetId> vNeighborsDetId;
185  HcalZDCDetId zdcId = HcalZDCDetId(id);
186  HcalZDCDetId zdcDetId;
187  if (validRaw(zdcId) && zdcId.section() == HcalZDCDetId::EM) {
188  bool isPositive = false;
189  if (zdcId.zside() == 1)
190  isPositive = true;
191  if (zdcId.channel() == 1) {
192  zdcDetId = HcalZDCDetId(zdcId.section(), isPositive, zdcId.channel() + 1);
193  vNeighborsDetId.emplace_back(zdcDetId.rawId());
194  return vNeighborsDetId;
195  }
196  if (zdcId.channel() == ICH_EM_MAX) {
197  zdcDetId = HcalZDCDetId(zdcId.section(), isPositive, zdcId.channel() - 1);
198  vNeighborsDetId.emplace_back(zdcDetId.rawId());
199  return vNeighborsDetId;
200  }
201  zdcDetId = HcalZDCDetId(zdcId.section(), isPositive, zdcId.channel() - 1);
202  vNeighborsDetId.emplace_back(zdcDetId.rawId());
203  zdcDetId = HcalZDCDetId(zdcId.section(), isPositive, zdcId.channel() + 1);
204  vNeighborsDetId.emplace_back(zdcDetId.rawId());
205  }
206  return vNeighborsDetId;
207 }
208 
209 std::vector<DetId> ZdcTopology::longitudinal(const DetId& id) const {
210  std::vector<DetId> vNeighborsDetId;
211  HcalZDCDetId zdcId = HcalZDCDetId(id);
212  HcalZDCDetId zdcDetId;
213  if (validRaw(zdcId) && zdcId.section() == HcalZDCDetId::HAD) {
214  bool isPositive = false;
215  if (zdcId.zside() == 1)
216  isPositive = true;
217  if (zdcId.channel() == 1) {
218  zdcDetId = HcalZDCDetId(zdcId.section(), isPositive, zdcId.channel() + 1);
219  vNeighborsDetId.emplace_back(zdcDetId.rawId());
220  return vNeighborsDetId;
221  }
222  if (zdcId.channel() == ICH_HAD_MAX) {
223  zdcDetId = HcalZDCDetId(zdcId.section(), isPositive, zdcId.channel() - 1);
224  vNeighborsDetId.emplace_back(zdcDetId.rawId());
225  return vNeighborsDetId;
226  }
227  zdcDetId = HcalZDCDetId(zdcId.section(), isPositive, zdcId.channel() - 1);
228  vNeighborsDetId.emplace_back(zdcDetId.rawId());
229  zdcDetId = HcalZDCDetId(zdcId.section(), isPositive, zdcId.channel() + 1);
230  vNeighborsDetId.emplace_back(zdcDetId.rawId());
231  }
232  if (validRaw(zdcId) && zdcId.section() == HcalZDCDetId::LUM) {
233  bool isPositive = false;
234  if (zdcId.zside() == 1)
235  isPositive = true;
236  if (zdcId.channel() == 1) {
237  zdcDetId = HcalZDCDetId(zdcId.section(), isPositive, zdcId.channel() + 1);
238  vNeighborsDetId.emplace_back(zdcDetId.rawId());
239  return vNeighborsDetId;
240  }
241  if (zdcId.channel() == ICH_LUM_MAX) {
242  zdcDetId = HcalZDCDetId(zdcId.section(), isPositive, zdcId.channel() - 1);
243  vNeighborsDetId.emplace_back(zdcDetId.rawId());
244  return vNeighborsDetId;
245  }
246  }
247  if (validRaw(zdcId) && zdcId.section() == HcalZDCDetId::RPD) {
248  bool isPositive = false;
249  if (zdcId.zside() == 1)
250  isPositive = true;
251  if (zdcId.channel() == 1) {
252  zdcDetId = HcalZDCDetId(zdcId.section(), isPositive, zdcId.channel() + 1);
253  vNeighborsDetId.emplace_back(zdcDetId.rawId());
254  return vNeighborsDetId;
255  }
256  if (zdcId.channel() == ICH_RPD_MAX) {
257  zdcDetId = HcalZDCDetId(zdcId.section(), isPositive, zdcId.channel() - 1);
258  vNeighborsDetId.emplace_back(zdcDetId.rawId());
259  return vNeighborsDetId;
260  }
261  }
262  return vNeighborsDetId;
263 }
264 
265 std::vector<DetId> ZdcTopology::east(const DetId& /*id*/) const {
266  std::cout << "ZdcTopology::east() not yet implemented" << std::endl;
267  std::vector<DetId> vNeighborsDetId;
268  return vNeighborsDetId;
269 }
270 
271 std::vector<DetId> ZdcTopology::west(const DetId& /*id*/) const {
272  std::cout << "ZdcTopology::west() not yet implemented" << std::endl;
273  std::vector<DetId> vNeighborsDetId;
274  return vNeighborsDetId;
275 }
276 
277 std::vector<DetId> ZdcTopology::north(const DetId& /*id*/) const {
278  std::cout << "ZdcTopology::north() not yet implemented" << std::endl;
279  std::vector<DetId> vNeighborsDetId;
280  return vNeighborsDetId;
281 }
282 std::vector<DetId> ZdcTopology::south(const DetId& /*id*/) const {
283  std::cout << "ZdcTopology::south() not yet implemented" << std::endl;
284  std::vector<DetId> vNeighborsDetId;
285  return vNeighborsDetId;
286 }
287 std::vector<DetId> ZdcTopology::up(const DetId& /*id*/) const {
288  std::cout << "ZdcTopology::up() not yet implemented" << std::endl;
289  std::vector<DetId> vNeighborsDetId;
290  return vNeighborsDetId;
291 }
292 std::vector<DetId> ZdcTopology::down(const DetId& /*id*/) const {
293  std::cout << "ZdcTopology::down() not yet implemented" << std::endl;
294  std::vector<DetId> vNeighborsDetId;
295  return vNeighborsDetId;
296 }
297 
299  int ncells = 0;
300  switch (section) {
301  case (HcalZDCDetId::EM):
302  ncells = ICH_EM_MAX;
303  break;
304  case (HcalZDCDetId::HAD):
306  break;
307  case (HcalZDCDetId::LUM):
309  break;
310  case (HcalZDCDetId::RPD):
312  break;
313  case (HcalZDCDetId::Unknown):
314  ncells = 0;
315  break;
316  }
317  return ncells;
318 }
319 
321  int firstCell = 0;
322  switch (section) {
323  case (HcalZDCDetId::EM):
325  break;
326  case (HcalZDCDetId::HAD):
328  break;
329  case (HcalZDCDetId::LUM):
331  break;
332  case (HcalZDCDetId::RPD):
334  break;
335  case (HcalZDCDetId::Unknown):
336  firstCell = 0;
337  break;
338  }
339  return firstCell;
340 }
341 
343  int lastCell = 0;
344  switch (section) {
345  case (HcalZDCDetId::EM):
347  break;
348  case (HcalZDCDetId::HAD):
350  break;
351  case (HcalZDCDetId::LUM):
353  break;
354  case (HcalZDCDetId::RPD):
356  break;
357  case (HcalZDCDetId::Unknown):
358  lastCell = 0;
359  break;
360  }
361  return lastCell;
362 }
ICH_RPD_MAX
static const int ICH_RPD_MAX
Definition: ZdcTopology.cc:9
mps_fire.i
i
Definition: mps_fire.py:428
funct::false
false
Definition: Factorize.h:29
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
ZdcTopology::firstEMModule_
int firstEMModule_
Definition: ZdcTopology.h:59
ZdcTopology::validRaw
bool validRaw(const HcalZDCDetId &id) const
Definition: ZdcTopology.cc:161
ZdcTopology::up
std::vector< DetId > up(const DetId &id) const override
Definition: ZdcTopology.cc:287
ZdcTopology::excludeZN_
bool excludeZN_
Definition: ZdcTopology.h:57
ZdcTopology::exclusionList_
std::vector< HcalZDCDetId > exclusionList_
Definition: ZdcTopology.h:55
HcalZDCDetId::HAD
Definition: HcalZDCDetId.h:23
HcalZDCDetId::Section
Section
Definition: HcalZDCDetId.h:23
ZdcTopology::firstLUMModule_
int firstLUMModule_
Definition: ZdcTopology.h:59
ecaldqm::zside
int zside(DetId const &)
Definition: EcalDQMCommonUtils.cc:189
gather_cfg.cout
cout
Definition: gather_cfg.py:144
HcalZDCDetId::channel
int channel() const
get the channel
Definition: HcalZDCDetId.cc:63
ZdcTopology::lastHADModule_
int lastHADModule_
Definition: ZdcTopology.h:59
ZdcTopology::firstCell
int firstCell(HcalZDCDetId::Section section) const
Definition: ZdcTopology.cc:320
convertSQLiteXML.ok
bool ok
Definition: convertSQLiteXML.py:98
ZdcTopology::valid
virtual bool valid(const HcalZDCDetId &id) const
Definition: ZdcTopology.cc:27
DetId
Definition: DetId.h:17
ICH_HAD_MAX
static const int ICH_HAD_MAX
Definition: ZdcTopology.cc:7
HcalZDCDetId
Definition: HcalZDCDetId.h:16
ZdcTopology::north
std::vector< DetId > north(const DetId &id) const override
Definition: ZdcTopology.cc:277
ZdcTopology::south
std::vector< DetId > south(const DetId &id) const override
Definition: ZdcTopology.cc:282
ZdcTopology::firstRPDModule_
int firstRPDModule_
Definition: ZdcTopology.h:59
ZdcTopology::lastLUMModule_
int lastLUMModule_
Definition: ZdcTopology.h:59
ZdcTopology::east
std::vector< DetId > east(const DetId &id) const override
Definition: ZdcTopology.cc:265
ICH_EM_MAX
static const int ICH_EM_MAX
Definition: ZdcTopology.cc:6
ZdcTopology::excludeZP_
bool excludeZP_
Definition: ZdcTopology.h:57
ZdcTopology::west
std::vector< DetId > west(const DetId &id) const override
Definition: ZdcTopology.cc:271
ZdcTopology::excludeHAD_
bool excludeHAD_
Definition: ZdcTopology.h:57
HcalZDCDetId::zside
int zside() const
get the z-side of the cell (1/-1)
Definition: HcalZDCDetId.h:39
pfDeepBoostedJetPreprocessParams_cfi.lower_bound
lower_bound
Definition: pfDeepBoostedJetPreprocessParams_cfi.py:15
HcalZDCDetId::RPD
Definition: HcalZDCDetId.h:23
ICH_LUM_MAX
static const int ICH_LUM_MAX
Definition: ZdcTopology.cc:8
CaloSubdetectorTopology::ncells
virtual unsigned int ncells() const
return a count of valid cells (for dense indexing use)
Definition: CaloSubdetectorTopology.h:30
ZdcTopology::firstHADModule_
int firstHADModule_
Definition: ZdcTopology.h:59
HcalZDCDetId::Unknown
Definition: HcalZDCDetId.h:23
ZdcTopology::excludeLUM_
bool excludeLUM_
Definition: ZdcTopology.h:57
ZdcTopology::longitudinal
virtual std::vector< DetId > longitudinal(const DetId &id) const
Definition: ZdcTopology.cc:209
ZdcTopology::lastCell
int lastCell(HcalZDCDetId::Section section) const
Definition: ZdcTopology.cc:342
ZdcTopology::exclude
void exclude(const HcalZDCDetId &id)
Definition: ZdcTopology.cc:64
ZdcTopology::down
std::vector< DetId > down(const DetId &id) const override
Definition: ZdcTopology.cc:292
ZdcTopology::lastRPDModule_
int lastRPDModule_
Definition: ZdcTopology.h:59
ZdcTopology::transverse
virtual std::vector< DetId > transverse(const DetId &id) const
Definition: ZdcTopology.cc:183
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
ZdcTopology::excludeRPD_
bool excludeRPD_
Definition: ZdcTopology.h:57
hgcalPlots.section
section
Definition: hgcalPlots.py:2049
ZdcTopology::ZdcTopology
ZdcTopology()
Definition: ZdcTopology.cc:11
HcalZDCDetId::LUM
Definition: HcalZDCDetId.h:23
ZdcTopology::lastEMModule_
int lastEMModule_
Definition: ZdcTopology.h:59
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ZdcTopology::excludeEM_
bool excludeEM_
Definition: ZdcTopology.h:57
HcalZDCDetId::section
Section section() const
get the section
Definition: HcalZDCDetId.cc:44
HcalZDCDetId::EM
Definition: HcalZDCDetId.h:23
ZdcTopology::isExcluded
bool isExcluded(const HcalZDCDetId &id) const
Definition: ZdcTopology.cc:34
ZdcTopology.h