CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
11  excludeEM_(false),
12  excludeHAD_(false),
13  excludeLUM_(false),
14  excludeZP_(false),
15  excludeZN_(false),
16  firstEMModule_(1),
17  lastEMModule_(5),
18  firstHADModule_(1),
19  lastHADModule_(4),
20  firstLUMModule_(1),
21  lastLUMModule_(2)
22 {
23 }
24 
25 bool ZdcTopology::valid(const HcalZDCDetId& id) const {
26  // check the raw rules
27  bool ok=validRaw(id);
28  ok=ok && !isExcluded(id);
29  return ok;
30 }
31 
32 bool ZdcTopology::isExcluded(const HcalZDCDetId& id) const {
33  bool exed=false;
34 
35  //check the for side exclusions
36  switch(id.zside()){
37  case( 1): exed = excludeZP_; break;
38  case(-1): exed = excludeZN_; break;
39  default: exed = false;
40  }
41 
42  // check for section exclutions
43  switch (id.section()) {
44  case(HcalZDCDetId::EM) : exed = excludeEM_; break;
45  case(HcalZDCDetId::HAD) : exed = excludeHAD_; break;
46  case(HcalZDCDetId::LUM) : exed = excludeLUM_; break;
47  default: exed = false;
48  }
49 
50  // check the entire list
51  if (!exed && !exclusionList_.empty()) {
52  std::vector<HcalZDCDetId>::const_iterator
53  i=std::lower_bound(exclusionList_.begin(),exclusionList_.end(),id);
54  if (i!=exclusionList_.end() && *i==id) exed=true;
55  }
56  return exed;
57 }
58 
60  std::vector<HcalZDCDetId>::iterator
61  i=std::lower_bound(exclusionList_.begin(),exclusionList_.end(),id);
62  if (i==exclusionList_.end() || *i!=id) {
63  exclusionList_.insert(i,id);
64  }
65 }
66 
67 void ZdcTopology::exclude(int zside) {
68  switch(zside){
69  case( 1): excludeZP_ = true; break;
70  case(-1): excludeZN_ = true; break;
71  default: break;
72  }
73 }
74 
75 void ZdcTopology::exclude(int zside, HcalZDCDetId::Section section) {
76  switch(zside){
77  case( 1): excludeZP_ = true; break;
78  case(-1): excludeZN_ = true; break;
79  default: break;
80  }
81  switch (section) {
82  case(HcalZDCDetId::EM) : excludeEM_ = true; break;
83  case(HcalZDCDetId::HAD) : excludeHAD_ = true; break;
84  case(HcalZDCDetId::LUM) : excludeLUM_ = true; break;
85  default: break;
86  }
87 }
88 
89 int ZdcTopology::exclude(int zside, HcalZDCDetId::Section section, int ich1, int ich2) {
90  bool exed = false;
91  switch(zside){
92  case( 1): exed = excludeZP_; break;
93  case(-1): exed = excludeZN_; break;
94  default: exed = false;
95  }
96  if (exed) return 0;
97 
98  switch (section) {
99  case(HcalZDCDetId::EM) : exed = excludeEM_; break;
100  case(HcalZDCDetId::HAD) : exed = excludeHAD_; break;
101  case(HcalZDCDetId::LUM) : exed = excludeLUM_; 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)return false;
121  if(id.channel() <= 0)return false;
122  if(!(id.section()== HcalZDCDetId::EM ||
123  id.section()== HcalZDCDetId::HAD ||
124  id.section()== HcalZDCDetId::LUM)) return false;
125  if(id.section()== HcalZDCDetId::EM && id.channel() > ICH_EM_MAX)
126  return false;
127  if(id.section()== HcalZDCDetId::HAD && id.channel() > ICH_HAD_MAX)
128  return false;
129  if(id.section()== HcalZDCDetId::LUM && id.channel() > ICH_LUM_MAX)
130  return false;
131  return ok;
132 }
133 
134 std::vector<DetId> ZdcTopology::transverse(const DetId& id) const{
135  std::vector<DetId> vNeighborsDetId;
136  HcalZDCDetId zdcId = HcalZDCDetId(id);
137  HcalZDCDetId zdcDetId;
138  if(validRaw(zdcId) && zdcId.section()== HcalZDCDetId::EM){
139  bool isPositive = false;
140  if(zdcId.zside()==1)isPositive = true;
141  if(zdcId.channel()==1){
142  zdcDetId = HcalZDCDetId(zdcId.section(), isPositive, zdcId.channel()+1);
143  vNeighborsDetId.push_back(zdcDetId.rawId());
144  return vNeighborsDetId;
145  }
146  if(zdcId.channel()== ICH_EM_MAX){
147  zdcDetId = HcalZDCDetId(zdcId.section(), isPositive, zdcId.channel()-1);
148  vNeighborsDetId.push_back(zdcDetId.rawId());
149  return vNeighborsDetId;
150  }
151  zdcDetId = HcalZDCDetId(zdcId.section(), isPositive, zdcId.channel()-1);
152  vNeighborsDetId.push_back(zdcDetId.rawId());
153  zdcDetId = HcalZDCDetId(zdcId.section(), isPositive, zdcId.channel()+1);
154  vNeighborsDetId.push_back(zdcDetId.rawId());
155  }
156  return vNeighborsDetId;
157 }
158 
159 std::vector<DetId> ZdcTopology::longitudinal(const DetId& id) const{
160  std::vector<DetId> vNeighborsDetId;
161  HcalZDCDetId zdcId = HcalZDCDetId(id);
162  HcalZDCDetId zdcDetId;
163  if(validRaw(zdcId) && zdcId.section()== HcalZDCDetId::HAD){
164  bool isPositive = false;
165  if(zdcId.zside()==1)isPositive = true;
166  if(zdcId.channel()==1){
167  zdcDetId = HcalZDCDetId(zdcId.section(), isPositive, zdcId.channel()+1);
168  vNeighborsDetId.push_back(zdcDetId.rawId());
169  return vNeighborsDetId;
170  }
171  if(zdcId.channel()== ICH_HAD_MAX){
172  zdcDetId = HcalZDCDetId(zdcId.section(), isPositive, zdcId.channel()-1);
173  vNeighborsDetId.push_back(zdcDetId.rawId());
174  return vNeighborsDetId;
175  }
176  zdcDetId = HcalZDCDetId(zdcId.section(), isPositive, zdcId.channel()-1);
177  vNeighborsDetId.push_back(zdcDetId.rawId());
178  zdcDetId = HcalZDCDetId(zdcId.section(), isPositive, zdcId.channel()+1);
179  vNeighborsDetId.push_back(zdcDetId.rawId());
180  }
181  if(validRaw(zdcId) && zdcId.section()== HcalZDCDetId::LUM){
182  bool isPositive = false;
183  if(zdcId.zside()==1)isPositive = true;
184  if(zdcId.channel()==1){
185  zdcDetId = HcalZDCDetId(zdcId.section(), isPositive, zdcId.channel()+1);
186  vNeighborsDetId.push_back(zdcDetId.rawId());
187  return vNeighborsDetId;
188  }
189  if(zdcId.channel()== ICH_LUM_MAX){
190  zdcDetId = HcalZDCDetId(zdcId.section(), isPositive, zdcId.channel()-1);
191  vNeighborsDetId.push_back(zdcDetId.rawId());
192  return vNeighborsDetId;
193  }
194  }
195  return vNeighborsDetId;
196 }
197 
198 std::vector<DetId> ZdcTopology::east(const DetId& /*id*/) const
199 {
200  std::cout << "ZdcTopology::east() not yet implemented" << std::endl;
201  std::vector<DetId> vNeighborsDetId;
202  return vNeighborsDetId;
203 }
204 
205 std::vector<DetId> ZdcTopology::west(const DetId& /*id*/) const
206 {
207  std::cout << "ZdcTopology::west() not yet implemented" << std::endl;
208  std::vector<DetId> vNeighborsDetId;
209  return vNeighborsDetId;
210 }
211 
212 std::vector<DetId> ZdcTopology::north(const DetId& /*id*/) const
213 {
214  std::cout << "ZdcTopology::north() not yet implemented" << std::endl;
215  std::vector<DetId> vNeighborsDetId;
216  return vNeighborsDetId;
217 }
218 std::vector<DetId> ZdcTopology::south(const DetId& /*id*/) const
219 {
220  std::cout << "ZdcTopology::south() not yet implemented" << std::endl;
221  std::vector<DetId> vNeighborsDetId;
222  return vNeighborsDetId;
223 }
224 std::vector<DetId> ZdcTopology::up(const DetId& /*id*/) const
225 {
226  std::cout << "ZdcTopology::up() not yet implemented" << std::endl;
227  std::vector<DetId> vNeighborsDetId;
228  return vNeighborsDetId;
229 }
230 std::vector<DetId> ZdcTopology::down(const DetId& /*id*/) const
231 {
232  std::cout << "ZdcTopology::down() not yet implemented" << std::endl;
233  std::vector<DetId> vNeighborsDetId;
234  return vNeighborsDetId;
235 }
236 
238  int ncells = 0;
239  switch (section) {
240  case(HcalZDCDetId::EM) : ncells = ICH_EM_MAX; break;
241  case(HcalZDCDetId::HAD) : ncells = ICH_HAD_MAX; break;
242  case(HcalZDCDetId::LUM) : ncells = ICH_LUM_MAX; break;
243  case(HcalZDCDetId::Unknown) : ncells =0; break;
244  }
245  return ncells;
246 }
247 
249  int firstCell = 0;
250  switch (section) {
251  case(HcalZDCDetId::EM) : firstCell = firstEMModule_ ; break;
252  case(HcalZDCDetId::HAD) : firstCell = firstHADModule_; break;
253  case(HcalZDCDetId::LUM) : firstCell = firstLUMModule_; break;
254  case(HcalZDCDetId::Unknown) : firstCell = 0; break;
255  }
256  return firstCell;
257 }
258 
260  int lastCell = 0;
261  switch (section) {
262  case(HcalZDCDetId::EM) : lastCell = lastEMModule_; break;
263  case(HcalZDCDetId::HAD) : lastCell = lastHADModule_; break;
264  case(HcalZDCDetId::LUM) : lastCell = lastLUMModule_; break;
265  case(HcalZDCDetId::Unknown) : lastCell = 0; break;
266  }
267  return lastCell;
268 }
269 
270 
271 
272 
273 
int firstEMModule_
Definition: ZdcTopology.h:60
static const int ICH_LUM_MAX
Definition: ZdcTopology.cc:8
static const int ICH_EM_MAX
Definition: ZdcTopology.cc:6
int i
Definition: DBlmapReader.cc:9
bool excludeEM_
Definition: ZdcTopology.h:58
void exclude(const HcalZDCDetId &id)
Definition: ZdcTopology.cc:59
virtual std::vector< DetId > transverse(const DetId &id) const
Definition: ZdcTopology.cc:134
int lastLUMModule_
Definition: ZdcTopology.h:60
int zside() const
get the z-side of the cell (1/-1)
Definition: HcalZDCDetId.h:34
bool excludeHAD_
Definition: ZdcTopology.h:58
virtual std::vector< DetId > down(const DetId &id) const
Definition: ZdcTopology.cc:230
bool validRaw(const HcalZDCDetId &id) const
Definition: ZdcTopology.cc:118
virtual std::vector< DetId > up(const DetId &id) const
Definition: ZdcTopology.cc:224
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
virtual std::vector< DetId > south(const DetId &id) const
Definition: ZdcTopology.cc:218
virtual std::vector< DetId > west(const DetId &id) const
Definition: ZdcTopology.cc:205
virtual bool valid(const HcalZDCDetId &id) const
Definition: ZdcTopology.cc:25
int lastCell(HcalZDCDetId::Section section) const
Definition: ZdcTopology.cc:259
bool excludeZN_
Definition: ZdcTopology.h:58
virtual std::vector< DetId > north(const DetId &id) const
Definition: ZdcTopology.cc:212
virtual unsigned int ncells() const
return a count of valid cells (for dense indexing use)
int firstHADModule_
Definition: ZdcTopology.h:60
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< HcalZDCDetId > exclusionList_
Definition: ZdcTopology.h:56
bool excludeLUM_
Definition: ZdcTopology.h:58
Section section() const
get the section
Definition: HcalZDCDetId.h:36
Definition: DetId.h:18
int channel() const
get the channel
Definition: HcalZDCDetId.h:40
bool isExcluded(const HcalZDCDetId &id) const
Definition: ZdcTopology.cc:32
bool excludeZP_
Definition: ZdcTopology.h:58
int firstCell(HcalZDCDetId::Section section) const
Definition: ZdcTopology.cc:248
int lastEMModule_
Definition: ZdcTopology.h:60
tuple cout
Definition: gather_cfg.py:121
int firstLUMModule_
Definition: ZdcTopology.h:60
virtual std::vector< DetId > east(const DetId &id) const
Definition: ZdcTopology.cc:198
volatile std::atomic< bool > shutdown_flag false
static const int ICH_HAD_MAX
Definition: ZdcTopology.cc:7
virtual std::vector< DetId > longitudinal(const DetId &id) const
Definition: ZdcTopology.cc:159
int lastHADModule_
Definition: ZdcTopology.h:60