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 }
28 
29 bool ZdcTopology::valid(const HcalZDCDetId& id) const {
30  // check the raw rules
31  bool ok=validRaw(id);
32  ok=ok && !isExcluded(id);
33  return ok;
34 }
35 
36 bool ZdcTopology::isExcluded(const HcalZDCDetId& id) const {
37  bool exed=false;
38 
39  // check for section exclutions
40  switch (id.section()) {
41  case(HcalZDCDetId::EM) : exed = excludeEM_; break;
42  case(HcalZDCDetId::HAD) : exed = excludeHAD_; break;
43  case(HcalZDCDetId::LUM) : exed = excludeLUM_; break;
44  case(HcalZDCDetId::RPD) : exed = excludeRPD_; break;
45  default: exed = false;
46  }
47 
48  // check the entire list
49  if (!exed && !exclusionList_.empty()) {
50  std::vector<HcalZDCDetId>::const_iterator
51  i=std::lower_bound(exclusionList_.begin(),exclusionList_.end(),id);
52  if (i!=exclusionList_.end() && *i==id) exed=true;
53  }
54  return exed;
55 }
56 
58  std::vector<HcalZDCDetId>::iterator
59  i=std::lower_bound(exclusionList_.begin(),exclusionList_.end(),id);
60  if (i==exclusionList_.end() || *i!=id) {
61  exclusionList_.insert(i,id);
62  }
63 }
64 
66  switch(zside){
67  case( 1): excludeZP_ = true; break;
68  case(-1): excludeZN_ = true; break;
69  default: break;
70  }
71 }
72 
74  switch(zside){
75  case( 1): excludeZP_ = true; break;
76  case(-1): excludeZN_ = true; break;
77  default: break;
78  }
79  switch (section) {
80  case(HcalZDCDetId::EM) : excludeEM_ = true; break;
81  case(HcalZDCDetId::HAD) : excludeHAD_ = true; break;
82  case(HcalZDCDetId::LUM) : excludeLUM_ = true; break;
83  case(HcalZDCDetId::RPD) : excludeRPD_ = true; break;
84  default: break;
85  }
86 }
87 
89  bool exed = false;
90  switch(zside){
91  case( 1): exed = excludeZP_; break;
92  case(-1): exed = excludeZN_; break;
93  default: exed = false;
94  }
95  if (exed) return 0;
96 
97  switch (section) {
98  case(HcalZDCDetId::EM) : exed = excludeEM_; break;
99  case(HcalZDCDetId::HAD) : exed = excludeHAD_; break;
100  case(HcalZDCDetId::LUM) : exed = excludeLUM_; break;
101  case(HcalZDCDetId::RPD) : exed = excludeRPD_; break;
102  default: exed = false;
103  }
104  if (exed) return 0;
105 
106  bool isPositive = false;
107  if(zside == 1)isPositive = true;
108 
109  int n = 0;
110  for (int ich = ich1; ich < ich2; ich++){
111  HcalZDCDetId id(section, isPositive, ich);
112  if(validRaw(id))exclude(id);
113  n++;
114  }
115  return n;
116 }
117 
118 bool ZdcTopology::validRaw(const HcalZDCDetId& id) const{
119  bool ok = true;
120  if (abs(id.zside())!=1)
121  ok = false;
122  else if(id.channel() <= 0)
123  ok = false;
124  else if(!(id.section()== HcalZDCDetId::EM ||
125  id.section()== HcalZDCDetId::HAD ||
126  id.section()== HcalZDCDetId::LUM))
127 // id.section()== HcalZDCDetId::LUM ||
128 // id.section()== HcalZDCDetId::RPD))
129  ok = false;
130  else if(id.section()== HcalZDCDetId::EM && id.channel() > ICH_EM_MAX)
131  ok = false;
132  else if(id.section()== HcalZDCDetId::HAD && id.channel() > ICH_HAD_MAX)
133  ok = false;
134  else if(id.section()== HcalZDCDetId::LUM && id.channel() > ICH_LUM_MAX)
135  ok = false;
136  else if(id.section()== HcalZDCDetId::RPD && id.channel() > ICH_RPD_MAX)
137  ok = false;
138  return ok;
139 }
140 
141 std::vector<DetId> ZdcTopology::transverse(const DetId& id) const{
142  std::vector<DetId> vNeighborsDetId;
143  HcalZDCDetId zdcId = HcalZDCDetId(id);
144  HcalZDCDetId zdcDetId;
145  if(validRaw(zdcId) && zdcId.section()== HcalZDCDetId::EM){
146  bool isPositive = false;
147  if(zdcId.zside()==1)isPositive = true;
148  if(zdcId.channel()==1){
149  zdcDetId = HcalZDCDetId(zdcId.section(), isPositive, zdcId.channel()+1);
150  vNeighborsDetId.emplace_back(zdcDetId.rawId());
151  return vNeighborsDetId;
152  }
153  if(zdcId.channel()== ICH_EM_MAX){
154  zdcDetId = HcalZDCDetId(zdcId.section(), isPositive, zdcId.channel()-1);
155  vNeighborsDetId.emplace_back(zdcDetId.rawId());
156  return vNeighborsDetId;
157  }
158  zdcDetId = HcalZDCDetId(zdcId.section(), isPositive, zdcId.channel()-1);
159  vNeighborsDetId.emplace_back(zdcDetId.rawId());
160  zdcDetId = HcalZDCDetId(zdcId.section(), isPositive, zdcId.channel()+1);
161  vNeighborsDetId.emplace_back(zdcDetId.rawId());
162  }
163  return vNeighborsDetId;
164 }
165 
166 std::vector<DetId> ZdcTopology::longitudinal(const DetId& id) const{
167  std::vector<DetId> vNeighborsDetId;
168  HcalZDCDetId zdcId = HcalZDCDetId(id);
169  HcalZDCDetId zdcDetId;
170  if(validRaw(zdcId) && zdcId.section()== HcalZDCDetId::HAD){
171  bool isPositive = false;
172  if(zdcId.zside()==1)isPositive = true;
173  if(zdcId.channel()==1){
174  zdcDetId = HcalZDCDetId(zdcId.section(), isPositive, zdcId.channel()+1);
175  vNeighborsDetId.emplace_back(zdcDetId.rawId());
176  return vNeighborsDetId;
177  }
178  if(zdcId.channel()== ICH_HAD_MAX){
179  zdcDetId = HcalZDCDetId(zdcId.section(), isPositive, zdcId.channel()-1);
180  vNeighborsDetId.emplace_back(zdcDetId.rawId());
181  return vNeighborsDetId;
182  }
183  zdcDetId = HcalZDCDetId(zdcId.section(), isPositive, zdcId.channel()-1);
184  vNeighborsDetId.emplace_back(zdcDetId.rawId());
185  zdcDetId = HcalZDCDetId(zdcId.section(), isPositive, zdcId.channel()+1);
186  vNeighborsDetId.emplace_back(zdcDetId.rawId());
187  }
188  if(validRaw(zdcId) && zdcId.section()== HcalZDCDetId::LUM){
189  bool isPositive = false;
190  if(zdcId.zside()==1)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_LUM_MAX){
197  zdcDetId = HcalZDCDetId(zdcId.section(), isPositive, zdcId.channel()-1);
198  vNeighborsDetId.emplace_back(zdcDetId.rawId());
199  return vNeighborsDetId;
200  }
201  }
202  if(validRaw(zdcId) && zdcId.section()== HcalZDCDetId::RPD){
203  bool isPositive = false;
204  if(zdcId.zside()==1)isPositive = true;
205  if(zdcId.channel()==1){
206  zdcDetId = HcalZDCDetId(zdcId.section(), isPositive, zdcId.channel()+1);
207  vNeighborsDetId.emplace_back(zdcDetId.rawId());
208  return vNeighborsDetId;
209  }
210  if(zdcId.channel()== ICH_RPD_MAX){
211  zdcDetId = HcalZDCDetId(zdcId.section(), isPositive, zdcId.channel()-1);
212  vNeighborsDetId.emplace_back(zdcDetId.rawId());
213  return vNeighborsDetId;
214  }
215  }
216  return vNeighborsDetId;
217 }
218 
219 std::vector<DetId> ZdcTopology::east(const DetId& /*id*/) const
220 {
221  std::cout << "ZdcTopology::east() not yet implemented" << std::endl;
222  std::vector<DetId> vNeighborsDetId;
223  return vNeighborsDetId;
224 }
225 
226 std::vector<DetId> ZdcTopology::west(const DetId& /*id*/) const
227 {
228  std::cout << "ZdcTopology::west() not yet implemented" << std::endl;
229  std::vector<DetId> vNeighborsDetId;
230  return vNeighborsDetId;
231 }
232 
233 std::vector<DetId> ZdcTopology::north(const DetId& /*id*/) const
234 {
235  std::cout << "ZdcTopology::north() not yet implemented" << std::endl;
236  std::vector<DetId> vNeighborsDetId;
237  return vNeighborsDetId;
238 }
239 std::vector<DetId> ZdcTopology::south(const DetId& /*id*/) const
240 {
241  std::cout << "ZdcTopology::south() not yet implemented" << std::endl;
242  std::vector<DetId> vNeighborsDetId;
243  return vNeighborsDetId;
244 }
245 std::vector<DetId> ZdcTopology::up(const DetId& /*id*/) const
246 {
247  std::cout << "ZdcTopology::up() not yet implemented" << std::endl;
248  std::vector<DetId> vNeighborsDetId;
249  return vNeighborsDetId;
250 }
251 std::vector<DetId> ZdcTopology::down(const DetId& /*id*/) const
252 {
253  std::cout << "ZdcTopology::down() not yet implemented" << std::endl;
254  std::vector<DetId> vNeighborsDetId;
255  return vNeighborsDetId;
256 }
257 
259  int ncells = 0;
260  switch (section) {
261  case(HcalZDCDetId::EM) : ncells = ICH_EM_MAX; break;
262  case(HcalZDCDetId::HAD) : ncells = ICH_HAD_MAX; break;
263  case(HcalZDCDetId::LUM) : ncells = ICH_LUM_MAX; break;
264  case(HcalZDCDetId::RPD) : ncells = ICH_RPD_MAX; break;
265  case(HcalZDCDetId::Unknown) : ncells =0; break;
266  }
267  return ncells;
268 }
269 
271  int firstCell = 0;
272  switch (section) {
273  case(HcalZDCDetId::EM) : firstCell = firstEMModule_ ; break;
274  case(HcalZDCDetId::HAD) : firstCell = firstHADModule_; break;
275  case(HcalZDCDetId::LUM) : firstCell = firstLUMModule_; break;
276  case(HcalZDCDetId::RPD) : firstCell = firstRPDModule_; break;
277  case(HcalZDCDetId::Unknown) : firstCell = 0; break;
278  }
279  return firstCell;
280 }
281 
283  int lastCell = 0;
284  switch (section) {
285  case(HcalZDCDetId::EM) : lastCell = lastEMModule_; break;
286  case(HcalZDCDetId::HAD) : lastCell = lastHADModule_; break;
287  case(HcalZDCDetId::LUM) : lastCell = lastLUMModule_; break;
288  case(HcalZDCDetId::RPD) : lastCell = lastRPDModule_; break;
289  case(HcalZDCDetId::Unknown) : lastCell = 0; break;
290  }
291  return lastCell;
292 }
int firstEMModule_
Definition: ZdcTopology.h:62
static const int ICH_LUM_MAX
Definition: ZdcTopology.cc:8
static const int ICH_EM_MAX
Definition: ZdcTopology.cc:6
bool excludeEM_
Definition: ZdcTopology.h:60
std::vector< DetId > north(const DetId &id) const override
Definition: ZdcTopology.cc:233
void exclude(const HcalZDCDetId &id)
Definition: ZdcTopology.cc:57
virtual std::vector< DetId > transverse(const DetId &id) const
Definition: ZdcTopology.cc:141
int lastLUMModule_
Definition: ZdcTopology.h:62
bool excludeRPD_
Definition: ZdcTopology.h:60
int zside() const
get the z-side of the cell (1/-1)
Definition: HcalZDCDetId.h:39
bool excludeHAD_
Definition: ZdcTopology.h:60
std::vector< DetId > up(const DetId &id) const override
Definition: ZdcTopology.cc:245
int zside(DetId const &)
std::vector< DetId > east(const DetId &id) const override
Definition: ZdcTopology.cc:219
bool validRaw(const HcalZDCDetId &id) const
Definition: ZdcTopology.cc:118
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
std::vector< DetId > west(const DetId &id) const override
Definition: ZdcTopology.cc:226
virtual bool valid(const HcalZDCDetId &id) const
Definition: ZdcTopology.cc:29
int firstRPDModule_
Definition: ZdcTopology.h:62
int lastCell(HcalZDCDetId::Section section) const
Definition: ZdcTopology.cc:282
bool excludeZN_
Definition: ZdcTopology.h:60
static const int ICH_RPD_MAX
Definition: ZdcTopology.cc:9
virtual unsigned int ncells() const
return a count of valid cells (for dense indexing use)
int firstHADModule_
Definition: ZdcTopology.h:62
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< HcalZDCDetId > exclusionList_
Definition: ZdcTopology.h:58
bool excludeLUM_
Definition: ZdcTopology.h:60
int lastRPDModule_
Definition: ZdcTopology.h:62
std::vector< DetId > down(const DetId &id) const override
Definition: ZdcTopology.cc:251
Definition: DetId.h:18
int channel() const
get the channel
Definition: HcalZDCDetId.cc:62
Section section() const
get the section
Definition: HcalZDCDetId.cc:47
bool isExcluded(const HcalZDCDetId &id) const
Definition: ZdcTopology.cc:36
bool excludeZP_
Definition: ZdcTopology.h:60
int firstCell(HcalZDCDetId::Section section) const
Definition: ZdcTopology.cc:270
int lastEMModule_
Definition: ZdcTopology.h:62
int firstLUMModule_
Definition: ZdcTopology.h:62
static const int ICH_HAD_MAX
Definition: ZdcTopology.cc:7
std::vector< DetId > south(const DetId &id) const override
Definition: ZdcTopology.cc:239
virtual std::vector< DetId > longitudinal(const DetId &id) const
Definition: ZdcTopology.cc:166
int lastHADModule_
Definition: ZdcTopology.h:62